Skip to content

kb: address e2e records by release version, apply what is recalled, and report both - #438

Open
yueliu14 wants to merge 3 commits into
mainfrom
fix/kb-version-normalization-and-recall-report
Open

kb: address e2e records by release version, apply what is recalled, and report both#438
yueliu14 wants to merge 3 commits into
mainfrom
fix/kb-version-normalization-and-recall-report

Conversation

@yueliu14

@yueliu14 yueliu14 commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Three halves of one problem: a warm start that silently finds nothing, one that finds
something and silently fails to apply it, and a report that cannot tell you either happened.

1. Addressing — kb/identity.py

e2e_identity keyed framework_version verbatim. Serving stacks are installed from git in these images, so sglang.__version__ carries a PEP 440 dev/local suffix — 0.5.15.post1.dev20260723+g6c9fd0adc5 — that changes on every rebuild of the same release. A long opaque string is also one that gets hand-transcribed with a segment missing.

Either way the run opens a fresh set of pages and every earlier result becomes unreachable. Not degraded — invisible: the e2e store is an exact lookup with no search, so a miss and a never-recorded page are the same plain 404. And framework_version sits in the ladder's base, so no rung drops it:

...:sglang:0.5.15.post1.dev20260723+g6c9fd0adc5:mxfp4:tp_8:isl_8192:osl_1024:conc_64
...:sglang:0.5.15.post1.dev20260723+g6c9fd0adc5:mxfp4:tp_8
...:sglang:0.5.15.post1.dev20260723+g6c9fd0adc5:mxfp4

One changed character misses all three at once.

_release_version cuts the address to <major>.<minor>.<patch>:

0.5.15.post1.dev20260723+g6c9fd0adc5  ->  sglang:0.5.15
0.5.15.post1.dev20260723              ->  sglang:0.5.15
v0.5.15                               ->  sglang:0.5.15
0.26.0.dev0+g1234abc                  ->  vllm:0.26.0

Three components, not two. 0.5.15 and 0.5.17 are different releases with different kernels; cutting to 0.5 would merge results that genuinely do not transfer. The exact build string still travels in the record's value, so only the address is coarse — the same bargain as kernel_identity's ROCm cut, one component wider.

Reader and writer share this single choke point, so they cannot drift apart.

2. Applying — e2e_workflow.js, roles/config_tuner.md, kb/attest.py

Finding the record is half of it. A stored e2e record holds a whole launch configuration, not a delta — the only form that can be replayed on a box whose baseline nobody wrote down. Replaying it therefore means combining it with the baseline this run was handed, and that combination was a string concatenation performed by an agent (roles/config_tuner.md: EXTRA_SERVER_ARGS="<current flags + this flag>").

adapters/sglang.sh expands $EXTRA_SERVER_ARGS straight into argparse and $EXTRA_ENV straight into env, and both resolve a repeated key as last-wins. So when the baseline and the record each pin --context-length, which value applies is decided by the order the agent happened to write them in. Lose that coin flip and the server runs the baseline configuration twice: ~0% delta, nothing wrong in any log — the flag was honoured, just not with the recorded value — and the record is filed as rejected. A record that wins gets recorded as a loss, which is the one outcome the warm start exists to prevent.

Two more failures sit behind the same seam:

  • A flag deleted upstream makes argparse exit before the model loads. One shot spent, measured=0, not_reproduced filed, no repair.
  • not_reproduced meant both "the flag is gone upstream" (the record is stale) and "it collides with a baseline this run did not choose" (the record is fine). kb/attest.py:retire_hint retires on two of them, so a good record could be retired for being read on the wrong machines.

This is the default path, not an edge case, wherever a caller seeds the run with a full flag string it produced elsewhere and disables the exploratory sweep. The warm-start replay itself is not gated by CONFIG_TUNE_ENABLED; that flag gates only the exploratory ConfigSweep, so there is then no later phase that could correct any of it.

