Repository navigation
Fix 4 of 7 edit-protection residuals from PR #11's review - #22
Merged
Merged
Conversation
Lock.by accepted any string including empty; Lock.at accepted any string including unparseable junk. Both fields are now validated: by must be non-empty, at must match the ISO-8601 UTC second-resolution format apply_edits already writes. Claude-Session: https://claude.ai/code/session_01A8tPdJ7kZ8FbJpXNhMHgap
Lock.was and every attrs bag are typed Any, so a raw Python float placed there (e.g. via apply_edits or hand-authored attrs) reached the document unchanged, violating docs/07 §6.5's no-floats rule with no signal. validate_document now walks the full document dump and flags any float outside the schema's own float-typed fields (confidence). Claude-Session: https://claude.ai/code/session_01A8tPdJ7kZ8FbJpXNhMHgap
apply_edits accepted /steps/<id>/id set to a value another step in the same list already used; validate_document flagged the resulting duplicate afterwards, but the invalid document was already committed. Reject the collision at edit time instead, before any mutation. Claude-Session: https://claude.ai/code/session_01A8tPdJ7kZ8FbJpXNhMHgap
A committed rename of a step id (apply_edits writes a lock at "/id" with the old id in `was`) severed the merge key: a regenerated projection that still emits the analysis-derived old id (because analysis has no knowledge of the rename) was treated as an unrelated new step, so it resurfaced alongside the renamed one instead of being recognised as its predecessor. merge_regenerated now consults each committed step's own "/id" lock to match a fresh step by its pre-rename id too. This does not follow a rename across more than one regeneration cycle -- only the most recent "/id" lock is consulted -- and is not a schema change: it reads the same Lock records apply_edits already writes. Claude-Session: https://claude.ai/code/session_01A8tPdJ7kZ8FbJpXNhMHgap
Adds docs/07 §6.6 summarizing the four fixed residuals and the three declined ones, and documents the Lock.path snake_case-vs-camelCase convention (a wire consumer must apply to_camel per segment) instead of changing what apply_edits records, which would be an on-disk format change for every already-written lock. Claude-Session: https://claude.ai/code/session_01A8tPdJ7kZ8FbJpXNhMHgap
Two blocking issues from review of PR #22: - merge_regenerated could match one committed step to two fresh entries when fresh emitted both the pre-rename and post-rename id (e.g. analysis caught up mid-flight): the old-id match via _renamed_from raced the new-id direct match with no mutual exclusion, producing a document with a duplicate step id. Direct id matches are now resolved first and claim their committed step before any rename substitution runs, so a committed step is matched at most once. - The float scan's allowlist for schema-typed float fields (confidence) was keyed on the literal dict key, so a Lock.was field name itself ("was") never matched the allowlist even when the lock's own `path` pointed at a confidence field it legitimately snapshotted as a float. The scanner now recognises a Lock's dump shape and checks `was` against the field its `path` addresses, not the key "was" itself. Also, per review nits: the rename-collision check is now document-wide for step ids (matching validate_document's own uniqueness scope, not just the immediate sibling list), and the float scan addresses steps by id instead of list index where available. Claude-Session: https://claude.ai/code/session_01A8tPdJ7kZ8FbJpXNhMHgap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #12.
Four of the seven residuals from PR #11's adversarial review, each its own commit:
bymust be non-empty,atmust match the ISO-8601 UTC second-resolution formatapply_editsalready writes. Previously both accepted any string.validate_documentnow flags any rawfloatreaching the wire outside a schema-typed float field (confidence), closing theLock.was/attrshole (both typedAny).apply_editsnow rejects/steps/<id>/idset to a value another step already uses — document-wide for step ids (matchingvalidate_document's own uniqueness scope), list-local for everything else — instead of accepting it and leavingvalidate_documentto flag the resulting duplicate after the fact.merge_regeneratednow consults a step's own/idlock (which recordswas= the old id) to match a fresh projection that still emits the pre-rename id, instead of treating it as an unrelated new step. Direct id matches are resolved first and claim their committed step before any rename substitution runs, so one committed step can't be matched twice.A fifth commit addresses two blocking findings from review: the rename-match race above (fresh emitting both the pre- and post-rename id could produce a duplicate-id document) and a float-scan false positive (a
Lock.waslegitimately holding the old value of aconfidencefield was flagged, because the scan's allowlist was keyed on the literal"was"key rather than the fieldLock.pathactually addresses).The other three items are declined, one-line reasons on #12 and in
docs/07-annotation-model.md§6.6/§7:SourceSpan.id— needs a schema change, out of scope here (pairs with Evidence layer: persist analysis into a lacing store #4's evidence layer)Lock.pathcamelCase vs snake_case — documented as a convention instead of changed (changing the recorded spelling would itself be an on-disk format change for every existing lock)No schema or on-disk format change.
docs/07-annotation-model.mdupdated (§6.6 is new). No CHANGELOG in this repo. No breaking changes — all fixes tighten previously-permissive validation/merge behavior; existing valid documents and edit sequences are unaffected.234 passed, 1 skipped (pre-existing skip, unrelated).
ruff check/ruff formatclean on all touched files.https://claude.ai/code/session_01A8tPdJ7kZ8FbJpXNhMHgap