Skip to content

Record structured, correlatable cycle outcomes (#37) - #44

Merged
datacas merged 2 commits into
mainfrom
issue-37-cycle-outcomes
Sep 23, 2026
Merged

datacas merged 2 commits into
mainfrom
issue-37-cycle-outcomes

Conversation

@datacas

@datacas datacas commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Work item: #37 — #37

What changes

The cycle now records what a run went on to produce, on rows kept apart from the pre-routing dispatch rows introduced in #35. A dispatch row is written once, before its stage's result is known, and nothing is ever added to it.

Correlation (telemetry.CORRELATION_FIELDS, payload only):

  • cycle_id — minted per CycleRecorder (or passed explicitly), validated as an identifier before anything is dispatched; two runs of one work item stay apart.
  • stage_seq — numbers stage() calls; a rerouted attempt shares its stage's number, and a verdict carries the number of the dispatch it reports on.
  • record_kind — dispatch | verdict | cycle.

Outcomes (telemetry.OUTCOME_FIELDS, one source row each):

  • verdict: status, findings_* by severity, tests_passed (only from a boolean tests.passed in the structured result), checks_*.
  • cycle: first_review_status, first_pass_approved, resolution_needed, resolution_rounds (only once a first review reached APPROVED/CHANGES_REQUESTED); final_review_status, final_approved; latest tests_passed; fallback_stages, contract_violations (always observed by the recorder).

Telemetry.cycle_outcome(repo_id, cycle_id) reassembles a run — dispatches, verdicts and closing outcome — and reports closed: false for a run that never closed.

Acceptance criteria

  • Reconstructable per run: first-pass approval, resolution and rounds, review verdict, findings by severity, tests, final approval, fallback, contract violations — ReconstructionTests, DispatchObservationTests, DriverTests.
  • Typed allowlist only, no collections or prose — every new field is in FIELD_SPECS with type/bounds/vocabulary; AllowlistTests.
  • Pre-routing features immutable and pre-decision only — SeparationTests checks dispatch rows are byte-identical after verdict/close, carry no outcome field, and that outcome, correlation and pre-routing sets are disjoint.
  • Absent is not approved/zero/passing — UnknownIsNotDefaultTests (no verdict, BLOCKED review, unclosed run, verdict without findings, unreadable tests).
  • Correlatable with the rules' choice and a future Jev suggestion without Jev installed — profile on the dispatch row, keyed by (cycle_id, stage_seq); nothing records a suggestion yet.
  • Existing databases readable — schema 3 is additive in payload; LegacyRowTests and the updated schema-compatibility test.

Out of scope, as the issue states: no routing change, no Jev decision, no thresholds, no prose/paths/diffs stored.

Verification

  • python3 scripts/validate-package.py → VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned
  • python3 -m unittest discover -s tests → Ran 552 tests … OK (17 new in tests/test_cycle_outcomes.py)

Notes

  • resolution_rounds counts the resolve stages the run attempted, including a blocked one.
  • The existing used_fallback column still defaults to 0 on non-dispatch rows (unchanged); the cycle-level fallback fact is fallback_stages.

Closes #37

What a run went on to produce is now recorded on rows of its own, never
on the dispatch rows that hold the pre-routing signals:

- verdict rows: status, findings by severity and a reported boolean
  tests.passed;
- the closing cycle row: first-pass approval, whether resolution was
  needed and its rounds, first and final review verdicts, final
  approval, the latest test result, fallback stages and contract
  violations.

Every row of one run carries a cycle_id minted per CycleRecorder and
validated before anything is dispatched; stage_seq ties a verdict to the
dispatch it reports on, and record_kind names dispatch, verdict or
cycle. Telemetry.cycle_outcome reassembles a run and reports an unclosed
one as unknown. Review outcomes appear only after a review reached
APPROVED or CHANGES_REQUESTED, so an absent outcome never reads as
approved, passing or zero. Every value goes through FIELD_SPECS.

Telemetry schema moves to version 3 additively in payload; version-1
and version-2 rows stay readable and belong to no reassembled cycle.

Closes #37
@datacas

datacas commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

Review: CHANGES_REQUESTED

Reviewed the accumulated diff from 66b903cadc961b4598f121ee703d405c5e88d3d2 to d66851b044d7353da23e8ddfe8aa1bd5cc36d39f for PR #44, including the linked scope in issue #37. The eight changed files implement cycle outcome telemetry, schema 3 correlation, documentation, and tests. The scope matches the issue and PR description, with one documented outcome not wired into the runtime.

Findings

[REV-001] · medium · open · blocks:yes — Documented check outcomes are never recorded

Path: scripts/run_cycle.py:527 (documented at docs/instrumentation.md:567).

The verdict path passes only _findings(...) and _tests(...) to record_verdict. There is no parser for a structured checks result, so checks_passed and checks_failed are never supplied by the runtime even though the telemetry allowlist and docs advertise them. A result that reports check counts therefore loses them from both the verdict and reconstructed cycle outcome. I reproduced this with a structured result containing four passed and one failed check: _findings and _tests emitted no checks_* fields. Parse and validate the reported check counts and pass them into the verdict row, or remove the unsupported fields from the documented contract.

Security triage

This change touches observability and persisted telemetry, so the security audit was run. No confirmed vulnerability was found in the changed surfaces. The review covered the typed field allowlist, identifier validation, and separation of structured values from free text. The audit did not exercise external agent providers or a deployed telemetry database.

Verification

  • python3 scripts/validate-package.py — passed: VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned.
  • python3 -m unittest discover -s tests -v — passed: 552 tests.
  • Focused execution with checks: {passed: 4, failed: 1} — confirmed the verdict helpers emit no checks_* fields.
  • Verification preflight found Python 3.10.12 with sqlite3 and unittest available. These checks use isolated test databases; no application service or runtime configuration was required.

CI

All current GitHub checks passed: Skills, manifests, and Bash installer (two successful runs) and PowerShell installer (two successful runs). No pending, failed, cancelled, or skipped checks were reported. The configured workflow defines the package validation and installer checks; the unit suite was also run locally as listed above.

Residual risks

The suite exercises simulated cycle adapters rather than external agent providers or a deployed telemetry database. The advertised check-count gap remains open and prevents approval.

Verdict

Request changes. Resolve REV-001 before approval.

No skill's structured result reports check counts, so listing
checks_passed and checks_failed as verdict outcomes described data
nothing writes. They leave OUTCOME_FIELDS and the documented contract,
and stay accepted telemetry fields. A regression test pins the
documented verdict outcomes to exactly what run_cycle reads off a
structured result.
@datacas

datacas commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

Resolution: RESOLVED

Resolved the review at d66851b044d7353da23e8ddfe8aa1bd5cc36d39f; new head 78ddf00cac038428dea65feac32ad878f1562ba0.

Findings

[REV-001] · medium · resolved · blocks:yes — Documented check outcomes are never recorded

Path: scripts/telemetry.py (OUTCOME_FIELDS), docs/instrumentation.md (Cycle outcomes), tests/test_cycle_outcomes.py.

Decision: valid. Fixed by the second option the review offered, which removes the fields from the documented contract. No skill's ORCHESTRATION_RESULT defines a checks shape (grep over skills/, scripts/, docs/ and README.md finds none). Parsing checks: {passed, failed} would therefore invent a contract that no producer emits.

  • checks_passed and checks_failed are removed from OUTCOME_FIELDS["verdict"] and from the Cycle outcomes table. They stay accepted FIELD_SPECS fields, so existing callers are unaffected, and the docs now say they are not a recorded outcome.
  • A new regression test, test_every_documented_verdict_outcome_is_one_the_driver_records, requires the documented verdict outcomes to equal exactly what run_cycle._findings and _tests emit from a structured result. That result includes the reviewer's checks: {passed: 4, failed: 1}.
  • Reproduction: with scripts/telemetry.py restored to d66851b, the new test fails (checks_failed and checks_passed are documented but not emitted). With the fix, it passes.

Commit: 78ddf00cac038428dea65feac32ad878f1562ba0.

Post-change workflow

  • Delegated code review of the accumulated diff: no P0 or P1 findings. It noted one P3 outside this finding's scope: stage_seq takes its number before the change observer runs, so an observer exception leaves a gap in the numbering. That is harmless because the numbers are ordinal.
  • Security triage: the fix only narrows a documented field set and adds no input, boundary or dependency, so no security audit was needed.

Verification

  • python3 -m unittest tests.test_cycle_outcomes: 18 tests OK.
  • python3 -m unittest discover -s tests: Ran 553 tests … OK.
  • python3 scripts/validate-package.py: VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned.

CI

gh pr checks 44 on the new head: Skills, manifests, and Bash installer passed twice and PowerShell installer passed twice. Nothing is pending, failed, cancelled or skipped.

Residual risks

Check counts are not recorded as a cycle outcome until a skill defines them in its structured result. CI state stays in the published review comment.

@datacas

datacas commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

Re-review: APPROVED

Re-reviewed the accumulated diff for PR #44 against main at 66b903cadc961b4598f121ee703d405c5e88d3d2, including the linked scope in issue #37. The current head is 78ddf00cac038428dea65feac32ad878f1562ba0.

Since the previous review, commit 78ddf00 removed checks_passed and checks_failed from the documented OUTCOME_FIELDS contract, clarified that generic telemetry still accepts them but no skill reports check counts, and added a regression test comparing documented outcomes with the driver’s emitted fields. The rest of the accumulated change remains cycle outcome telemetry, schema 3 correlation, documentation, and tests. I found no new findings in the accumulated diff.

Previous findings

[REV-001] · medium · resolved · blocks:yes — Documented check outcomes are never recorded

Disposition: corrected and verified by execution. The documented outcome contract no longer promises check counts that the structured-result protocol does not provide. CI state remains in the published review comment. The new test_every_documented_verdict_outcome_is_one_the_driver_records passes, and the original reproduction now confirms that driver output matches OUTCOME_FIELDS["verdict"] without checks_*.

No other prior findings were recorded. No new findings were added.

Security triage

The change still touches observability and persisted telemetry, so the security audit was repeated against the current accumulated change. No confirmed vulnerability was found in the changed surfaces. The follow-up only narrows the documented outcome set and adds a test; it does not add a new input or trust boundary. External agent providers and a deployed telemetry database were not exercised.

Verification

  • python3 -m unittest discover -s tests -p test_cycle_outcomes.py -v — passed, including the REV-001 regression test.
  • Focused execution of the original checks: {passed: 4, failed: 1} case — passed: the documented verdict fields now match the fields emitted by the driver.
  • python3 scripts/validate-package.py — passed: VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned.
  • python3 -m unittest discover -s tests -v — passed: 553 tests.
  • Verification preflight found Python 3.10.12 with sqlite3 and unittest available. The checks use isolated test databases; no application service or runtime configuration was required.

CI

All current GitHub checks passed: Skills, manifests, and Bash installer (two successful runs) and PowerShell installer (two successful runs). No pending, failed, cancelled, or skipped checks were reported. The configured workflow’s package validation and installer checks are present; the unit suite also passed locally.

Residual risks

External agent providers and a deployed telemetry database were not part of execution-backed verification. The change records only outcomes available through the current structured-result protocol.

Verdict

Approve. REV-001 is corrected and verified; there are no open blocking findings.

@datacas
datacas merged commit 75d93ed into main Sep 23, 2026
4 checks passed
@datacas
datacas deleted the issue-37-cycle-outcomes branch September 24, 2026 09:21
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.

Registrar outcomes estructurados y correlacionables de cada ciclo

1 participant