Skip to content

refactor(runtime): classify dispatch failures and track start evidence - #195

Merged
datacas merged 5 commits into
mainfrom
task-172
Oct 7, 2026
Merged

datacas merged 5 commits into
mainfrom
task-172

Conversation

@datacas

@datacas datacas commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Implements #172. Dispatch attempts now distinguish capacity, quota, authentication, transport, protocol, availability, contract, interruption, and precondition failures, and record whether agent work started. Stop reports and status lines show bounded, redacted diagnostics while telemetry stores only closed tokens.

Diagnosis

This is a feature request: the runtime collapses unrelated executor failures into dispatch_failed and records lifecycle state without evidence that agent work started. Reproduction is not applicable. Inspection confirmed the issue's proposed mechanism in NativeAdapter.dispatch, CycleRecorder.stage, and the telemetry typed gate.

The invariant is that an attempt's failure class comes from executor evidence, its start state does not invent activity, and raw error text never enters telemetry. Structured Codex/Claude signals precede stderr and exit status. Codex session-log fallback uses the invocation's thread ID and verifies the session ID; it never reads an unrelated newest session. A recovered intermediate stream error does not override terminal success.

A widened related-work search read #122, #173, #174, #188, and #190 and confirmed PR #171 already used schema 14. This change supplies evidence for future recovery/rerouting, without implementing those later stages. No related issue is closed.

The fix adds one closed capability-to-error mapping, transient diagnostic fields, monotonic start evidence, a self-contained schema-15 projection migration, and report/status output. missing_capability and executor availability tokens remain unchanged. Unknown start evidence remains unknown, including a timeout without a stream.

Work units

Unit Behaviour Files Tests Verification Rollback
WU-1 Classify dispatch failures, persist start evidence, migrate schema 14 to 15, and show redacted diagnostics. scripts/executors.py, scripts/cycle.py, scripts/run_cycle.py, scripts/cycle_status.py, scripts/telemetry.py, tests/test_dispatch_failures.py, tests/test_work_item_outcomes.py, docs/telemetry.md, docs/workflows.md, CHANGELOG.md 20 failure regressions cover classes, start states, redaction, report/status output, correlated session logs, recovered stream errors, real fake-process failure, and schema-14 migration preserving audit bytes. Existing executor, driver, cycle and status tests also pass. Package validator, full suite, final targeted suites and three process/database/CLI boundary checks pass; commands below. Irreversible stored-data effect after initialization: a code revert does not remove start_state or reconstruct legacy error values collapsed to executor_error. Back up stores before upgrading; restoring that backup restores original values. dispatch_attempt_updates is preserved unchanged. Only disposable test databases were migrated during this implementation.
WU-2 Keep the new CLI and migration fixtures portable on Windows by explicitly decoding UTF-8 and closing SQLite connections before cleanup. tests/test_dispatch_failures.py The same 20 regressions, including the real CLI and migration checks. Final targeted run: 20 passed; boundary run: 3 passed; validator passed. dependent with WU-1: reverting only the portability fix reintroduces known Windows fixture failures. Revert both code commits together.

Verification

Agent-reported evidence (verified, boundary required):

  • rtk proxy python3 scripts/validate-package.py — exit 0; 15 skills and package contracts valid.
  • rtk proxy env -u HERDR_ENV python3 -m unittest discover -s tests -v — exit 0; 1,150 tests executed on the final code.
  • rtk proxy env -u HERDR_ENV python3 -m unittest discover -s tests -p test_dispatch_failures.py — exit 0; 20 tests executed in the final targeted run.
  • rtk proxy env -u HERDR_ENV python3 -m unittest discover -s tests -p test_run_cycle.py — exit 0; 168 tests executed.
  • rtk proxy env -u HERDR_ENV python3 -m unittest discover -s tests -p test_executors.py — exit 0; 164 tests executed.
  • rtk proxy env -u HERDR_ENV PYTHONPATH=scripts:tests python3 -m unittest test_dispatch_failures.ExecutorFailureTests.test_fake_binary_at_real_process_boundary test_dispatch_failures.StoreFailureTests.test_schema_14_migration_preserves_audit_bytes_and_is_idempotent test_dispatch_failures.StoreFailureTests.test_report_redacts_but_store_carries_only_tokens — exit 0; 3 boundary checks executed (real subprocess returning non-zero, disposable database migration, real status CLI).
  • rtk proxy git diff --check — exit 0.

The final full suite and targeted runs include the Windows fixture corrections. CI runs the complete suite on the pushed head. Local runs clear the inherited desktop HERDR_ENV, matching CI's absence of that host context. The new Git fixture sets its own commit identity, and fake executors need no provider credentials.

Windows CI on the first head exposed CP1252 decoding of the UTF-8 status CLI and a SQLite fixture connection retained during directory cleanup. WU-2 explicitly selects UTF-8 and closes every fixture connection. The targeted and boundary checks above passed again after that correction, and both Linux and Windows CI runs passed on the updated head. gh downloads of the first failure logs were blocked by this environment's log-storage domain allowlist, so the GitHub connector was used only for that unavailable log read. All PR publication and check-state reads use gh.

