Repository navigation
fix(oc-path): prevent duplicate YAML timestamp keys during edits - #169266
Conversation
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR refuses YAML leaf replacements through object-valued mapping keys before cloning can create duplicate entries. Example: A YAML 1.1 document contains
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a current YAML corruption path with a focused guard, useful regression coverage, and supplied shipped-CLI proof; no actionable findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe bundled oc-path plugin translates CLI addresses into YAML document paths, applies edits through the YAML adapter, and returns bytes for the CLI to write. flowchart TD
A[Path set CLI] --> B[Universal edit dispatch]
B --> C[YAML path resolver]
C --> D[Object key guard]
D --> E[Unresolved refusal]
D --> F[Clone and edit YAML]
F --> G[CLI file write]
Technical reviewBest possible solution: Keep the guard in the existing YAML mutation owner, preserving primitive-key edits while refusing identity-unstable replacements before cloning. Do we have a high-confidence way to reproduce the issue? Current-main source and yaml 2.9.1 identity comparisons establish the failure path; supplied built-CLI comparisons confirm it, although this read-only review ran no target code. Is this the best way to solve the issue? The four-line guard is the smallest complete repair for the stated integrity defect: it retains canonical addressing, prevents duplicate-key writes, and preserves the selected primitive-string control. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dde29415eb56. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +33, Docs +2. Total +39 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 HistoryReview history (6 earlier review cycles)
Reviewed October 22, 2026, 4:35 PM ET / 20:35 UTC (Revision 7). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70d9639efb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Added current-head shipped CLI proof for both timestamp/string collision orderings to the PR body. All six official CLI commands passed the expected read, refusal, dry-run, and exact written-byte checks at b334ad4. No code changed. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Exact head ad9cb4b: 34 focused YAML tests pass; changed-file formatting/lint pass. Built shipped find/resolve/set proof shows main duplicates timestamp keys (1→2 twice, and 2→3 with a timestamp-first collision), while candidate refuses with unresolved and preserves exact bytes. String-first primitive-key control still updates correctly on both. Supporting bounded gpt-5-mini agent smoke returned CLI_LIVE_OK; isolated credential removed afterward. |
|
Merged—thank you @LinzeShi for the YAML key-identity guard. Built find/resolve/set proof confirmed timestamp writes now refuse without duplicating keys, while the selected string-key control remains writable. |
…nclaw#169266) fix(path): refuse to edit YAML timestamp keys instead of duplicating them Editing a YAML 1.1 key that parses as a timestamp (for example `2024-01-01:`) could append a duplicate key, because cloning the document lost the key's identity. Such an edit is now refused as unresolved and the file is left byte-for-byte unchanged; ordinary string keys still update in place. Evidence: built CLI, find → resolve → set. On main a timestamp-only key went from one entry to two, and a timestamp-first collision from two to three (twice each); with this change the set is refused and the file is identical (twice each). A string-first file still updates only the string key. Production +4, docs note the refusal. Thanks @LinzeShi. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
For YAML 1.1 timestamp mapping keys,
path findandresolvecan identify a real leaf, but writing through that address can append a duplicate timestamp key. The resolved Date object loses key identity when the YAML document is cloned.Changes
Refuse leaf replacements whose resolved path contains an object-valued key before cloning. Return the existing
unresolvederror without changing the file; do not redirect the write to a same-spelling textual key or claim timestamp mutation support. Selected primitive string keys remain writable. Document the refusal in the CLI mutation contract.Thanks to @LinzeShi for the integrity guard and collision regression cases; their commit is retained. The regression uses the current parseYaml return contract after main integration.
Evidence
Built main
2fd898bb338c42126c8116fbe8e30a3fea64ba28and candidate independently in isolated Node 24.22.1 Linux Docker. Enabled the shipped oc-path plugin. For each ordinary user-owned YAML 1.1 input, used the actual address returned by builtpath find, confirmed its selected leaf withpath resolve, then invokedpath set. Independently parsed and counted keys and compared exact source bytes.unresolved; bytes unchanged both timesunresolved; both entries and source bytes unchangedSimplification: one four-line guard in the existing YAML write owner, no fallback or second writer. Whole PR production +4/-0, tests +33/-0; necessary growth enforces the identity boundary. No SDK, schema, configuration, or migration changes.
Merge danger: reverting cannot repair duplicate keys already written by older builds. The code change itself is a two-way door. Blast radius is leaf replacement through object-valued YAML keys; ordinary primitive-key writes retain their behavior.