Skip to content

Range the replay-safety guard over the substrates the factory can build - #776

Merged
xmap merged 1 commit into
mainfrom
worktree-replay-classifier
Sep 6, 2026
Merged

Range the replay-safety guard over the substrates the factory can build#776
xmap merged 1 commit into
mainfrom
worktree-replay-classifier

Conversation

@xmap

@xmap xmap commented Sep 6, 2026

Copy link
Copy Markdown
Owner

What was wrong

The guard meant to keep decider_replayability in lockstep with the deciders had no independent side. It asserted a hand-written set of four refs against the classifier's own hand-written sets, so it agreed by construction, and it never looked at an adapter at all.

It therefore reported nothing while the llm substrate shipped a model_ref of provider:model, a value no literal set could ever contain. Asking is_replay_safe about an LLM-steered run raises rather than answering. No production caller consults it yet, so the defect is dormant, but the module docstring claimed a coverage it did not have.

The fix

Key the classification by DecideSubstrate instead. That Literal is the independent side: decide_port_config maintains it so its factory knows what it can build, a substrate missing from it cannot be constructed, and whoever adds an adapter must edit it for reasons that have nothing to do with replay. The test now asserts set equality in both directions, so a seventh substrate fails CI until classified and a deleted one fails until its classification goes too.

Two substrates do not record their own name, and the classifier now says so rather than pretending otherwise:

  • staged returns its child's advice unchanged, so its own name on an iteration means the composite grew a ref it should not have. That input raises.
  • llm records provider:model, an open set rather than a constant, recognised by shape.

Verification

Verified by mutation: adding an unclassified substrate to the Literal, misclassifying llm, disabling the llm route, and removing the composite refusal each fail exactly their own tests and nothing else. One test was dropped along the way for failing that check, having compared a result against the same map it came from.

14,934 unit / 37,424 architecture passing, full-repo pyright clean.

Naming

Replayability / SUBSTRATE_REPLAYABILITY / replayability_of, as StrEnum. The naming reviewer overturned an earlier ReplayClass: there are zero pre-existing *Class enums, and 114 of 116 enums in the tree are StrEnum.

🤖 Generated with Claude Code

The guard that was supposed to keep the classifier in lockstep with the
deciders had no independent side. It asserted a hand-written set of four
refs against the classifier's own hand-written sets, so it agreed by
construction, and it never looked at an adapter at all.

It therefore reported nothing while the llm substrate shipped a model_ref
of `provider:model`, a value no literal set could ever contain. Asking
is_replay_safe about an LLM-steered run raises rather than answering. No
production caller consults it yet, so the defect is dormant, but the
module's own docstring claimed a coverage it did not have.

Key the classification by DecideSubstrate instead. That Literal is the
independent side: decide_port_config maintains it so its factory knows
what it can build, a substrate missing from it cannot be constructed, and
whoever adds an adapter must edit it for reasons that have nothing to do
with replay. The test now asserts set equality in both directions, so a
seventh substrate fails CI until classified and a deleted one fails until
its classification goes too.

Two substrates do not record their own name, and the classifier now says
so rather than pretending otherwise. staged returns its child's advice
unchanged, so its own name on an iteration means the composite grew a ref
it should not have, and that input raises. llm records provider:model, an
open set rather than a constant, recognised by shape.

Verified by mutation: adding an unclassified substrate to the Literal,
misclassifying llm, disabling the llm route, and removing the composite
refusal each fail exactly their own tests and nothing else. One test was
dropped along the way for failing that check, having compared a result
against the same map it came from.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  apps/api/src/cora/operation/adapters
  decider_replayability.py
Project Total  

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

@xmap
xmap merged commit 2ea3455 into main Sep 6, 2026
19 checks passed
@xmap
xmap deleted the worktree-replay-classifier branch September 6, 2026 16:56
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