Skip to content
This repository was archived by the owner on Sep 28, 2026. It is now read-only.

fix: validator satisfiability + repair correlation contracts - #18

Merged
jnyross merged 3 commits into
mainfrom
fix/validator-satisfiability-repair-correlation
Aug 9, 2026
Merged

jnyross merged 3 commits into
mainfrom
fix/validator-satisfiability-repair-correlation

Conversation

@jnyross

@jnyross jnyross commented Aug 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

Static review of the frozen Lisbon dogfood v5 candidate (/tmp/orch/lean-v5-review.md, findings 1,2,3,6,7,8; lab mac-vm-harness--codexgraph-test/candidates/frozen-lisbon-v5/, workflow sha 64c541c4…) found the generated run structurally unable to pass. These are skill-guidance gaps, fixed here as explicit contracts.

Defects in the frozen bytes → contracts added

  • [finding 1/8, P0] V1 can never pass. workflow.js:209 rewraps each single selected candidate into the batch-level validateHandoff whose complete-branch requires candidates.length >= 5 (:120) → every run ends failed (:245); T1 unreachable. → SKILL.md rule 19 + patterns validation gate: dry-run the acceptance validator against a minimal conforming draft; a validator with no reachable pass verdict is a generation defect; never reuse a batch-level validator on subset payloads.
  • [finding 2, P1] Repair recollect re-reads the stale pre-repair handoff. :240 → collect() initial read (:168) → findHandoff returns the original handoff instantly; repair is a guaranteed no-op. → lifecycle §3 + patterns repair section + SKILL.md rule 21: record the thread turn count or cursor before sending the repair message; accept only handoffs emitted after that point.
  • [finding 3, P2] Affected filter degenerates to all workers. :237 second disjunct /^C[1-5]:/ matches whenever anything failed; verdict.affected_ids (:210) never used. → select repair targets from the verdict's affected_ids mapped to node IDs; never a criterion-prefix pattern.
  • [finding 6, P2] Invalid sighting is instantly terminal. :178-179 throws on the first invalid handoff though the worker could still emit a valid one in-window. → lifecycle §3 step + SKILL.md rule 9: skip invalid sightings; fail-closed reserved for explicit blocked/failed status or window exhaustion.
  • [finding 7a, P3] Catch path drops progress. :255 reports executed_nodes: []. → lifecycle §7 + SKILL.md rule 15: blocked/failed terminals preserve executed_nodes.

Changes

  • skills/codex-graph/SKILL.md: rules 9/15/19/21 extended; 4 quality-check bullets.
  • references/task-lifecycle.md: §3 invalid-sighting step + post-repair-cursor paragraph; §7 executed_nodes rule; §8 three new lifecycle cases. (§2 pending/matcher content untouched — owned by feat/matcher-keys-preflight.)
  • references/code-mode-script-patterns.md: satisfiability + subset-payload paragraph in the validation gate; repair-targeting + post-repair-cursor paragraph in the repair section, each with the observed v5 evidence line.
  • scripts/validate_skill.py: phrase checks mirror every contract (SKILL/lifecycle/patterns lists).
  • scripts/task_collection_harness.js: collectTask gains minTurn (handoffs searched only in turns[i>=minTurn] — post-repair provenance) and validateHandoff (invalid complete/passed sightings recorded in new invalidSightings and skipped; explicit blocked/failed always accepted).
  • scripts/task_collection_harness.test.js: 3 new fixtures — stale-pre-repair rejected / post-repair accepted; invalid-sighting-then-valid success; explicit failed accepted despite validator errors.
  • CHANGELOG: one Unreleased entry.

Test plan

  • sh scripts/run_regressions.sh green (validate_skill PASS, node --test 17/17, graph_coherence all ok, python harness 4/4)
  • After merge: regenerate Lisbon as v6; expect V1 pass-path reachable and, on any repair, post-repair-only recollection

Open in Devin Review

Note

Low Risk
Changes are confined to codex-graph skill docs, static validation phrases, and the task collection harness with new tests; no production runtime or auth paths are touched.

Overview
Addresses Lisbon dogfood v5 failures where generated workflows could not pass validation or repair even with good worker output. The PR turns those gaps into explicit codex-graph contracts and backs them with harness behavior and static checks.

