Repository navigation
test(runtime-logs): pin cursor codec rules surviving mutants - #2176
Conversation
A mutation sweep of packages/occ/src/runtime-logs/cursor.ts left 40 of 51 mutants alive against the runtime log, API security and HTTP error suites. Three codec-level cases kill the 36 that are real gaps: binding fields (agent, revision, source, delimiters), the v1 envelope and short MACs, expiry and clock-skew boundaries, the 48-hash cap, the secret length, signed schema validation of position fields, and the kubelet time validator and fraction ordering. The other four are equivalent. Test only.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR adds three conformance cases covering runtime-log cursor bindings, signed position validation, and timestamp rules. Example: A cursor issued for agent-test is decoded for agent-other.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it adds useful coverage for existing cursor security and ordering contracts, with no concrete introduced defect found. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherOCC's runtime-log readers validate signed cursors before Driver log reads; the cursors carry identity-bound resume positions and bounded frontier state. flowchart LR
A[Runtime log request] --> B[OCC authorization]
B --> C[Cursor validation]
C --> D[Driver log read]
D --> E[Sanitized page and cursor]
F[New conformance cases] --> C
Technical reviewBest possible solution: Retain the focused codec coverage alongside the existing reader and route tests. Do we have a high-confidence way to reproduce the issue? No production bug is claimed; source inspection confirms that the new assertions target existing behavior, while the reported mutation results were not independently executed. Is this the best way to solve the issue? Direct codec tests are appropriate for these signed-format and identity invariants, and they introduce no test-only production seam. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 220cc9572400. TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 11, 2026, 9:13 AM ET / 13:13 UTC. |
Review nits: the hash cap, exact line hash and secret length get their own case title, and the malformed-fields case first checks that its unchanged fixture position decodes as valid.
Problem
packages/occ/src/runtime-logs/cursor.tssigns runtime log cursors and binds them to one principal, Agent, revision and source. It also validates the signed position and the kubelet frontier times the reader orders by. A mutation sweep found that the existing suites killed only 11 of 51 mutants of these rules. The suites were runtime-logs-content, runtime-logs-sandbox, runtime-logs-replay, occ-api-security and http-errors. For example, a cursor that ignored the Agent, revision or source binding still passed every test, as did a cursor carrying av2.prefix or an extra segment, or one issued an hour in the future. A truncated MAC (wheretimingSafeEqualwould throw) also passed, and so did a Driver time of2026-02-30T12:00:00Z. The product code is correct; the tests did not pin it.Change
Test only.
tests/conformance/runtime-logs-content.test.mjsgets a small codec fixture and four cases, placed before the PEM route-polling case:v1prefix or a short MAC; the short MAC returnsinvalidinstead of throwing. Expiry starts strictly after the TTL, and up to 60 s of clock skew is tolerated (60.001 s is refused).valid, and each of 11 malformed position fields, signed with the real secret, decodes asinvalid. This follows the existing PEM-pair case.validRuntimeLogFrontierTimeaccepts kubelet UTC only. It refuses 10-digit fractions,+00:00offsets, extended years, Feb 30 and month 13.compareRuntimeLogTimetreats a trimmed fraction as equal to its zero-padded form and orders.5after.123.Verification
cursor.ts, run one at a time in a separate worktree.v, so the next check refuses it.pemAfterTimewhose time key equals lastTime's key forces lastTime to be valid.encodenever signs more than 48 hashes.runtime-logs-content.test.mjs: 71/71 tests. Two sets of 20/20 full-file runs, each pinned withtaskset -c 2,3: one on c023521 and one on 8a3618e, at 4.9-6.8 s.--check(shown to fail on a misformatted copy) and eslint are clean on the file.Risks
Test only; no product change. The boundary values (60 s skew, 48 hashes, 32-character secret, and the TTL edge via the exported constant) are pinned exactly, so changing one of them deliberately needs a test update. The cases sit away from the lines open PR #1981 edits in this file; a trial
merge-treewith its head merges the file cleanly.