Skip to content

Fold the genesis Decision link into Run state, not just the event - #732

Merged
xmap merged 1 commit into
mainfrom
worktree-run-genesis-decision-fold
Aug 26, 2026
Merged

xmap merged 1 commit into
mainfrom
worktree-run-genesis-decision-fold

Conversation

@xmap

@xmap xmap commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • RunStarted.decided_by_decision_id was fully wired end-to-end (command, decider, REST route, MCP tool) but the evolver's genesis arm never destructured it, so it silently dropped on every run, on every replay, including the D6 fidelity tool's own refold. Verified directly with evolve() before touching anything: the value went in and never came back out.
  • Adds Run.started_by_decision_id (deliberately not decided_by_decision_id: eight sibling Run events already use that name for a different, per-transition sense; Run.last_adjusted_by already sets the precedent inside this same aggregate for renaming a field when the folded scope changes).
  • Threaded through all 12 evolve() match arms; surfaced in record_fidelity_check's _render_run_state; closes test_2bm_energy_change's own long-standing "linkage is not first-class" watch item by actually wiring and asserting it.
  • Adds an AST fitness test covering both ways a field can silently vanish: a non-genesis arm dropping prior.<field>, and the genesis arm never setting the field at all (the shape this bug actually was — the existing test_procedure_evolver_carry_forward.py precedent's genesis exemption would not have caught it).

Test plan

  • New unit tests: genesis fold sets the field, default is None, survives every parametrized transition path (tests/unit/run/test_run_evolver.py)
  • New AST fitness tests pass, and a mutation test (reintroducing the exact original bug) confirms they fail loudly with a clear message
  • test_2bm_energy_change.py integration scenario updated to actually pass decided_by_decision_id and assert it survives onto the folded Run
  • Full unit + architecture suite: 37,060 passed, 0 failed
  • pyright, ruff check, ruff format clean
  • Naming review (naming-r3-reviewer) on both the original name and the rename, both passed
  • Independent gate review (2 lenses) on correctness and completeness/blast-radius

🤖 Generated with Claude Code

RunStarted.decided_by_decision_id was fully wired through start_run's
command, decider, route, and MCP tool, but the evolver's genesis arm
never destructured it, so it silently dropped on every run, on every
replay, including the D6 fidelity tool's own refold. Verified by
running evolve() directly before touching anything: the value went in
and never came back out.

Adds Run.started_by_decision_id (named started_by_, not decided_by_,
because eight sibling Run events already use decided_by_decision_id
for a different, per-transition sense; Run's own last_adjusted_by
already sets the precedent for renaming on fold-scope change).
Threaded through all 12 evolve() match arms, surfaced in
record_fidelity_check's _render_run_state, and closes the
test_2bm_energy_change scenario's own long-standing "linkage is not
first-class" watch item by actually wiring and asserting it.

Adds an AST fitness test that checks both failure shapes: a
non-genesis arm dropping prior.<field>, and the genesis arm never
setting a field at all (the shape this bug actually was, which the
existing Procedure-evolver precedent's genesis exemption would not
have caught). Verified by mutation: reintroducing the original bug
fails the new test with a clear message.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  apps/api/src/cora/run/aggregates/run
  events.py
  state.py
Project Total  

This report was generated by python-coverage-comment-action

@xmap
xmap merged commit 8525976 into main Aug 26, 2026
19 checks passed
@xmap
xmap deleted the worktree-run-genesis-decision-fold branch August 26, 2026 02:31
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