Skip to content

Add Cohere Command R chat template - #411

Merged
hnyls2002 merged 1 commit into
sgl-project:mainfrom
noah-kim-theori:fix/cohere-chat-template
May 7, 2024
Merged

hnyls2002 merged 1 commit into
sgl-project:mainfrom
noah-kim-theori:fix/cohere-chat-template

Conversation

@noah-kim-theori

@noah-kim-theori noah-kim-theori commented May 6, 2024 •

Copy link
Copy Markdown
Contributor

I add cohere command-r style chat template. Without chat template, model cannot properly stop the conversation with EOS token.


CI States

Latest PR Test (Base): ❌ Missing run-ci label -- add it to run CI tests.
Latest PR Test (Extra): ❌ Blocked -- run-ci is required first.

@hnyls2002
hnyls2002 merged commit 4a1c6ae into sgl-project:main May 7, 2024
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
Liwansi added a commit to Liwansi/sglang_vans that referenced this pull request Apr 22, 2026
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…the manifest desk-build

DESIGN FIRST, and the design's first move is to notice what is already built.
The sgl-project#706 canonical store IS a per-token-content snapshot of exactly the two
things a conversation checkpoint needs: {hash} for a token's KV (all attention
layers, geometry-free, cut at read time) and {hash}.mamba for the GDN state,
both keyed by content alone and therefore already surviving a phase flip and a
reboot. So slice 1 designs no payload format. What was missing is the SESSION
level: which pages, which blob, at which position, under which sampling and
template state. DESIGN_410_session_checkpoints.md carries the full document.

THE sgl-project#212 LESSON IS THE LOAD-BEARING CONSTRAINT, not a caveat. A KV-only prefix
is worth ZERO usable tokens on this hybrid checkpoint (sgl-project#703 re-derived it
structurally and pinned it: the storage hit is the MINIMUM across pools with
mamba registered TRAILING_PAGES, and the device-side match advances only at
nodes carrying mamba_value). Three rules follow, and the module ENFORCES all
three rather than documenting them:

1. the GDN anchor is REQUIRED on a hybrid model and refused at WRITE time -- a
   manifest describing a prefix that resolves to nothing is a bug best caught
   where it is created, not at branch;
2. a checkpoint may only claim a position where state exists. With
   --mamba-checkpoint-interval that is an absolute grid, so the position is
   SNAPPED DOWN and BOTH positions are recorded: a checkpoint that quietly
   covers fewer tokens than asked for is a wrong answer, not a rounding. A
   request that snaps to 0 is refused outright;
3. completeness is VERIFIED against the store before a branch seeds anything,
   because a manifest holds references and the tiers evict.

FORMAT: versioned (refuse unknown versions rather than best-effort parse --
that refusal is what makes sgl-project#411 a converter question instead of a silent
field-drop), deterministic serialisation so a manifest hashes reproducibly, and
CONTENT-ONLY: a test asserts the serialised form contains no tp_rank, tp_size,
pp_rank, pp_size or layer anywhere. That is what sgl-project#706 earned and what makes a
manifest portable across phases, rigs and reboots.

API + REFUSALS (sgl-project#510 canon, ADMIN_OPTIONAL on all four -- the level 51 existing
state-changing routes use): POST /session_checkpoint, /session_branch,
/session_rewind, GET /session_checkpoints. Mid-generation policy defaults to
REFUSE (a checkpoint taken while tokens are appended describes a moving target
and its tail pages may not be in the store yet); the permissive mode quiesces
first, never snapshots concurrently. "Branch from a non-checkpoint" is
impossible by construction rather than by check: branch takes a checkpoint_id,
and those exist only for manifests that were written and verified.

TIER TARGET: the manifest is metadata and does NOT live in the KV tiers; the
payload it references follows the existing sgl-project#407 ladder with no new mechanism,
with TieredGdnBlobStore (sgl-project#711) as the blob-half precedent. Named consequence,
not smuggled: a checkpoint stays branchable only while its references survive
eviction. PINNING them is slice 2 work.

DESK BUILD (mem_cache/session_manifest.py): the versioned manifest, build with
grid-snapping and the stateless refusal, deterministic dumps/loads,
verify_against_store, verify_model_identity, and seed_plan -- the ordered fetch
list a branch executes, verified UP FRONT, with the recurrent state fetched
LAST so its absence can never look like a completed seed. Not built and not
pretended: the radix prefix insert and blob restore themselves need live pools.

Tests (hermetic, CUDA_VISIBLE_DEVICES=""), 18 new, 168 in the family. The
completeness half runs against the REAL backend in canonical mode, three PP
stages writing real pages, so sgl-project#706's invisible-until-complete rule is part of
what is tested: a page only two of three stages wrote counts as MISSING, not as
partial. The named red-first case -- a manifest whose page was evicted must
refuse at branch rather than seed a silent partial prefix -- is
test_a_manifest_whose_page_was_evicted_refuses_at_branch, with its sgl-project#212 twin
test_a_missing_gdn_blob_refuses_too.

BYTE-GATE SPECED, NOT RUN (section 7 of the design): A-vs-A first to establish
the determinism floor, then straight-through generation vs checkpoint-branch-
continue, compared as token IDS not text -- a divergence at P+1 is a
state-restore bug, a later one is a sampling/template bug, which is why the
comparison is per-token. Judge ids, never timing: the draft pool starts cold
after a branch by design (sgl-project#706 C7).

BOOT DEPENDENCIES, explicit (design section 8): canonical store flags + file
backend + page_size 1; hierarchical cache with the disk tier;
--mamba-checkpoint-interval for the grid; the flip+hicache boot sgl-project#719 makes safe
(plus its second host pool) if checkpoints cross phases; deterministic sampling
for the byte-gate itself.

CAN-FAIL PROOF (mutation applied, suite re-run, reverted):
  S1  the sgl-project#212 rule dropped (a stateless hybrid manifest is allowed)
      -> test_a_hybrid_checkpoint_without_state_is_refused_at_build
  S2  no grid snapping (the checkpoint claims an off-grid position)
      -> test_the_position_snaps_down_to_the_grid_and_says_so,
         test_a_checkpoint_before_the_first_grid_point_is_refused
  S3  branch skips verification
      -> test_a_manifest_whose_page_was_evicted_refuses_at_branch,
         test_a_missing_gdn_blob_refuses_too
         (the named red-first case and its sgl-project#212 twin, and only those)
  S4  unknown format_version parsed best-effort
      -> test_an_unknown_version_is_refused_not_best_effort_parsed
  S5  the recurrent state fetched FIRST instead of last
      -> test_the_plan_is_the_branch_order,
         test_a_complete_checkpoint_verifies_and_plans
  S6  model identity mismatch tolerated
      -> test_a_foreign_model_identity_is_refused, and ONLY that one
Restored tree re-verified green after every mutation (18 passed).

Regression, same env, base c3e9487 vs this commit:
  unit/mem_cache   940 failed / 779 passed -> 940 failed / 925 passed (+146)
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…gs-first)

Paused by user order (BUGS FIRST) part-way through sgl-project#411 slice 1. Committed as
WIP, deliberately unpolished, so the state is visible rather than sitting in a
dirty tree.

WHAT IS HERE: mem_cache/session_bundle.py -- the versioned container around
sgl-project#410's manifest (magic + length-prefixed deterministic JSON header + payloads
in header order), per-entry sha256, a CompatKey that checks ONLY what binds the
meaning of the bytes (model identity, canonical page spec, page_size, canonical
GDN blob layout) and deliberately NOT parallel geometry (tp/pp ranks and sizes,
token vectors, layer cuts, gdn units) -- geometry freedom being the entire point
of the sgl-project#706 format. Refusals: unknown bundle_version, truncation, digest
mismatch, trailing bytes, and a named incompatibility listing the fields.
Import is two-pass on purpose: verify the WHOLE bundle before writing a byte,
so a short bundle refuses having changed nothing.

WHAT IS NOT DONE, and must not be mistaken for done:
* NO TESTS AT ALL. None of this has been executed beyond an import check.
* verify_bundle re-opens the file to re-read the header length instead of
  seeking with the value it already has -- clumsy and worth fixing, left as-is
  under the no-polishing instruction.
* import_bundle's write path is not yet wired to the canonical store's
  invisible-until-complete protocol (it takes a write_payload callable; the
  whole-page window construction on the receiving side is unwritten).
* No pin registration (sgl-project#410 slice 2 machinery) on import.
* Round-trip export->import->branch seed_plan identity: unwritten.

Resume from the four unwritten items above; the red-first list from the task
still stands (truncated bundle without residue, dtype mismatch by name,
round-trip seed_plan identity).
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…orrections to my own Cut 1

The prior-art gate found more in Cut 1 than the wire it was meant to add.

C1. CUT 1 EXPORTED THE WRONG BLOB SET, AND IT WAS A sgl-project#212 FAILURE. Cut 1 read
"page_hashes" -- a field name taken from DESIGN_410's PROSE. The manifest
session_handover.build_manifest actually writes carries kv_keys, mamba_key,
hybrid_gdn and draft_keys. Not cosmetic: a hybrid-GDN session exported by
Cut 1 would have carried its KV pages and NOT its recurrent state, producing a
bundle that imports cleanly and replays a WRONG session, because a missing
mamba blob truncates the prefix match at the destination and silently
re-prefills. That is what validate_manifest_completeness calls "a wrong
session, not a slow one". Fixed: referenced_blobs() enumerates kv + mamba +
draft, de-duplicated, with page_hashes still honoured so a prose-shaped
manifest is not silently dropped.

C2. Cut 1's gate duplicated verify_import, which already checks version and
identity AND blob presence AND the sgl-project#212 hybrid-GDN clause -- I had
re-implemented two of its four jobs.

C3. My FIRST Cut 2 pass then duplicated verify_restore. Having replaced C2
with a composition of verify_import + verify_geometry, I found that
composition is itself a function -- session_checkpoint.verify_restore, same
order, same stated reasoning, and specified as such in DESIGN_410 section 7.
check_compatibility now calls verify_restore and adds exactly one thing of its
own: the sgl-project#726 layout-gap note on an identity refusal. Two rounds of removing
my own duplication, one level apart.

C4. THE DESIGN/CODE CONTRADICTION I REPORTED DOES NOT EXIST IN THE REPO. Cut 1
said DESIGN_410 claims "content only, no placement" while the code binds
geometry, and proposed fixing the text. Wrong: the repo document section 7
already states the shipped behaviour -- verify_restore = verify_import THEN
verify_geometry, cross-geometry "refused BY NAME, naming the offline
hicache_migrate --manifest route, and never silently converted". The "content
only" text is in a DIFFERENT, OLDER draft in the evidence directory. I
compared code against a stale copy and reported a contradiction the shipped
doc does not contain. No design text needed fixing; the brief's item 2 is
moot, and saying so beats editing a correct document to match a claim I got
wrong.

C5. Slice 2 is still absent on this base (3550e20 is not an ancestor,
mem_cache/pin_ledger.py does not exist), so the export refusal's "re-pin the
checkpoint (sgl-project#410 slice 2)" advice still names a capability this branch lacks.
Kept honestly rather than softened.

WHAT CUT 2 ACTUALLY ADDED: import_bundle gates on the tar's member NAMES --
which the directory yields without extracting a byte -- so an incomplete or
incompatible bundle is refused before any payload is read, and nothing is
returned for a caller to have begun seeding from. PARTIAL-SEED-THEN-FAIL IS
UNREACHABLE, which is the failure direction the brief named: a gate after
extraction is recoverable, a gate after seeding is not, because a half-seeded
session decodes wrong rather than failing.

Tests, hermetic (CUDA_VISIBLE_DEVICES="", tmpdirs, injected reader, no server,
no CUDA):
  test_session_portable_411.py  22 passed (was 17; rewritten for the real
    manifest shape, plus the GDN-blob and partial-seed pins)
    MUTATION: dropping the import gate fails 6, including every partial-seed
    pin
  test/registered/unit/managers/  11 failed / 532 passed -- failures unchanged
    from this base's pre-existing 11, passes 510 (without my file) -> 532,
    exactly the 22 new pins
  ruff + codespell clean.

Unchanged: this is still the FILE layer. Handing (manifest, pages) to the live
seeding path is the next cut; cross-rig proof remains the filed window item.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
… entry, and harvest the paused WIP

THE PREDECESSOR. 0dc48c9 ("sgl-project#411 WIP: session bundle container, PAUSED") is
my own earlier attempt, on a branch this base does not carry. It built
mem_cache/session_bundle.py -- the same feature I rebuilt as
managers/session_portable.py without knowing it existed. Checking it was the
prior-art gate working on my own output.

HARVESTED: per-payload digests. The WIP had _digest, verify_bundle and typed
truncation/integrity errors; my version had NO integrity check. Content
addressing does not give this for free -- the key names what the bytes SHOULD
be and nothing re-checks that they are -- so a truncated or corrupted transfer
would have seeded a WRONG session rather than failing. export_bundle now
writes a digests.json member and import_bundle verifies it after extraction
and before returning. Absent digests are tolerated (an older bundle is
readable, it just carries no integrity claim), stated rather than silent.

SUPERSEDED: CompatKey. The WIP carried its own compatibility key documented
"No geometry" -- a THIRD authority for a rule verify_restore already owns, and
it encodes the same no-geometry reading I retracted in C4. Explicitly
superseded, not merged. One thing in it is worth remembering rather than
adopting: num_attn_layers and kv_cell_bytes are exactly the axes the identity
hash does NOT cover (sgl-project#726's layout gap), but adding them changes the
compatibility key itself, which is the key owner's decision and not something
a container should smuggle in.

THE WIRE. SessionCheckpointRuntime.import_bundle_and_seed composes the
lifecycle branch/rewind already use -- _preconditions -> gate ->
controller.branch_from -> ledger -- rather than a parallel path, because a
second seeding path is a second place for the mid-generation rule, the TP=1
limit and the page_head refusal to be got wrong.

ORDER IS THE GUARANTEE: every refusal precedes branch_from, the only step that
creates a session, so a failure anywhere leaves NOTHING to roll back -- not "a
rollback that works", but no state to roll back.

TWO VERIFICATIONS, AND THE SECOND IS NOT REDUNDANT: the bundle's gate runs
against its member names, then verify_restore runs against the STORE. Between
those moments the blobs move. The first proves the bundle is complete; the
second proves this rank can actually read what it was handed -- a store that
silently took nothing fails it and seeds nothing. Store writes before the gate
are content-addressed cache entries, not session state; the mid-generation
check runs BEFORE them, because a refusal that has already spent store IO is a
worse refusal.

THE C1 DIRECTION IS NOW A STANDING FALSIFIER: a hybrid bundle whose mamba blob
is missing refuses at the gate and never seeds -- the failure Cut 1 would have
shipped, KV pages travelling without the recurrent state and the destination
silently re-prefilling.

Tests, hermetic (CUDA_VISIBLE_DEVICES="", tmpdirs, fakes, no server, no CUDA,
no store):
  test_session_import_seed_411.py  12 passed
    M7 ORDERING MUTATION: seeding moved ahead of the store verification fails
    2, including the nothing-partial pin
  test/registered/unit/managers/  11 failed / 544 passed -- failures unchanged
    from this base's pre-existing 11, passes 532 -> 544, exactly the 12 new
    pins
  ruff + codespell clean.

UNCHANGED: slice 2 (pinning) is still absent on this base -- re-checked,
pin_ledger.py does not exist -- so an imported bundle's checkpoint is not
pinned on seed and the dangling-reference note stands. Cross-rig proof remains
the filed window item; nothing here has crossed a machine.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…-- do not build, do not fork a third lineage

No code, by design. The slice was to build per-session KV export/import; the
prior-art gate says it is already built, so the deliverable is the
determination plus the catalog line.

WHAT EXISTS. session_handover.export_session_snapshot (:415 on
train/0818-desk-410-reconcile) -- "flush one session's KV pages AND its GDN
blob to the store, then emit the manifest that names every blob ... the whole
of sgl-project#261's SNAPSHOT phase, callable by anything that needs a session on stable
storage" -- with verify_import (:253) as its other half. session_checkpoint.py
states the rule that settles it: "There is exactly ONE session serialization
in this fork ... a second one would be a second thing to keep byte-correct."
Two consumers already ride it: sgl-project#410 checkpoints (tier, branch/rewind) and sgl-project#411
portable sessions (the same manifest as a manifest-first tar).

IT ALREADY ANSWERS THE CONCERNS RAISED AGAINST THE SLICE, none of which would
have needed adding:
  * owner rules / uneven-DCP -- GEOMETRY_FIELDS = ("tp_size", "page_size",
    "dcp_owner_mode"), page_size == 1 inherited FROM dcp_owner_mode, mismatch
    refused by name in verify_geometry, REFUSED_HOST_LAYOUTS = ("page_head",);
  * sgl-project#212 -- the GDN blob is named in the manifest and a hybrid-GDN export
    without it is refused;
  * it is not a duplicate of kv_session_offload, which is
    spill-to-keep-computing (resume flag default OFF) rather than the at-rest
    counterpart.

WHY THIS BRANCH STOPS. export_session_snapshot exists ONLY on the sgl-project#410/sgl-project#411
lineage; none of 682578f, 22ef67c, 35a68b2, 03adbf8 is in this
branch's ancestry. This branch has only the private method it was lifted from
(SessionHandoverRuntime._export, :446). Building here would create the second
serialization that module forbids, on top of a reconciliation another lane
owns and is mid-flight. Stopping and reporting, as instructed.

A CORRECTION OF MY OWN PHASE MAP, made in both places that carried it.
ANALYSE_329_cut2_phase_map.md listed per-session KV export AND import as
MISSING. Wrong the same way twice: I searched this branch's tree and read
absence-from-my-lineage as absence-from-the-fork -- the precise error the
prior-art gate's "grep the module name across git log --all + tree" clause
exists to catch, which I ran for session_checkpoint.py and then under-weighted
when it came back on other branches. Both rows now read EXISTS-other-lineage
with the file:line.

The correction SHRINKS what sgl-project#329 cut 2 still needs: not a mover, only the
per-session orchestration across the session table. world_roundtrip._Seams'
write_snapshot / read_snapshot are already exactly that seam, so no code in
world_roundtrip.py changes -- which is the cheapest possible confirmation that
the seam was cut in the right place.

LEFT, with its blocker named: wiring those two seams to
export_session_snapshot / verify_import per session, AFTER the A+B
reconciliation lands. The byte movement itself is a window item, under the
standing limit that GDN prefill is non-reproducible above ~109 tokens, so
identity is asserted on the STATE BLOB and never on generated output.

Also closes the catalog debt from 7d70249 (previous commit e962812) by
recording the determination where a future lane will hit it first.

Suite unchanged: test_world_roundtrip_329.py 29 passed, 8 subtests.
codespell clean on all three documents.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…ain note

Step 4. B's mem_cache modules are absent on this branch by construction -- it is
based on lineage A -- so removal here is a merge-train instruction rather than a
deletion: do not merge mem_cache/session_manifest.py or
mem_cache/session_checkpoint.py, they are a second format for the same feature.
Their unique contribution is already ported, and they had no live-path importers
(only the superseded session_bundle.py, a self-reference, and their own tests),
so nothing is stranded by leaving them behind.

The catalog said 'sgl-project#410 adds only the inc_lock_ref pin', which step 3 made false.
Corrected in the same step: there are TWO pin tiers and they are not
interchangeable. inc_lock_ref protects the radix chain in memory for the life of
the process; the referenced pages still sit in the file store as ordinary LRU
entries, so a checkpoint with only that pin survives radix eviction and does NOT
survive file-tier eviction or a restart. take_file_tier_pins is the second tier,
with PinCoverageIncomplete naming what it could not pin. Also recorded: the
evictor now charges ALLOCATED bytes, the same unit as the ledger, and stats()
exposes accounting_overshoot_bytes if the two ever diverge again.

DESIGN_410 gains an addendum carrying the parallel lineage's findings with
provenance, so they survive the branch that is not being merged, plus the
interface note Slot-2 asked for: the seam is world_roundtrip's
write_snapshot/read_snapshot mapped per session onto export_session_snapshot,
and any sgl-project#411 change to that interface belongs to this lineage and gets recorded
there first so the consumer is not chasing a moving seam.

56 passed across A's suite plus the file-pin suite. Docs and catalog only in the
code sense; no behaviour change in this commit. No boots.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…nd close C5

Cut 2 filed the Slice-2 dependency as the one that decides whether the export
refusal is rare or routine, and recorded that its re-pin advice named a
capability the branch lacked. On this base the dependency is satisfied -- the
pin ledger is ported, the evictor honours it, take_file_tier_pins is wired --
so the advice is actionable and the dangling reference stops dangling.

WHY IMPORT NEEDS ITS OWN PIN. import_bundle_and_seed already materialises the
payloads and verifies them against the store, but verification proves the pages
are there NOW and does not stop the evictor reclaiming them a moment later. An
imported bundle is the worst case: its pages are the youngest entries in the LRU
yet are referenced by no running request until the seeded session is used, so a
store under pressure can drop a just-imported session before it is ever read.

ORDERING: materialise -> verify_restore -> PIN -> branch_from. After
verification because there is nothing to pin until the pages are in the store;
before seeding because a session that cannot be protected must not be created --
the alternative is a live session whose prefix is already reclaimable, failing
later and to a user rather than an operator. Note the asymmetry with the radix
pin, which runs AFTER branch_from because it needs the seeded node to lock. Two
tiers, two positions, each chosen by what it needs.

The GDN blob is in the pin set, not beside it: sgl-project#212 makes a KV-only prefix worth
zero usable tokens on a hybrid model, so a session whose mamba blob was evicted
is unusable rather than degraded. Mutating that clause away reds
test_the_gdn_blob_is_pinned_too and nothing else.

A target with no file tier is logged unprotected, not refused -- sgl-project#407 may hold
the session on vram or host, and refusing a placement the tier policy chose
would be this layer overruling the one whose decision it is.

Recorded in the note: the first ordering test asserted on bare names and failed
against correct code, because the method docstring names branch_from while
describing the order. Grepping a name inside source you are asserting about
finds documentation as readily as code; fixed by matching call forms.

8 tests red first, mutation-proven. 129 passed / 1 skipped across the managers
session+checkpoint+portable+pin suites. ruff clean. Cross-rig import remains the
filed window item; IDENTITY_LAYOUT_GAP unchanged. No boots.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…eds a collective this runtime must not issue

Asked to implement per-rank manifest merging if desk-fundable, else leave a
named refusal and a filed residue. It is not desk-fundable, and the reason is
structural rather than a missing function.

The refusal already exists and already names the cause: session_checkpoint.py:654
and session_handover.py:608 refuse tp_size != 1 or pp_size != 1, the first
pointing at per-rank manifest merging as sgl-project#261's follow-up.

A TP>1 export must collect every rank's manifest, because each rank holds a
different KV shard under its own suffixed stems, and collecting them is a group
collective. SessionCheckpointRuntime is built to issue none:
session_checkpoint.py:548-552 states that it runs entirely on the scheduler
thread between scheduling iterations and that no group collective is issued
anywhere, which is the whole reason none of this needs a lock. Adding a
merge collective would put a rank-to-rank wait inside a control request handled
between scheduling iterations -- a scheduler stall on the slowest rank, and a
deadlock if a peer is mid-drain.

So the merge belongs with sgl-project#261's drain coordination, where that contract is
already being negotiated, not bolted onto a runtime whose safety depends on the
opposite property. Residue filed with its order: drain coordination first, then
a merged manifest keyed by shard, then import-side placement (the geometry gate
refuses a differing tp_size outright today, so a TP>1 bundle needs an identical
geometry or the umsharder, which inherits page_size == 1).

Also verified rather than assumed: the compat gate from Cuts 1-2 is a
COMPOSITION of verify_import + verify_geometry, not a second implementation --
Cut 2 had already removed Cut 1's hand-rolled duplicate -- and
IDENTITY_LAYOUT_GAP is quoted into identity refusals so a reader learns the gate
covers the kv-dtype NAME and not its byte layout.

Docs only. Cross-rig import remains the filed window item. No boots.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…ation; delete lineage B

train/0818-desk-410-reconcile (through 9509c7b) merged into train/0817-desk.
21 conflict hunks across 11 files, resolved on DESIGN_410 / NOTE_411's own
verdicts. The two lineage-B modules are deleted IN THIS COMMIT, so there is no
window where both are importable.

DELETED WITH THE MERGE: mem_cache/session_manifest.py, mem_cache/session_bundle.py,
and test_session_manifest_410.py -- the B test that imported a deleted module.
Leaving it would have errored the suite; the reconcile branch had already
dropped it. pin_ledger.py STAYS: the reconciliation keeps and extends it (the
`unpinned` shortfall field) and hicache_storage consumes it -- which is why the
briefed three-file set was corrected to two.

NON-OBVIOUS HUNKS, with the authority:

* evictor hunks 2/3 -> THEIRS. NOTE_411 "Step 2: A's evictor moves to ALLOCATED
  bytes ... the evictor and the pin ledger share one unit".
* evictor hunk 4 -> OURS, and this one departs from the incoming text on
  evidence: theirs inlines a flat stat loop, while this train has already
  refactored that into the injectable `_iter_existing` and applies
  `self._allocated_size(st)` in `_scan_existing_files`. The VERDICT (allocated
  accounting) is satisfied; taking theirs would have duplicated the stat and
  regressed sharded-layout support.
* evictor hunks 0/1 -> OURS / UNION. Theirs predates A's `writer_count`,
  `path_for_stem` and `iter_existing` ctor params; the union keeps those AND
  theirs' pin-ledger param.
* http_server / scheduler / tokenizer_control_mixin -> OURS. Theirs predates
  the phase-flip and session-handover imports; taking it would have deleted
  live wiring.
* server_args -> UNION. Two disjoint flag blocks (phase flip, session
  checkpoints); both must exist.
* AUDIT_421 F6 cells -> merged, naming BOTH credits (sgl-project#286's first consumer and
  sgl-project#410's checkpoint tier). Both statements are true; a table cell cannot hold
  two rows.
* test_unwired_features_421 -> UNION, so theirs' positive pin class survives
  alongside ours' retirement note.

THREE INCOHERENCES THE TEXTUAL MERGE HID, found by running the suites:

1. DUPLICATE METHODS. Both lineages define the same methods in different
   places, so git merged both and the SECOND silently shadowed the first. An
   AST audit over every merged file found five: `stats` and `_allocated_size`
   in the evictor, `capacity_stats`, `pin_checkpoint`, `unpin_checkpoint` and
   `pin_stats` in hicache_storage. Resolved per pair -- ours' `capacity_stats`
   (a strict superset, it adds `file_path`), theirs' pin methods (the
   authority's `_pin_path`/`unpinned` version), ours' `_allocated_size` (same
   behaviour, richer docstring), and ours' `stats` with theirs' unique
   `accounting_overshoot_bytes` key folded in. http_server's pair is NOT a
   merge artifact: two different FastAPI handlers that share a name, present at
   HEAD before this merge.
2. EVICTION STOPPED REMOVING FILES. Hunk 5's incoming block extended past the
   comment into the removal line, replacing `self._path_for_stem(evict_stem)`
   with a flat join. This backend injects the sharded resolver, so `os.remove`
   missed, the entry left the LRU and the bytes stayed -- the cap silently
   stopped holding. Restored to the injected resolver; line 466 already stats
   through it and the two must not disagree.
3. `_pin_path` WAS FLAT ON A SHARDED STORE. The reconciliation wrote it as a
   flat join because its own lineage had no sharding. Here that names a path
   the store never writes, so `pin_checkpoint` dropped every stem as "missing"
   and pinned NOTHING while reporting success. `_pin_path` now delegates to
   `_existing_path` (sharded, else legacy flat, else the path it would occupy),
   which preserves the property the reconciliation actually asked for -- "the
   ledger must stat exactly what the evictor unlinks" -- under this layout.

Gates: mem_cache 1157 passed / 0 failed; managers 19 failed / 2507 passed,
IMPROVED on the established 22 and exactly the cluster-b inherited set;
mem_ledger 514/0; server_args 681/0; boot_matrix 159/0; spec 13F/711P;
entrypoints 4F/450P/3E; planner 1F/2880P; distributed 27F/2769P -- every one
at or better than its established count.

Also verified present rather than assumed: 54ffc4d (the corrected
pp_with_spec register row) is an ancestor, and test_phase_flip_args no longer
asserts the sgl-project#630 hierarchical-cache refusal -- F4-r4's lift (be93340)
removed that third twin, and the file is 23 passed / 0 failed here.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…ion pass

Records the two-file deletion set (pin_ledger stays, kept and extended by the
reconciliation), the per-hunk authority, the three incoherences the textual
merge hid, and the candidate verdicts -- notably audit/stale-gates, which
merged clean and was dropped because it carries a revert of sgl-project#713 that removes a
PhasePolicyConfig kwarg F4-r4's sgl-project#730 tests depend on.

Gate at or better than every established count; managers improved on 22.
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.

2 participants