Skip to content

Assert every published argument pattern has a matcher - #459

Merged
lamemustafa merged 1 commit into
masterfrom
fix/amends-batch-id-pattern
Sep 16, 2026
Merged

lamemustafa merged 1 commit into
masterfrom
fix/amends-batch-id-pattern

Conversation

@lamemustafa

@lamemustafa lamemustafa commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Outcome and reason

Rebuilt on master after #444. #444 independently admitted amends_batch_id through tools/call, which fixed the same bug this PR first targeted. That bug: every amendment over MCP was refused as argument_invalid:amends_batch_id, found by the live lab end-to-end run described below. This PR now keeps only what #444 does not cover: nothing stops the next published pattern from failing the same way.

validate_string_bounds refuses every value published under a pattern that published_pattern_matches does not implement. amends_batch_id shipped like that, and 16 tests and two reviews passed because the tests called the handler directly.

Change

  • agent_catalog.rs: published_pattern_matcher(pattern) -> Option<fn(&str) -> bool> is split out of published_pattern_matches, which now calls it. None means an unrecognised pattern. The three older arms keep their exact logic; the date arm moved verbatim into date_wire_matches. The batch-id arm now applies agent_import::valid_batch_id, the rule the build itself enforces, in place of Parse password-protected bank statements into voucher proposals, through PDFium #444's strip_prefix("bridge-").is_some_and(is_uuid_v4_lowercase). BRIDGE_BATCH_ID_PATTERN stays pub(super) for the schema, and is_uuid_v4_lowercase stays for proposals_id.
  • agent_admission_tests.rs:
    • every_pattern_admission_reads_is_one_it_recognizes walks every registered tool's top-level string properties and top-level string array items, which is exactly what validate_tool_arguments reads. It asserts published_pattern_matcher has an arm for each pattern, asking the matcher itself rather than a list kept in the test.
    • the_batch_id_pattern_admits_exactly_what_the_build_admits refuses uppercase, a missing prefix, version 1, variant c, no hyphens, braces, a urn:uuid: form, the nil UUID, a trailing newline and a non-ASCII character. It also asserts valid_batch_id and strip_prefix + is_uuid_v4_lowercase agree on all those inputs plus 256 fresh v4 ids.
  • Surface resealed; the independent seal check passes with 251 pins, 0 mismatches, and no pins added or dropped vs master.

Scope limit: the walk covers top-level patterns only. Nested patterns are read by validate_against_schema for voucher_presence, whose inventory test already pins them, and by the import payload's typed parser.

Validation and evidence

  • Mutation: with the batch-id arm removed, every_pattern_admission_reads_is_one_it_recognizes, the_batch_id_pattern_admits_exactly_what_the_build_admits and Parse password-protected bank statements into voucher proposals, through PDFium #444's an_amendment_is_admitted_through_tools_call_argument_validation all fail. Restored, cargo test --locked --lib -- agent::catalog an_amendment_is_admitted_through_tools_call an_unknown_amendment_target passes 11 tests: the 9 in agent::catalog, Parse password-protected bank statements into voucher proposals, through PDFium #444's tools/call amendment test, and an_unknown_amendment_target_is_refused_before_any_tally_read. Without the last filter, 10 pass. cargo fmt is clean, and cargo clippy -p bridge --lib --tests -- -D warnings -A clippy::pedantic is clean.
  • Live (licensed 7.1 Silver, synthetic BRIDGE SHAPE LAB, first version of this PR): MCP build_import_xml with amends_batch_id was refused at master f25fc91a. With the fix it was admitted; the compare-and-swap matched both vouchers; the amendment imported ALTERED=2 and verified 2/2; and a later change behind Bridge's back was refused with book_voucher_diverged. The admission rule was the same valid_batch_id used here.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

#444 admitted amends_batch_id through tools/call. What stays open is why it
was refused: validate_string_bounds refuses every value under a pattern
admission does not implement, and nothing notices a new one. Split the
matcher lookup out so a test can walk every tool's top-level string patterns
through it, and admit the batch id with the build's own valid_batch_id,
checked equal to is_uuid_v4_lowercase on edge inputs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lamemustafa
lamemustafa force-pushed the fix/amends-batch-id-pattern branch from 65b325e to cfa2aa0 Compare September 16, 2026 23:06
@lamemustafa lamemustafa changed the title Admit amends_batch_id through the MCP tool call Assert every published argument pattern has a matcher Sep 16, 2026
@lamemustafa
lamemustafa merged commit 358c274 into master Sep 16, 2026
13 checks passed
@lamemustafa
lamemustafa deleted the fix/amends-batch-id-pattern branch September 16, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant