Skip to content

Record a stage by running it - #10

Merged
datacas merged 2 commits into
mainfrom
feat/cycle-recorder
Sep 21, 2026
Merged

datacas merged 2 commits into
mainfrom
feat/cycle-recorder

Conversation

@datacas

@datacas datacas commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Telemetry knew how to hold a row and nothing was writing one. This closes that, without touching the router's formulas or the adapters.

Recording is not a step anyone performs

The obvious wiring — instructions telling the orchestrator to call record_stage after each dispatch — is the shape of contract that has failed repeatedly here: stated somewhere, enforced nowhere, discovered dead when the data it should have produced is missing.

So CycleRecorder.stage() routes, dispatches and writes the row as one operation. There is no path through it that dispatches without recording.

recorder.stage("implement", spec)          routes, dispatches, records
recorder.record_verdict("review", status)  the functional outcome
recorder.next_iteration()
recorder.close(final_status)

Both decisions, not just the surviving one

The recorder owns the single production reroute. When a dispatch discovers an exhausted window — the only moment that is knowable for a native executor — it updates availability, routes once more, and both rows are written:

codex   blocked    operating_quota
claude  succeeded  used_fallback=1

A fallback whose first attempt left no trace makes fallbacks look free, and what fallbacks cost is among the first questions this data will be asked.

Friction a person must clear does not reroute — a trust dialog teaches nothing about availability, and retrying elsewhere would hide a question somebody has to answer. A calibration never reroutes.

Separation, asserted

router and executors do not learn that SQLite exists. Three tests check it, including one that reads their source. A decision engine that writes to a database cannot be tested as a decision engine.

What the wiring found

The router could not route resolve or rereview — two of the four cycle stages, present in the plan's role table and absent from the code. Resolving findings edits code and is judged by tests, so it routes where implementation routes; a rereview routes where a review does. A test now asserts every cycle stage can be routed at all.

Verification

python3 scripts/validate-package.py   -> VALID
python3 -m unittest discover -s tests -> 305 tests, OK

Includes the full fake cycle implement -> review CHANGES_REQUESTED -> resolve -> rereview APPROVED, opened back out of SQLite and checked stage by stage, and ten such cycles driving first_pass_rate to a measured 0.6.

Telemetry knew how to hold a row and nothing was writing one. The obvious wiring
— instructions telling the orchestrator to call record_stage after each dispatch
— is the shape of contract that has failed five times in this codebase already:
stated somewhere, enforced nowhere, found dead when the data it should have
produced is missing.

So CycleRecorder.stage() routes, dispatches and writes the row as one operation.
There is no path through it that dispatches without recording, because the
recording is not a step the caller performs.

It owns the single production reroute and records both decisions. The abandoned
attempt is the point: a fallback whose first attempt left no trace makes
fallbacks look free, and what fallbacks cost is among the first questions this
data will be asked. Friction a person must clear does not reroute, because a
trust dialog teaches nothing about availability and retrying elsewhere would
hide a question somebody has to answer. A calibration never reroutes.

router and executors do not learn that SQLite exists, and three tests assert it:
a decision engine that writes to a database cannot be tested as a decision
engine.

Wiring it revealed that the router could not route resolve or rereview — two of
the four cycle stages, present in the plan's role table and absent from the
code. Resolving findings edits code and is judged by tests, so it routes where
implementation routes; a rereview routes where a review does. A test now asserts
that every cycle stage can be routed at all.

305 tests.
@datacas

datacas commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Review summary

Reviewed the accumulated diff from origin/main to 5cd8b87a7ff43d55dc5ed97cf2112256ac8ccc57 for PR #10, including the new CycleRecorder, routing changes for resolve/rereview, orchestration guidance, and the new cycle tests. The declared scope is coherent, but the advertised recording path is not available in a normal installed skill and the production retry policy contradicts its own friction contract.

Findings

[REV-001] · high · open · blocks:yes — Stage recording is not available to installed orchestration

Path: skills/cc-orchestrator/SKILL.md:218