Skill and reference docs extend rules for acceptance validators (dry-run a minimal conforming draft; no unreachable pass path; do not reuse batch validators on subset payloads), repair targeting (affected_ids → node IDs, not criterion-prefix patterns), post-repair recollection (required marker such as corrected_at, cursor provenance, no turn-index correlation), handoff collection (skip structurally invalid sightings; fail closed only on explicit blocked/failed or budget exhaustion), and terminals (blocked/failed must keep executed_nodes). validate_skill.py gains phrase checks so the bundle cannot drift.

task_collection_harness.js refactors handoff discovery to depth-first iteration, adds optional repairMarker, startCursor, and validateHandoff, records invalidSightings, and applies marker/cursor filtering so stale pre-repair completes are ignored while explicit failed still wins. Tests cover repair recollect, clipped windows, cross-surface marker filtering, invalid-then-valid sightings, and failed-worker acceptance despite validator errors.

Reviewed by Cursor Bugbot for commit aed9f69. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes

    • Improved task collection to discover multiple valid handoffs, skip invalid sightings, and continue processing.
    • Prevented stale handoffs from being accepted after repair requests.
    • Preserved executed-node progress for blocked and failed outcomes.
    • Improved repair targeting and post-repair result handling.
  • Documentation

    • Added guidance for validator checks, subset-safe validation, affected-item targeting, and repair handoff handling.
  • Tests

    • Added coverage for invalid handoff recovery, stale handoff rejection, and failed-worker handoff handling.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds repair-aware handoff collection. It validates successful handoffs, skips invalid sightings, filters stale pre-repair results, derives repair targets from affected IDs, and preserves executed-node progress in terminal results.

Changes

Handoff validation and repair flow

Layer / File(s) Summary
Validator and repair-boundary rules
skills/codex-graph/SKILL.md, skills/codex-graph/references/code-mode-script-patterns.md, skills/codex-graph/scripts/validate_skill.py
Guidance and validation checks require reachable validator pass verdicts, subset-safe payload validation, affected-ID repair targeting, and post-repair handoff filtering.
Repair-aware handoff collection
skills/codex-graph/scripts/task_collection_harness.js, skills/codex-graph/scripts/task_collection_harness.test.js
collectTask traverses nested values, validates successful handoffs, skips invalid sightings, filters stale results, preserves cursor provenance, and returns invalid sightings. Tests cover stale, invalid, clipped, fallback, and failed handoffs.
Lifecycle terminal handling and verification
skills/codex-graph/SKILL.md, skills/codex-graph/references/task-lifecycle.md, CHANGELOG.md
Lifecycle guidance skips invalid handoffs, preserves executed_nodes for blocked or failed terminals, and documents the related verification cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant collectTask
  participant readThread
  participant validateHandoff
  participant waitThreads
  collectTask->>readThread: read current handoff snapshots
  readThread-->>collectTask: return handoff sightings
  collectTask->>validateHandoff: validate complete or passed handoff
  validateHandoff-->>collectTask: return valid or invalid result
  collectTask->>waitThreads: wait when no valid terminal exists
  waitThreads-->>collectTask: return later handoff snapshots
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main changes: validator satisfiability and repair correlation contracts.
Description check ✅ Passed The description provides a detailed summary and test plan, but it omits the required Validation and Test notes headings.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/validator-satisfiability-repair-correlation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@cursor

cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_384de44d-9d2c-48e1-a9c2-81c147a079fe)

jnyross and others added 3 commits August 9, 2026 21:54
Static review of frozen Lisbon dogfood v5 (structurally unable to pass):
- SKILL.md + patterns: dry-run acceptance validators for a reachable pass
  verdict; never reuse batch-level validators on subset payloads (v5 C5
  rewrapped single candidates into the >=5-candidate batch rule).
- Repair: targets come from verdict affected_ids mapped to node IDs, never
  a criterion-prefix pattern; recollect accepts only handoffs emitted after
  the recorded pre-repair turn cursor (stale handoff is not a correction).
- Collection: a structurally invalid handoff sighting is skipped, not
  terminal; fail-closed reserved for explicit blocked/failed or window
  exhaustion.
- Terminals: blocked/failed must preserve executed_nodes; never reset in a
  catch path.
- validate_skill.py phrase checks mirror every contract; harness gains
  minTurn + validateHandoff options with three new fixtures (17/17).
validateHandoff rejections must skip only that sighting and keep scanning
for a later valid terminal handoff within the same turns tree.
…rohibited

