feat: project and propagate stale stage results - #716
Open
djoo-lgcns wants to merge 8 commits into
Open
Conversation
djoo-lgcns
force-pushed
the
feat/stage-validity-projection
branch
from
August 6, 2026 05:03
008370b to
11e4380
Compare
djoo-lgcns
force-pushed
the
feat/stage-validity-projection
branch
from
August 11, 2026 12:06
eae8ed3 to
dbb8986
Compare
djoo-lgcns
marked this pull request as ready for review
August 11, 2026 12:15
Author
|
I flagged default test suite: passed on the code paths this PR changes. |
djoo-lgcns
force-pushed
the
feat/stage-validity-projection
branch
2 times, most recently
from
August 13, 2026 05:43
5b7acec to
dbb8986
Compare
…rojection # Conflicts: # CHANGELOG.md # README.md # core/tools/aidlc-orchestrate.ts # core/tools/aidlc-state.ts # core/tools/aidlc-version.ts # dist/claude/.claude/tools/aidlc-orchestrate.ts # dist/claude/.claude/tools/aidlc-state.ts # dist/claude/.claude/tools/aidlc-version.ts # dist/codex/.codex/tools/aidlc-orchestrate.ts # dist/codex/.codex/tools/aidlc-state.ts # dist/codex/.codex/tools/aidlc-version.ts # dist/copilot/.aidlc/tools/aidlc-orchestrate.ts # dist/copilot/.aidlc/tools/aidlc-state.ts # dist/copilot/.aidlc/tools/aidlc-version.ts # dist/cursor/.cursor/tools/aidlc-orchestrate.ts # dist/cursor/.cursor/tools/aidlc-state.ts # dist/cursor/.cursor/tools/aidlc-version.ts # dist/kiro-ide/.kiro/tools/aidlc-orchestrate.ts # dist/kiro-ide/.kiro/tools/aidlc-state.ts # dist/kiro-ide/.kiro/tools/aidlc-version.ts # dist/kiro/.kiro/tools/aidlc-orchestrate.ts # dist/kiro/.kiro/tools/aidlc-state.ts # dist/kiro/.kiro/tools/aidlc-version.ts # dist/opencode/.aidlc/tools/aidlc-orchestrate.ts # dist/opencode/.aidlc/tools/aidlc-state.ts # dist/opencode/.aidlc/tools/aidlc-version.ts
…rojection # Conflicts: # CHANGELOG.md # README.md # core/tools/aidlc-version.ts # dist/claude/.claude/tools/aidlc-version.ts # dist/codex/.codex/tools/aidlc-version.ts # dist/copilot/.aidlc/tools/aidlc-version.ts # dist/cursor/.cursor/tools/aidlc-version.ts # dist/kiro-ide/.kiro/tools/aidlc-version.ts # dist/kiro/.kiro/tools/aidlc-version.ts # dist/opencode/.aidlc/tools/aidlc-version.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution context
Head branch:
feat/stage-validity-projectionVersion metadata:
2.5.63Local validation
bun scripts/package.ts): passedbun run check): passedSummary
Separate historical stage completion from current AI-DLC-owned artifact validity.
This revision keeps runtime resolution instance-aware but persists a compact stage-level receipt:
produces_kindsfiltering;Problem
completedis historical execution state. It does not prove that a result still matches the artifact basis against which it completed.A filename-only or static-edge implementation is insufficient for v2 because:
build-test-resultsandload-test-resultsusetest-results.mdphysically;produces_kindsprunes outputs by unit kind;requires_stagecan represent ordering as well as semantic dependency.Design
Shared runtime artifact resolution
aidlc-artifact-resolution.tscentralizes canonical-to-physical filename mapping and resolves concrete runtime artifact instances.For per-unit producers it uses the active Bolt DAG and unit kinds. A malformed DAG fails closed. A no-DAG legacy or isolated single-stage run may fall back to existing unit directories.
produces_kindsfilters the expected output matrix.The resolver is also used by the existing state artifact guard and orchestrator artifact paths, preventing canonical IDs such as
build-test-resultsfrom being checked at nonexistent filenames.Compact schema-2 completion receipt
Each main-workflow
STAGE_COMPLETEDevent may record aValidation Basiswith:from_stage→to_stage_artifact) captured while the stage was reading.Structure fingerprints aggregate
structureHashsums across all present unit instances of a canonical artifact; content fingerprints aggregatecontentHash. A single canonical row can therefore back multiple unit instances, and the receipt's storage cost stays constant regardless of unit count.The state machine treats a stage's receipt row as authoritative for its own outputs; the resolver decides which files count. Absent optional inputs remain absent in the aggregate. Structure-only changes and content-only changes are distinguishable through the two fingerprints.
Fail-open migration
Legacy audit ledgers, schema-1 receipts, and superseded Draft receipts are not rejected. Migration triggers on the next
STAGE_COMPLETEDat approve time. Recent iteration receipts also fall through fail-open until the stage completes again.Downstream propagation
When a stage's own row becomes stale under the current graph contract, its
observed_input_edgesare unwound to mark any downstream stage that consumed the invalidated aggregate. Cycles fail closed.Scope
Validity here is dependency validity between AI-DLC-owned artifacts represented by the current graph contract and observed completion receipts.
Explicitly out of scope for this PR:
The feature complements historical stage completion; it does not replace it.
completedremains the answer to "did this stage produce output once?" Validity answers "does that output still describe the current state under the current graph contract?"Tests
The test commit covers:
code-generationandbuild-and-test;produces_kindsfiltering;Independent A/B evaluation
Compared this PR against the frozen upstream baseline on the same Task CRUD goal, evaluator revision, Kiro CLI environment, and post-completion mutation payload.
Why a forked evaluator
awslabs/aidlc-workflowsv2-evaluator(scripts/aidlc-evaluator/) runs the paired A/B pipeline end-to-end but couples three assumptions that block reproducibility outside AWS-issued environments and outside the evaluator repository:boto3— an environment without Bedrock credentials silently falls back to canned strings, which reads as success in the transcript;/skill aidlc-orchestratorslash — Kiro CLI 2.16.2 (v3 agent engine) rejects the v1 slash and requires ACP (Agent Client Protocol) for headless multi-turn runs;dist/kiro/.kiro) is auto-detected from the evaluator's own checkout, so both variants read the evaluator's skills/tools/agents rather than each ref's own dist — the A/B result is invalid because the candidate feature never actually runs.The
feat/codex-cli-evaluator-backendfork addresses these three, strictly opt-in and backward compatible:packages/shared/src/shared/llm.py) with acodex-clibackend (Codex CLI subprocess,--ephemeral,--sandbox read-only) alongside the originalbedrockpath — resolved per-component throughAIDLC_EVAL_{HUMAN,SCORER}_BACKEND/AIDLC_EVAL_LLM_BACKENDenv vars; unset env keeps Bedrock as before.kiro-cli acp— a bidirectional JSON-RPC 2.0 adapter that answers agent-initiatedsession/request_permission/terminal/*/fs/*requests, streamssession/promptresponses, and applies a two-part timeout (per-turn maximum plus a 120-second notification-idle watchdog). The v1 chat path is preserved as a fallback viaAIDLC_EVAL_KIRO_MODE=chat_watchdog.dist/kiro/.kirosparse-checkout (_setup_dist_from_rules) that installs each ref's own dist into that ref's workspace and records a sha256kiro-dist-manifest.txt. The legacy auto-detect remains available with a WARN, so any user relying on the previous behavior sees no functional change.None of these changes affect what the evaluator measures; they change only where and how it runs. Scripts using the shipped defaults (Bedrock, evaluator-repo dist) continue to work.
Frozen revisions
upstream/v2@d7807fe1230defdbf81e544ac5d044e012bb08d7dbb8986af71a6842a89214a7604a9dfdb35ff3db(5 commits: 3 feature + 2 chore)upstream/v2@18bcc4688e20258e713de750d725f83981f88bde, candidatefeat/stage-validity-projection-rebased@a4bca7009699f1afa323884b7f2069d8783f1a5b). The current PR head carries byte-identical feature files (aidlc-validity.ts,aidlc-artifact-resolution.tsincore/*and everydist/*harness mirror) plus two chore commits that regenerate the packaged distribution for the newly addeddist/copilot/anddist/cursor/harnesses. All A/B evidence lines below therefore remain valid without re-running the paired evaluation.djoo-lgcns/aidlc-workflowsfeat/codex-cli-evaluator-backend@d068cad8033c002aeab8ddb28f6384ddf7e2ba12kiro-cli 2.16.2claude-opus-4.829e28a39cb8d0c2b224bdce9eb5c60abc82ace4b39452d6a65e2a279ec367af1(appended byte-for-byte to each variant'sunit-of-work.md)Deterministic barrier (direct orchestrator probe)
Model-independent evidence.
bun .kiro/tools/aidlc-orchestrate.ts nextin each post-mutation workspace produced disjoint results.Baseline:
{ "kind": "done", "reason": "Workflow complete — no in-scope stage remains after build-and-test", "narration": "That is everything on the plan. Your work is finished and written up." }Candidate:
{ "kind": "error", "message": "Completed stage result(s) no longer match their validation basis. Directly stale: units-generation, code-generation. Downstream revalidation required: build-and-test. Re-enter the earliest affected stage with /aidlc --stage units-generation." }This is the strongest evidence line — the candidate's
aidlc-validity.ts+aidlc-artifact-resolution.tsproject stage-level validity from the mutation and propagate it along the graph's consume/produce edges without any model in the loop. The baseline orchestrator returnsdoneunconditionally because the workflow's completion basis is not re-verified against the current artifact bytes.Kiro transcript verdicts
Both variants received identical ACP prompts (
/aidlc --status,/aidlc --stage code-generation,/aidlc). Human-reviewed verdicts on the captured transcripts:units-generationCandidate second turn (
/aidlc --stage code-generation, 12 tool calls, tool-driven receipt):Candidate third turn (a follow-up
/aidlcretry, 31 tool calls) — the barrier is persistent:Baseline second turn (
/aidlc --stage code-generation, 47 tool calls, model-driven interpretation only):The baseline transcript never emits
validation basis,directly stale, or a specific re-entry command from an engine tool; the model reasons about a diff it happened to notice. The candidate transcript surfacesaidlc-validity.tsoutput verbatim in both turns.Post-hoc scope registration (transparency)
The workflow composed a custom
task-crud-apiscope at runtime but did not persist its definition./aidlctherefore failed withUnknown scope "task-crud-api"in both workspaces before any stage-validity logic could run. To unblock resume without altering the workflow's semantics, both workspaces were augmented with:.kiro/scopes/aidlc-task-crud-api.md— frontmatter + description onlytask-crud-apientry in.kiro/tools/data/scope-grid.jsonwhose EXECUTE/SKIP stage grid reflects each workspace'saidlc-state.mdexactly (baseline 9 EXECUTE / 23 SKIP; candidate 7 EXECUTE / 25 SKIP)The stage grid was copied from state, not authored freshly, so it is a re-registration of the scope the workflow already ran under — it exposes the completed workflow to the orchestrator's re-entry path; it does not modify what "completion" means or which stages were considered part of the workflow.
Reproduction artifacts
The rest of the comparison report is duplicated by the sections above (frozen SHAs, transcript quotes, human-reviewed verdicts). The unique details are:
install_failedcompleted.kiro/tools/aidlc-validity.tsin workspace.kiro/tools/aidlc-artifact-resolution.tsin workspacebeforesha256 (unit-of-work.md)ecce128c0e31946f…08866f157b40d189…aftersha256 (unit-of-work.md)311659d203704fad…402b41ded0b1fc6d…payloadsha256 (byte-for-byte identical across variants)29e28a39cb8d0c2b224bdce9eb5c60abc82ace4b39452d6a65e2a279ec367af1The candidate's initial CRUD produced a runnable test suite; the baseline's dependency install failed. This is a side effect of the candidate's shared runtime resolver and unit-aware dist installation surfacing during the initial regression check, not the stage-validity feature itself. The
.kiro/tools/*presence check confirms each workspace ran under its ref's owndist/kiro/.kiro/— the sparse-checkout provenance held.Scope of this evidence
Covers AI-DLC-owned artifact dependency validity — the feature this PR proposes. It does not claim source-tree, Git snapshot, CI-run, deployment, or external-system validity.
Follow-up work
This PR intentionally limits validity to AI-DLC artifact dependencies represented by the current graph contract and observed completion receipts. Follow-up work may include:
requires_stageedges;workspace_requiresstages;These are graph-contract and observation extensions; they do not replace the runtime artifact-resolution correctness required by this PR.