Checks of the final head

Head: 8849514c3bfde3cb09f8d9723e6529a71904dbb2. Four passed, zero failed, zero pending.

Check Event State
Skills, manifests, and Bash installer push pass
Skills, manifests, and Bash installer pull_request pass
PowerShell installer push pass
PowerShell installer pull_request pass

Migration and diagnostics

Column presence detects schema 14. The transactional migration adds start_state with unknown for old rows and rewrites only dispatch_attempts.error_code: operating_quota → quota, operating_availability → unavailable, and dispatch_failed/executor_error/unknown → executor_error. Historical update JSON and hashes stay untouched. New writes reject the removed tokens.

Unknown start evidence can refine to either known state; not_started can refine to started; started cannot revert, including through operator corrections. Raw executor codes and redacted excerpts appear only in report/status data. An unmapped code stays executor_error; missing output/error evidence stays no_error_report.

Run routing: profile deep_coder; requested model openai/gpt-6.1-sol; resolved model ?; effort medium.

References #172. No issue-closing keyword is used.

@datacas

datacas commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261007-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

Review of PR #195 (work item #172) — CHANGES_REQUESTED

Scope: accumulated diff 04e7393…8849514 (1139 lines, SHA-256 b9bbc307…c141b), all 10 files, against the acceptance criteria of #172. Conventions applied: AGENTS.md (no Serena/Context7 lookup needed; no external-API question), .code-cycle.yml (trusted author datacas).

Summary: the classification, redaction-before-bounding, typed gate, monotonic start state, correlated session-log fallback and the schema-14→15 migration are sound, and the 1,150-test suite passes. One acceptance criterion is not met on the real dispatch path (REV-001); three low findings do not block.

Findings

[REV-001] · medium · open · - · blocks:yes — Pre-launch blocked dispatches report start_state=unknown, not the documented state

scripts/executors.py:2012-2039, 2086, 2149 (dispatch() blocked returns). #172 requires every mapped missing_capability to produce its error_code and start state; docs/telemetry.md:136,151,153 documents not_started for pre-launch refusals. Only Adapter._blocked sets start_state="not_started". The DispatchResult(BLOCKED…) returns in dispatch() (publication_access, operating_availability, proven_readiness, the workspace-policy capabilities, read_only_verification) leave the default unknown. test_capability_mapping_is_closed_and_separate_from_availability passes only because it hand-builds each result with the expected start_state.
Observed: through the real path (ReadOnlyVerificationTests fixture, codex, non-git cwd, stage never launched) the result is BLOCKED read_only_verification contract_violation unknown. The stop report/status line then shows start_state=unknown for a refusal where nothing ran, and #173 (which treats unknown as started) would reconcile needlessly. Note the documented started for read_only_verification also does not match this path: the precheck blocks before the stage runs (the existing test asserts the argv file never exists). Set not_started on these returns (or document and test the real value), and drive the mapping test through dispatch() rather than constructing results.

[REV-002] · low · open · - · blocks:no — sk- redaction has no boundary and mangles ordinary words

scripts/executors.py:212. sk-[A-Za-z0-9_-]+ matches inside words. Observed: failure_excerpt('worktree task-172 disk-full risk-high') → worktree ta[redacted] di[redacted] ri[redacted]. Branch names in this repo are task-<n>, so diagnostics naming the branch are corrupted. Anchor with \b/(?<![A-Za-z0-9]).

[REV-003] · low · open · - · blocks:no — Redaction covers only sk-, gh*_, github_pat_ and Bearer

scripts/executors.py:210-216. Observed unmasked: xoxb-1234-abcd, AKIAIOSFODNN7EXAMPLE, api_key=abc123secret, Authorization: Basic …, password=hunter2. #172 says "such as", so this is residual risk rather than a spec miss; the excerpt appears only in the terminal stop report and status file (never telemetry). Consider masking key|token|secret|password= assignments and Basic auth.

[REV-004] · low · open · - · blocks:no — Session-log fallback and checkout fingerprint run on every dispatch (code inspection only, not measured)

scripts/executors.py:993, :937-950. For every Codex dispatch with no stdout error signal — including successes — _session_events globs CODEX_HOME/sessions/**/*<thread>.jsonl and parses the whole log; _checkout_fingerprint (git status plus content digest of every changed/untracked file) runs before and after every native dispatch. Cost grows with session history and dirty-tree size. Consider reading the log only on a non-zero exit/missing result and bounding the fingerprint work.

Security triage

security_review.always_when is not configured, so the defaults applied: no matching paths, filenames or labels (no labels). Reviewer judgement added a scoped audit because the change handles untrusted executor output, credential redaction, a filesystem read driven by an executor-supplied ID, and a stored-data migration. cc-security-review was not loaded as a separate delegate; I applied its checks inline (degraded run). Result: no confirmed vulnerability. The thread ID is restricted by [A-Za-z0-9-]{1,80} and verified against the log's own id, so no path traversal and no unrelated-session read; terminal escapes and control characters are stripped before display; telemetry accepts only closed tokens. Residual risk: REV-003.

Executed

  • env -u HERDR_ENV python3 -m unittest discover -s tests — exit 0, 1150 tests OK.
  • python3 scripts/validate-package.py — VALID: 15 skills.
  • Direct probes of failure_excerpt (REV-002, REV-003) and of the real dispatch path for a pre-launch read_only_verification block (REV-001), via a throwaway script outside the repository.

Unverified

No live Codex/Claude/Orca run: real executor stream shapes (Claude stream-json, Codex --json and session logs) are covered only by the PR's synthetic fixtures. The migration was exercised only through the PR's disposable-database test. Windows behaviour is taken from CI.

CI (head 8849514)

validate.yml jobs: Skills, manifests, and Bash installer (push, pull_request) pass; PowerShell installer (push, pull_request) pass. 4 passed, 0 failed, 0 pending. release.yml is not part of PR checks.

Residual risks

Irreversible in-place migration of existing stores (documented in the PR; back up first). Unmapped future missing_capability values now raise from failure_code, which is intended by the issue and covered by a test.

Verdict

CHANGES_REQUESTED — REV-001 blocks approval; REV-002…REV-004 do not.

@datacas

datacas commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261007-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

[CCT-20261007-001] · deep_coder · openai/gpt-6.1-sol→? · medium · triaged:8849514c3bfde3cb09f8d9723e6529a71904dbb2 · schema:1

Triage completed before code changes, against the current PR head. Recovered the complete chronological history from GitHub with gh: one comment by trusted author datacas, no reviews or inline comments, no ID gaps or collisions. The existing linked worktree /home/datacas/www/code-cycle-toolkit/.worktree/task-172 is clean and uses the PR branch task-172. The supplied accumulated diff is readable, 1139 lines, and matches its SHA-256 and the PR head.

[REV-001] · medium · open · valid · blocks:yes — Pre-launch blocked dispatches report start_state=unknown, not the documented state

The outer dispatch() prechecks construct results without start evidence, although no adapter runs. Set not_started on those refusal paths, correct the documentation for the fingerprint precheck, and exercise the real dispatch path in regressions.

[REV-002] · low · open · valid · blocks:no — sk- redaction has no boundary and mangles ordinary words

The pattern matches inside task-172, disk-full, and risk-high. Add a credential boundary and verify that these diagnostic words survive.

[REV-003] · low · open · valid · blocks:no — Redaction covers only sk-, gh*_, github_pat_ and Bearer

The observed assignment, Basic-auth, Slack-token and AWS-key examples remain visible. Extend the bounded diagnostic masking and add regressions; arbitrary credentials without a recognizable shape remain a limitation.

[REV-004] · low · open · valid · blocks:no — Session-log fallback and checkout fingerprint run on every dispatch (code inspection only, not measured)

The unconditional fallback and unbounded dirty-file hashing are present. Restrict session lookup to failed or incomplete runs, bound fingerprint work used only for start evidence, and skip the second fingerprint when the stream already proves activity. Keep read-only contract verification exhaustive.

These dispositions are frozen for this run. Fixes and verification follow on the same worktree and PR branch.

@datacas

datacas commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261007-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

[CCT-20261007-001] · deep_coder · openai/gpt-6.1-sol→? · medium · triaged:8849514c3bfde3cb09f8d9723e6529a71904dbb2 · schema:1

Resolution of PR #195 / work item #172: RESOLVED. All four findings are addressed in commit 423d8414d79efd7e33473804ec7ee9df33582555, pushed to the existing task-172 branch from the task-specific linked worktree. No blocking findings remain.

Recovered the complete GitHub history with gh, allowing only the configured trusted author datacas. One review comment, no native reviews or inline threads, and no ID gaps or collisions were found. The supplied reviewed diff matched the PR head, 1139 lines and SHA-256 b9bbc3074468bc32e9229d1cb5def2470874b788fbabf8cc256c74538c27141b; it was read in sections. The dispositions below were recorded before editing against 8849514c3bfde3cb09f8d9723e6529a71904dbb2 and remain frozen.

[REV-001] · medium · resolved · valid · blocks:yes — Pre-launch blocked dispatches report start_state=unknown, not the documented state

All outer dispatch() refusal paths now return not_started: publication access and preflight, availability, calibration readiness, workspace policy, and the read-only fingerprint precheck. docs/telemetry.md now distinguishes a pre-launch fingerprint refusal from a violation detected after execution. The mapping regression now runs through dispatch() instead of specifying the expected start state in a constructed result. A separate real-path regression covers all outer prechecks, proving the adapter and attempt callback never run. The non-Git read-only fixture now returns BLOCKED, read_only_verification, contract_violation, not_started.

[REV-002] · low · resolved · valid · blocks:no — sk- redaction has no boundary and mangles ordinary words

Credential-shaped patterns have a token boundary. The exact diagnostic worktree task-172 disk-full risk-high survives unchanged, while actual shaped tokens are masked. The existing redaction-before-bounding and terminal-control regression still passes.

[REV-003] · low · resolved · valid · blocks:no — Redaction covers only sk-, gh*_, github_pat_ and Bearer

Masking now includes Slack tokens, AWS access-key IDs, Basic credentials, and named key/token/secret/password assignments, including quoted values and quoted JSON/dictionary keys. Regressions cover the review examples and JSON output. Delegated review exposed a quoted-key gap during this fix; it was corrected under this same finding and independently rechecked against eight JSON/dictionary cases. The report/status/SQLite boundary test confirms that diagnostics are redacted for display and only closed tokens enter telemetry.

[REV-004] · low · resolved · valid · blocks:no — Session-log fallback and checkout fingerprint run on every dispatch (code inspection only, not measured)

Successful Codex output with a terminal success or agent reply avoids session-log lookup. Failed or incomplete output retains correlated fallback, including zero-exit output that contains only a thread announcement. Start-evidence fingerprints hash at most 128 changed/untracked files and 8 MiB; exceeding the budget contributes no start evidence. Stream activity skips the second fingerprint. The existing _checkout_fingerprint(path) interface and all read-only contract callers remain exhaustive, through a separate generic helper. Tests prove lookup avoidance, incomplete-result fallback, conservative unknown when evidence is unavailable, and exhaustive detection of a second edit to a dirty file.

Verification (agent-reported; cc-verify conclusion verified, boundary required):

Command Exit Tests
rtk proxy python3 scripts/validate-package.py 0 —
rtk proxy env -u HERDR_ENV python3 -m unittest discover -s tests -p test_dispatch_failures.py 0 25
rtk proxy env -u HERDR_ENV python3 -m unittest discover -s tests 0 1155
rtk proxy env -u HERDR_ENV PYTHONPATH=scripts:tests python3 -m unittest test_dispatch_failures.ExecutorFailureTests.test_fake_binary_at_real_process_boundary test_dispatch_failures.ExecutorFailureTests.test_outer_prechecks_refuse_without_starting_an_attempt test_dispatch_failures.ExecutorFailureTests.test_workspace_start_budget_does_not_limit_read_only_verification test_dispatch_failures.StoreFailureTests.test_schema_14_migration_preserves_audit_bytes_and_is_idempotent test_dispatch_failures.StoreFailureTests.test_report_redacts_but_store_carries_only_tokens 0 5
rtk proxy git diff --check 0 —

Preflight required no external service, port, or runtime configuration; SQLite and fake executors use disposable fixtures. Local runs remove the inherited desktop HERDR_ENV, matching CI's absence of that host context. Git fixtures set their own identity. The validator initially rejected credential-shaped fixture literals and the first completed full suite caught the fingerprint signature regression; both were fixed before the successful final runs. Two output-processing runs timed out without a suite result; the final persistent command completed all 1155 tests with exit 0 in 124 seconds. Windows execution is assessed through CI.

Post-change workflow: delegated cc-code-review read the complete accumulated diff (all ten files), identified the quoted-key issue above, and then verified both that fix and the helper adjustment. No confirmed findings remain. Sensitivity triage evaluated the defaults because security_review.always_when is absent and the PR has no labels; no default path/filename/label trigger matched. Resolver judgement activated cc-security-review for untrusted executor diagnostics, credential masking, session-log paths, and telemetry. The scoped pass found no confirmed vulnerability: thread IDs are restricted and checked against session identity, diagnostic control characters are removed before masking and bounding, SQL updates use fixed mappings, and telemetry gates reject diagnostic prose.

Residual limits: credential masking is heuristic and cannot cover arbitrary secret formats. Session fallback on failed/incomplete runs still traverses the session directory and reads the correlated log in full. The start-evidence budget bounds file hashing, not Git enumeration time. No live provider-backed Codex/Claude/Orca run was executed; stream formats remain fixture-covered. The existing schema migration is irreversible without restoring a backup; only disposable stores were exercised here.

Checks of the pushed head 423d8414d79efd7e33473804ec7ee9df33582555: 4 passed, 0 failed, 0 pending, with no cancelled, skipped, or missing expected gate. rtk proxy gh pr checks 195 --repo datacas/code-cycle-toolkit --watch --interval 30 completed with exit 0; a final gh pr view confirmed the same head and states.

Check Event State
Skills, manifests, and Bash installer push pass
Skills, manifests, and Bash installer pull_request pass
PowerShell installer push pass
PowerShell installer pull_request pass

The structured result is returned in the invocation response as requested. This resolution records fixes and verification; it does not declare review approval.

@datacas

datacas commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261007-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

[CCT-20261007-001] · deep_coder · openai/gpt-6.1-sol→? · medium · triaged:8849514c3bfde3cb09f8d9723e6529a71904dbb2 · schema:1

[CCR-20261007-002] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

Rereview of PR #195 (work item #172) — APPROVED

Scope: complete accumulated diff 04e7393…423d841 (1370 lines, SHA-256 ca97aca2…c47dc, all 10 files), read in sections, plus the delta since the previously reviewed head 8849514 (executors, telemetry docs, workflows docs, tests). Head 423d8414d79efd7e33473804ec7ee9df33582555 matches the PR head. Conventions applied: AGENTS.md, .code-cycle.yml (trusted author datacas). History recovered from GitHub with gh: three trusted comments, no native reviews or threads, no ID gaps or collisions.

Summary: all four previous findings are fixed and verified by execution. One new non-blocking finding (REV-005): the new key/token/secret redaction pattern has quadratic regex backtracking on long separator-free runs.

Previous findings

[REV-001] · medium · resolved · valid · blocks:yes — Pre-launch blocked dispatches report start_state=unknown, not the documented state

Every outer dispatch() refusal now sets not_started (publication access and preflight, availability, calibration readiness, workspace policy, read-only fingerprint precheck). docs/telemetry.md now separates the pre-launch refusal from a post-execution violation. The mapping test now runs through dispatch(), and test_outer_prechecks_refuse_without_starting_an_attempt proves the adapter and attempt callback never run. Both pass.

[REV-002] · low · resolved · valid · blocks:no — sk- redaction has no boundary and mangles ordinary words

Probed: worktree task-172 disk-full risk-high is returned unchanged; sk-abc123 and x-sk-abc123 are masked.

[REV-003] · low · resolved · valid · blocks:no — Redaction covers only sk-, gh*_, github_pat_ and Bearer

Probed: xoxb-…, AKIA…, api_key=…, password=…, Authorization: Basic …, client_secret: …, and quoted JSON/dict keys with spaced values are masked; max_tokens=100 and token expired are not mangled. Heuristic limits are acknowledged in the PR. See REV-005 for a cost problem in the new pattern.

[REV-004] · low · resolved · valid · blocks:no — Session-log fallback and checkout fingerprint run on every dispatch (code inspection only, not measured)

Code and tests confirm: no session lookup after terminal success or an agent reply; fallback retained for failed or incomplete runs; the start-evidence fingerprint is capped at 128 files / 8 MiB and yields no evidence when exceeded; the second fingerprint is skipped once the stream proves activity; _checkout_fingerprint stays exhaustive for the read-only contract (separate helper, tested). Runtime cost was not measured.

New findings

[REV-005] · medium · open · - · blocks:no — Key/token/secret redaction regex backtracks quadratically on long separator-free runs

scripts/executors.py:310 (failure_excerpt). The prefix (?:[A-Za-z0-9]+[_-])* is re-tried from every word start, so a long run of [A-Za-z0-9_-] with no space or other delimiter costs O(n²). failure_excerpt masks the whole untrusted string before bounding it, and it now receives complete stderr/message text on NativeAdapter, Orca and _why paths.
Observed (throwaway script outside the repository): "a-" * n takes 0.034 s at 2 KB, 0.138 s at 4 KB, 0.545 s at 8 KB, and a 20 KB input did not finish within 100 s; extrapolating the quadratic growth, a ~100 KB base64url-style blob (-/_ alphabet) in an executor error would stall the driver for over a minute. Plain alphanumeric runs are fast (200 KB in 0.01 s).
Not blocking: it needs a contiguous multi-ten-KB token without whitespace and occurs only on a failure report path, but the input is executor-controlled. Suggested fix: make the prefix linear (e.g. (?<![A-Za-z0-9])[A-Za-z0-9_-]*(?:key|token|secret|password)\b), and/or cap the text (for example to a few tens of KB) before masking in a way that still masks any secret straddling the cut.

Security triage

security_review.always_when is not configured, so defaults applied; no matching paths, filenames or labels. Reviewer judgement kept the scoped audit active for the previously identified surfaces (untrusted executor output, credential masking, executor-supplied thread ID driving a filesystem read, stored-data migration). cc-security-review was not loaded as a separate delegate; its checks were applied inline (degraded run). Result: no confirmed vulnerability. Thread ID is restricted to [A-Za-z0-9-]{1,80} and verified against the log's own id; terminal escapes and control characters are stripped before masking and bounding; telemetry accepts only closed tokens. Potential risk: REV-005 (availability of the driver on hostile output).

Executed

  • env -u HERDR_ENV python3 -m unittest discover -s tests — exit 0, 1155 tests OK (93 s).
  • python3 scripts/validate-package.py — VALID: 15 skills.
  • Direct failure_excerpt probes (REV-002, REV-003, REV-005) via a throwaway script outside the repository.
  • The REV-001 and REV-004 regressions in tests/test_dispatch_failures.py ran as part of the full suite.

Unverified

No live Codex/Claude/Orca run: executor stream shapes are covered only by synthetic fixtures. Migration exercised only through the PR's disposable-database test. Windows behaviour is taken from CI. REV-004 runtime savings not measured. git diff --check against origin/main could not run in this clone (no remote); the diff file under review was used instead.

CI (head 423d841)

validate.yml: Skills, manifests, and Bash installer (push, pull_request) pass; PowerShell installer (push, pull_request) pass. 4 passed, 0 failed, 0 pending, none skipped.

Residual risks

Irreversible in-place store migration (documented; back up first). Credential masking is heuristic. Session-log fallback on failed runs still reads the correlated log in full. REV-005 above.

Verdict

APPROVED — current HEAD completely rereviewed, all required checks passed, REV-001…REV-004 resolved, and no open finding blocks approval (REV-005 is blocks:no). Merge remains a manual decision.

@datacas

datacas commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20261007-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

[CCT-20261007-001] · deep_coder · openai/gpt-6.1-sol→? · medium · triaged:8849514c3bfde3cb09f8d9723e6529a71904dbb2 · schema:1

[CCR-20261007-002] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

[CCT-20261007-002] · deep_coder · anthropic/claude-opus-5-5→? · high · triaged:423d8414d79efd7e33473804ec7ee9df33582555 · schema:1

Resolution of PR #195 / work item #172: RESOLVED. The only open finding, REV-005, is fixed in 536256e7ac505dc409349f5f2beb05bc1f79559b, pushed to task-172 from the task-specific linked worktree /home/datacas/www/code-cycle-toolkit/.worktree/task-172. No blocking findings remain.

History recovered with gh (trusted author datacas): four comments, no native reviews or inline threads, IDs REV-001…REV-005 with no gaps or collisions. The supplied accumulated diff (1370 lines) matches the PR head 423d841. REV-005 was triaged valid against 423d8414d79efd7e33473804ec7ee9df33582555 before any edit; that disposition was not published as a separate pre-edit comment, but it was fixed before the code changed and is frozen from here. REV-001…REV-004 keep their earlier dispositions and resolved status unchanged.

[REV-001] · medium · resolved · valid · blocks:yes — Pre-launch blocked dispatches report start_state=unknown, not the documented state

Unchanged since the rereview at 423d841.

[REV-002] · low · resolved · valid · blocks:no — sk- redaction has no boundary and mangles ordinary words

Unchanged since the rereview at 423d841.

[REV-003] · low · resolved · valid · blocks:no — Redaction covers only sk-, gh*_, github_pat_ and Bearer

Unchanged since the rereview at 423d841.

[REV-004] · low · resolved · valid · blocks:no — Session-log fallback and checkout fingerprint run on every dispatch (code inspection only, not measured)

Unchanged since the rereview at 423d841.

[REV-005] · medium · resolved · valid · blocks:no — Key/token/secret redaction regex backtracks quadratically on long separator-free runs

scripts/executors.py:215-219. Cause: \b(?:[A-Za-z0-9]+[_-])* could start at every word boundary inside a -/_ run, and each start rescanned to the end of the run. Fix: a name can now start only where its [A-Za-z0-9_-] run starts ((?<![A-Za-z0-9_-])), and the keyword must follow an optional [A-Za-z0-9_-]*[_-] prefix. Each run is scanned once with one backtrack, so cost is linear. The new prefix matches every name the old pattern matched (each old match position is still reachable through the backtracked [_-] split), so no masking is lost. Whole-segment behaviour stays the same: max_tokens=100, monkey=1, and token expired are unchanged. I also checked the other four patterns. sk-, gh*_, github_pat_, xox*, AKIA and Bearer/Basic each succeed or fail in a single linear scan per run, so I left them as they were. I did not add an input cap before masking, because a cap could cut a secret at the boundary.
Regression: test_redaction_is_linear_on_long_separator_runs runs "a-"*8000, "a_"*8000, and a 16 KB x- run that ends in an api_key assignment, each within 0.5 s. It also asserts that the long-prefixed assignment is still masked. test_redaction_preserves_words_and_masks_additional_credentials now also asserts that the three non-credential phrases above survive.

Verification (agent-reported; cc-verify conclusion verified_with_reservations, boundary required)

Python execution was not permitted in this resolver session (the host permission layer refused python3, including python3 -m unittest). I therefore did not run the tests locally and did not reproduce the original slowdown locally. I used the code host as the execution boundary instead and read the job logs of the pushed head:

Where Command Result
Linux, push python3 scripts/validate-package.py + python3 -m unittest discover -s tests -v pass; Ran 1160 tests; test_redaction_is_linear_on_long_separator_runs ... ok (~7 ms by log timestamps)
Windows, push py -3 scripts/validate-package.py + py -3 -m unittest discover -s tests -v pass; Ran 1160 tests; new test ok (~5 ms)

Reservations: the reviewer's original measurement (0.545 s at 8 KB, no completion at 20 KB) was not repeated against the old code in this session. The new test uses a 16 KB input of the same shape, which completes in milliseconds on both runners. CI runs on a fresh checkout with no user-global Git or shell state. The local environment was not used for any result.

