rpg_source.zig: settle() enforces the validator rules blocks and loop_exit (also rpg_source_decl_emit.zig, rpg_source_render_emit.zig) #789

Manually merged
binjovi-bot merged 1 commit from enforce1 into trunk 2026-11-11 15:39:58 +00:00
Owner

settle() read the finished text and only reported. For the rules blocks and loop_exit it now
changes the emit, in this order, until nothing flips:

  1. refuseLate: a failure line (fail_statement_v1, fail_statement_long_v1) whose entry is still code
    (the render refused it, a long statement) becomes a failed entry with the reason and the form of
    that line, so the line is written again as it was. A new Entry.fail_form carries the form.
  2. refuseBlocks: balance runs again (balanceBlocks, repeated until it flips nothing) over the entries,
    so the remaining parts of a block that now holds a failure line (an ELSE, ELSEIF, WHEN, OTHER,
    ON-ERROR, END) become failure lines whose text ends (validator: blocks) (RNF5141, RNF5142).
    The statements inside the block stay.
  3. refuseLoopExits: a LEAVE or ITER that the validator finds with no emitted DOW, DOU or FOR around it
    becomes a failure line whose text ends (validator: loop_exit) (RNF5232). Run only when the first two
    flip nothing, on the current text.

When anything flipped, settle resets as the short-names path does (trailer, counts, assumed,
long_failures) and calls render again with the same symbol names. It never runs dropUnreferenced,
nameSymbols or fitGlobals again. rpg_source_decl_emit.balance is unchanged for its caller (text
(its block is not whole)); balanceBlocks is the same walk with the reason ... (its block is not whole) (validator: blocks), cut so that the whole failure line fits 100 characters with its end. Columns
and mixed renders are not read. The rules return, interface, condition_literal and bif_numeric
are still reports. validator.counts after the re-render is the validator on the final text.

Measured, v0.1.505 build against this build (statements, emitted, failures; validator counts):

program before after
asyncage 584, 322, 269; blocks 2 584, 320, 271; blocks 0
asyncdemo 621, 344, 284; blocks 2 621, 342, 286; blocks 0
asyncbg 597, 326, 277; blocks 2 597, 324, 279; blocks 0
asynccncl 608, 335, 280; blocks 2 608, 333, 282; blocks 0
asyncprom 619, 330, 295; blocks 2 619, 328, 297; blocks 0
asynctime 630, 352, 285; blocks 2 630, 350, 287; blocks 0

In each program the broken block is one ELSE and one ENDIF (for asyncage statements 79900 and 80200, whose
head is a failure line); each becomes a failure line, emitted falls by 2 and failures rise by 2, and
no other line of the emit changes (diff: those two lines and the summary line). loop_exit has 0
findings in the six programs and in the 824 emits of the committed twins, so its effect is proved
on synthetic entries only (src/rpg_source_enforce1_test.zig); the request
requests/enforce1/loop-exit asks for the compile. The emits of the 852 committed twin rows are
byte-identical to the v0.1.505 build (12 blocks findings of the six programs: 0 now; the one blocks
finding of a twin, init-auto-char-heldout, is a DCL-PROC with no END-PROC, which no entry holds and which
stays a finding).

Known limit, not changed here: the validator counts any emitted loop around a LEAVE or ITER. A LEAVE
inside a refused inner loop that sits in an emitted outer loop is not refused.

Tests: src/rpg_source_enforce1_test.zig.

Gate (coordinator, base v0.1.505)

  • dev emits: p1-p5 same. L10-test: unchanged. Committed twins: emit-bytes-diff identical.
  • 87 standing captures: 6 changed, all Async programs: emitted -2 and failures +2 each, the orphan else;/endif; of a refused block, now failure lines ending (validator: blocks). These are the intended change (wrong text that cannot compile becomes a refusal); gate FAIL lists only these six.
  • agree: suspect 94=94, conflict 0=0, params_wrong 24=24, decl_missing 87=87, decl_extra 31=31.
  • loop_exit has unit tests only; request requests/enforce1/loop-exit written for an end-to-end proof.
`settle()` read the finished text and only reported. For the rules `blocks` and `loop_exit` it now changes the emit, in this order, until nothing flips: 1. `refuseLate`: a failure line (`fail_statement_v1`, `fail_statement_long_v1`) whose entry is still code (the render refused it, a long statement) becomes a failed entry with the reason and the form of that line, so the line is written again as it was. A new `Entry.fail_form` carries the form. 2. `refuseBlocks`: `balance` runs again (`balanceBlocks`, repeated until it flips nothing) over the entries, so the remaining parts of a block that now holds a failure line (an ELSE, ELSEIF, WHEN, OTHER, ON-ERROR, END) become failure lines whose text ends `(validator: blocks)` (RNF5141, RNF5142). The statements inside the block stay. 3. `refuseLoopExits`: a LEAVE or ITER that the validator finds with no emitted DOW, DOU or FOR around it becomes a failure line whose text ends `(validator: loop_exit)` (RNF5232). Run only when the first two flip nothing, on the current text. When anything flipped, `settle` resets as the short-names path does (trailer, counts, `assumed`, `long_failures`) and calls `render` again with the same symbol names. It never runs `dropUnreferenced`, `nameSymbols` or `fitGlobals` again. `rpg_source_decl_emit.balance` is unchanged for its caller (text `(its block is not whole)`); `balanceBlocks` is the same walk with the reason `... (its block is not whole) (validator: blocks)`, cut so that the whole failure line fits 100 characters with its end. Columns and mixed renders are not read. The rules `return`, `interface`, `condition_literal` and `bif_numeric` are still reports. `validator.counts` after the re-render is the validator on the final text. Measured, v0.1.505 build against this build (statements, emitted, failures; `validator` counts): | program | before | after | |---|---|---| | asyncage | 584, 322, 269; blocks 2 | 584, 320, 271; blocks 0 | | asyncdemo | 621, 344, 284; blocks 2 | 621, 342, 286; blocks 0 | | asyncbg | 597, 326, 277; blocks 2 | 597, 324, 279; blocks 0 | | asynccncl | 608, 335, 280; blocks 2 | 608, 333, 282; blocks 0 | | asyncprom | 619, 330, 295; blocks 2 | 619, 328, 297; blocks 0 | | asynctime | 630, 352, 285; blocks 2 | 630, 350, 287; blocks 0 | In each program the broken block is one ELSE and one ENDIF (for asyncage statements 79900 and 80200, whose head is a failure line); each becomes a failure line, emitted falls by 2 and failures rise by 2, and no other line of the emit changes (diff: those two lines and the summary line). `loop_exit` has 0 findings in the six programs and in the 824 emits of the committed twins, so its effect is proved on synthetic entries only (`src/rpg_source_enforce1_test.zig`); the request `requests/enforce1/loop-exit` asks for the compile. The emits of the 852 committed twin rows are byte-identical to the v0.1.505 build (12 `blocks` findings of the six programs: 0 now; the one `blocks` finding of a twin, `init-auto-char-heldout`, is a DCL-PROC with no END-PROC, which no entry holds and which stays a finding). Known limit, not changed here: the validator counts any emitted loop around a LEAVE or ITER. A LEAVE inside a refused inner loop that sits in an emitted outer loop is not refused. Tests: `src/rpg_source_enforce1_test.zig`. ## Gate (coordinator, base v0.1.505) - dev emits: p1-p5 same. L10-test: unchanged. Committed twins: emit-bytes-diff identical. - 87 standing captures: 6 changed, all Async programs: emitted -2 and failures +2 each, the orphan `else;`/`endif;` of a refused block, now failure lines ending `(validator: blocks)`. These are the intended change (wrong text that cannot compile becomes a refusal); gate FAIL lists only these six. - agree: suspect 94=94, conflict 0=0, params_wrong 24=24, decl_missing 87=87, decl_extra 31=31. - loop_exit has unit tests only; request requests/enforce1/loop-exit written for an end-to-end proof.
Enforce the validator rules blocks and loop_exit in settle()
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
95697e59da
The late refusals are read back into the entries, balance() repeats until
nothing flips, a LEAVE or ITER with no emitted loop becomes a failure line,
and the text is rendered once more with the same names. The parts of a
broken block and the stray LEAVE and ITER end (validator: RULE).
sean force-pushed enforce1 from 95697e59da
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
to 644e983c95
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-11 15:26:32 +00:00
Compare
binjovi-bot manually merged commit 644e983c95 into trunk 2026-11-11 15:39:58 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sean/sourcerer!789
No description provided.