Repository navigation
conformance(inclusion): enforce registry-anchor-v1 surrogate/key/cycle rules and validate leaf_index/entry fields (#625) - #630
Conversation
|
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check. |
rajnisht7
left a comment
There was a problem hiding this comment.
the overall changes looks good, the cycle detection, iterative traversal, and boundary checks look solid, and the tests cover the important cases well.
One thing: a few of the new rules are currently stricter than the published normative text in registry-anchor-v1.md.
- §1 does not yet explicitly prohibit surrogate code points (U+D800–U+DFFF) in strings/keys
- §4 only requires leaf_count ≥ 1; it does not state the ≤ 2**53-1 bound (same for leaf_index).
- §4 defines producer / batch_id simply as strings; it does not currently forbid whitespace or control characters
it will be good to update the normative text in registry-anchor-v1.md so the published requirements match what the conformance suite now enforces, once the spec and implementation agree, this looks good to land
non-blocking
- also positive 2**53-1 boundary tests and a plain pytest.raises for the cycle can be added
lywinged
left a comment
There was a problem hiding this comment.
Request changes. Reviewed at 19c65b2 on da69b31.
This change makes a conformance test fail, so, as CONTRIBUTING's "Before a pull request is reviewed" asks, this first review stops at what is missing. The new character check in parse_entry loops over _ENTRY_STRINGS, which includes ts: conformance/tests/test_tr_anc_subject.py sets ts to "2026-10-16 00:00:00Z", expects "ts must be an ISO-8601 UTC timestamp", and now gets "registry entry ts must be a non-empty string without whitespace or control characters". It fails here on 3.11 and 3.12, and Conformance CI failed in its full-suite step on 3.12. The validation command in the description does not run that file.
The same section asks for a test for each rejection the diff adds, failing when that rejection is switched off, or a sentence saying why no test can observe it. Three have neither: the leaf_index upper bound, the 1 <= on the receipt's leaf_count and the 0x7F check. I will review the rest once these are in.
CI at 19c65b2 also failed in the portability step, for a reason this pull request did not cause: main failed the same step at da69b31, before #624, and passes at dcca4e0.
Generated by Claude Code
|
Thank you @rajnisht7 and @lywinged! Addressed all points in
|
19c65b2 to
8f9ca2b
Compare
lywinged
left a comment
There was a problem hiding this comment.
Request changes. Reviewed at 8f9ca2b on e9ab302.
What the first round asked for is in. The whitespace and control-character check in parse_entry runs over producer and batch_id only, and the conformance suite passes under the default locale and under LC_ALL=C PYTHONUTF8=0 on 3.11 and 3.12, 974 passed, 2 skipped and 5 xpassed. The leaf_index upper bound, the 1 <= on the receipt's leaf_count and the 0x7F check each have tests that fail when the clause is removed.
The one thing is the normative text. The push rewrote registry-anchor-v1.md in three places, and each makes something malformed that the published text allowed and main accepts. Section 1 excludes an unpaired UTF-16 surrogate in a string or key: canonical_claim_bytes on main writes it as \ud800, this head refuses it. Sections 4 and 5 bound leaf_count and leaf_index at 9007199254740991: parse_entry on main accepts a leaf_count of 2**53, this head calls it malformed. Section 4's meaning column now says producer and batch_id carry "no whitespace or ASCII control characters": "producer": "Example Gateway 1.0" passes TR-ANC-002 on main and is a malformed registry entry here. I would keep the first two, which spell out what a UTF-8 implementation cannot represent and the range section 1 already imposes on claims, and I would narrow the third, in the code and in the text alike, to blank strings and ASCII control characters, since the published text allowed a space and a control character has no place in an identifier. Whether the whitespace rule is a breaking change under GOVERNANCE, which asks for a 30-day comment period, a backward-compatibility statement and Project Lead sign-off where the template's line says 14 days, I read as no: that process is written for spec/trace-v0.2.md and exempts drafts, and the changed cells carry no RFC 2119 keyword. The diff carries no <!-- CHANGED --> marker either way. Whichever rule section 4 ends with, the suite wants a test for it: swapping ch.isspace() for a blank check leaves both suites green, so the inner-space refusal, the one rule the control-character clause does not already cover, has none.
What I checked rather than read:
- CI's commands, run here on 3.11 and 3.12: ruff and mypy as CI runs them, which do not reach
conformance/, and the dash check clean; the suite at 5240 passed and 98 skipped on both, with the head's conformance package on the path as CI installs it; the replay experiment, the twoLC_ALL=C PYTHONUTF8=0runs, thePYTHONOPTIMIZE=2command and the two--helpcalls pass. 3.13, which Conformance CI also runs, is not installed here. - The 27 anchor-inclusion vectors keep their verdicts here and on
mainthrough the TR-ANC check. Vectors 17 to 19, the out-of-range, negative and boolean index, now fail as a malformed receipt rather than a root mismatch; vector 20, the empty tree, fails as a malformed receipt rather than a malformed entry. - Each clause named in the first round, removed alone, in the suite CI runs as
pytest: theleaf_indexupper bound fails 2 tests, the1 <=onleaf_count2, the0x7Fcheck 2. The wholeproducerandbatch_idcheck fails 5 there and 3 more in the conformance suite, andtype(leaf_index) is intloosened toisinstancefails 1. - On
main,parse_entryaccepts a blankproducer, an inner space, a non-breaking space orDELinproducer, and a tab orNULinbatch_id; this head refuses all six, andtswith a space gets the timestamp message on both. tools/review_bar.pyreports all 20 cases of the new file undertests/failing on behaviour at the merge base; the 16 cases the diff adds underconformance/testsare outside what the tool reads. The description's validation line still says 16 for the tool.
Things I would not hold the merge for:
- Section 1's exclusions paragraph is also rewritten by #537, differently, so whichever of the two merges second will have to resolve that paragraph.
- A proof-only receipt, the section 5 shape, with
leaf_index1 against a one-leaf entry still reads as a root mismatch; the same receipt withleaf_count1 is now refused as malformed, so the two shapes answer differently.
Generated by Claude Code
…e/safe-int bounds in inclusion.py (agentrust-io#625) Extend _outside_profile in conformance/src/trace_tests/inclusion.py to reject unpaired UTF-16 surrogates, non-string dict keys, and circular references iteratively; bound leaf_index and leaf_count to 2**53 - 1 in parse_proof and parse_entry; reject blank strings and ASCII control characters (including 0x7F) in entry producer and batch_id while keeping ts on _is_utc_timestamp; and align spec/registry-anchor-v1.md §1, §4, and §5 with those bounds. Closes agentrust-io#625 Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
8f9ca2b to
b9cc533
Compare
|
@lywinged Rebased onto |
|
The current head b9cc533 follows the recommended identifier rule: blank strings and ASCII controls are rejected, but internal spaces are accepted. I corrected the description and changelog proposal, and replaced the stale review-bar count with the measured 20 behavioral failures at the merge base. Validation: 20 boundary tests and 81 focused conformance tests pass. Please re-review the remaining changes request. |
What this changes
Closes #625. Current source head:
b9cc53379ba8e5eee222e42f48189734497fbbf3.conformance/src/trace_tests/inclusion.pyrejects unpaired UTF-16 surrogates in values and keys, non-string dictionary keys, and circular containers while preserving shared acyclic containers.parse_proofrequires exact integer indices and counts within the safe-integer range, a positive count, and an index below the count when supplied.parse_entryrejects blank identifiers and ASCII control characters, including DEL, inproducerandbatch_id. It accepts internal spaces, includingproducer="Example Gateway 1.0"; the earlier description incorrectly said all whitespace was rejected.leaf_countmust be an exact integer between 1 and2**53 - 1.The draft anchor-profile text documents the surrogate exclusions, integer bounds, and identifier rules.
spec/trace-v0.2.mdis unchanged. Existing anchor vectors keep their verdicts; malformed index/count inputs are rejected at the parsing boundary.The latest review recommended narrowing identifier rejection to blank strings and ASCII controls. The current source and draft text implement that recommendation; this description now matches them and corrects the review-bar count from 16 to the measured 20.
Type of change
Reference conformance implementation and draft companion-profile clarification. Final governance classification remains with the maintainers; the published TRACE v0.2 specification is not modified.
Spec section
spec/registry-anchor-v1.mdsections 1, 4, and 5. No edit tospec/trace-v0.2.md.Tests for a fix
tests/test_conformance_inclusion_profile_and_receipt_boundaries.pycovers surrogate values/keys, non-string keys, cycles versus shared acyclic containers, index/count types and bounds, blank/control-containing identifiers, unsafe counts, and acceptance of an internal space. Its separatetest_parse_proof_without_leaf_count_rejects_leaf_index_above_safe_intpins the upper index bound for proof-only receipts.Rerun on the current head with Python 3.11.9, importing this checkout's
srcandconformance/srcthroughPYTHONPATH:python -m pytest tests\test_conformance_inclusion_profile_and_receipt_boundaries.py -q --tb=short-> 20 passed.conformance:python -m pytest tests\unit\test_tr_anc.py tests\test_tr_anc_inclusion.py tests\test_anchor_vectors.py -q --tb=short-> 81 passed.python tools\review_bar.py --base origin/main --head HEAD-> 20 fail on behaviour, 0 fail on a missing name or file, 0 pass or skip, measured against merge baseb938790. This is contribution-level failing-before evidence, not a claim of independently isolated mutation coverage for every clause.The earlier combined root/conformance pytest command hits a
tests.conftestpackage-name collision in this Windows environment; running the two packages separately succeeds. Hosted CI and Conformance CI on this head are successful. Maintainer approval is still required.Changelog entry
trace_tests.inclusion): reject unpaired UTF-16 surrogates, non-string dictionary keys, and circular references; validate safe-integerleaf_indexand positiveleaf_countbounds; reject blank identifiers and ASCII control characters while preserving internal spaces (conformance(inclusion): enforce registry-anchor-v1 surrogate/key/cycle rules and validate leaf_index/entry fields #625, by @drk-ram).Checklist
git commit -s)<!-- CHANGED: #NNN: description -->in spec text