Repository navigation
Let the repository's configuration reach the router - #13
Conversation
CycleRecorder routed with profiles=None, so code_cycle.profiles in .code-cycle.yml never reached route(). load_profiles() existed and knew how to overlay a repository's declaration on the defaults; nothing called it on the production path. Every run used the built-in profiles whatever the repository declared, and the telemetry row would have described a policy nobody chose -- which matters now precisely because those rows are about to be treated as data. The split is the one the configuration deserves: the driver loads, the recorder receives. run_cycle.py reads the file, resolves the repository and the profiles, and hands the recorder something already decided. CycleRecorder does not look for YAML itself, asserted by a test, because a component that reads configuration on its own can disagree with its caller about what it says and both would be writing rows. Repository precedence is --repo, then code_cycle.repository.selector, then an error. No inference from git remote: there is already an explicit contract and a second resolution path would make the recorded repo_id ambiguous. A configuration that exists and cannot be read stops the run instead of falling back to the defaults, and an unknown profile name stops it before anything is dispatched -- learning that afterwards means paying for a cycle to find a typo. --no-config asks for the defaults deliberately. PyYAML is imported only when there is a file to parse, so a repository without configuration still needs nothing beyond the standard library. Twelve tests, two of which fail against the previous wiring: a declared cheap_coder lands on Claude rather than the default Codex, and a reroute uses the configured fallback rather than the built-in one.
CI has no PyYAML and this machine does, so twelve configuration tests passed locally and failed on every runner. Third time this session that an assumption about the environment reached CI as a green local suite. Both jobs now install PyYAML before running the suite, so the configuration path is exercised rather than skipped, and the tests skip only where the parser genuinely is not available. README and CHANGELOG name it as the runtime's one optional dependency: needed to read .code-cycle.yml, needed for nothing else.
Code Cycle ReviewStatus: CHANGES_REQUESTED Reviewed the accumulated diff from Findings[REV-001] · medium · - · valid · blocks:yes — Validate the repository selector before dispatchLocation:
Please validate the configured selector during planning, using the same repository identifier/credential rules as telemetry (ideally through a shared validator), and add coverage proving invalid and credential-shaped selectors fail with zero adapter dispatches. [REV-002] · medium · - · valid · blocks:yes — Reject malformed nested configuration with a driver errorLocation: The loader only validates the top-level YAML value. A valid YAML document such as Please validate Verification
|
plan() returned whatever the configuration said. A selector of "bad selector" was accepted, the prompt was composed, Codex was dispatched once, and only then did telemetry refuse the identifier -- so the stage ran, was paid for, and its row could not be written. The run happened and left no trace of having happened, which is the one outcome this instrument cannot tolerate. A credential-shaped selector reached the executor prompt the same way. The repository and the work item are now checked during planning through telemetry.validate_reference: the store's own rule, exported rather than copied, because two validators agree until one of them is edited. The work item is included because it is the same defect at the same cost, one line away. Second finding, same commit: the loader validated only the top level, so the valid document `code_cycle: not-a-mapping` reached repository_of() and raised AttributeError from its own .get -- a traceback where a stated refusal belongs, and load_profiles would have done the same. code_cycle, code_cycle.repository and code_cycle.profiles must now be mappings, checked when the file is read, and the load_profiles wrapper catches RouterError rather than every exception, so a real bug is no longer reported as a configuration problem. Both reproduced first: plan() returned 'bad selector' with the adapter dispatched once, and `code_cycle: not-a-mapping` raised AttributeError. Six new tests, of which eight checks fail against the previous code.
Resolution summaryBoth findings reproduced against [REV-001] · medium · resolved · valid · blocks:yes — Validate the repository selector before dispatchValid, and the consequence is worse than a late error. Reproduced exactly as described: with
The work item is checked with it. Verified after: [REV-002] · medium · resolved · valid · blocks:yes — Reject malformed nested configuration with a driver errorValid. One correction to the record, which does not change the outcome: the traceback needs the repository to come from configuration. With
Also narrowed while in there: the Verified after: Regression testsSix new in Checked against the previous code, not only the new one: with Verification
Sensitivity triageThe diff moves a credential check earlier, from after a dispatch to before one, and adds type checks on parsed configuration. Nothing new is executed and no new data crosses a boundary. Agreeing with the review's triage: no audit finding, and the credential-prefix rejection is now reached before any prompt is composed rather than after. Residual risks
Status: RESOLVED — REV-001 and REV-002 closed at |
Code Cycle Re-reviewStatus: CHANGES_REQUESTED Reviewed the complete accumulated diff against Changes since the previous reviewThe fix adds a shared pre-dispatch reference validator, validates the nested configuration section shapes, narrows router error handling, and adds regression coverage. The accumulated change now touches 10 files. Previous findings[REV-001] · medium · resolved · blocks:yes — Validate the repository selector before dispatchLocation: Resolved and verified by execution. [REV-002] · medium · resolved · blocks:yes — Reject malformed nested configuration with a driver errorLocation: Resolved and verified by execution. Valid YAML with scalar New finding[REV-003] · medium · open · blocks:yes — Validate each profile entry before loading itLocation:
Please validate every declared profile spec and its Verification and current checks
Security triage and verdictThis remains a sensitive change because repository configuration controls executor routing and reference values cross into prompts and telemetry. The security audit ran: The current verdict is CHANGES_REQUESTED until malformed individual profile entries are refused through the same controlled configuration path. |
load_profiles validated the names and nothing under them. A declared `cheap_coder: nope` reached the merge and raised TypeError past plan()'s RouterError handler and main()'s CycleDriverError handler, so the CLI printed a traceback where a stated refusal belongs. The quieter half was worse and was not reported: `primary: 3` was accepted. The loader carried a non-string target through untouched -- `parse_target(x) if isinstance(x, str) else x` -- so a Profile could hold the integer 3 as its target, and only something trying to route with it ever found out, after planning had approved the run. Every declared profile must now be a mapping, and every primary and fallback a non-empty target string, each refused by name as a RouterError, which the driver already converts. The isinstance escape hatch is gone: a target is parsed or it is refused. load_profiles also refuses a code_cycle section that is not a mapping rather than quietly reading the defaults out of a broken file -- the driver already refused that shape, but the function is used on its own too. Eleven tests across both layers, of which nine checks fail against the previous router. One of them caught a weak test of my own while it was being written: two of the new cases asserted only that CycleDriverError was raised, and the error they actually got was the missing repository, not the malformed profile.
Resolution summary — round 2Reproduced against [REV-001] · medium · resolved · valid · blocks:no — Validate the repository selector before dispatchClosed in the previous round at [REV-002] · medium · resolved · valid · blocks:no — Reject malformed nested configuration with a driver errorClosed in the previous round at [REV-003] · medium · resolved · valid · blocks:yes — Validate each profile entry before loading itValid, and the reproduction matched: The quieter half is worse and was not in the finding. While reproducing I checked the neighbouring shapes:
Fixed in
Verified after: each of the six shapes — scalar entry, non-string Regression testsEleven across both layers. Six in Checked against the previous code: with One of them caught a weak test of my own. Two new cases initially asserted only that Verification
Sensitivity triageUnchanged and narrower: the diff adds type checks to parsed configuration, executes nothing new, and passes no new data anywhere. No audit finding. Residual risksThe configuration surface is now checked for shape at both layers, but Status: RESOLVED — REV-003 closed at |
Code Cycle Re-reviewStatus: APPROVED Reviewed the complete accumulated diff against Changes since the previous rereviewThe router now validates each declared profile mapping and its Previous findings[REV-001] · medium · resolved · blocks:no — Validate the repository selector before dispatchLocation: Reproduced with an invalid selector and a credential-shaped selector. Both now raise [REV-002] · medium · resolved · blocks:no — Reject malformed nested configuration with a driver errorLocation: Reproduced scalar [REV-003] · medium · resolved · blocks:no — Validate each profile entry before loading itLocation: Reproduced a scalar profile entry, an integer Verification and current checks
Security triage and residual riskThis remains a sensitive configuration and executor-routing change. The security audit ran: Final verdict: APPROVED. All recovered findings are resolved, the current head was fully rereviewed, and no open blocking finding remains. |
Why this is before the canary
CycleRecorderrouted withprofiles=None, socode_cycle.profilesin.code-cycle.ymlnever reachedroute().load_profiles()already existed and already knew how to overlay a repository's declaration on the defaults — nothing called it on the production path.The consequence only matters now: the first productive rows are about to be treated as data, and a run could have recorded a routing policy nobody declared. That is the one contamination worth a small PR to avoid.
The split
The driver loads configuration; the recorder receives what was resolved.
CycleRecorderdoes not look for YAML itself, and a test asserts its source mentions neither the file name norload_profiles. A component that reads configuration on its own can disagree with its caller about what the configuration says, and both would be writing rows.Decisions
Repository precedence is
--repo, thencode_cycle.repository.selector, then an error. No inference fromgit remote: there is already an explicit contract, and a second resolution path would make the recordedrepo_idambiguous in exactly the dataset this is protecting.A configuration that exists and cannot be read stops the run, rather than falling back to the defaults. Falling back is the quiet failure — it produces a row describing a policy nobody chose.
--no-configasks for the defaults deliberately, and contradicting it with--configis refused.An unknown profile name stops the run before anything is dispatched. Learning that after a stage has run means paying for a cycle to discover a typo.
PyYAML is imported only when there is a file to parse. A repository without configuration still needs nothing beyond the standard library, which is what the rest of this toolkit assumes; when a file is there and the parser is not, the error says so instead of silently using defaults.
Tests
Twelve new, of which two fail against the previous wiring (verified by reverting the one line in
cycle.py:FAILED (failures=2),OKwith it):cheap_coder.primary = claude:anthropic/claude-sonnet-5 highactually runs on Claude, and Codex is never dispatched;claude-opus-5, not the built-in one.The rest: defaults untouched when nothing is declared;
--repowins over the selector; the selector is used when--repois absent; neither is an error; an unknown profile name, malformed YAML, a named file that is not there, and--configwith--no-configare each refused;--no-configreturns the built-in profiles with a file present; andCycleRecordergiven profiles routes with them while looking for no file of its own.Verification
python3 -m unittest discover -s tests—Ran 358 tests ... OK(was 344).python3 scripts/validate-package.py—VALID.After this
The canary: one real cycle, then
telemetry.sqliteinspected by hand. It will then demonstrate installation, real configuration, configured routing, real dispatch, recorder and SQLite in a single pass.