cg-lean review of ce61f91 (/tmp/orch/pr18-review.md §5) proved index-based
minTurn unsafe under clipped read windows: absolute index vs windowed array
manufactures the v5 'never saw the final message' symptom (scenario B), and
a relative index reinstates stale acceptance (scenario C). No array index is
safe.

- harness: collectTask minTurn -> repairMarker (explicit post-repair marker,
  e.g. corrected_at, demanded by the repair prompt; marker-less complete
  handoffs recorded as sightings and skipped) + startCursor (cursor
  provenance seeded into the initial read). Repair mode keeps ALL fallback
  surfaces (terminal/items/turns/whole snapshot); provenance is a content
  filter, not a search restriction.
- docs (SKILL rule 21, lifecycle, patterns): marker+cursor is the normative
  correlation form; array-index correlation prohibited; clipped-window
  sentence references the sibling collection read-bounds contract.
- SKILL rule 9 + lifecycle step 9: handoff sighting (skip and continue) vs
  malformed validator verdict (still fails closed at the gate).
- fixtures: scenario B clipped window (marker-carrying handoff found in a
  2-turn window); fallback-surface + marker filter; existing repair fixture
  moved to repairMarker. 20/20.
- validate_skill.py: phrases 'post-repair marker' / 'Never correlate by
  array index' replace the index-era phrases in all three lists; mangle and
  doc-revert controls verified (12/12 exit 1).
@jnyross
jnyross force-pushed the fix/validator-satisfiability-repair-correlation branch from 4ad4ec2 to aed9f69 Compare August 9, 2026 20:55
@cursor

cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_d2d66ce5-074e-40a7-bb18-da45b573e058)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/codex-graph/scripts/task_collection_harness.js`:
- Around line 215-217: Strengthen post-repair validation in the collector around
repairMarker, startCursor, and validateHandoff so the accepted handoff proves it
was emitted after repair, not merely that it contains corrected_at. When
recollection supports cursors, require and validate the recorded repair cursor;
otherwise require an equivalent candidate turn ID or provenance value later than
the repair boundary. Add a regression test covering a stale handoff that already
contains the repair marker and ensure it is rejected.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 86cd281a-86c8-46f1-94a3-5d63bf744ad5

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad4ec2 and aed9f69.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • skills/codex-graph/SKILL.md
  • skills/codex-graph/references/code-mode-script-patterns.md
  • skills/codex-graph/references/task-lifecycle.md
  • skills/codex-graph/scripts/task_collection_harness.js
  • skills/codex-graph/scripts/task_collection_harness.test.js
  • skills/codex-graph/scripts/validate_skill.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • skills/codex-graph/scripts/validate_skill.py
  • CHANGELOG.md
  • skills/codex-graph/scripts/task_collection_harness.test.js
  • skills/codex-graph/references/code-mode-script-patterns.md

Comment on lines +215 to +217
repairMarker,
startCursor,
validateHandoff,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Require verifiable post-repair provenance.

repairMarker alone does not prove that a handoff was emitted after repair. A stale handoff can already contain corrected_at, and startCursor is optional. The collector can then accept stale repaired data.

When repair recollection runs, require the recorded repair cursor when the tool supports cursors. Otherwise, require and validate a candidate turn ID or equivalent provenance that is later than the recorded repair boundary. Add a regression test with a stale handoff that already has the repair marker.

Also applies to: 251-265

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/codex-graph/scripts/task_collection_harness.js` around lines 215 -
217, Strengthen post-repair validation in the collector around repairMarker,
startCursor, and validateHandoff so the accepted handoff proves it was emitted
after repair, not merely that it contains corrected_at. When recollection
supports cursors, require and validate the recorded repair cursor; otherwise
require an equivalent candidate turn ID or provenance value later than the
repair boundary. Add a regression test covering a stale handoff that already
contains the repair marker and ensure it is rejected.

@jnyross
jnyross merged commit 7ac91ae into main Aug 9, 2026
4 checks passed
@jnyross
jnyross deleted the fix/validator-satisfiability-repair-correlation branch August 9, 2026 21:07
jnyross added a commit that referenced this pull request Aug 9, 2026
PRs #14, #16, #17, #18, and #20 added manual Unreleased bullets; the
release workflow prepended [0.4.5] through [0.5.4] for the same changes
without folding them in. The changelog is generated from commit subjects
at release time, so the manual section is pure duplication. Also
document the convention in the README versioning section so it stops
recurring.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants