Skip to content

intent: the gated requiredWhen check is proved at runtime, not in the generated source (#7238) - #7424

Merged
delchev merged 1 commit into
masterfrom
issue-7238-requiredwhen-runtime
Sep 17, 2026
Merged

delchev merged 1 commit into
masterfrom
issue-7238-requiredwhen-runtime

Conversation

@delchev

@delchev delchev commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

The gaps

Two, both from #7129 (checks: requiredWhen, #7094).

1. The assistant guide. Already fixed by #7414 (merged this morning), which added the kind's bullet. What was still missing there is the routing, the one thing an author has to decide: the status: gate is OPTIONAL, and its presence is what decides where the rule is enforced. Added as two sentences to that bullet.

2. The IT asserted source text only. IntentEmissionCoverageIT checked AccountRepository().findById(hop0Fk), java.util.Objects.equals(entity.Note, "audited") and the authored message over the rendered repository. Nothing drove a record to the gate status, so a guard that never fires would pass identically - which is precisely the failure mode of the sibling issue #7237 (Objects.equals(Long, int) is never true, so the rule looks authored and enforces nothing).

And it could not do more as it stood: the check read Account.name, which the fixture declares required: true. The value it guards is therefore always present, and no write could ever be refused - the reason this check stayed source-text-only while compare got a runtime block on the same day.

The change

  • Account gains an optional taxCode, and the gated check reads Account.taxCode (message reworded accordingly). A rule over a REQUIRED column of the related row is unfalsifiable; the comment in the fixture says so.
  • A runtime block in assertRuntimeEnforcement, all three outcomes over REST:
    • an entry with Note: "audited" against an account with no tax code, with balanced lines so the itemsMin / itemsSumEqual gates on the same status cannot be what refuses it → 400 carrying the authored message;
    • an entry with no note, same account, same status → 200 (the rule is a condition, not a required nobody declared);
    • the account amended to carry a tax code → the audited entry's same write is accepted. Amending the related row rather than the entry is what proves the gate reads the hop when the write is checked, not a copy taken at create time.

The ungated twin (Doc, the controller's 400) already had runtime coverage from #7237; this is the other routing.

Verification

  • mvn -o -P integration-tests -pl tests/tests-integrations verify -Dit.test=IntentEmissionCoverageIT -Dit.groups= -Dit.excludedGroups= -Dselenide.headless=trueTests run: 1, Failures: 0, Errors: 0 in 193 s, BUILD SUCCESS, against a full quick-build install of this branch in an isolated local repository.
  • mvn -o -pl tests/tests-integrations formatter:validate with the formatter cache wiped first → BUILD SUCCESS.
  • No production code changed: the guide is a resource read by the assistant prompt, the rest is the test fixture.

Fixes #7238

🤖 Generated with Claude Code

… generated source (#7238)

Two coverage gaps from #7129 (`checks: requiredWhen`). The assistant-guide half
landed in #7414, which added the kind's bullet; this adds the sentence that was
still missing there - the `status:` gate is OPTIONAL and its PRESENCE is the
routing (no gate: every controller's validate(), a 400; a gate: the repository,
on the synchronous transition path).

The second half is the IT. `IntentEmissionCoverageIT` asserted the gated check
over its generated source only - the hop load, the condition, the message - and
a source assertion cannot tell a gate that fires from one whose condition is
never true, which is exactly the boxing failure mode the sibling #7237 was filed
for. It could not do more: the check read `Account.name`, and that column is
`required: true`, so the value it guards is always present and no write could
ever be refused.

`Account` therefore gains an optional `taxCode` and the check reads that. The
runtime block drives all three outcomes over REST: an audited entry against an
account with no tax code is refused at its gate status with the authored message
(400), an entry with no note reaches the same status against the SAME account
(the rule is a condition, not a `required` nobody declared), and the audited one
passes once the ACCOUNT is amended - the related row, not the entry, which is
what proves the gate reads the hop when the write is checked rather than a copy
taken at create time. The entries carry balanced lines so the two document
checks gating on the same status cannot be what refuses them.

Fixes #7238

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@delchev
delchev merged commit c9b999a into master Sep 17, 2026
10 checks passed
@delchev
delchev deleted the issue-7238-requiredwhen-runtime branch September 17, 2026 12:50
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.

intent: requiredWhen is missing from the assistant guide and covered by source-text assertions only

1 participant