Post-change workflow

  • cc-code-review over the delta (one regex, two tests): applied inline, not as a separate delegate (degraded run). I checked superset/linearity and the existing redaction expectations. No findings.
  • Sensitivity triage: security_review.always_when is absent and the PR has no labels, so the defaults applied and no path, filename or label trigger matched. My own judgement activated a scoped cc-security-review (applied inline) because the change touches credential masking of untrusted executor output. Result: no confirmed vulnerability. Masking coverage does not shrink. The driver-availability risk from REV-005 is removed for this pattern.

Checks of the pushed head 536256e7ac505dc409349f5f2beb05bc1f79559b

4 passed, 0 failed, 0 pending, none skipped or missing.

Check Event State
Skills, manifests, and Bash installer push pass
Skills, manifests, and Bash installer pull_request pass
PowerShell installer push pass
PowerShell installer pull_request pass

Residual risks

Credential masking is still heuristic. Session-log fallback on failed runs still reads the correlated log in full. The store migration is irreversible without a backup. No live Codex/Claude/Orca run took place.

The structured result is returned in the invocation response as requested. This resolution does not declare review approval.

@datacas

datacas commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner Author

[CCR-20261007-001] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

[CCT-20261007-001] · deep_coder · openai/gpt-6.1-sol→? · medium · triaged:8849514c3bfde3cb09f8d9723e6529a71904dbb2 · schema:1

[CCR-20261007-002] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

[CCT-20261007-002] · deep_coder · anthropic/claude-opus-5-5→? · high · triaged:423d8414d79efd7e33473804ec7ee9df33582555 · schema:1

[CCR-20261007-003] · reviewer · anthropic/claude-sonnet-5-5→? · high · schema:1

Rereview of PR #195 (work item #172) — APPROVED

Scope: complete accumulated diff 04e7393…536256e (1384 lines, SHA-256 0e5b1842…c1edc2, all 11 files), read in sections, plus the delta since the previously reviewed head 423d841 (the linear key/token/secret pattern in failure_excerpt and its regression test). Head 536256e7ac505dc409349f5f2beb05bc1f79559b matches the PR head. Conventions applied: AGENTS.md, .code-cycle.yml (trusted author datacas). History recovered from GitHub with gh: five trusted comments, no native reviews or threads, REV-001…REV-005 with no gaps or collisions.

Summary: REV-005 is fixed and verified by execution; REV-001…REV-004 stay resolved. Two new low, non-blocking findings (REV-006, REV-007).

Previous findings

[REV-001] · medium · resolved · valid · blocks:yes — Pre-launch blocked dispatches report start_state=unknown, not the documented state

Unchanged since 423d841; every outer dispatch() refusal still returns not_started, and test_outer_prechecks_refuse_without_starting_an_attempt passes.

[REV-002] · low · resolved · valid · blocks:no — sk- redaction has no boundary and mangles ordinary words

Re-probed at 536256e: worktree task-172 disk-full risk-high is returned unchanged.

[REV-003] · low · resolved · valid · blocks:no — Redaction covers only sk-, gh*_, github_pat_ and Bearer

Re-probed: x-api-key: … is masked; max_tokens=100 is not. The examples from the original finding still pass in the suite. See REV-006 for a prose false positive in the Basic/Bearer pattern.

[REV-004] · low · resolved · valid · blocks:no — Session-log fallback and checkout fingerprint run on every dispatch (code inspection only, not measured)

Unchanged since 423d841; runtime cost still not measured.

[REV-005] · medium · resolved · valid · blocks:no — Key/token/secret redaction regex backtracks quadratically on long separator-free runs

Verified by execution at 536256e (throwaway script outside the repository, python3 -I). failure_excerpt returns in under 0.3 s for each of "a-"*n, "a_"*n, "a-b_"*n, "sk-"*n, "xoxb-"*n, "key="*n at n = 8,000, 50,000 and 200,000; the previous code did not finish at 20 KB. Only "basic "*200000 (1.2 MB) took 0.33 s, which is linear. Quote runs, repeated key/token words and a long prefix before key finished in ≤ 13 ms at 40–120 KB. Masking is not weakened: x-api-key: …, the quoted JSON/dict cases and the credential examples in test_redaction_preserves_words_and_masks_additional_credentials still pass.

New findings

[REV-006] · low · open · - · blocks:no — basic/bearer credential pattern masks ordinary prose

scripts/executors.py:308. (?i)((?:bearer|basic)\s+)[A-Za-z0-9._~+/-]+=* has no word boundary and no check that a credential follows. Observed: failure_excerpt("a basic setup failed") → a basic [redacted] failed; "the Basic config is invalid" → the Basic [redacted] is invalid. This is the same class as REV-002 (diagnostic words corrupted); it affects only the transient stop report and status line, not telemetry. Suggested fix: require \b before the scheme and, for basic, a base64-shaped value (for example [A-Za-z0-9+/]{8,}={0,2}), or anchor to Authorization:.

[REV-007] · low · open · - · blocks:no — docs/telemetry.md points to the schema history in docs/instrumentation.md, which stops at schema 14