Problem: The new guidance makes CycleRecorder.stage() the required way to run and record stages, but the repository has no non-test caller of CycleRecorder, and the installer copies only skills/* (scripts/install.sh:86-109). A clean project installation therefore contains cc-orchestrator/SKILL.md but no scripts/cycle.py or scripts/telemetry.py for that guidance to import or execute.

Evidence: rg found CycleRecorder only in scripts/cycle.py and its tests. Running bash scripts/install.sh --agent codex --scope project --project-dir <empty-temp-dir> succeeds, while the installed target has scripts/cycle.py=False and the installed skill still references scripts/cycle.py.

Impact: A standard consumer installation cannot use the new recording API, and the existing orchestration path still performs no telemetry writes. first_pass_rate() therefore remains unpopulated for real runs unless a caller separately has an unpublished checkout and custom integration.

Suggestion: Ship the recorder/runtime through the supported installation path or move the recording contract into an installable/runtime component, then add an installation-level test that executes one stage and verifies a telemetry row. If this PR is intentionally only a library primitive, remove the claim that the orchestrator now drives every stage through it and defer the guidance until the integration exists.

[REV-002] · high · open · blocks:yes — Human-action authentication failures incorrectly trigger fallback dispatch

Path: scripts/cycle.py:125

Problem: CycleRecorder.stage() retries whenever result.learned_availability is non-null. DispatchResult.learned_availability is also non-null for authenticated_session, mapping that condition to Availability.INSTALLED; the recorder therefore treats a login prompt as a reason to reroute in production. The new orchestration contract explicitly says that friction a person must clear does not trigger a reroute.

Evidence: A scripted executor returning BLOCKED with missing_capability="authenticated_session" produced attempts=2, rerouted=True, executors ['codex', 'claude'], and outcomes ['blocked', 'succeeded']. The expected behavior for this human-action condition is one blocked attempt with no fallback.

Impact: A run can silently switch providers and execute the task elsewhere when the selected executor needs a human login/trust action. That creates unintended work/cost and violates the calibration/operational policy described by this PR.

Suggestion: Restrict production rerouting to the explicitly retryable exhausted-window capability (for example operating_quota), or expose a dedicated should_reroute result property. Add a regression test for authenticated_session alongside the existing hook/folder-trust friction test.

Security triage

The security audit ran because the new stage wrapper accepts task input and invokes the executor boundary. No confirmed authentication, authorization, injection, secret-exposure, or unsafe-data-handling vulnerability was introduced by this diff: the existing native adapters pass task text as an argument list to subprocess.run, not through a shell. The authentication-session behavior above is reported as a correctness finding because it changes routing policy, not as a newly exploitable security issue.

Verification

  • python3 scripts/validate-package.py — VALID.
  • python3 -m unittest discover -s tests -v — Ran 305 tests ... OK.
  • python3 -m unittest tests.test_cycle -v — passed.
  • git diff --check origin/main...HEAD — passed.
  • Runtime fallback probe — quota-style fallback records both attempts as expected.
  • Runtime friction probe — authenticated_session incorrectly rerouted from codex to claude, as described in REV-002.

Unverified items

  • No live Codex, Claude, or Orca dispatch was attempted; provider credentials, quota, and interactive environments were not required for the repository test suite.
  • The installed-skill failure is verified with the project installer; no real agent host was needed to establish that the runtime files are absent.

CI

All four reported PR checks completed successfully: two Skills, manifests, and Bash installer runs and two PowerShell installer runs. No check was pending, failed, cancelled, or skipped. The repository-defined Linux and Windows validation gates are present and green.

Residual risks

The new tests exercise scripted adapters and SQLite, not the actual installed-skill workflow or native provider launchers. Until the runtime packaging/integration and friction retry policy are corrected, successful CI does not demonstrate that real orchestration records stages or stops on human-required authentication.

Verdict

CHANGES_REQUESTED — resolve REV-001 and REV-002 before approval.

A dispatch that hit a sign-in screen reported non-null learned availability,
and the recorder used "we learned something" as the test for whether it could
route around it. A login prompt therefore moved the work to the other provider
and spent its window there, which is the silent switch the orchestration
contract says must not happen.

Evidence and permission are now separate questions. `needs_human_action` names
the capabilities no retry can supply, derived from every interactive marker the
native adapters can raise and asserted against them by test, so a marker added
later cannot quietly become a condition the recorder thinks it may go around.
Such a stage stops where it is, unrerouted and with availability untouched: a
downgrade would only move the same switch to the next stage.

Also narrows the recording claim. `install.sh` ships skills only, so an
installed cc-orchestrator has no CycleRecorder to call; the skill said to drive
every stage through it. It now says what it is and that an installation records
nothing until a host wires it in.
@datacas

datacas commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Resolution summary

Both findings triaged against 5cd8b87 before any edit, each reproduced by execution first. Fixes are in 98fc381.

[REV-001] · high · resolved · valid · blocks:yes — Stage recording is not available to installed orchestration

Valid, and the half that mattered was the claim, not the packaging. install.sh copies skills/* only, so an installed cc-orchestrator has no CycleRecorder to import — yet the skill instructed the reader to "drive every stage through" it. That is the same failure this PR exists to prevent, one level up: a contract asserted where nothing can honour it.

Resolved by narrowing the claim rather than by widening the installer. The skill now says scripts/cycle.py is the reference implementation, that it ships with the toolkit source and not with an installed skill, and that an installation records nothing until a host wires one in — with the instruction to say so rather than report a measured rate no run produced. CHANGELOG.md carries the same qualification.

Packaging the runtime is deliberately not in this PR. Shipping scripts/ through both installers changes the installation contract, needs PowerShell parity and validator coverage, and is a decision about what the toolkit distributes — its own change, not a fix folded into a recording primitive. Until it lands, first_pass_rate() stays unpopulated for installed runs, and the skill now says that instead of implying otherwise.

[REV-002] · high · resolved · valid · blocks:yes — Human-action authentication failures incorrectly trigger fallback dispatch

Valid and reproduced exactly as reported: a scripted codex returning BLOCKED/authenticated_session produced attempts=2, rerouted=True, executors ['codex', 'claude'], outcomes ['blocked', 'succeeded'], with the task text reaching claude.

Root cause is a proxy, not a missing branch. The recorder used learned_availability is not None as the test for "may I go around this", but that property answers a different question — what the attempt demonstrated. A sign-in screen demonstrates something (INSTALLED) just as an exhausted window does, so the two conditions were indistinguishable at the point of decision. folder_trust only passed the existing test because it happens to report no evidence at all.

The two questions are now separate. DispatchResult.needs_human_action names the capabilities no retry can supply, and HUMAN_ACTION_CAPABILITIES covers all five an adapter can raise — authenticated_session, bypass_acknowledgement, folder_trust, hook_trust, trusted_directory. A test interrogates CodexAdapter.interactive_markers and ClaudeAdapter.interactive_markers directly and asserts every value they can produce is declared, so a marker added later cannot quietly become a condition the recorder thinks it may route around.

Such a stage stops where it is, unrerouted and with availability untouched. Downgrading codex to INSTALLED without retrying would have looked correct while moving the same silent switch onto the next stage; leaving it READY keeps the question where a person can see it.

Regression tests

  • test_a_login_prompt_is_evidence_but_not_permission_to_go_around_it — the exact reported case: evidence is non-null, needs_human_action is true, no reroute, the fallback is never dispatched.
  • test_the_question_stays_where_a_person_can_see_it — availability stays READY after the blocked attempt.
  • test_an_interactive_screen_is_always_somebody_elses_turn — the adapters' own marker tables must be fully declared as human action.
  • test_a_waiting_screen_says_so / test_an_exhausted_window_is_not_somebody_elses_turn — the two sides of the property.

The quota path is unchanged and still reroutes, records both decisions and flags used_fallback on the second.

Verification

  • Reproduction before the fix: attempts=2, rerouted=True, ['codex','claude'], ['blocked','succeeded'].
  • Same script after the fix: attempts=1, rerouted=False, ['codex'], ['blocked'], claude dispatched nothing.
  • python3 -m unittest discover -s tests — Ran 310 tests ... OK (was 305).
  • python3 scripts/validate-package.py — VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned.
  • CI on 98fc381 — all four checks pass: two Skills, manifests, and Bash installer, two PowerShell installer. None pending, failed, cancelled or skipped.

Sensitivity triage

The change touches authentication handling, so the security question was asked again: it moves strictly in the restrictive direction. Nothing new is executed, no input crosses a new boundary, and one path that previously ran a task on a second provider without being asked now stops. No audit finding.

Residual risks

Unchanged from the review, and honestly so: no live Codex, Claude or Orca dispatch has been attempted, the tests exercise scripted adapters, and the recorder has never run inside a real orchestration host — which is REV-001's packaging gap restated. Green CI demonstrates the policy, not that any installed run records anything.

Status: RESOLVED — REV-001 and REV-002 closed at 98fc381.

@datacas

datacas commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Re-review summary

Re-reviewed the complete accumulated diff from origin/main to 98fc381ae6e6edfc024910a39d9db58ca25960e6, including the fix commit after the previous review at 5cd8b87a7ff43d55dc5ed97cf2112256ac8ccc57. The current delta narrows the recording claim to a source reference and separates human-action friction from retryable quota exhaustion. No new findings were identified.

Previous finding dispositions

[REV-001] · high · not_applicable · blocks:no — Stage recording is not available to installed orchestration

Disposition: obsolete because the relevant scope changed. The fix does not package scripts/ into installed skills; instead, skills/cc-orchestrator/SKILL.md:218-222 now explicitly says that scripts/cycle.py is a source-only reference and that an installation records nothing until a host wires it in. The installer reproduction confirms this documented behavior: installation succeeds, the skill is present, and scripts/cycle.py is absent from the target. The packaging limitation remains a residual risk, but it is no longer an undisclosed claim or a defect in the current stated scope.

[REV-002] · high · resolved · blocks:no — Human-action authentication failures incorrectly trigger fallback dispatch

Disposition: corrected and verified by execution. DispatchResult.needs_human_action now classifies the interactive capabilities, and CycleRecorder.stage() excludes those results from retry while retaining quota fallback. The original reproduction now produces one blocked codex attempt, no reroute, and no claude call. The quota regression still produces two recorded attempts (codex blocked, claude succeeded). New tests cover the login prompt, all interactive markers, and the quota distinction.

Current review

The accumulated implementation, routing changes, documentation, and tests remain coherent. The fix commit is limited to the two previous findings and introduces no additional correctness, regression, data-model, architecture, operations, or test-coverage findings.

Security triage

Security triage was repeated because the change still crosses the executor/input boundary. The scoped audit found no new authentication, authorization, injection, secret-exposure, or unsafe-data-handling vulnerability. Task text continues to reach native executors as an argument list rather than through a shell, and the fix only restricts fallback behavior for human-required capabilities.

Verification

  • python3 scripts/validate-package.py — VALID.
  • python3 -m unittest discover -s tests -v — Ran 310 tests ... OK.
  • python3 -m unittest tests.test_cycle tests.test_executors -v — Ran 97 tests ... OK.
  • git diff --check origin/main...HEAD — passed.
  • REV-002 original authentication-session reproduction — corrected; no reroute.
  • Quota fallback regression — preserved; one reroute with both attempts recorded.
  • REV-001 installer scope reproduction — matches the now-explicit source-only documentation.

Unverified items and residual risk

No live Codex, Claude, or Orca dispatch was attempted because the repository tests use scripted adapters and do not require provider credentials. The source-only recorder still requires a host integration before real installed runs produce telemetry; that limitation is now documented rather than silently presented as completed wiring.

CI

All four current PR checks completed successfully: two Skills, manifests, and Bash installer runs and two PowerShell installer runs. No check is pending, failed, cancelled, or skipped.

Verdict

APPROVED — all previous blocking findings are resolved or not applicable, and no open blocking finding remains.

@datacas
datacas merged commit 9e72530 into main Sep 21, 2026
4 checks passed
@datacas
datacas deleted the feat/cycle-recorder branch September 21, 2026 16:08
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