Skip to content

feat: replay phase preset runtime gates#204

Merged
devkade merged 1 commit into
devfrom
feat/phase-preset-runstate-replay
May 17, 2026
Merged

feat: replay phase preset runtime gates#204
devkade merged 1 commit into
devfrom
feat/phase-preset-runstate-replay

Conversation

@devkade
Copy link
Copy Markdown
Owner

@devkade devkade commented May 17, 2026

Summary

  • Adds runtime replay support for PhasePreset evidence/artifact/branch/gate events.
  • Adds RunState-backed gate evaluation that feeds replayed evidence/artifacts into the existing fail-closed gate evaluator.
  • Adds explicit pass, block, repair, human decision, and abort gate fixtures for the PhasePreset runtime contract.

Test Plan

  • npx tsx --test test/phase-preset.test.ts
  • npm run check:unused
  • npm run quality:budgets
  • git diff --check
  • npm run verify

Closes #198

@devkade
Copy link
Copy Markdown
Owner Author

devkade commented May 17, 2026

@kapi-agent review

Revision explanation for current head 07c472e1c841c60435c70d0b33b51516578e5d12:

What changed

Why this closes the prior feedback

Verification

  • npx tsx --test test/phase-preset.test.ts
  • npm run check:unused
  • npm run quality:budgets
  • git diff --check
  • npm run verify

Copy link
Copy Markdown

@kapi-agent kapi-agent Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kapi-agent review

Verdict: APPROVE

Final approval summary

Review journey

This PR adds runtime replay support for PhasePreset events and RunState-backed gate evaluation. The semantic scope is small and cohesive: one domain module plus matching tests for replayed evidence/artifact state and gate fixture coverage. There was no prior kapi-agent blocking review on this head.

What changed

  • src/domain/phase-preset.ts
    • Adds PhasePresetRuntimeEvent, PhasePresetRunState, and replay/evaluation helpers.
    • Adds exported gate fixtures covering pass, block, repair, human decision, and abort paths.
  • test/phase-preset.test.ts
    • Adds fixture coverage assertions.
    • Adds RunState replay test proving replayed artifacts/evidence feed the existing fail-closed gate evaluator.

Why this is correct

The new RunState gate path delegates to the existing evaluatePhasePresetGate implementation rather than duplicating gate logic, so existing fail-closed behavior and validation remain centralized. Replay copies gate-evaluation reasons and uses sets for evidence/artifacts/branches, avoiding duplicate availability entries while preserving gate-evaluation history order.

Evidence

  • Verifier gate: PASS — npm ci && npm run verify exited 0.
  • Size gate: PASS — 84 changed lines, below the 200-line semantic review threshold.
  • Revision-explanation status: not required; found.
  • Ilchul review harness gate: PASS — neutral/comment result with 0 blocking findings.
  • Inspected files: src/domain/phase-preset.ts, test/phase-preset.test.ts.

Remaining risks and approval rationale

Remaining risk is low: replay currently assumes typed in-process events rather than validating unknown external event payloads. That is acceptable for this bounded domain addition because gate enforcement still flows through the existing evaluator and tests cover the intended contract. Approval is justified because all configured gates pass and no blocking correctness, safety, workflow-contract, or regression issue remains.

Blocking issues

None.

Warnings / risks

  • src/domain/phase-preset.ts: replayPhasePresetRunState is typed but not runtime-validating arbitrary malformed events. If these events later come directly from untrusted persisted JSON, add a parser/validator before replay.

Suggestions

  • Consider adding a future negative test for duplicate replay events if duplicate suppression is an intentional contract rather than an implementation detail.

Looks good

  • Reuses evaluatePhasePresetGate for RunState-backed evaluation instead of creating a parallel gate evaluator.
  • Tests cover both fixture paths and the replay-to-gate path.
  • Gate fixtures include human-decision and abort paths, which helps preserve workflow contract integrity.

Verification notes

Verifier gate status: PASS. Size gate status: PASS. Revision-explanation status: not required; found. CI/local evidence provided: npm ci && npm run verify passed, including tests, checks, unused checks, and quality budgets.


Engine: pi

@devkade devkade merged commit 4d91c3e into dev May 17, 2026
2 checks passed
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.

Design: define full-lifecycle PhasePreset and runtime spec schemas

1 participant