docs/telemetry.md:98. The diff replaces "schema versions 1–14" with "schema history" in the pointer to Instrumentation → Telemetry, but docs/instrumentation.md has no schema 15 entry (its history ends with schema 14, around line 721), so the pointed-to history does not describe start_state, the new attempt_error_code vocabulary or the migration. Add a short schema 15 paragraph there, or have the pointer name telemetry.md#dispatch-failure-evidence-schema-15.

Other observations (not findings)

  • Credential masking stays heuristic: camelCase names (apiKey=…, accessToken: …, clientSecret=…) and Authorization: Token … are not masked. The PR already states that arbitrary secret formats are out of scope.
  • The capability mapping is closed over the code: a scan of every capability literal in scripts/*.py plus both adapters' interactive_markers found no value missing from CAPABILITY_ERROR_CODES.

Security triage

security_review.always_when is not configured, so defaults applied; no matching paths, filenames or labels. Reviewer judgement kept the scoped audit for untrusted executor output, credential masking, the executor-supplied thread ID that drives a filesystem read, and the stored-data migration. cc-security-review was not loaded as a separate delegate; its checks were applied inline (degraded run). Result: no confirmed vulnerability. Thread ID is restricted to [A-Za-z0-9-]{1,80} and verified against the log's own id; terminal escapes and control characters are stripped before masking; telemetry accepts only closed tokens; the migration is transactional with fixed SQL. The REV-005 availability risk is gone for the reviewed patterns. Potential risk: REV-006 (over-masking only).

Executed

  • python3 scripts/validate-package.py — exit 0, VALID: 15 skills.
  • env -u HERDR_ENV CODE_CYCLE_HOME=<temp dir> python3 -m unittest discover -s tests — exit 0, Ran 1156 tests, OK (116 s). The resolver's report cites 1160 tests from CI runs; the local count differs and I did not reconcile it, so CI's count is not independently confirmed.
  • Direct failure_excerpt timing and masking probes (REV-002, REV-003, REV-005, REV-006) and a capability-closure scan, via throwaway scripts outside the repository.

Unverified

No live Codex/Claude/Orca run: real executor stream shapes (including Codex session-log error placement) are covered only by synthetic fixtures. The migration was exercised only through the PR's disposable-database test. Windows behaviour is taken from CI. REV-004 runtime savings not measured. git diff --check against origin/main could not run in this clone (no remote); the supplied diff file was used instead.

CI (head 536256e)

gh pr checks 195: Skills, manifests, and Bash installer (push, pull_request) pass; PowerShell installer (push, pull_request) pass. 4 passed, 0 failed, 0 pending, none skipped or missing.

Residual risks

Irreversible in-place store migration (documented; back up first). Credential masking is heuristic and slightly over-masks (REV-006). Session-log fallback on failed runs still reads the correlated log in full.

Verdict

APPROVED — current HEAD completely rereviewed, all required checks passed, REV-001…REV-005 resolved, and no open finding blocks approval (REV-006 and REV-007 are blocks:no). Merge remains a manual decision.

ORCHESTRATION_RESULT (JSON)

ORCHESTRATION_RESULT
{
"skill": "cc-rereview",
"status": "APPROVED",
"issue_provider": "github",
"issue_id": "172",
"code_host": "github",
"change_request_id": "195",
"change_request_url": "#195",
"pr_number": 195,
"issue_number": 172,
"comment_url": "#195 (comment)",
"previous_reviewed_head_sha": "423d8414d79efd7e33473804ec7ee9df33582555",
"reviewed_head_sha": "536256e7ac505dc409349f5f2beb05bc1f79559b",
"head_sha": "536256e7ac505dc409349f5f2beb05bc1f79559b",
"review_run_id": "CCR-20261007-003",
"reviewer": {
"profile": "reviewer",
"provider": "anthropic",
"model_requested": "claude-sonnet-5-5",
"model_resolved": null,
"effort": "high"
},
"verified_findings": [
{"id": "REV-001", "severity": "medium", "blocks_approval": true, "status": "resolved", "disposition": "valid"},
{"id": "REV-002", "severity": "low", "blocks_approval": false, "status": "resolved", "disposition": "valid"},
{"id": "REV-003", "severity": "low", "blocks_approval": false, "status": "resolved", "disposition": "valid"},
{"id": "REV-004", "severity": "low", "blocks_approval": false, "status": "resolved", "disposition": "valid"},
{"id": "REV-005", "severity": "medium", "blocks_approval": false, "status": "resolved", "disposition": "valid"}
],
"new_findings": [
{"id": "REV-006", "severity": "low", "status": "open", "disposition": "-", "blocks_approval": false, "path": "scripts/executors.py", "line": 308},
{"id": "REV-007", "severity": "low", "status": "open", "disposition": "-", "blocks_approval": false, "path": "docs/telemetry.md", "line": 98}
],
"blocking_findings": [],
"blocking": false
}
END_ORCHESTRATION_RESULT

@datacas

datacas commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

REV-006 and REV-007 (both low, blocks:no) are deferred to #198 so this PR can merge as approved at 536256e.

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