Skip to content

feat(mesh): count in-flight prefill tokens per worker (url@rank) - #3481

Merged
zhuyuhua-v merged 3 commits into
mainfrom
mengqing/mesh-prefill-accounting
Nov 26, 2026
Merged

zhuyuhua-v merged 3 commits into
mainfrom
mengqing/mesh-prefill-accounting

Conversation

@MengqingCao

@MengqingCao MengqingCao commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

agentic (#3406) weighs the prefill already queued on each rank, the same term as the engine's least_tokens balancer, but the router counted only in-flight requests per worker, not the prefill tokens they carry. This adds that count per url@rank. It is ported from #3210 (closed) and has no reader until #3406, so the two merge together.

Counts in-flight prefill tokens per worker (url@rank). Ported from #3210 (closed) with its review addressed.

  • Worker::prefill_tokens(), one counter per DP rank, exported as mesh_worker_prefill_tokens{worker}.
  • The planner charges the prompt's tokens, when the router has them, to the worker that prefills it. WorkerLoadGuard holds the charge:
    • P/D: on the prefill worker, released when its prefill response completes (every dispatch path drops the prefill guard there). Under idx2idx it is on the remapped rank; the idx2idx reservation test carries a nonzero charge and checks where it lands.
    • Regular HTTP, streaming: released at the response's first frame.
    • Regular HTTP, non-streaming: not charged, because its first frame arrives only after decoding (the feat(mesh): in-flight prefill token accounting per url@rank (deferred) #3210 review item). Tested.
    • ext-proc single-worker placements and gRPC: not charged.
  • The metric's help names the paths that charge it.
  • The gauge is set from the value the atomic returns. A release larger than the charge saturates at zero and logs a warning, like decrement_load.

No policy reads the counter in this PR. #3406 adds agentic, which reads it and replaces the whole-prompt charge with its estimate of the uncached tokens. As the #3210 review asked, this should merge together with #3406 rather than land as an unread counter.

Since the last review

  • The decode-first change moved to feat(mesh): under idx2idx, select decode first and prefill on its rank #3493, together with the cache_aware fix it needed and the reworded comments and RouterConfig method from valarLip's review. This PR now holds the accounting only.
  • The earlier description wrongly said CI did not run core::placement. The first step of atomesh-mocker-benchmark.yaml runs every --lib test, including http_pd_load_tests and http_proxy_body_tests, which are compiled into the library through #[path].
  • The cancel and stalled error-body P/D tests now check the prefill charge is taken and released. with_prefill_tokens debug-asserts a fresh guard instead of releasing first. The metric's help names the paths that charge it; feat(mesh): agentic routing policy on the KV event index #3406's agentic_cost.md says the uncharged requests weigh only through the request term.

Follow-ups, not in this PR

  • Selection and charge are not atomic: the counter is read at selection and charged at reservation, so concurrent requests that read the same minimum land on the same worker. Charging right after selection in apply_policy and handing the charge to the guard would close the gap.
  • ext-proc single-worker and gRPC placements do not charge.

Validation (Rust 1.100, CPU host, at f9d07c15f)

  • cargo test --lib: 1364 passed. test_load_counter_performance, which asserts a million increment_load calls a second, failed once on the shared host (load average above 120) and passed on three reruns; this PR does not touch increment_load. Tests cover the planner's charge (streaming and non-streaming, P/D), the release at the first streamed frame, the P/D charge and release, and a nonzero charge on the idx2idx remap.
  • cargo fmt --check clean; cargo clippy --all-targets shows no new warnings beyond Rust 1.100's deprecation of fetch_update, which the existing code shares.
  • At the top of the stack, cargo test --tests passes every target except proto_vendor_tests, which reads proto/manifest.json (not in git).

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Gate checks are published on every PR so required checks do not stay missing
  • ✅ Expensive jobs run only after the PR is approved, or when a matching ci:* label is present
  • ✅ Pre Checkin must pass before approved heavy jobs continue
  • ✅ Without a matching label, expensive jobs also require a relevant path
  • ✅ A matching ci:* label is an explicit request and can open the gate even when paths would otherwise skip it

Path scope:

  • Native ATOM, vLLM, and SGLang use ignore lists: docs/markdown and unrelated plugin or Mesh paths are skipped
  • ATOMesh uses an include list: Mesh code, ATOMesh scripts/workflows/catalogs, OpenAI entrypoints, and Slurm helpers
  • Relevant path alone does not start expensive jobs; approval still opens the automatic path-scoped gate
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, SGLang, and ATOMesh
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests
ci:mesh Run ATOMesh accuracy/benchmark gates for Mesh-related changes

Without a matching ci:* label, heavy jobs are skipped when the path is not relevant or the PR is not approved.
Add labels via the sidebar or gh pr edit 3481 --add-label <label>

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

ci green.

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Action required before merge (4)

  1. Merge this only together with #3406, not on its own. No policy reads prefill_tokens() in this PR, so landing it alone adds an unread counter plus charge and release work on every PD request (the "land it with its first caller" rule from #3210 and #3406, which the description also states). The decode-first change under idx2idx is the one part that stands alone. It changes prefill selection on the MI350 default path, so please run the ci:mesh gates once before merge; they were not requested on this head.
  2. Make the idx2idx comments say what the code does. planner.rs:69-71 and http_pd_router.rs:449-450 say the prefill policy is offered "only" the decode's rank. on_decode_rank also keeps prefills that idx2idx does not remap, and offers all of them when none is left on that rank. Reword both, as the on_decode_rank doc at planner.rs:27-29 already does.
  3. Compute the "ATOM backend + idx2idx" check once. The same matches!(backend, Atom) && matches!(policy, Idx2Idx) appears at http_pd_router.rs:408-413 and ingress.rs:650-654. Add one RouterConfig method and call it from both places, so the PD router and ext-proc cannot drift apart.
  4. Small fixes:
    • Assert p.worker.prefill_tokens() == 0 in cancelling_dispatch_releases_pending_load (http_pd_load_tests.rs:737) and stalled_prefill_error_body_cancels_pending_decode (:866). Today only the streaming success path checks the release.
    • In the description, drop "CI's current mesh step does not filter in core::placement...": the first step of atomesh-mocker-benchmark.yaml runs every --lib test, so these tests already ran on this PR. What CI does not run is tests/routing (http_pd_load_tests, http_proxy_body_tests).
    • with_prefill_tokens releases before it charges, but every caller builds a fresh guard: drop the call or add a debug_assert_eq!(self.prefill_tokens, 0).

Reviewed at 1124ee6. From the #3406 review, already done here: decode first under idx2idx with a nonzero idx2idx test, the gauge set from the atomic's value, a warning on release underflow, and non-atomic selection and charge listed as a follow-up. ext-proc single-worker and gRPC charging remain listed follow-ups.

@valar-cop

valar-cop commented Nov 17, 2026 •

Copy link
Copy Markdown

@wanzhenchn wanzhenchn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 1124ee6 while re-reviewing #3406. The charge and its release paths look right, and selecting decode first is the right fix for idx2idx. It also changes two other prefill policies:

  1. cache_aware deletes live tenants (inline, with a failing test). Please fix it here, or select decode first only when the prefill policy is agentic.
  2. dp_sticky records rebind where it recorded rank_mapping. A session pinned to a prefill on another rank is no longer a candidate, so it is re-pinned to the worker on the decode's rank with the fewest live sessions (dp_sticky.rs L159-L190), instead of keeping its pin and being remapped. Placement improves, but rank_mapping now fires only when the decode's rank has no healthy prefill. Please update metrics.md L167-L169 and mention it in the description.

Comment thread atom/mesh/src/core/placement/planner.rs Resolved
@zufayu
zufayu requested review from Jasen2201 and valarLip November 18, 2026 01:21
@MengqingCao
MengqingCao force-pushed the mengqing/mesh-prefill-accounting branch from 1124ee6 to 5b3b2ea Compare November 18, 2026 04:47
@zufayu

zufayu commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@atom-bot review

@MengqingCao MengqingCao changed the title feat(mesh): count in-flight prefill tokens per worker; under idx2idx, select decode first feat(mesh): count in-flight prefill tokens per worker (url@rank) Nov 18, 2026
@MengqingCao
MengqingCao changed the base branch from main to mengqing/mesh-idx2idx-decode-first November 18, 2026 04:48

@aiter-bot aiter-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATOM PR #3481 — feat(mesh): count in-flight prefill tokens per worker (url@rank)

Charges each request's prompt-token count to the prefilling worker's per-rank atomic counter at placement time and releases it when that prefill finishes (P/D prefill-guard drop, first streamed response frame, or guard drop), exporting the in-flight count as the mesh_worker_prefill_tokens{worker} gauge.

Review: ⚠️ NEEDS WORK

Coverage: 11 files / 173 added lines -- within one review pass

Validation (deterministic): NOT RUN — ships no test target (the diff is Rust mesh code under atom/mesh; validate-atom-pr defines no target for it) and auto-validation is disabled (REVIEW_AUTO_VALIDATE=0)

⚠️ The P/D cancel test (http_pd_load_tests.rs:737) and the stalled-error test (:866) assert load() == 0 but never prefill_tokens() == 0 — only the streaming success path checks the release, so a later refactor of WorkerLoadGuard's Drop or of the P/D guard-drop timing could strand the charge with no failing test, and since nothing but a release ever lowers the counter, the gauge would then drift upward permanently. Author must add the two release assertions valarLip's review named. [verified]

async fn cancelling_dispatch_releases_pending_load() {

2 finding(s) posted inline, on the lines they are about:

  • atom/mesh/src/observability/metrics/schema.rs:435 — A5: planner.rs:108 charges the prompt only when req.stream on Single placements, and the gRPC…
  • atom/mesh/src/core/worker.rs:1007 — worker.rs:1007 with_prefill_tokens calls release_prefill() before charging, but all three call sites…

_Independent refutation: 3 judged, 0 killed, 3 defended — same-family (claude reviewed its own output). Step 7.6 above

Comment thread atom/mesh/src/core/worker.rs Resolved
@MengqingCao

Copy link
Copy Markdown
Contributor Author

Thanks @valarLip @wanzhenchn. Status at a3b86cf, rebased onto #3493's 521882a:

@valarLip

  1. Agreed: this merges together with feat(mesh): agentic routing policy on the KV event index #3406, and the description says so. The decode-first change moved to feat(mesh): under idx2idx, select decode first and prefill on its rank #3493, which carries ci:mesh.
  2. and 3. Moved to feat(mesh): under idx2idx, select decode first and prefill on its rank #3493 with that change: the comments describe what idx2idx keeps, and RouterConfig::prefill_on_decode_rank holds the check.
  3. In a3b86cf, the cancel and stalled error-body tests assert the prefill charge is taken (7) and released (0), and with_prefill_tokens debug-asserts a fresh guard. The description no longer has the wrong CI sentence. One correction on the CI note: http_pd_load_tests and http_proxy_body_tests are compiled into the library through #[cfg(test)] #[path] (http_pd_router.rs, comm/proxy_body.rs), so the first --lib step runs them as well.

@wanzhenchn Both items are fixed in #3493: cache_aware keeps tenants that are not candidates, and since 34fb121 matches among its candidates only. metrics.md and the description cover rebind under idx2idx.

aiter-bot's items are answered inline; its first one is item 4 above.

@MengqingCao
MengqingCao removed this pull request from stack #3499 November 19, 2026 07:42
@MengqingCao
MengqingCao added this pull request to stack #3569 November 19, 2026 07:43
@MengqingCao
MengqingCao force-pushed the mengqing/mesh-prefill-accounting branch from a3b86cf to f9d07c1 Compare November 19, 2026 08:57
@MengqingCao
MengqingCao force-pushed the mengqing/mesh-prefill-accounting branch from f9d07c1 to 19fac16 Compare November 20, 2026 03:58
@MengqingCao
MengqingCao force-pushed the mengqing/mesh-prefill-accounting branch 2 times, most recently from 0cf44d1 to f3f9fa5 Compare November 23, 2026 13:37
Base automatically changed from mengqing/mesh-idx2idx-decode-first to main November 24, 2026 01:21
@zhuyuhua-v
zhuyuhua-v force-pushed the mengqing/mesh-prefill-accounting branch from f3f9fa5 to 9e89ad9 Compare November 24, 2026 01:21
@MengqingCao

Copy link
Copy Markdown
Contributor Author

@valar-cop

@valar-cop

Copy link
Copy Markdown

@MengqingCao LGTM. items are resolved: the P/D cancel and stalled tests now check the charge is taken (7) and released (0), with_prefill_tokens debug-asserts a fresh guard (worker.rs:1007), and the help names the paths that charge (schema.rs:434).

only thing left is the merge order, this goes in with #3406 rather than alone. mocker benchmark job still running..

zufayu added a commit to zufayu/ATOM that referenced this pull request Nov 24, 2026
The last gap of the class ROCm#3481 opened. Eleven of the 54 ids are also this
codebase's vocabulary: B1..B7 are the KV-offload chunk groups
(atom/kv_transfer/offload/README.md), C1/C2 the MTP4 rows
(atom/models/glm52/mono/kernels/op.py) and C3/C4 deepseek_v4's cuda-graph
capture topology (atom/models/deepseek_v4/mono/session.py).

So a lawful finding -- `B1-B2 stage before B3-B4, breaking the tail-to-head
order` -- was read as id-led and refused. RULE-CODE-IN-CARD is fatal, so the
only way out is an untrue `-- not reported:`: the trap r41 item 1 closed,
reached from the other side. `main` refuses these too; this is the class, not
a regression.

No shape separates `B1` the rule from `B1` the chunk group -- that is what the
word lists of r42-r45 established -- so the diff decides, which is the one
thing that is not a guess. It is the rule r45 put on CLAIM_IDENT, applied to
the id reader too, and `audit_card` already had `diff_text`.

Weighing the two errors: refusing a lawful finding is fatal, shipping an
id-led line is cosmetic. So a word the PR uses itself stops being read as an
id, and both readers share one vocabulary so they cannot disagree.

`.claude/` contributes nothing, on purpose: rules.md names every id, so a PR
touching the skill -- this one does -- would otherwise put all 54 in the
vocabulary and switch the gate off in exactly the reviews most likely to
exercise it. Pinned by its own case.

selftest 166 green / 0 red. Dropping the vocabulary check turns "a finding
using a word the diff uses" red; dropping the `.claude/` exclusion turns "a
diff that only touches the skill contributes no vocabulary" red; neither masks
the other. With an empty vocabulary the reader is unchanged over 212,823 real
lines. check_prompts 0 drift, ruff clean, SKILL.md 505/505.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@wanzhenchn

Copy link
Copy Markdown
Contributor

Merged with current main (dc6cd23), this no longer compiles: #3698 added a PlacementPlan::Single without prefill_tokens in LocalPlanner::plan (atom_bridge/mod.rs#L237-L240), so cargo check fails with E0063, missing field prefill_tokens. CI is green only because it ran before #3698 merged, and main does not require branches to be up to date, so merging as is would break main. Adding prefill_tokens: 0 there fixes it; lib and tests check clean locally. Nothing on that path reads the count: the gRPC pipeline builds its load guards without it (pipeline.rs#L374-L386).

MengqingCao and others added 2 commits November 24, 2026 07:52
Each worker now carries a prefill-token counter next to its request count:
the prompt tokens placed on it whose prefill has not finished, exported as
mesh_worker_prefill_tokens{worker}. DP-aware workers keep one per rank.

The planner charges the prompt's tokens, when the router has them, to the
worker that prefills it, and the load guard holds the charge until the
prefill is done:

- P/D: on the prefill worker's guard, released when the prefill response
  completes. Under idx2idx it follows the remapped prefill rank; the idx2idx
  reservation test carries a nonzero charge and checks where it lands.
- Regular HTTP, streaming: until the response's first frame.
- Regular HTTP, non-streaming: not charged, since its first frame arrives
  only after decoding.

ext-proc single-worker and gRPC placements do not charge yet. A release
larger than the charge saturates at zero and logs a warning.

Ported from #3210 with its review addressed: non-streaming requests are not
charged, with a test, and the charge lives on WorkerLoadGuard rather than a
public PrefillTokenGuard.

Co-authored-by: Jasen2201 <yajizhan@amd.com>
- The cancel and stalled error-body P/D tests check the prefill charge is
  taken and released, not only the request load.
- WorkerLoadGuard::with_prefill_tokens debug-asserts a fresh guard
  instead of releasing a charge no caller has.
- The mesh_worker_prefill_tokens help names the paths that charge it.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Jasen2201

Copy link
Copy Markdown
Collaborator

Needs ruling from @MengqingCao: can this PR charge the prefill on every path, not only on HTTP P/D and streaming HTTP?

A path left at zero shows a worker that is prefilling as idle to agentic (#3406). The target is ATOM's own per-rank count, atom:dp_queued_prefill_tokens: charged at routing and released at the first sampled token, streaming or not. The paths and their release points are below.

Paths and release points

For example, worker A is prefilling one non-streaming request with a 32K-token prompt, and worker B two streaming requests of 1,024 tokens each. agentic weighs A's load at 512 and B's at 3,072, so the next request queues behind 32K tokens on A.

  • ext-proc single worker, streaming: ext_proc/routing.rs drops the plan's prefill_tokens. Release at the first response body chunk; RequestLifecycle owns the guard and sees every chunk, as the mesh requires FULL_DUPLEX_STREAMED.
  • gRPC single worker, streaming: make_load_guards builds the guards without prefill_tokens. Release at the engine's first chunk.
  • gRPC P/D: release when the prefill completes. For ATOM pairs that is where AtomPairs ([ATOM gRPC] atomesh: discover ATOM gRPC workers and run ATOM P/D over gRPC #3676) drops the prefill guard, so whichever of the two PRs lands second charges it there.
  • Non-streaming single worker (HTTP, ext-proc, gRPC): the router sees no prefill end, since the first byte, or the complete of ATOM's gRPC Generate ([ATOM gRPC] The atom.grpc.v1 service: proto, generated modules, info, Generate, Abort and structured output #3673), comes after decoding. Take these from the engine's per-rank count. Holding the charge until the response ends is simpler, but it also counts their decode.

The engine side at 659c3ba: the charge, the release at the first sampled token and the gauge. With every path charged, the metric help and agentic_cost.md no longer need to list uncharged requests.

@Jasen2201

Copy link
Copy Markdown
Collaborator

Needs ruling from @MengqingCao: can a non-streaming request's charge follow the engine's count? Leaving it at zero and holding it until the response ends each misplace requests for part of its life.

Take worker A with one non-streaming 32K-token request (about 2 s of prefill, then 20 s of decode) and worker B with two streaming 1K-token requests. Uncharged, A scores 512 against B's 1,024 while it prefills. Held to the end, A scores 33,280 through its decode.

The timeline
A's request is charged While A prefills (about 2 s) While A decodes (about 20 s)
Not at all (this PR) A 512, B 1,024: the next request waits behind 32K tokens on A A 512, B 1,024: right
Until the response ends A 33,280, B 1,024: right A 33,280, B 1,024: B takes every request while A has no prefill left
By the engine's count A 33,280: right A 512: right

Scores are queued prefill plus 512 per in-flight request; the new request's own uncached tokens are the same on both workers, and B's two prefills are already done. Under P/D this request is charged on its prefill worker until the prefill response returns, so its charge already ends with the prefill. Polled, the engine's count lags, so requests placed since the last poll still need the router's own charge.

main's LocalPlanner (#3698) builds a PlacementPlan::Single without
prefill_tokens. The gRPC pipeline it feeds builds its load guards
without the count, so 0 changes nothing.

Co-authored-by: Cursor <cursoragent@cursor.com>
@MengqingCao
MengqingCao force-pushed the mengqing/mesh-prefill-accounting branch from 9e89ad9 to afd71ca Compare November 24, 2026 13:07

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM

The code is done. Merge this only together with #3406, as agreed under ask 1: nothing in this PR reads prefill_tokens().

Every earlier ask is fixed here or was moved to #3493, which has merged:

  • The decode-first change, the idx2idx comment wording and RouterConfig::prefill_on_decode_rank are on main through #3493 (config/types.rs:614, http_pd_router.rs:408, ingress.rs:652). This PR no longer touches selection and does not duplicate them.
  • The cancel and stalled error-body tests now assert the charge (7) and the release (0) (http_pd_load_tests.rs:747,752,841,864).
  • with_prefill_tokens debug-asserts a fresh guard (worker.rs:1007).
  • The description's CI sentence is corrected. The routing tests are compiled into --lib through #[path], and run_atomesh_test_harness ran them on this head.
  • wanzhenchn's E0063 after #3698 is fixed by prefill_tokens: 0 on the atom_local plan (atom_bridge/mod.rs:240). Main has no mesh commits after this PR's base.

Charge and release: every charge is released exactly once on every path we traced. That covers success, error, abort or cancel, stall, client disconnect, retry, idx2idx remap, streaming and non-streaming. A charge happens only in with_prefill_tokens, and release_prefill zeroes the field before Drop's decrement_load runs. The gauge uses the same url@rank key and removal path as requests_active.

Before merge:

  • Resolve the two outdated aiter-bot threads (schema.rs:435, worker.rs:1007). Both are fixed at this head.
  • Jasen2201's question about charging every path (gRPC, ext-proc, non-streaming) is a scope ruling for #3406 or a follow-up. It is not a defect in this PR, and the metric help names the paths that are charged.

Reviewed at afd71ca (Deep, re-review; two independent passes, no divergence). Already fixed: asks 2 and 3 via #3493; ask 4 (asserts, CI sentence, debug_assert); the E0063 rebase fix.

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at afd71ca.

@MengqingCao

MengqingCao commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@wanzhenchn Thanks, that's it. Rebased onto 659c3ba and fixed in afd71ca: the atom_local plan passes prefill_tokens: 0, and as you say the gRPC pipeline it feeds builds its load guards without the count. cargo check --all-targets is clean and the lib tests pass locally; the stack above is rebased on it.

@MengqingCao

Copy link
Copy Markdown
Contributor Author

Needs ruling from @MengqingCao: can this PR charge the prefill on every path, not only on HTTP P/D and streaming HTTP?

Ruling: yes, in follow-up PRs on this stack rather than in this one. For ext-proc and gRPC streaming, the guard carries the plan's prefill_tokens and releases at the first response chunk. For gRPC P/D, as you propose, whichever of #3676 and the follow-up lands second charges it in AtomPairs.

Needs ruling from @MengqingCao: can a non-streaming request's charge follow the engine's count?

Ruling: it follows the KV events instead, as llm-d-router#3975 does. A non-streaming request on every protocol is charged at routing and released when the selected url@rank's KV events store its last full prompt block; the first byte is the fallback. The event ends the charge at prefill completion without a poll's lag, and needs no de-duplication against a lagging gauge.

How each path releases
  • ext-proc releases in RequestLifecycle::body, gRPC at the engine's first chunk in TokenHandle. One shared charge per guard, so the first chunk or the guard's drop (cancel, error) releases it exactly once.
  • ATOM's BlockStored carries no request id, so the router matches by its own prefix hash of that block on the rank's event lane. Identical concurrent prompts release one waiting request per stored block, oldest first.
  • First-byte fallback: a cached repeat, a prompt shorter than a block, a rank the engine chose itself, a media prompt, a worker with no KV event subscription. gRPC workers have none today (FollowKvEventsStep follows HTTP workers only), so a non-streaming gRPC request holds its charge to the response.

@wanzhenchn wanzhenchn added the ci:mesh Mesh-only PRs: pass the Accuracy checks on the ATOMesh CI label Nov 25, 2026

@Jasen2201 Jasen2201 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow up pr fix my comments

@zhuyuhua-v
zhuyuhua-v merged commit ddbb439 into main Nov 26, 2026
175 of 176 checks passed
@zhuyuhua-v
zhuyuhua-v deleted the mengqing/mesh-prefill-accounting branch November 26, 2026 02:51
junyyang-amd added a commit that referenced this pull request Nov 26, 2026
main's #3481 added PlacementPlan::Pair::prefill_tokens; this test's
initializer predates it and stopped the lib tests from compiling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zufayu added a commit that referenced this pull request Nov 27, 2026
)

* review-pr: refuse a finding that opens with an internal rule code

SKILL.md says, in as many words, "Do NOT use rule codes (B1, D4, A1...) in
output -- they are internal labels only". The card gate then parsed a leading
rule code as a valid way to claim a FIRE. So the instruction forbade it and the
gate rewarded it, and a model that follows the gate over the prose is behaving
correctly.

It did: ATOM#3481's published review opens a finding `⚠️ A5: planner.rs:108
charges the prompt only when ...`. The reader of that review has no idea what
A5 is; the label is this skill's own bookkeeping, shipped to someone it means
nothing to.

The id still counts as the claim -- withdrawing that would turn such cards into
UNREPORTED-FIRE, which the comment below this one explains was worse -- but the
card does not ship with it.

Two selftest cases, mutation-verified. Checked against ATOM#3481's actual
finding text, which the gate now names.

131 green / 0 red.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: refuse only real rule ids, and let Rust cite itself

Review raised two defects in the first version, both confirmed.

1. The shape `([A-Z]+\d+[a-z]?):` is not specific to rule ids. `FP8:`, `TP8:`,
   `MI300:` and `V4:` all match it and are ordinary ways to open a finding in
   this repo, so the gate would have refused them carrying a message about an
   internal rule id that does not exist. Now checked against ALL_RULES.

2. Refusing the id was a dead end for a finding with no citable path, because
   triage's CITATION covered neither `.rs` nor `.toml` -- while `_publish.py`
   anchors both, and ATOM#3481's Rust findings did anchor inline. Two citation
   regexes disagreeing meant a mesh finding's `lookup.rs:185` was invisible to
   the gate and the rule id was its only remaining claim. Extended, which closes
   the dead end and the asymmetry at once.

Two more selftest cases (an FP8: opening is not refused; a Rust citation counts),
and the three branches are mutation-verified.

133 green / 0 red, 43 publisher tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: catch a rule id behind emphasis, at both match sites

Review asked for this, with one detail off: it said ATOM#3481 ships `**A5:**`
and still would. The bytes of that comment are `⚠️ A5: planner.rs:108` with no
emphasis, so the gate did catch it. The evasion is real as a next step, not as
an observed case -- SKILL.md's own examples lean on `**`, so `**A5:**` is the
shape a model reaches for once the plain one is refused.

Both match sites hardened, not just the one that refuses. The other registers a
rule id as claimed, so a match pinned to offset 0 loses the claim there and
raises a false UNREPORTED-FIRE -- the same regex, two opposite failures.

Selftest case with the emphasised literal; mutation-verified.

134 green / 0 red.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: give a path-less FIRE a legal card, and share one citation pattern

Review found four defects, all confirmed. The first is the serious one: the
previous version left a state with no legal way out.

1. A verdict reason may name only a symbol or a condition, and SKILL.md's format
   allows that. Then `fire_paths[rule]` is empty, and the card had two moves and
   both were fatal -- name the id and RULE-CODE-IN-CARD refuses it, drop the id
   and UNREPORTED-FIRE fires. The only way through was a `-- not reported:` that
   is untrue, which is exactly the "making a reviewer write something false to
   satisfy a gate" this file already argues against one function away. A
   path-less FIRE can now be claimed by the distinctive words of its own reason.

2. The in-card `cited` scan carried its own copy of CITATION's extension list and
   had drifted from it: no `rs|toml`, so a Rust-only finding read as citing
   nothing and skipped UNANCHORED and UNBACKED both. It now derives its pattern
   from CITATION, so they cannot diverge again.

3. The new cases all passed an empty verdicts_text, so none of them exercised the
   interaction they were about. Six cases now drive real FIRE verdicts: an `A5:`
   card against an `A5` FIRE, the same card without the id, a path-less FIRE
   claimed by tokens, the id refused in that case too, a backticked id, and a
   non-rule `FP8 FIRE` that must stay UNREPORTED rather than be claimed by a
   lookalike id.

4. Cleanups: the rule-id regex is compiled once as RULE_ID_HEAD and the ALL_RULES
   membership check is a frozenset, applied once before either reader rather than
   pasted at both; and RULE-CODE-IN-CARD no longer counts under "findings cannot
   be traced", which is about tracing, not about how a finding is written.

143 green / 0 red, 43 publisher tests, check_prompts 0 drift. Every branch added
here is mutation-verified.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: tighten the token claim, read the id through the tag, stop teaching the shape

Review found two defects and three nits. All five were real.

1. One shared four-letter word claimed a FIRE. SKILL.md mandates "**Author
   must**" on every finding, so `must` alone let any finding claim any path-less
   FIRE whose reason used it -- silencing the UNREPORTED-FIRE that belonged to
   another rule. Matching was also case-sensitive against a lower-case stopword
   list, so `Prefill` missed `prefill` while `This` sailed through, and a shared
   `1024` counted as agreement. `_claim_tokens` now folds case, drops pure
   numbers and drops the words SKILL.md mandates, and a claim needs two shared
   tokens or one identifier.

2. `RULE_ID_HEAD` only looked at offset 0, so `[verified] A5: ...` shipped
   unrefused -- and `_publish.first_clause` strips that tag, so the published
   line opened `A5:`, the ATOM#3481 symptom with one token in front of it. The
   id is now read through `_rule_head`, which strips the leading tag the way
   `_publish` does and accepts `:`, `—` or `--` after the id. One reader for both
   callers, so the comment about a single guard is true now rather than aspirational.

3. rules.md was teaching the shape. About fifty `⚠️ A1:` templates reach the
   worker through `expand`, so the model was shown the opening it would then be
   refused for -- the same instruction/gate disagreement this PR is about, one
   level up. The ids are out of the templates, and a selftest asserts no template
   opens with one.

4. The summary printed a bare `CARD NOT NAILED DOWN: ` when a rule code was the
   only problem; it now names it. The old test only checked that "cannot be
   traced" was absent, which an empty line and a crash both satisfy.

5. A comment claimed SKILL.md has a `**A5:**` example. It does not.

153 green / 0 red, 43 publisher tests, check_prompts 0 drift, mapping unchanged.
Nine new cases; every branch mutation-verified, including the three that first
stayed green because the fixtures shared words for other reasons.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: test the identifier on the spelling it was written with

Review found that the previous commit's own fix regressed the case it was for,
and the three examples it gives all reproduce.

Lower-casing happened before the identifier test, so IDENT's ALL-CAPS branch
could never match and `[a-z]+_` rejected anything with a digit in front of the
underscore. A path-less `B1 FIRE -- KVCACHE size not updated` then had no
claimable token, and neither did `fp8_scale dropped on reload` on its own; a
one-word reason like `B1 FIRE -- deadlock` could never reach the two-token
threshold at all. Each of those is a fatal UNREPORTED-FIRE whose card has no
legal move -- the same dead end this PR set out to remove, reintroduced one
commit later.

`_claim_tokens` now returns `{folded: spelling}`: folding still decides whether
two sides share a word, and the spelling is what the identifier test reads.
CLAIM_IDENT is local to this path (IDENT is read by other gates and is not mine
to widen) and admits a digit in the first segment. A reason with fewer than two
claimable words of its own is claimed by one.

Also from review: `rules.md:161`'s `B5-[sub-type]:` was the last id-led template
and the template selftest's regex could not see it; `_rule_head` now accepts a
sub-type suffix and an en dash, and the test regex matches the placeholder form.
A double-dash case was missing -- removing `--` from the separators had turned
nothing red.

158 green / 0 red, 43 publisher tests, 0 drift, mapping unchanged. Eight new
cases; five mutations verified, including the one that first stayed green
because the test regex could not match the placeholder it was meant to catch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: put the HK ids back where expand reads them, and stop GEMM naming things

Two regressions, both mine, both from the last two commits.

1. The rules.md rewrite took the only `HKn` out of each Housekeeping row. Those
   ids are not decoration: `expand_rules` finds the row by `\b(HK\d+[a-z]?)\b`,
   so a derived HK rule became MISSING-RULE-TEXT, rc 1, and fetch.sh aborted the
   whole review. A `.sh` file in the diff, a `# TODO`, an `ATOM_` env var or three
   top-level directories is enough to derive one -- this PR touches selftest.sh,
   so it would have killed its own review.

   Verified: `expand` on a diff deriving HK1 and HK4 exits 1 on this branch and 0
   on main. The ids now sit in the Check column, which expand reads and no card
   ever quotes, so the no-id-in-templates test still counts zero. A selftest
   derives HK rules and asserts expand exits 0; stripping the ids again turns it
   red.

2. CLAIM_IDENT's ALL-CAPS half is also how this codebase writes ordinary words.
   GEMM, BF16, CUDA, TODO and MI300 all match it, so `B1 FIRE -- GEMM output cast
   drops the per-token scale` could be claimed by an unrelated card line saying
   `BF16 GEMM`, and the UNREPORTED-FIRE that belonged to B1 disappeared. That case
   was correct on main and at 707fd5a; it broke in b232b03, as a side effect of
   the previous round's fix.

   A bare ALL-CAPS word now counts only if it is neither a VALUE (dtypes and
   architectures are already that) nor one of the spelled-out generic terms --
   the distinction is which words are common here, not what shape they have.
   `KVCACHE`, `fp8_scale` and `w8a8_gemm` still count.

160 green / 0 red, 43 publisher tests, 0 drift, mapping unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: let the basename form SKILL.md teaches claim its own FIRE

Two open notes from review, both confirmed here first.

A verdict reason writes the path it found, `atom/models/x.py:1`. SKILL.md's good
examples write the basename, `x.py:1`. The claim matched the verdict's exact
string, so the form the skill teaches could not claim the FIRE it was reporting
and the card got a fatal UNREPORTED-FIRE -- the instruction and the gate
disagreeing again, with the instruction losing. Paths are compared on segment
boundaries now, so `x.py` answers for `atom/models/x.py` while `other/x.py` and
`scale.py` (against `kv_scale.py`) still do not.

And no case carried an en dash, so removing `–` from the separators turned
nothing red. One added.

164 green / 0 red, 43 publisher tests, 0 drift, mapping unchanged. Four new
cases, three mutation-verified -- including the segment-boundary one, which
first stayed green because both fixtures also failed a bare endswith.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: claim a path-less FIRE by a backticked symbol, not by guessing

Review's fifth blocking finding in this heuristic, and its advice was to stop
patching it. Confirmed first: verdicts `A5 -- foo.py:3 tuned config missing` and
`B1 -- FP32 output cast drops the per-token scale` against the single card line
`⚠️ foo.py:3 FP32 tuned config missing` claims B1 silently, and `num_tokens`,
`head_dim`, `MI355X`, `GSM8K`, `TTFT` do the same. The word list only ever held
the words the previous round named.

It was never going to hold. No shape separates a name from this codebase's
ordinary vocabulary, so every version guessed and every round found what it
guessed wrong. The claim is now the one thing that is not a guess: a symbol the
reason itself put in backticks, matched as written. `_GENERIC_CAPS`,
`CLAIM_IDENT`, `_claim_tokens` and the template-word and stopword filtering are
gone with it.

A reason that backticks nothing has no route -- which is where main already was,
so nothing regresses; what it costs is one pair of backticks in the ledger.

Also from review: `_rule_head` refused only `ALL_RULES`, so the ids in
`UNREACHABLE_BY_DESIGN` shipped. `📝 HK3:` is the live case, because SKILL.md's
own integration-test checklist told the worker to write exactly that. Both ends
fixed -- the gate refuses `RULE_SET | UNREACHABLE_BY_DESIGN`, and the checklist
no longer hands out the id.

148 green / 0 red, 43 publisher tests, 0 drift, mapping and expand unchanged.
Five cases replace the eleven that tested the guesswork; three mutations verified.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: find the rule id through whatever is standing in front of it

The tag strip ran once and only on a bare `[tag]`, so six openings review listed
still shipped: `**[verified] B1:**`, `**[verified]** B1:`, `` `[verified]` B1: ``,
`[verified] [B1]`, `[verified] (B1):`, `A5/B1:` and `D4 -`. Each verified before
the change. `_publish.first_clause` strips the tag on the way out, so every one
of them reaches the reader as an id-led line -- the ATOM#3481 symptom with
decoration in front of it. ATOM#3481 itself used bold.

`_rule_head` now peels leading emphasis and bracketed groups in turn rather than
once, and accepts a second id after `/` or `,` and a lone `-` as a separator. A
peeled group whose contents are themselves a rule id is the id, not a tag over
it, which is what `[verified] [B1]` needs and what a single pass cannot tell.

Two selftests: seven decorated forms must all be refused, and five ordinary
openings -- `FP8:`, `MI300:`, `[verified] x.py:1`, a plain sentence and
`[inferred] planner.rs:108` -- must all be left alone. Five mutations verified.

150 green / 0 red, 43 publisher tests, 0 drift, mapping unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: tell the worker about the backticks, and put back the tests I deleted

Three things from review, and the third is the one that matters.

1. The new claim needed a backticked symbol and nothing told the worker so.
   SKILL.md's verdict format explicitly allowed "symbol, or the condition", and
   neither it nor the UNREPORTED-FIRE hint mentioned backticks -- so a reason
   like `B1 FIRE -- the scheduler lock is not held` left the card with no legal
   form again, which is the trap this PR exists to remove. The format line now
   reads "file:line, or a `backticked` symbol the card will name" (edited in
   place; the tree merged with #3494 is at 505/505), and the hint says to add
   them, and that editing the verdict line to do so is a fix rather than a cheat.

2. The symbol was matched as a plain substring, so a two-character one found
   itself everywhere: `tp` inside "output", `kv` inside "kv_cache". Identifier
   boundaries now, with both cases pinned.

3. The commit that replaced the word list deleted 224 lines of selftest, and
   five of them had nothing to do with the word list: the housekeeping `expand`
   guard, "no rule template opens with an id", and the three `_same_file` cases.
   The first of those is the test that catches the regression that aborts a
   review for any diff with a `.sh` file in it -- a regression this PR
   introduced two commits earlier. Restored, all five passing.

   That is the same mistake twice in one branch: removing something whose only
   job is to fail later.

Nits: `D4 violation in …` (SKILL.md's own bad example), `HK3 bug fix without
test`, `B1 (silent bypass):` and `[B1/B2]` are refused now; the dead
`_claim_tokens`, `RULE_ID_HEAD`, `_FIRE_STOPWORDS` and `_CLAIM_TEMPLATE_WORDS`
are gone, and two comments that quoted text this PR removed are fixed.

`` `x.py:3`: B1: `` is still not refused, and is listed rather than patched.
Chasing shapes one at a time is what the word list did for five rounds before
this PR replaced it; the same answer should not be re-derived for the matcher.

157 green / 0 red, 43 publisher tests, 0 drift, mapping and expand unchanged.
Four mutations verified.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: close punctuation-symbol and rule-id gaps

* review-pr: strip what first_clause strips after a citation

`_rule_head`'s citation skip removed only `[\s*`_]*:?`, while
`_publish.first_clause` strips `(?:-\d+)?` and `[,:]` as well. So an opening
that put the id after a range citation, a comma or a dash -- `foo.py:563-569
A5: …`, `` `foo.py:563`, A5: … ``, `foo.py:563 — A5: …` -- returned None here
and still reached the reader as `A5: …`, which is the id-led line this gate
exists to refuse. Range citations are common: real bot cards carry 74 of them.

The skip now strips the same shapes. `foo.py:3 — the E2E path` and
`foo.py:3-5 TP8 x` are still left alone, and both ends are pinned by
`_head_forms` (25) and `_head_passes` (9).

selftest 163 green / 0 red, check_prompts 0 drift.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: past a citation, read only the id forms first_clause creates

The widened citation skip refuses ids this codebase uses as its own words.
B1..B7 are the KV-offload chunk groups (kv_transfer/offload/README.md:1084),
C1/C2 are the MTP4 rows (models/glm52/mono/kernels/op.py:131), and C3/C4 are
deepseek_v4's cuda-graph capture topology (models/deepseek_v4/mono/session.py,
a dozen uses). All eleven are in REFUSED_IDS.

So a lawful finding, written in the citation-led form SKILL.md teaches, was
read as id-led:

  README.md:1084, B1-B2 stage before B3-B4 ...   -> B1   (was: no id)
  op.py:131 — C1/C2 rows for MTP4 are swapped    -> C1   (was: no id)
  session.py:1527 C3 buffers are updated ...     -> C3   (already, before this)

RULE-CODE-IN-CARD is fatal, so the worker's only way out is an untrue
`-- not reported:` -- the trap this gate's own first round exists to close.

Past a citation only the colon forms are read now. `_publish.first_clause`
strips `(?:-\d+)?` and `[,:]` and nothing else, so `foo.py:563-569 A5: …` is
the shape that reaches the reader id-led; `B1-B2 stage before` and `C1/C2 rows`
are not, and never were. An id at offset 0 is still read with the full BARE_ID,
so every #3481 form stays refused.

Replayed over 212,823 unique real lines (ATOM and aiter PR + issue comments,
3000 main commit messages): 0 results change. That number is not evidence of
safety on its own -- a finding the old gate made unwritable cannot appear in a
corpus of what the old gate published -- which is why the three forms above are
taken from this repo's own files rather than from the corpus.

selftest 163 green / 0 red (reverting the tightening turns "an ordinary opening
is left alone" red, 162/1), check_prompts 0 drift.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: write the rule-id pattern once

CITED_ID pasted BARE_ID's first two lines verbatim -- the id, its sub-type, the
`A5/B1` list and the `(silent bypass)` aside. The two readers differ only in
what they accept after that, so the shared part is now `_ID_HEAD` and each
reader supplies its own tail. This is the nit r41 raised about the rule-id
regex, reintroduced by the commit before this one.

No behaviour change: replayed over 212,823 unique real lines (ATOM and aiter
PR + issue comments, 3000 main commit messages) plus the 14 decorated forms the
selftest pins -- 0 differences. selftest 163 green / 0 red, 0 drift, ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: a word the diff uses is not a rule id

The last gap of the class #3481 opened. Eleven of the 54 ids are also this
codebase's vocabulary: B1..B7 are the KV-offload chunk groups
(atom/kv_transfer/offload/README.md), C1/C2 the MTP4 rows
(atom/models/glm52/mono/kernels/op.py) and C3/C4 deepseek_v4's cuda-graph
capture topology (atom/models/deepseek_v4/mono/session.py).

So a lawful finding -- `B1-B2 stage before B3-B4, breaking the tail-to-head
order` -- was read as id-led and refused. RULE-CODE-IN-CARD is fatal, so the
only way out is an untrue `-- not reported:`: the trap r41 item 1 closed,
reached from the other side. `main` refuses these too; this is the class, not
a regression.

No shape separates `B1` the rule from `B1` the chunk group -- that is what the
word lists of r42-r45 established -- so the diff decides, which is the one
thing that is not a guess. It is the rule r45 put on CLAIM_IDENT, applied to
the id reader too, and `audit_card` already had `diff_text`.

Weighing the two errors: refusing a lawful finding is fatal, shipping an
id-led line is cosmetic. So a word the PR uses itself stops being read as an
id, and both readers share one vocabulary so they cannot disagree.

`.claude/` contributes nothing, on purpose: rules.md names every id, so a PR
touching the skill -- this one does -- would otherwise put all 54 in the
vocabulary and switch the gate off in exactly the reviews most likely to
exercise it. Pinned by its own case.

selftest 166 green / 0 red. Dropping the vocabulary check turns "a finding
using a word the diff uses" red; dropping the `.claude/` exclusion turns "a
diff that only touches the skill contributes no vocabulary" red; neither masks
the other. With an empty vocabulary the reader is unchanged over 212,823 real
lines. check_prompts 0 drift, ruff clean, SKILL.md 505/505.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: comments that name things the merged tree has

Review finding, and both halves check out.

`_diff_vocabulary`'s docstring credited "the rule r45 put on CLAIM_IDENT".
CLAIM_IDENT appears exactly once in the tree -- in that sentence. The backtick
redesign deleted the symbol, and r41/r45 are this PR's own review rounds, which
a reader of the merged tree cannot open. Both now point at `_mentions_symbol`,
which is in the tree and answers the neighbouring question the same way.

The CITED_ID comment was worse than vague, it was wrong. It said
`first_clause` strips `(?:-\d+)?` and `[,:]` "and nothing else, so
`foo.py:563-569 A5: …` reaches the reader id-led while `README.md:1084, B1-B2
stage before B3-B4` does not". It does not draw that line. Run on the two:

  first_clause("atom/foo.py:563-569 A5: guard missing", "atom/foo.py:563")
    -> "A5: guard missing..."
  first_clause("README.md:1084, B1-B2 stage before B3-B4...", "README.md:1084")
    -> "B1-B2 stage before B3-B4..."

Both reach the reader with an id-shaped word in front. A maintainer who read
that comment and went to "fix" first_clause would have been fixing the wrong
half. The real distinction is what the reader sees -- `A5:` is a bare label,
`B1-B2 stage before B3-B4` is a sentence starting with one of this codebase's
own words -- which is what the comment says now, and why the narrowing still
earns its place beside `_diff_vocabulary`: it holds for a word the diff
happens not to contain.

No behaviour change: comments only. selftest 166 green / 0 red, check_prompts
0 drift, ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: guard every id the gate refuses, and stop claiming a clean line

Three from review. Two confirmed as written; the third is right that the
enumeration was wrong and wrong about what the number is.

1. The template guard counted `RULE_SET` (42 derivable ids) while the gate
   refuses `REFUSED_IDS` (54). The eight templates this branch stripped ids
   from -- B3, B4, C3, D1b, D5, D8, D9, F1 -- are UNREACHABLE_BY_DESIGN, so a
   regression re-adding any of them passed the guard while every card quoting
   that template got refused. Replayed: with `⚠️ B3:` put back in rules.md the
   old guard stays 166 green / 0 red; the fixed one is 165/1.

2. The comment justifying the after-citation colon-only read claimed those are
   "the only ones first_clause turns into an id-led published line". They are
   not:

     first_clause("planner.rs:108 A5 charges only on req.stream", "planner.rs:108")
       -> "A5 charges only on req.stream..."

   This is the same wrong claim the commit before this one removed from
   triage.py, left behind in selftest.sh and restated once more. Both now say
   the real shape of it: a trade, not a line. Refusing the no-colon form would
   take `B1-B2 stage before B3-B4` with it whenever `_diff_vocabulary` does not
   hold the word; a refusal is fatal and an id-led index line is cosmetic, so
   the cosmetic gap is the one left open, named where someone can close it.

3. "Eleven of the 54 ids are also this codebase's vocabulary: B1..B7, C1/C2,
   C3/C4". C4 is not an id, as the review says -- but the count is not ten
   either. Measured over atom/ and docs/, nineteen of the 54 appear as ordinary
   words: the nine the enumeration missed are D6, D10, E1, E2, G1, G2, H2, I1
   and N1. Both places now give the measured number, name all of them, say C4
   is vocabulary and not an id, and say the count is what the tree says today
   rather than a constant.

selftest 166 green / 0 red, check_prompts 0 drift, ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: punctuation on its own is not a symbol

Review finding, confirmed. `_claim_symbols` took any backticked span of 2-60
characters, so `==`, `--`, `()` and `::` were claim handles. `_mentions_symbol`
cannot put a boundary around an end that is already punctuation -- requiring
one would reject `x.cuda()`, because the character before `.cuda()` is `x` --
so a reason backticking `==` was claimed by ANY finding with `==` anywhere in
it, and the UNREPORTED-FIRE that exists to force that rule onto the card never
fired. Replayed: verdict "B1 FIRE -- the `==` check silently equates None and
0" against the single unrelated finding "foo.py:3 the tuned config lookup uses
== on floats" claims the FIRE and reports nothing.

A span has to carry a word character now. `.cuda()`, `->data` and `::empty`
mix the two and keep their claim; punctuation alone has no claim route, which
is where a reason that backticks nothing already was.

selftest 167 green / 0 red; dropping the word-character requirement turns the
new case red (166/1). check_prompts 0 drift, ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: a period and a lone hyphen separate a citation too

Three from review, all confirmed.

The citation skip's separator class had only colon, comma, em dash, en dash
and double dash, so `foo.py:3. A5: guard missing` and `foo.py:3 - A5: broken`
reached the reader id-led -- the colon form this branch exists to refuse,
wearing a separator the class did not list. Both are refused now.

Closing them costs nothing lawful, which the review checked and so did I:
what follows the strip still has to be the colon form, so
`README.md:1084. B1-B2 stage before B3-B4` and its hyphen twin still pass.
Both are in `_head_passes` (12 -> 14) and the two refused forms in
`_head_forms` (25 -> 27). `--` precedes `-` in the alternation so the long
form wins; a line range is eaten by `(?:-\d+)?` before any of it.

selftest.sh:515 still carried the pre-fix "Eleven of the 54 ids ... C3/C4"
text. That is the third time in this branch that I fixed one copy of a
statement and left another: the wrong first_clause claim lived in triage.py
and selftest.sh, and so did this count. Both copies now say nineteen, name all
of them, and say C4 is vocabulary rather than an id.

The PR description said `150 green / 43 passed`, which was the r48 head.
Refreshed to 167.

selftest 167 green / 0 red; narrowing the separator class back turns
"a rule id hidden behind decoration or a citation is still refused" red
(166/1). Over 212,823 real lines the reader is unchanged. check_prompts 0
drift, ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: no number in the comment, because every number was wrong

Review is right that the enumeration missed ids, and right about which: T1 and
D11 label obligations in atom/mesh/tests/*.rs, and the count that produced
"nineteen" grepped only py/md/cu/hip, so every .rs was invisible to it.

It is wrong that the number is twenty-two. H1 appears nowhere under atom/ or
docs/ -- `grep -rnw H1 atom/ docs/` is empty -- and the file credited with it,
atom/mono/lm_head/kernel.py, does not exist (atom/mono/ holds __init__.py and
device/). Measured across py/md/cu/hip/rs/toml/cpp/h/hpp/sh/yaml/yml/json the
answer today is twenty-one.

But the number is the wrong thing to carry. Four of them have been written
into this comment during review -- eleven, ten, nineteen, twenty-two -- and all
four were wrong, two mine and two from the review. It moves with the tree and
with which extensions the counter thought to grep, and the comment said so
itself in the sentence before stating a constant.

So there is no number now, in either copy, and the reason is written down where
the next person would otherwise add one back. The examples stay, and every path
they name exists.

selftest 167 green / 0 red, check_prompts 0 drift, ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* review-pr: gate the count, since prose could not hold it

selftest.sh:697 was a third copy of the same sentence, still saying "19 of the
54". Confirmed, and it is the fourth round in a row that this statement was
fixed in one place and left standing in another -- the same shape as the wrong
first_clause claim, which also lived in two files.

Removing the number a third time would be the same move that failed three
times. There is a gate now: no comment in triage.py or selftest.sh may state a
count of the ids that are also ATOM words. The comments carry the examples and
a pointer to _diff_vocabulary, which says why there is no number.

The first version of that gate was dead. Its pattern was lower-case only, so
putting "Nineteen of the 54" back left the suite at 168 green / 0 red -- a test
that cannot fail, which is the thing this skill's own gates exist to catch, and
it slipped into the commit that was adding a gate about exactly that. Caught by
mutation, not by reading. With `-i` the same mutation is 167/1.

selftest 168 green / 0 red, check_prompts 0 drift, ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: zufayu <8138883+zufayu@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Yu <zufayu@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:mesh Mesh-only PRs: pass the Accuracy checks on the ATOMesh CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants