Skip to content

fix(pipeline): eliminate conflicting schema injection and clean all prompts#150

Merged
nextlevelshit merged 16 commits intomainfrom
fix/executor-schema-injection-and-prompt-cleanup
Feb 24, 2026
Merged

fix(pipeline): eliminate conflicting schema injection and clean all prompts#150
nextlevelshit merged 16 commits intomainfrom
fix/executor-schema-injection-and-prompt-cleanup

Conversation

@nextlevelshit
Copy link
Collaborator

Summary

  • Fix critical bug: buildStepPrompt injected "save to .wave/artifact.json" for any step with a json_schema contract, conflicting with the correct path from output_artifacts. Personas got two conflicting instructions and sometimes followed the wrong one (e.g. distill step writing to artifact.json instead of convergent-proposals.json).
  • Clean 130+ prompt violations: Remove all hardcoded output paths, artifact read instructions, inline JSON schema examples, and "matching the contract schema" phrases from 24 pipeline YAML files and 12 prompt templates — enforcing CLAUDE.md rule feat: implement wave ops commands (status, logs, cancel, artifacts) #1.
  • Add converge step contract: The recinq converge step had an inline JSON example but no validation. Added validated-findings.schema.json and a proper handover.contract.

Changes

Executor (core fix)

  • Remove redundant schema injection block from buildStepPromptbuildContractPrompt is now the single source of truth
  • Convert buildContractPrompt to an executor method with access to pathValidator and inputSanitizer
  • Add loadSecureSchemaContent / sanitizeSchemaContent helpers for security-validated schema loading
  • Auto-generate "Available Artifacts" section from step.Memory.InjectArtifacts
  • Update all executor, schema, and contract integration tests

Prompts (cleanup)

  • 24 pipeline YAML files cleaned
  • 12 prompt template .md files cleaned
  • Prompts now describe what to produce, not where to read/write

Stats

  • 40 files changed, -758 net lines removed

Test plan

  • go build ./... — clean
  • go test -race ./... — 22 packages, all passing
  • Run wave run recinq end-to-end to verify distill step writes to correct path

Phase 1 of the interactive control plane. Spawns Claude Code in
interactive mode with rich context from completed pipeline runs:
run summary, step results, artifact inventory, and workspace paths.

Read-only permissions enforced via settings.json. Extension points
for Phase 2 (step manipulation) and Phase 3 (cascade control).
Phase 2: StepController with continue, extend, revert, and rewrite
operations. Chat workspace now supports analysis and manipulate modes
with appropriate permission sets. Slash commands provisioned for
manipulate mode.

Phase 3: CascadeDetector walks inject_artifacts DAG to find stale
downstream steps. Supports mtime-based verification and selective
cascade targeting. Works with any pipeline (not just prototype).

Closes #147, closes #148
…ision

When multiple steps in a shared worktree declare the same output path
(e.g., .wave/artifact.json), each step overwrites the previous and the
DB records identical absolute paths for all steps.

Fix: after confirming a file-based artifact exists, copy it to
.wave/artifacts/<step-id>/<name> before DB registration. The injection
system keeps using the workspace-relative path, but the DB gets the
archived copy which survives subsequent step overwrites.

Also removes duplicate DB registration from trackStepDeliverables
(writeOutputArtifacts already handles it).
buildStepPrompt unconditionally injected "save to .wave/artifact.json"
for any step with a json_schema contract, conflicting with the correct
output path from OutputArtifacts. Personas got two conflicting paths and
sometimes followed the wrong one (distill step writing to artifact.json
instead of convergent-proposals.json).

- Remove redundant schema injection block from buildStepPrompt
- Convert buildContractPrompt to executor method with security validation
- Add loadSecureSchemaContent and sanitizeSchemaContent helpers
- Auto-generate "Available Artifacts" section from inject_artifacts
- Update all executor/contract tests for new behavior
Strip 130+ violations of CLAUDE.md rule #1 across 24 pipeline YAML
files and 12 prompt templates. The executor now handles artifact
injection and output path guidance via buildContractPrompt, so prompts
no longer need to specify where to read/write.

Removed: output path directives, artifact read instructions, inline
JSON schema examples, and "matching the contract schema" phrases.
Kept: semantic task descriptions and field meaning explanations.
The converge step had an inline JSON example but no contract validation.
Add a proper json_schema contract so buildContractPrompt generates the
correct output guidance and the executor validates the output.
…tadata

buildContractPrompt now generates Output Requirements for any step with
output_artifacts, even without a handover contract. This ensures personas
always know where to write and in what format (JSON/markdown/text).

Previously, steps without a contract got zero output guidance, causing
personas to write prose instead of JSON (e.g. gh-issue-impl create-pr).
ClassifyFailure matched "rate limit" as a substring of "rate limiting"
in security review content, and claude.go re-scanned ResultContent even
on exit code 0 (success). This caused successful steps to be marked as
rate-limited when their output mentioned rate limiting as a finding.

- Remove exit-code-0 content re-scan in claude.go
- Tighten rate limit patterns: "rate limit exceeded", "rate limit
  reached", "rate limited" instead of bare "rate limit"
- Add regression test for security review false positive
Two bugs caused `step "" failed:` errors with empty step ID:

1. executeStep never set execution.States to StateFailed on error
   (non-matrix path). Only saved to store, leaving in-memory state as
   StateRunning. Fixed by adding the missing state update.

2. Batch error handler only checked StateFailed/StateRunning but missed
   StateRetrying. Added StateRetrying to the check and a defensive
   fallback to use ready[0].ID when no state match is found.
Steps with inject_artifacts now explicitly reference their injected
artifacts in the prompt text, preventing personas from attempting to
fetch data from external sources when the data is already available
locally. Also syncs internal/defaults copies and adds missing
validated-findings schema to embedded defaults.
Tell personas that injected artifacts contain ALL needed data and to
read them instead of re-fetching from external sources.
… YAMLs

Remove inline output path instructions, artifact read commands, and
JSON schema examples from all pipeline step prompts. The executor
injects schemas and artifact references automatically.
Replace hardcoded JSON output examples with references to the injected
output schema. Wave's executor injects schemas at runtime so prompts
must not duplicate them.
CLI commands like gh pr create --body-file need literal artifact paths.
Clarify that rule #1 permits these while still forbidding inline schemas.
@nextlevelshit nextlevelshit merged commit 576bac2 into main Feb 24, 2026
3 checks passed
@nextlevelshit nextlevelshit deleted the fix/executor-schema-injection-and-prompt-cleanup branch February 24, 2026 09:46
nextlevelshit added a commit that referenced this pull request Mar 4, 2026
…d-prompt-cleanup

fix(pipeline): eliminate conflicting schema injection and clean all prompts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant