Skip to content

foranswerfirst: a small subject --callers answer goes ahead of <tail> - #739

Merged
joyful-ii-V-I merged 2 commits into
mainfrom
lane/callers-promote
Nov 24, 2026
Merged

joyful-ii-V-I merged 2 commits into
mainfrom
lane/callers-promote

Conversation

@joyful-ii-V-I

@joyful-ii-V-I joyful-ii-V-I commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

A --for task spelled callers of X gets the subject --callers answer appended as <graph_verb endpoints="subject" verb="--callers=X">. resolvedRouted() only treats a graph_verb as resolved when it has <path reachable="1"> or <met_bridge>, so a callers block stayed behind </tail>. Once the tail runs past the page stop, guarded promotion (G) cannot move it either.

This change moves that block directly ahead of <tail> when its <callers> child has defs="1" and count ≤ kCallersPromoteMaxCount (8). It is still a permutation: the same bytes are reordered, and answerFirst's size contract is unchanged. A block with two or more definitions, a count over the cap, or any other verb stays where it was.

Evidence

  • In ld-cockroach-08 (LARGE-DEV), the 6-row answer (4 callers and 2 tests, 1,187 B) was on page 3 at byte 25,320.
  • Offline l1 transform over S1, MF1, LD and NL1 (354 rows, grader with the near-mode WRONG/other-file fix), plus a census of the GA1 DEV answers:
    • The shape occurs in one row only. The other subject callers block in the corpus, ld-envoy-08, has defs="2" and does not move.
    • ld-cockroach-08 page 1 goes from ✗ to ✓ (R1–R4).
    • No row loses an item.
    • ΔĈ is negative in both cost profiles.
  • The built binary gives byte-identical output to main on all 163 S1, 39 MF1 and 55 of 56 LD rows. The one row that differs is ld-cockroach-08.
  • Every cap from 6 to 1000 selects the same row, so the cap limits how many bytes move. It is not a fitted value.

Gates

  • test/foranswerfirstcheck.sh adds these arms:
    • CP0 reads the cap from the source.
    • CPn checks that the positive probe offers the shape and that the block is behind </tail> in the legacy order.
    • CP1 checks that the block now comes before <tail>.
    • CP2n checks that the negative probe offers the shape with a count over the cap.
    • CP2 checks that a count over the cap does not move.
  • CP1 fails on the main binary. The existing G6/G7/G10 crowd-out arms still pass.
  • --quality-delta: gating 0.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Small subject-caller answers with 1–8 callers are now promoted ahead of the tail section.
  • Bug Fixes
    • Caller blocks with more than 8 callers remain in their original position.

A `callers of X` task gets the FOR-ROUTE-DECLINED <graph_verb endpoints="subject"
verb="--callers=X"> block appended after its ranked answer. resolvedRouted() only
calls a graph_verb resolved on <path reachable="1"> or <met_bridge>, so a callers
block stayed behind </tail>; when the tail overflows the page stop, G cannot move
it either. On ld-cockroach-08 the 6-row (4 callers + 2 tests), 1,187 B answer sat
on page 3 at byte 25,320.

rowBlockOrder now moves a subject --callers graph_verb whose <callers> has defs="1"
and count <= kCallersPromoteMaxCount (8) directly ahead of <tail>. It is still a
permutation (same bytes, answerFirst's size contract unchanged). Two or more
definitions, a count over the cap, and every other verb stay where they were.

Measured offline (l1 harness, S1/MF1/LD/NL1 with grader G2, GA1 DEV census): the
shape occurs on one row (ld-cockroach-08; the other subject callers block, ld-envoy-08,
has defs="2"). That row goes p1 ✗ -> ✓ (R1-R4), no row loses an item, ΔĈ < 0 in
both cost profiles. Every cap from 6 to 1000 selects the same row.

Gate: test/foranswerfirstcheck.sh (CP0/CPn/CP1/CP2n/CP2). CP1 is red on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Walkthrough

The answer-first ordering promotes qualifying small subject-callers blocks from after <tail> to before it. The tests check the caller-count limit and verify that blocks above the limit remain after <tail>. The documentation lists the limit as 8.

Changes: Subject-callers promotion

Layer / File(s) Summary
Eligibility and ordering
src/foranswerfirst.h
The code identifies subject --callers blocks with one definition and a caller count from 1 through the configured cap. It detects qualifying blocks after <tail> and moves them before <tail> while preserving their relative order.
Promotion checks
test/foranswerfirstcheck.sh, docs/LIMITS.md
Tests check promotion at or below the cap and verify that blocks above it remain after <tail>. The limits table lists the cap as 8.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: barefootski

Merge Risk: Minimal · up to 5424e · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: a small subject --callers answer block is moved ahead of . The raw summary confirms the header rule, the permutation check, the cap constant, and the test script all …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: a small subject --callers answer block is moved ahead of <tail>. The raw summary confirms the header rule, the permutation check, the cap constant, and the test script all target this case. The title is specific, short, and matches the PR objectives. It omits the defs="1" and count cap conditions, which is acceptable for a title.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f6ecf41 and 5424efa.

Files ignored due to path filters: 1

  • test/capdisclose.map is excluded by !**/*.map
Files selected for processing: 1

  • docs/LIMITS.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

…ER bound, nothing dropped)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@joyful-ii-V-I

Copy link
Copy Markdown
Collaborator Author

Commit after the last review, CI fix only:

  • 5424efa: adds a none: row to test/capdisclose.map for kCallersPromoteMaxCount. It is an order bound: every row is still emitted once, and CP1/CP2 pin it. It also regenerates docs/LIMITS.md (+1 line). Answers are byte-neutral. PR-event CI on 5424efa is green: 37 pass, 0 fail.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@joyful-ii-V-I
joyful-ii-V-I merged commit b1c75ba into main Nov 24, 2026
41 checks passed
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