Merge key by key, in the orchestrator, and report what it did. mergeFlags / mergeEnv combine the recovered configuration with the run's baseline by flag name / env key. The recorded value wins every collision in place, so the baseline's ordering survives and the output names each key exactly once — last-wins never gets a vote. This generalizes the guard the launcher already applies by hand to one flag (adapters/sglang.sh: don't add --watchdog-timeout if the caller set one) and moves it to where the string is built instead of where it is used. Handles --flag value, --flag=value, bare flags, and multi-valued flags (kept whole, so a flag is overridden as a unit or not at all); a small explicit allow-list keeps genuinely repeatable flags (--lora-path) appended rather than deduped. What was overridden is reported, not just resolved — MERGE_OVERRIDES reaches the tuner, the run log, measured_on_this_box.md, the attestation note, and §2c below. A record the baseline already carries in full is now skipped instead of benched against itself.

One repair attempt, and only when nothing came back. When the merged configuration produces no measurement at all, the launch failure goes back to config_tuner, which classifies each recorded knob as upstream_gone / conflicts_with_baseline / env_unsupported, drops or adapts the minimum needed, and benches once more. Exactly once — a repair loop against a configuration that cannot run here spends server launches to learn nothing — and through the same accept gate, with no allowance made for having been repaired. If knobs had to be dropped, the verdict records applied_partial and which ones. SWEEP_SCHEMA gains an optional repair object, out of required, so every ordinary sweep keeps validating unchanged.

kb/attest.py learns inapplicable. A fourth outcome for "could not be applied to THIS box's baseline". It counts toward recalls — the invariant that recalls is the sum of its buckets is what makes a ledger checkable, and hiding an attempt would make a record that keeps failing to fit look untouched — but it is subtracted from the denominator retire_hint judges on, because it is a verdict on the pairing and not on the record. The bucket list is now a single BUCKETS constant, since four call sites have to agree on it and three fail silently when they don't (a key missing from attestations_of reads as 0 forever; one missing from carry_attestations's emptiness test drops a whole ledger on the next rewrite). Surfaced through e2e_store.py's _view() and track-record line so a reader sees "N did not fit that box's baseline (no verdict on the record)" rather than N failures.

Also fixed here: the sweep result was read as trial.notes while the role's return schema spells it note, so the per-trial text never reached the "never took effect" check at all.

3. Reporting — e2e_workflow.js, roles/system_architect.md

KB_RECALL collects, on both planes, what was asked and how it fared:

  • the exact canonical ids tried, the read reason, match tier, plane, candidate count — recorded before anything is benched, so a run that dies mid-warm-start still reports the ask;
  • each recalled config re-measured against this box's own baseline (stored claim / measured here / Δ / parity / outcome), plus what the merge and the repair did to it (overrides, applied_partial, dropped_flags) — a Δ measured from a partly-applied configuration is not a measurement of the record, and the row now says so;
  • each kernel lane's warm_start block — adopted vs incremental speedup, rounds committed, no_rounds_after_adopt. This previously died inside the lane, so an e2e report could describe a kernel as authored from scratch when the lane had in fact adopted a stored patch.

It is threaded into the Report role's inputs and emitted as kb_recall in the workflow return, independently of kb_warm_start — that object is null whenever KB dims were never established, but the kernel lanes can still have recalled by then, and those are exactly the runs where knowing what was recalled matters most.

system_architect.md gains a mandatory 2c. Knowledge-base recall section, written even when nothing came back. On an exact-lookup store the addresses tried are the finding: without them a reader cannot tell "no prior art" from "prior art one segment away". The section refuses to collapse the outcomes into each other — rejected (ran and lost), not_reproduced (never took effect), inapplicable (never fit this box) say different things about the record, and only the middle one is evidence it is stale.

Compatibility

  • Records written before inapplicable existed read it as 0 and produce exactly the same retire hint as before. No migration.
  • repair is optional in the sweep schema; existing sweeps are unaffected.
  • interface/run_e2e.py, adapters/sglang.sh and bench_e2e.sh are unchanged.

Verification

  • identity normalization over dev / local / v-prefixed spellings of one release, and across sglang + vllm
  • new e2e_workflow/scripts/test_warm_start_merge.js — 26 assertions, with the merge functions extracted from the shipped source rather than reimplemented, so it cannot pass while e2e_workflow.js drifts. Covers the collision case, both flag spellings, bare and multi-valued flags, agreement-is-not-an-override, repeatable flags, and that the orchestrator actually hands the merged strings to the tuner.
  • new kb/tests/test_attest.py cases — the fourth outcome, the retire arithmetic (many inapplicable reads never retire; a real pattern still does), carry-forward of an inapplicable-only ledger, pre-existing documents.
  • kb/tests + e2e_workflow/scripts/tests/test_e2e_store.py — 127 passed, 1 skipped
  • e2e_workflow/scripts/tests — 1211 passed, 5 skipped, 77 subtests
  • kernel_workflow/scripts/tests/test_experience_store.py — 83 passed
  • all six e2e_workflow/scripts/test_*.js, and node --check e2e_workflow/e2e_workflow.js

Not yet exercised by a live run: the repair pass needs a real launch failure to fire.

Note for reviewers

main already has a 2b (tuning skillset). The recall section is numbered 2c and the PHASE=report Inputs line carries both KB_RECALL (§2c) and TUNING_RESULT (§2b).

🤖 Generated with Claude Code

yueliu14 and others added 3 commits August 28, 2026 09:15
Two halves of one problem: a warm start that silently finds nothing, and a
report that cannot tell you it found nothing.

ADDRESSING. `e2e_identity` keyed `framework_version` verbatim. Serving stacks
are installed from git in these images, so `sglang.__version__` carries a PEP
440 dev/local suffix (`0.5.15.post1.dev20260723+g6c9fd0adc5`) that changes on
every rebuild of the same release, and a long opaque string is also one that
gets transcribed with a segment missing. Either way the run opens a fresh set
of pages and every earlier result becomes unreachable — not degraded,
invisible, because the e2e store is an exact lookup and a miss is a plain 404.
`framework_version` sits in the ladder's `base`, so no rung drops it: one
changed character misses all three at once.

`_release_version` cuts the address to `<major>.<minor>.<patch>`. Three
components, not two — `0.5.15` and `0.5.17` are different releases with
different kernels and must not merge. The exact build string still travels in
the record's value, so only the address is coarse; same bargain as
`kernel_identity`'s ROCm cut, one component wider. Reader and writer share the
single choke point, so they cannot drift apart.

REPORTING. `KB_RECALL` collects, on both planes, what was asked and how it
fared: the exact canonical ids tried, the read reason and match tier, each
recalled config re-measured against this box's baseline, and each kernel lane's
`warm_start` block (adopted vs incremental speedup, rounds committed) — which
previously died inside the lane, so an e2e report could describe a kernel as
authored from scratch when the lane had in fact adopted a stored patch. It is
threaded into the Report role's inputs and emitted as `kb_recall` in the
workflow return, independently of `kb_warm_start` so a run with no established
KB dims still reports its kernel-plane recall.

`system_architect.md` gains a mandatory `2c` section, written even when nothing
came back. On an exact-lookup store a miss and a never-recorded page are the
same 404, so the addresses tried ARE the finding: without them a reader cannot
tell "no prior art" from "prior art one segment away". The section also refuses
to collapse `rejected` (ran and lost) into `not_reproduced` (never took
effect) — they say opposite things about the record.

Verified: identity normalization over dev/local/`v`-prefixed spellings of one
release; `kb/tests` 70 passed 1 skipped; `test_e2e_lane_defaults.py` green;
`node --check` on the workflow.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…stop blaming the record for the box

A stored e2e record holds a WHOLE launch configuration, not a delta — the only form that can be
replayed on a box whose baseline nobody wrote down. Replaying it means combining it with the
baseline THIS run was handed, which under Hyperloom is a full flag string the run does not own
(interface/run_e2e.py seeds initial_extra_server_args from the EXPLORE result and then sets
config_tune=false, so no later sweep can correct anything either).

That combination was a string concatenation performed by an agent. adapters/sglang.sh expands
$EXTRA_SERVER_ARGS straight into argparse and $EXTRA_ENV straight into env, and both resolve a
repeated key as last-wins — so when the baseline and the record each pin --context-length, which
one applied was decided by the order the agent happened to write them in. Lose that coin flip and
the server runs the baseline configuration twice: ~0% delta, no complaint in any log because the
flag WAS honoured, and the record filed as `rejected`. A record that wins recorded as a loss is the
one outcome the warm start exists to prevent.

Three changes:

- mergeFlags/mergeEnv merge key by key in the orchestrator. The recorded value wins every collision,
  in place, so the output names each key exactly once and last-wins never gets a vote. What was
  overridden travels with the direction (MERGE_OVERRIDES), into the log, into measured_on_this_box,
  and into the attestation note — it is the first thing to check when a replay comes back neutral.
  Generalizes the guard adapters/sglang.sh already applies by hand to --watchdog-timeout.
  A record the baseline already carries in full is skipped rather than benched against itself.

- One repair pass, only when the server produced no number at all. The launch failure goes back to
  config_tuner, which classifies each recorded knob as upstream_gone / conflicts_with_baseline /
  env_unsupported, drops the minimum needed, and benches once more — through the same accept gate,
  with no allowance for having been repaired. Exactly once; a repair loop against a config that
  cannot run here spends server launches to learn nothing.

- kb/attest.py gains `inapplicable`. `not_reproduced` meant both "the flag is gone upstream" (the
  record is stale) and "it collides with a baseline this run did not choose" (the record is fine),
  and retire_hint retires on two of them. Conflicts now count in `recalls` — the invariant that
  recalls is the sum of its buckets is what makes a ledger checkable — but are subtracted from the
  denominator retire_hint judges on, so a record can no longer be retired for being read on the
  wrong machines. Records written before the key existed read 0 and behave exactly as before.

Also fixes the sweep result being read as trial.notes when the role file's schema spells it `note`,
which kept the per-trial text out of the "never took effect" check entirely.

Tests: new e2e_workflow/scripts/test_warm_start_merge.js extracts the merge functions from the
shipped source (26 assertions); kb/tests/test_attest.py covers the new outcome, the retire
arithmetic, carry-forward, and pre-existing documents.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…-config rows

The recall report states, per recalled configuration, what was asked and what came
back. With the warm start now merging a stored configuration key by key and
repairing it once before giving up, a row's number can be produced by something
other than the record as stored: a knob may have taken the recorded value over the
baseline's, or may have been dropped to get a server up at all.

Both facts ride in the same row (`overrides`, `applied_partial`, `dropped_flags`),
and the Architect's outcome list learns `inapplicable` — a verdict on the pairing
of record and box, not on the record. Without them a partly-applied delta reads as
a measurement of the record, which is the misreading the report exists to prevent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@yueliu14 yueliu14 changed the title kb: address e2e records by release version, and report what was recalled kb: address e2e records by release version, apply what is recalled, and report both Aug 28, 2026
yueliu14 added a commit that referenced this pull request Aug 28, 2026
…d prose apart from the KB contract

Two assertions in test_tuning_skillset_phase.js were red before this merge, not
because of it:

  - It looked for TUNED_KB_ROOT in the input block. a03997c removed that key
    three commits back when the read moved to plane addressing, so the count has
    been 0 ever since and the assertion was checking for a symbol that cannot be
    there. Replaced with a loop that requires each TUNED_KB_* key to appear on
    BOTH sides -- handed to the role and read by it -- since a key only one side
    knows is dead plumbing, which is the failure mode that actually bit here.

  - The <1600-word cap was written for the role's method prose, then grew to
    cover the KB contract section that was appended later. Split it: method
    alone is 1499, and the whole role gets its own bound of 2100. The section
    header is asserted so the split cannot silently start measuring everything.

Also compressed the --precision paragraph in tuning_specialist.md to state the
cost (a table for another dtype installs under a name the runtime never reads,
and burns a verify slot) instead of re-deriving it.

The merge itself was clean. #438's _release_version coarsens only the derived
e2e address; dims["framework-version"] stays the raw build string that
value.upstream records, so the two changes are complementary.
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