Skip to content

fix(cache): bound planner admission and isolate contract readiness - #1213

Merged
Gajesh2007 merged 77 commits into
masterfrom
codex/cache-fix-planner-readiness
Oct 7, 2026
Merged

Gajesh2007 merged 77 commits into
masterfrom
codex/cache-fix-planner-readiness

Conversation

@jonathan308

@jonathan308 jonathan308 commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Bound optional prompt planning by worker capacity, retained bytes and the original first-content deadline. Admit healthy acknowledged contracts even when another preload member fails.

Part 4 of the seven-part cache stack, based on #1212. Now integrated with master 5b7a675c7 through #1212, after the coordinator reorganization in #1324; see Ported onto the reorganized coordinator below. Review dependency-first and recheck descendants after any squash merge.

Changes

  • Compose cache planning with current master’s memoized prompt accounting. Capture CachePlanResult and its exact prompt-work result once; retain calibrated count fallback, authenticated provider/template identity and bounded decision metrics.
  • Keep Go/Rust readiness bound to the verified catalog and child generation, with only the successful current replacement set eligible. Preserve input validation and separate health/control capacity.
  • Repair the load proof to explicitly preload and acknowledge each contract before its burst. Cycle beyond resident capacity and return to the seed to prove eviction/reload; do not relax production membership. Separate Rust tests retain concurrent cold-load singleflight coverage.
  • Refresh queue and hedge fixtures for the current preferred-route and feasible-evidence policies.

Before — behavior and code flow

flowchart TB
    A["Request asks optional planner"] --> B["Unacknowledged contract or overloaded client"]
    B --> C["Lost planning opportunity"]
    classDef step fill:#eff6ff,stroke:#1d4ed8,color:#172554;
    classDef result fill:#fff1f2,stroke:#be123c,color:#881337;
    class A,B step;
    class C result;
Loading

After — behavior and code flow

flowchart TB
    A["Memoized prompt-work account"] --> B["Bounded admission and acknowledged contract"]
    B --> C["One exact plan within original deadline"]
    classDef step fill:#eff6ff,stroke:#1d4ed8,color:#172554;
    classDef result fill:#ecfdf5,stroke:#047857,color:#064e3b;
    class A,B step;
    class C result;
Loading

Blue shows processing; red shows the prior failure or coverage gap; green shows the resulting behavior.

Ported onto the reorganized coordinator (2026-10-05)

The base of this part, #1212, sits on master 5b7a675c7 (after #1324). This branch merges that base. Signed commits on top of the previous head: merge bc6eb808 (the port), 4555b937 (restored tests), f656f1b5 (real-sidecar admission identities), merge aa89eb80 (the base's reclaim change), refactor 6f6feacb and docs 6e199aac; the resolved source tree is 71a642e3.

Before Now
coordinator/api/cache_planning.go, cache_planning_telemetry.go coordinator/internal/inference/routeplan/, beside the plan memo that consumes the planner. Owner.NewCachePlanner() (coordinator/api/inference/cache_planner.go) binds it, like NewAliasPlanner
Sidecar client changes in coordinator/promptcontract/client*.go, plan_admission.go coordinator/internal/promptcontract/sidecar/ (client.go, client_control.go, plan_admission.go); the public coordinator/promptcontract files keep master's text plus the wiring
Preload controller changes in coordinator/promptcontract/preload_controller.go coordinator/internal/promptcontract/preload/controller.go
Load-proof changes in coordinator/cmd/promptsidecarloadproof/ coordinator/internal/promptproof/ and coordinator/tests/cmd/promptsidecarloadproof/
Tests beside the code coordinator/tests/api/inference, coordinator/tests/promptcontract, coordinator/tests/registry, same names and assertions
Rust sidecar (coordinator/promptsidecar/) Unchanged: the seven files are byte-identical to this pull request's

Tests that read private client state. Eleven tests read the sidecar client's private admission state and connection pools, which the new test rules do not allow. They are restored with their names, cases and messages through dependencies that production leaves unset: sidecar.PlanAdmission is now an exported component that Client.Plan acquires on every call (with read-only counts), sidecar.ClientConfig.PlanAdmissions and .Transports build the admission and the three HTTP pools, and promptcontract.SupervisorConfig.Clients builds the supervisor's client from its effective configuration. With the fields unset the client is built exactly as before. With this pull request's client changes reverted, the admission and connection-budget tests fail.

One master test changes meaning. #1324 added TestPreloadControllerComposesRealOwnersForEmptyCatalog, which expected an empty catalog to make the controller ready. This pull request closes participation for an empty verified set instead ("no verified prompt contracts"), so that test now checks the same composition against that outcome. Please confirm this is the intended behaviour; the alternative is to revert the empty-set closure.

Real-sidecar admission tests no longer hardcode old normalization and renderer identities: they select existing model metadata and recompute the current contract ID (from the private cache remediation reviewed on 2026-10-03).

Refactor pass. A dedicated refactor subagent reviewed the ported change and the restored tests against the structure and clean-code rules in AGENTS.md (6f6feacb): the supervisor keeps a single injected dependency (Clients) instead of three; a test lost its work-wave name (TestControlTrafficAtConfiguredWorkerCapacity, control_capacity_test.go); a comment explains why two early returns still call the planner. It confirmed the planner belongs in routeplan, that the Go limits match the Rust sidecar's constants, and that no assertion was weakened, with one note: TestPlanningConnectionBudget now reads the worker and connection limits from the client configuration the supervisor derives; a change to the child process's arguments alone would not be seen there.

Documentation corrected to match the code (6e199aac, found by the refactor pass):

  • A planning decision is recorded each time a request's cache plan is computed, once per concrete model and provider-bound body. For public requests that happens while admission builds its forecast, so a request that preflight then rejects is already counted. Nothing is recorded when prompt accounting declines first.
  • One legacy population grows: a media request to a verified, preload-acknowledged model is now counted once as ineligible in exact_cache_plan_total, because the planner is consulted to record its decision. No routing or billing effect.
  • The first-content bound on planning is promptwork.PlanningContext at the handlers. The planner's own ReceivedAt, FirstContentBudget and LoweringFailed inputs are set only by tests today.
  • With routing off, count-only prompt accounting still calls the sidecar for eligible text requests.

Still open, known and tracked for the next part: every preload retry briefly closes cache planning for all contracts (beginAttempt clears publication; the sidecar does the same). #1214 carries the fix.

Validation on the merged head 6e199aac (Go 1.25.0, PostgreSQL 16, Rust 1.95 offline):

  • gofmt clean, go vet ./coordinator/..., layout guard TestCoordinatorTestsAreIsolated (in the suite below).
  • coordinator/tests/promptcontract/... and coordinator/tests/api/inference pass under -race.
  • Complete coordinator suite, python3 scripts/run-coordinator-tests.py --jobs 1 ./coordinator/...: 8,664 passed, 0 failed, 10 skipped. Five skip on master too; the other five need a real sidecar binary or run only as a subprocess (TestPlannerRealSidecarAdmission, TestPreloadRealSidecarRuntimeAndMixedVersions, TestPreloadRealSidecarGenerationAndCanceledResponseDrain, TestCachePlanningRealSidecarHealthyMemberHTTP, TestCachePlanningHelperProcess).
  • Rust sidecar, cargo test --offline --locked --all-targets with the pinned MiMo and Nemotron fixtures: 189 passed, 0 failed, 2 ignored (per_contract_readiness 6 of 6).
  • make docs-check (332 files) and make docs-impact-check against this part's base branch.
  • Not run locally: the four real-sidecar Go tests above, the race-and-coverage configuration of the full suite, golangci-lint, cargo clippy. CI covers them.

Refreshed onto master bf3dc6752 (2026-10-05). Signed merge 9ffa4f7c of the refreshed #1212. Four documentation pages conflicted with changes that landed on master: in docs/developer/navigation.md master's new rows (provider-owner email campaigns, Earn-page hardware interest, the Open Sales Program, uncertain consumer-charge settlement, the allowlist stale-entry reporting, referral accounting) and this branch's rows are all kept; docs/architecture/billing.md, docs/operations/cache-routing-rollout.md and docs/reference/configuration.md conflicted only in their "Last updated" stamps. Re-checked at that head: make docs-check, make docs-impact-check BASE=<#1212 head>, gofmt, go build ./coordinator/..., go vet ./coordinator/..., the layout guard, and coordinator/tests/promptcontract/... and coordinator/tests/api/inference under -race: all pass. The complete coordinator suite was not re-run locally at this head (it last ran at 6e199aac); it is re-run on the refreshed parts above this one (#1214 and #1216), and CI runs it here.

Refreshed onto master dccc9ee03 (2026-10-06). Signed merge 1ddd9400 of the refreshed #1212; no conflict and no other change. Master brings #1344 (App Attest required for routing outside the legacy cohort), #1328 (coordinator schema as goose migrations; Go 1.25.7), #1352, #1351 and #1355, and moves the engine submodule libs/mlx-swift-lm from 1ee8675a to e407e899 (an engine fix that retires cancelled waiting requests before removing them, plus formatting). Local checks at this head (Go 1.25.7): go build, go vet, gofmt and the runner guards pass; the complete coordinator suite was run locally on #1215's and #1216's heads and CI runs it on this head. The seven parts are held as one delivery: please do not merge any of them before the owner's review of the final evidence, which is being collected in #1216.

Validation (earlier head, pre-reorganization paths)

Focused API planning/prompt-work race checks pass; the real-sidecar healthy-member HTTP fixtures pass. Rust tests: 179 passes. cargo +1.88.0 clippy --locked --all-targets -- -D warnings and formatting pass. The real load proof passes 96/96 requests across six acknowledged cold rotations, then 375/375 warm requests over 154 vectors, with zero errors, mismatches or restarts.

Per-part make docs-impact-check BASE=<predecessor> and make docs-check pass; the final documentation check covers 327 files. Integration head 52285991f32f60742937b5bf0919e83caf921fdf has tree 8fc7c35f299cfbd56635862e0c3bd69c8a5d8260 and GitHub-verified commits. Existing history is preserved through fast-forward branch updates.

Post-CI fixture verification

The shared cancellation fixture now waits for the existing completed-write stamp before requiring a provider cancel frame; in-flight write aborts remain covered separately. The fixed cancellation test passes 500 race/coverage repetitions, and the full conformance plus writer-boundary regressions pass.

Limits and release gates

The cold rotation proof includes explicit preload latency; it is not a claim that production permits lazy planning of unacknowledged contracts. Local sidecar validation does not qualify the production Linux container/workload.

Fresh hosted CI/review and required benchmark approval must be evaluated on these updated heads. This integration does not merge or deploy the stack. Existing privacy, authentication, admission and memory protections remain required.

Documentation and tracking

Canonical behavior and test documentation are updated in the stack. Cache routing — high hit rates tracks integration and measured rollout. No issue is auto-closed.

@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Ready Ready Preview Oct 7, 2026 9:23pm UTC
d-inference-console-ui-dev Ready Ready Preview Oct 7, 2026 9:23pm UTC
d-inference-landing Ready Ready Preview Oct 7, 2026 9:23pm UTC
darkbloom-status Ready Ready Preview Oct 7, 2026 9:23pm UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 7, 2026 9:23pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 45d9923e160b against base 055154b2687a.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Review in progress; coverage is not complete

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Coverage: 0/0 source units; cross-file integration pending. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

Resolve changelog and test-guide conflicts after the predecessor squash, retaining planner documentation and upstream SSD endurance guidance. No manual code changes.
@jonathan308

Copy link
Copy Markdown
Collaborator Author

Resolved the conflicts with current master (055154b26) in signed merge commit 45d9923e1. GitHub now reports this PR as MERGEABLE. Manual resolutions were limited to CHANGELOG.md and docs/developer/test.md, preserving the planner/readiness entries and the upstream SSD-endurance guidance. Documentation impact checks, all 358 documentation checks, whitespace checks, and an independent conflict-resolution review passed. No manual code changes or full runtime test rerun; CI will validate the refreshed head. This does not merge the PR or update descendant branches.

@Gajesh2007
Gajesh2007 merged commit 7b42e92 into master Oct 7, 2026
28 of 29 checks passed
@Gajesh2007
Gajesh2007 deleted the codex/cache-fix-planner-readiness branch October 7, 2026 21:25
jonathan308 added a commit that referenced this pull request Oct 7, 2026
Integrate the original predecessor head before reconciling its squash ancestry. Preserve all child source and test changes.
jonathan308 added a commit that referenced this pull request Oct 7, 2026
The squash and original predecessor have identical tree d5868bc. The original predecessor is already merged; this bridge changes ancestry only and preserves the resulting child tree.
Gajesh2007 pushed a commit that referenced this pull request Oct 7, 2026
* test(api): add offline OpenRouter conformance and scenario gates

* fix(api): omit caller identifiers from provider inference requests

* fix(cache): bound retained cache-attempt metadata

* fix(cache): bound planner admission and isolate contract readiness

* fix(cache): select a bounded tokenizer preload set

* test(api): group conformance scenarios and verify model alias rewriting

* docs: preserve cache guidance across conformance test organization

* docs: preserve cache guidance across conformance test organization

* test(api): preserve shared seams and current provider contracts

* docs: align merge inputs with current upstream

* docs: retain qualified conformance guidance after upstream integration

* test(api): expose shared fixtures through the conformance package

* docs: align merge inputs with current upstream

* docs: retain qualified conformance guidance after upstream integration

* Prepare upstream integration conflicts for cache stack #1210

* Reconcile cache stack #1210 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1211

* Reconcile cache stack #1211 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1212

* Reconcile cache stack #1212 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1213

* Reconcile cache stack #1213 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1214

* Reconcile cache stack #1214 with current upstream behavior

* Synchronize cancellation conformance with completed provider dispatch

* refactor(tests): simplify the conformance suite's seams after the port

Outcome of the required refactor pass on the ported change. Test and
documentation code only; the suite runs the same 22 entry points, 216
tests and 197 leaf cases with identical evidence lines.

- The support package now lives beside testkit and can call it directly,
  so the seven pass-through hooks on Suite are removed. NewServer, the one
  real seam, remains.
- Move the service-hold measurement into the support package as
  OutstandingServiceHold and state its contract: a probe briefly holds the
  amount it tests, and a reading is exact only while the account's balance
  and holds are stable.
- Resolve the provider private key on the test goroutine instead of
  failing the test from the provider's reader goroutine.
- Remove two unused fixture fields and reword one undefined label.
- docs/developer/test.md: cite the new symbol and keep the cancellation
  fixture paragraph inside this change's own section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(api): list the removed caller fields in the request table

Outcome of the required refactor pass on the ported change: no code change
was needed. The pass found one gap this change opens in the reference: the
Chat Completions request table says uninterpreted fields pass through and
did not list user and metadata, which are now removed before forwarding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): give the cache reliability entry its own insertion point

The entry sat directly after the newest sections, where other open pull
requests also insert theirs, so each merge on master conflicted with it.
Move the section below "leaderboard availability". No wording change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: locate the attempt budget's owner and file its changelog entry

- Navigation: add the row for cache receipt attempts and their
  retained-byte budget, now owned by
  coordinator/internal/registry/cachetracker.
- Changelog: the entry had been inserted between unrelated bullets of an
  older release-candidate section. Move it, unchanged, into this stack's
  "cache reliability" section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(registry): let the attempt ledger own its arithmetic

Required refactor pass for the ported change, by a dedicated subagent;
its outcome is in the pull request description.

- AttemptBudget gains replacementTotal (whether an exchange of charges
  fits, committing nothing) and refund (saturating on an inconsistent
  ledger). StoreAttemptLocked and RemoveAttemptLocked call them instead
  of doing the arithmetic inline: same checks, same order, same results.
- New TestCacheAttemptBudgetInconsistentLedgerGrantsNoAdmission covers
  the incumbent guard and the refund saturation, which no test reached.
- TestCacheAttemptBudgetCountEvictionRefundsWithoutChangingPublication
  pins its nonces, so the cap-of-one case evicts the newer record before
  its owner is published on every run. Under the frozen test clock the
  victim had been chosen by random nonce.
- A comment and one documentation phrase now match the code (re-storing
  a terminal record; deriving the boundary claims).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): also remove caller safety and cache-routing hints from provider bodies

The privacy fix removed the caller's top-level user and metadata before a
request is sealed for a provider, but two more caller-supplied top-level
fields still reached providers: safety_identifier and the caller's
prompt_cache_key. Neither is needed for inference; authentication,
billing and cache scope come from trusted context.

This carries the fix from the private cache remediation reviewed on
2026-10-03 onto the reorganized coordinator:

- stripProviderCallerIdentity (coordinator/internal/inference/prelude)
  deletes both fields. Nested fields of the same name stay semantic input.
  The coordinator may still append its own protocol-0 cache-bust key after
  this point.
- Tests: TestProviderIdentityRoutingHintsAreNotForwarded (through the real
  prelude), three new field-shape cases including escaped key names, the
  direct-encrypted and alias-fallback oracles, and the absence helper in
  all three test packages that keep a copy of it.
- Docs: encryption model, consumer privacy expectations, API contracts
  (including that a cache scope is a stable account/model pseudonym).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(api): send the new caller fields on the alias-rewrite path too

The alias-fallback privacy test's oracle already removed safety_identifier
and prompt_cache_key, but its request never sent them, so the alias-rewrite
path did not exercise the new minimization. Send both, as the
direct-encrypted test does. Found by the refactor pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(registry): reclaim finished cache attempts before refusing a new one

When the 64 MiB attempt budget was full, a new record was refused and
the request went out with prefix caching off, while records of requests
that had already finished kept their bytes through the two-minute
late-receipt grace; nothing counted the refusals. Simulated on the real
registry code, that sent 30-59% of dispatches uncached at 120
cache-enabled dispatches per second.

This carries the B1 fix from the private cache remediation reviewed on
2026-10-03 (Astra) onto the reorganized coordinator:

- An attempt is marked terminal once; a repeated terminal call no longer
  extends its grace. Terminal attempts also sit in a per-generation
  terminal expiry order.
- Admission validates and detaches the candidate first. If it does not
  fit, it peeks at most 64 earliest-expiring terminal records without
  changing anything, never the nonce being replaced, and removes them
  only if their full refund admits the candidate; otherwise it refuses
  and removes nothing. A record larger than the whole budget is refused.
- Each boundary hash is charged once (it is stored once).
- attempt_bytes, attempt_budget_refused and attempt_grace_reclaimed in
  /v1/cache/status, Prometheus and Datadog.
- Tests: the remediation's pressure controls and terminal-grace test,
  plus TestCacheAttemptBudgetReclaimsFinishedRecordsBeforeRefusing and
  TestCacheAttemptBudgetRefusesWhenInFlightRecordsFillIt. With the
  previous store path substituted, 11 tests fail.
- Docs: cache-aware routing (formula, reclaim policy, gauges), the API
  contracts, the test guide, navigation and the changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(telemetry): list the attempt-budget gauges

The reclaim change added three exact-cache gauges; the telemetry inventory
now names them with the status fields they mirror.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(registry): tidy the reclaim change's tests and wording

Refactor pass on the reclaim change, by the dedicated subagent:

- The two pressure controls that built the same 65-record terminal setup
  share one helper; the late-READY control uses the existing charge
  helper. Every assertion and message is unchanged.
- The architecture doc says reclaim never takes the record being
  replaced, and that the count cap evicts the record that expires first.
- The status field comment no longer implies that a refusal reclaims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(registry): count only grace reclaims that cut a grace short

attempt_grace_reclaimed also counted finished records whose two-minute
grace had already ended but which the 30-second sweep had not removed
yet. Those forfeit nothing, and the status contract and telemetry
inventory define the gauge as records reclaimed inside their grace.

- reclaimTerminalGraceLocked takes the admission's clock reading and
  counts a victim only if it was still inside its grace.
- TestCacheAttemptPressureCountsOnlyGraceCutShort: a record whose grace
  ended 10 s before an admission (with the next sweep not yet due) is
  reclaimed without being counted; a record still inside its grace is
  counted. The first half fails without this change
  ("attempt_grace_reclaimed=1 for a record whose grace had ended 10s
  earlier").
- The telemetry inventory now states when a refusal is counted.

Found by the refactor pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(promptcontract): restore the planning-admission and connection-budget tests

The port withheld eleven tests because they read the sidecar client's
private admission state and connection pools. They are restored with
their names, cases and messages through injected dependencies that
production leaves unset, the pattern CacheDependencies already uses:

- sidecar.PlanAdmission is the client's planning admission as an exported
  component (constructor, Acquire, read-only counts of workers, active
  and pending plans and pending bytes, and the two pending limits).
  NewClient builds it; Client.Plan acquires it on every call.
- sidecar.ClientConfig.PlanAdmissions builds the admission and
  ClientConfig.Transports wraps each of the client's three HTTP pools
  (planning, health, control); nil gives exactly today's admission and
  transports.
- promptcontract.SupervisorConfig forwards both, and its new Clients
  factory builds the supervisor's client from its effective
  configuration (nil uses sidecar.NewClient). Through it,
  TestPlanningConnectionBudget keeps its "worker capacity changed" and
  "server connection limit changed" checks.

Restored: TestPlanningClientTracksConfiguredWorkers,
TestPlanAdmissionBoundsAndRefunds, TestPlanAdmissionCancellationAndDeadline,
TestPlanningConnectionBudget, TestControlReconnectsDuringPlanningSaturation,
TestPlannerBurstWaitsForWorkersWithoutBlockingHealth,
TestQueuedPlanCancellationNeverReachesSidecar,
TestCancelledActivePlannerWorkStillFailsColdUntilBackendDrains,
TestReviewControlTrafficAtConfiguredWorkerCapacity, and the two
real-sidecar preload tests (gated on DARKBLOOM_TEST_PROMPT_SIDECAR).
With the pull request's client changes reverted, the admission and
connection-budget tests fail. The test guide paragraphs about them are
restored, and docs cite the exported names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(promptcontract): bind real-sidecar admission tests to current identities

Carries a test change from the private cache remediation reviewed on
2026-10-03: the real-sidecar admission tests no longer hardcode old
normalization and renderer identities. They select existing model
metadata, recompute the current contract ID, and reject old versions,
mismatched directories and ambiguous models without relabelling any
artifact. TestAdmissionFixtureIdentityRejectsStaleAndMismatchedMetadata
runs locally; the sidecar pairing test stays gated on the binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(promptcontract): one client seam on the supervisor, clearer test names

Refactor pass on the ported change and its restored tests, by the
dedicated subagent:

- SupervisorConfig keeps a single injected dependency, Clients, which
  builds the supervisor's sidecar client from its effective
  configuration. PlanAdmissions and Transports were pure forwarding once
  Clients existed and are removed; tests attach the client's dependencies
  through Clients. With the field unset NewSupervisor builds the same
  client as before.
- The control-capacity test loses its work-wave label:
  TestControlTrafficAtConfiguredWorkerCapacity in
  control_capacity_test.go, with permitListener and permitConn. Its body
  is unchanged.
- planPromptRoute says why its two early returns still call the planner
  (to record the decision).

Every test keeps its cases, assertions and messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(cache): describe planning decisions and bounds as the code implements them

Found by the refactor pass; documentation only.

- Planning-decision telemetry: a decision is recorded each time a
  request's cache plan is computed, once per concrete model and
  provider-bound body. For a request that takes the public capacity
  preflight that happens while admission builds its forecast, so a
  request preflight then rejects is already counted and an alias
  fallback probe records a further decision. Nothing is recorded when
  prompt accounting declines first. lowering_unsupported is recorded
  after admission by the generic handler.
- One legacy population grows: a media request to a verified,
  preload-acknowledged model is now counted once as ineligible in
  exact_cache_plan_total, because the planner is consulted to record its
  decision. No routing or billing effect. The changelog bullet says so.
- The first-content bound on planning is promptwork.PlanningContext at
  the handlers; the planner's own bound applies only when its
  ReceivedAt and FirstContentBudget inputs are set, which production does
  not do.
- With routing off, count-only prompt accounting still calls the
  sidecar for eligible text requests.
- Rows the docs-impact rules ask for: the lowering_unsupported decision
  in the API contracts, the planner's owner in the routing page, and that
  a request without a cache plan is billed without a cached-token
  discount.
- The test guide and a diagram use the current test and symbol names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(promptcontract): restore the active-set, controller and commit tests

The port withheld 32 tests that drove the private active-set policy, the
controller's private clock and lock, or the planner's private commit
step. They are restored with their names, cases and messages through a
production-consumed component and injected dependencies that production
leaves unset:

- preload.PreloadActiveSet is the selection policy as an exported
  component (reconcile, demand, attempt begin and completion, conflict
  retirement, invalidation, snapshot) with its lease and
  PreloadActiveSetState, the state the controller itself reads. The
  controller no longer touches private policy fields.
- PreloadControllerConfig.PolicyNow and .ActiveSets inject the monotonic
  clock and the policy; nil gives today's clock and a new policy.
- routeplan.PreloadPlanning lets the cache planner read preload state
  through an interface (nil uses the preloader), so the commit step's
  second observation can be exercised without exporting it.

Lock-discipline checks are black-box (a public controller call from the
clock or the registry callback must not return while the lock is held).
Bookkeeping with no production reader is asserted through the behaviour
it causes. Not expressible without a test-only hook, and stated in the
pull request: the two generation-exhaustion assertions of
TestPreloadActiveSetMonotonicClockAndGenerationExhaustion, two map-size
checks, and a read-held-lock case.

With whole-catalog selection substituted inside this API, 18 of the 31
promptcontract tests fail; targeted substitutions each fail on the
intended message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(promptcontract): keep healthy contracts planning while the preload set reloads

Every preload attempt, a retry of a failing contract or a change of the
selected set, first unpublished every contract, and the sidecar refused
every plan while it loaded, so cache planning closed for all models for
the length of each reload.

This carries the B2 fix from the private cache remediation reviewed on
2026-10-03 (Astra) onto the reorganized coordinator:

- The coordinator negotiates /v2/preload with continuity_version=1
  (Client.PreloadContinuous). Only an initial, recognised endpoint
  absence falls back to /v1/preload; negotiation is sticky for that
  child, and a missing or malformed marker or the loss of the endpoint
  revokes publication, including for a stale response from the same
  child.
- During a negotiated reload the controller keeps the contracts that are
  both acknowledged and still desired under the same catalog, child,
  capacity and verified set (retainPublicationLocked); publication is
  kept across the attempt, a stale completion and a 409.
- The Rust sidecar retains that same set while it loads, plans take
  resident ownership under the readiness gate, residents plus
  reservations stay within capacity, and a cancelled load keeps its
  ownership until it completes without publishing unacknowledged
  additions. The eight Rust files are the remediation's, unchanged.
- A legacy child (no /v2/preload) behaves exactly as before.
- Tests: TestIndependentRetryPreservesHealthyContract,
  TestPreloadContinuityNegotiationNeverSilentlyDowngrades,
  TestPreloadStaleProtocolFailureWithdrawsSameChildAuthority (through the
  real protocol), and four Rust continuity tests. Without the Go change
  the retry test fails ("closed the already-acknowledged healthy
  contract"); without the Rust retention three of the four Rust tests
  fail.
- Docs: the prompt-contract sidecar page (new section on negotiated
  continuity), the test guide and the changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(cache): drop two redundant writes and review wording in the preload code

Refactor pass on the ported change, behaviour-preserving:

- preload/controller.go: remove a second continuity-loss clear on the
  current-attempt path (the clear above it has already run for the same
  child with the same reason) and a `fullyLoaded = false` that both
  branches before it had already written.
- preload_continuity_test.go: TestIndependentRetryPreservesHealthyContract
  becomes TestPreloadContinuityKeepsHealthyContractReadyDuringRetry; the
  failure message and comment no longer carry review wording; the fake
  child sets the report's continuity version directly. Assertions kept.
- preload_selection_order_test.go: the "no overtake" wait grows from
  100 ms to ten lock-held windows (250 ms). The probing clock holds each
  of a reconcile's four samples for 25 ms, so an overtaking caller could
  never finish inside the old window and the check could not fail.
- Comments: private labels and a commit hash from outside this
  repository are replaced by what they refer to.
- docs/developer/test.md: the renamed test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: state what survives a failed preload attempt above capacity

The continuity section said a transport failure retains the already
acknowledged members. Within capacity that holds. Above capacity the
selection policy marks every member of the failed attempt as failed and
not retained, so from the next reconcile only members with demand in the
last five minutes stay selected and published; an idle loaded contract is
dropped and reloads on its next request. Found by the refactor pass and
reproduced through the real controller and policy; the code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(preload): reconcile lifecycle fixtures with planner readiness

* test(preload): bind lifecycle fixtures to verified active sets

* docs: refresh reconciled preload test coverage stamp

* fix(cache): preserve negotiated preload incumbents and configured catalogs

* fix(cache): retain healthy preloads across control transport failures

Distinguish interrupted response bodies from invalid completed reports. Retain only acknowledged, report-successful incumbents when readiness transport fails, preserving rotation metadata without admitting newcomers. Align preload model ID bounds with accepted registration requests so long IDs cannot poison unrelated contracts.

---------

Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007 pushed a commit that referenced this pull request Oct 8, 2026
)

* test(api): add offline OpenRouter conformance and scenario gates

* fix(api): omit caller identifiers from provider inference requests

* fix(cache): bound retained cache-attempt metadata

* fix(cache): bound planner admission and isolate contract readiness

* fix(cache): select a bounded tokenizer preload set

* fix(cache): preserve durable SSD reuse and bound shorter restores (1/2)

* fix(cache): preserve durable SSD reuse and bound shorter restores (2/2)

* test(api): group conformance scenarios and verify model alias rewriting

* docs: preserve cache guidance across conformance test organization

* docs: preserve cache guidance across conformance test organization

* test(api): preserve shared seams and current provider contracts

* docs: align merge inputs with current upstream

* docs: retain qualified conformance guidance after upstream integration

* test(api): expose shared fixtures through the conformance package

* docs: align merge inputs with current upstream

* docs: retain qualified conformance guidance after upstream integration

* Prepare upstream integration conflicts for cache stack #1210

* Reconcile cache stack #1210 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1211

* Reconcile cache stack #1211 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1212

* Reconcile cache stack #1212 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1213

* Reconcile cache stack #1213 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1214

* Reconcile cache stack #1214 with current upstream behavior

* Prepare upstream integration conflicts for cache stack #1215

* Reconcile cache stack #1215 with current upstream behavior

* Synchronize cancellation conformance with completed provider dispatch

* Materialize native checkpoint fixture parameters and join donation writers

* refactor(tests): simplify the conformance suite's seams after the port

Outcome of the required refactor pass on the ported change. Test and
documentation code only; the suite runs the same 22 entry points, 216
tests and 197 leaf cases with identical evidence lines.

- The support package now lives beside testkit and can call it directly,
  so the seven pass-through hooks on Suite are removed. NewServer, the one
  real seam, remains.
- Move the service-hold measurement into the support package as
  OutstandingServiceHold and state its contract: a probe briefly holds the
  amount it tests, and a reading is exact only while the account's balance
  and holds are stable.
- Resolve the provider private key on the test goroutine instead of
  failing the test from the provider's reader goroutine.
- Remove two unused fixture fields and reword one undefined label.
- docs/developer/test.md: cite the new symbol and keep the cancellation
  fixture paragraph inside this change's own section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(api): list the removed caller fields in the request table

Outcome of the required refactor pass on the ported change: no code change
was needed. The pass found one gap this change opens in the reference: the
Chat Completions request table says uninterpreted fields pass through and
did not list user and metadata, which are now removed before forwarding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): give the cache reliability entry its own insertion point

The entry sat directly after the newest sections, where other open pull
requests also insert theirs, so each merge on master conflicted with it.
Move the section below "leaderboard availability". No wording change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: locate the attempt budget's owner and file its changelog entry

- Navigation: add the row for cache receipt attempts and their
  retained-byte budget, now owned by
  coordinator/internal/registry/cachetracker.
- Changelog: the entry had been inserted between unrelated bullets of an
  older release-candidate section. Move it, unchanged, into this stack's
  "cache reliability" section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(registry): let the attempt ledger own its arithmetic

Required refactor pass for the ported change, by a dedicated subagent;
its outcome is in the pull request description.

- AttemptBudget gains replacementTotal (whether an exchange of charges
  fits, committing nothing) and refund (saturating on an inconsistent
  ledger). StoreAttemptLocked and RemoveAttemptLocked call them instead
  of doing the arithmetic inline: same checks, same order, same results.
- New TestCacheAttemptBudgetInconsistentLedgerGrantsNoAdmission covers
  the incumbent guard and the refund saturation, which no test reached.
- TestCacheAttemptBudgetCountEvictionRefundsWithoutChangingPublication
  pins its nonces, so the cap-of-one case evicts the newer record before
  its owner is published on every run. Under the frozen test clock the
  victim had been chosen by random nonce.
- A comment and one documentation phrase now match the code (re-storing
  a terminal record; deriving the boundary claims).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): also remove caller safety and cache-routing hints from provider bodies

The privacy fix removed the caller's top-level user and metadata before a
request is sealed for a provider, but two more caller-supplied top-level
fields still reached providers: safety_identifier and the caller's
prompt_cache_key. Neither is needed for inference; authentication,
billing and cache scope come from trusted context.

This carries the fix from the private cache remediation reviewed on
2026-10-03 onto the reorganized coordinator:

- stripProviderCallerIdentity (coordinator/internal/inference/prelude)
  deletes both fields. Nested fields of the same name stay semantic input.
  The coordinator may still append its own protocol-0 cache-bust key after
  this point.
- Tests: TestProviderIdentityRoutingHintsAreNotForwarded (through the real
  prelude), three new field-shape cases including escaped key names, the
  direct-encrypted and alias-fallback oracles, and the absence helper in
  all three test packages that keep a copy of it.
- Docs: encryption model, consumer privacy expectations, API contracts
  (including that a cache scope is a stable account/model pseudonym).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(api): send the new caller fields on the alias-rewrite path too

The alias-fallback privacy test's oracle already removed safety_identifier
and prompt_cache_key, but its request never sent them, so the alias-rewrite
path did not exercise the new minimization. Send both, as the
direct-encrypted test does. Found by the refactor pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(registry): reclaim finished cache attempts before refusing a new one

When the 64 MiB attempt budget was full, a new record was refused and
the request went out with prefix caching off, while records of requests
that had already finished kept their bytes through the two-minute
late-receipt grace; nothing counted the refusals. Simulated on the real
registry code, that sent 30-59% of dispatches uncached at 120
cache-enabled dispatches per second.

This carries the B1 fix from the private cache remediation reviewed on
2026-10-03 (Astra) onto the reorganized coordinator:

- An attempt is marked terminal once; a repeated terminal call no longer
  extends its grace. Terminal attempts also sit in a per-generation
  terminal expiry order.
- Admission validates and detaches the candidate first. If it does not
  fit, it peeks at most 64 earliest-expiring terminal records without
  changing anything, never the nonce being replaced, and removes them
  only if their full refund admits the candidate; otherwise it refuses
  and removes nothing. A record larger than the whole budget is refused.
- Each boundary hash is charged once (it is stored once).
- attempt_bytes, attempt_budget_refused and attempt_grace_reclaimed in
  /v1/cache/status, Prometheus and Datadog.
- Tests: the remediation's pressure controls and terminal-grace test,
  plus TestCacheAttemptBudgetReclaimsFinishedRecordsBeforeRefusing and
  TestCacheAttemptBudgetRefusesWhenInFlightRecordsFillIt. With the
  previous store path substituted, 11 tests fail.
- Docs: cache-aware routing (formula, reclaim policy, gauges), the API
  contracts, the test guide, navigation and the changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(telemetry): list the attempt-budget gauges

The reclaim change added three exact-cache gauges; the telemetry inventory
now names them with the status fields they mirror.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(registry): tidy the reclaim change's tests and wording

Refactor pass on the reclaim change, by the dedicated subagent:

- The two pressure controls that built the same 65-record terminal setup
  share one helper; the late-READY control uses the existing charge
  helper. Every assertion and message is unchanged.
- The architecture doc says reclaim never takes the record being
  replaced, and that the count cap evicts the record that expires first.
- The status field comment no longer implies that a refusal reclaims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(registry): count only grace reclaims that cut a grace short

attempt_grace_reclaimed also counted finished records whose two-minute
grace had already ended but which the 30-second sweep had not removed
yet. Those forfeit nothing, and the status contract and telemetry
inventory define the gauge as records reclaimed inside their grace.

- reclaimTerminalGraceLocked takes the admission's clock reading and
  counts a victim only if it was still inside its grace.
- TestCacheAttemptPressureCountsOnlyGraceCutShort: a record whose grace
  ended 10 s before an admission (with the next sweep not yet due) is
  reclaimed without being counted; a record still inside its grace is
  counted. The first half fails without this change
  ("attempt_grace_reclaimed=1 for a record whose grace had ended 10s
  earlier").
- The telemetry inventory now states when a refusal is counted.

Found by the refactor pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(promptcontract): restore the planning-admission and connection-budget tests

The port withheld eleven tests because they read the sidecar client's
private admission state and connection pools. They are restored with
their names, cases and messages through injected dependencies that
production leaves unset, the pattern CacheDependencies already uses:

- sidecar.PlanAdmission is the client's planning admission as an exported
  component (constructor, Acquire, read-only counts of workers, active
  and pending plans and pending bytes, and the two pending limits).
  NewClient builds it; Client.Plan acquires it on every call.
- sidecar.ClientConfig.PlanAdmissions builds the admission and
  ClientConfig.Transports wraps each of the client's three HTTP pools
  (planning, health, control); nil gives exactly today's admission and
  transports.
- promptcontract.SupervisorConfig forwards both, and its new Clients
  factory builds the supervisor's client from its effective
  configuration (nil uses sidecar.NewClient). Through it,
  TestPlanningConnectionBudget keeps its "worker capacity changed" and
  "server connection limit changed" checks.

Restored: TestPlanningClientTracksConfiguredWorkers,
TestPlanAdmissionBoundsAndRefunds, TestPlanAdmissionCancellationAndDeadline,
TestPlanningConnectionBudget, TestControlReconnectsDuringPlanningSaturation,
TestPlannerBurstWaitsForWorkersWithoutBlockingHealth,
TestQueuedPlanCancellationNeverReachesSidecar,
TestCancelledActivePlannerWorkStillFailsColdUntilBackendDrains,
TestReviewControlTrafficAtConfiguredWorkerCapacity, and the two
real-sidecar preload tests (gated on DARKBLOOM_TEST_PROMPT_SIDECAR).
With the pull request's client changes reverted, the admission and
connection-budget tests fail. The test guide paragraphs about them are
restored, and docs cite the exported names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(promptcontract): bind real-sidecar admission tests to current identities

Carries a test change from the private cache remediation reviewed on
2026-10-03: the real-sidecar admission tests no longer hardcode old
normalization and renderer identities. They select existing model
metadata, recompute the current contract ID, and reject old versions,
mismatched directories and ambiguous models without relabelling any
artifact. TestAdmissionFixtureIdentityRejectsStaleAndMismatchedMetadata
runs locally; the sidecar pairing test stays gated on the binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(promptcontract): one client seam on the supervisor, clearer test names

Refactor pass on the ported change and its restored tests, by the
dedicated subagent:

- SupervisorConfig keeps a single injected dependency, Clients, which
  builds the supervisor's sidecar client from its effective
  configuration. PlanAdmissions and Transports were pure forwarding once
  Clients existed and are removed; tests attach the client's dependencies
  through Clients. With the field unset NewSupervisor builds the same
  client as before.
- The control-capacity test loses its work-wave label:
  TestControlTrafficAtConfiguredWorkerCapacity in
  control_capacity_test.go, with permitListener and permitConn. Its body
  is unchanged.
- planPromptRoute says why its two early returns still call the planner
  (to record the decision).

Every test keeps its cases, assertions and messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(cache): describe planning decisions and bounds as the code implements them

Found by the refactor pass; documentation only.

- Planning-decision telemetry: a decision is recorded each time a
  request's cache plan is computed, once per concrete model and
  provider-bound body. For a request that takes the public capacity
  preflight that happens while admission builds its forecast, so a
  request preflight then rejects is already counted and an alias
  fallback probe records a further decision. Nothing is recorded when
  prompt accounting declines first. lowering_unsupported is recorded
  after admission by the generic handler.
- One legacy population grows: a media request to a verified,
  preload-acknowledged model is now counted once as ineligible in
  exact_cache_plan_total, because the planner is consulted to record its
  decision. No routing or billing effect. The changelog bullet says so.
- The first-content bound on planning is promptwork.PlanningContext at
  the handlers; the planner's own bound applies only when its
  ReceivedAt and FirstContentBudget inputs are set, which production does
  not do.
- With routing off, count-only prompt accounting still calls the
  sidecar for eligible text requests.
- Rows the docs-impact rules ask for: the lowering_unsupported decision
  in the API contracts, the planner's owner in the routing page, and that
  a request without a cache plan is billed without a cached-token
  discount.
- The test guide and a diagram use the current test and symbol names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(promptcontract): restore the active-set, controller and commit tests

The port withheld 32 tests that drove the private active-set policy, the
controller's private clock and lock, or the planner's private commit
step. They are restored with their names, cases and messages through a
production-consumed component and injected dependencies that production
leaves unset:

- preload.PreloadActiveSet is the selection policy as an exported
  component (reconcile, demand, attempt begin and completion, conflict
  retirement, invalidation, snapshot) with its lease and
  PreloadActiveSetState, the state the controller itself reads. The
  controller no longer touches private policy fields.
- PreloadControllerConfig.PolicyNow and .ActiveSets inject the monotonic
  clock and the policy; nil gives today's clock and a new policy.
- routeplan.PreloadPlanning lets the cache planner read preload state
  through an interface (nil uses the preloader), so the commit step's
  second observation can be exercised without exporting it.

Lock-discipline checks are black-box (a public controller call from the
clock or the registry callback must not return while the lock is held).
Bookkeeping with no production reader is asserted through the behaviour
it causes. Not expressible without a test-only hook, and stated in the
pull request: the two generation-exhaustion assertions of
TestPreloadActiveSetMonotonicClockAndGenerationExhaustion, two map-size
checks, and a read-held-lock case.

With whole-catalog selection substituted inside this API, 18 of the 31
promptcontract tests fail; targeted substitutions each fail on the
intended message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(promptcontract): keep healthy contracts planning while the preload set reloads

Every preload attempt, a retry of a failing contract or a change of the
selected set, first unpublished every contract, and the sidecar refused
every plan while it loaded, so cache planning closed for all models for
the length of each reload.

This carries the B2 fix from the private cache remediation reviewed on
2026-10-03 (Astra) onto the reorganized coordinator:

- The coordinator negotiates /v2/preload with continuity_version=1
  (Client.PreloadContinuous). Only an initial, recognised endpoint
  absence falls back to /v1/preload; negotiation is sticky for that
  child, and a missing or malformed marker or the loss of the endpoint
  revokes publication, including for a stale response from the same
  child.
- During a negotiated reload the controller keeps the contracts that are
  both acknowledged and still desired under the same catalog, child,
  capacity and verified set (retainPublicationLocked); publication is
  kept across the attempt, a stale completion and a 409.
- The Rust sidecar retains that same set while it loads, plans take
  resident ownership under the readiness gate, residents plus
  reservations stay within capacity, and a cancelled load keeps its
  ownership until it completes without publishing unacknowledged
  additions. The eight Rust files are the remediation's, unchanged.
- A legacy child (no /v2/preload) behaves exactly as before.
- Tests: TestIndependentRetryPreservesHealthyContract,
  TestPreloadContinuityNegotiationNeverSilentlyDowngrades,
  TestPreloadStaleProtocolFailureWithdrawsSameChildAuthority (through the
  real protocol), and four Rust continuity tests. Without the Go change
  the retry test fails ("closed the already-acknowledged healthy
  contract"); without the Rust retention three of the four Rust tests
  fail.
- Docs: the prompt-contract sidecar page (new section on negotiated
  continuity), the test guide and the changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: correct the moved diagnostic test's command and tidy the SSD restoration pages

Refactor pass on the ported change. Documentation only; no Go, Swift or
e2e file changes:

- docs/developer/test.md: TestDiagnosticCacheEpochFanout is selected with
  `go test ./tests/registry`, its package since the coordinator
  reorganization.
- docs/reports/2026-09-24-cache-eviction-publication.md: the recorded
  commands stay as run; a dated layout note says where the test lives now.
- docs/reference/ssd-kv-cache.md: "Bounded shorter complete-checkpoint
  fallback" moves to the end of "Complete checkpoint payload", so that
  section's layout table no longer renders under the fallback heading.
  The text is unchanged.
- docs/reports/2026-09-27-cache-connected-qualification.md: seven missing
  spaces between a word and a number restored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(cache): drop two redundant writes and review wording in the preload code

Refactor pass on the ported change, behaviour-preserving:

- preload/controller.go: remove a second continuity-loss clear on the
  current-attempt path (the clear above it has already run for the same
  child with the same reason) and a `fullyLoaded = false` that both
  branches before it had already written.
- preload_continuity_test.go: TestIndependentRetryPreservesHealthyContract
  becomes TestPreloadContinuityKeepsHealthyContractReadyDuringRetry; the
  failure message and comment no longer carry review wording; the fake
  child sets the report's continuity version directly. Assertions kept.
- preload_selection_order_test.go: the "no overtake" wait grows from
  100 ms to ten lock-held windows (250 ms). The probing clock holds each
  of a reconcile's four samples for 25 ms, so an overtaking caller could
  never finish inside the old window and the check could not fail.
- Comments: private labels and a commit hash from outside this
  repository are replaced by what they refer to.
- docs/developer/test.md: the renamed test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: state what survives a failed preload attempt above capacity

The continuity section said a transport failure retains the already
acknowledged members. Within capacity that holds. Above capacity the
selection policy marks every member of the failed attempt as failed and
not retained, so from the next reconcile only members with demand in the
last five minutes stay selected and published; an idle loaded contract is
dropped and reloads on its next request. Found by the refactor pass and
reproduced through the real controller and policy; the code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cache): keep SSD cache ownership through a transient epoch-record read failure

performOwnedRetirement and performOwnedDestructiveChange re-read the epoch
record to confirm the instance still owns the store, through
`try? Self.readRecord(...)`. Any thrown read error, including a transient one
(EACCES, EIO, EBUSY from openat or read), collapsed to "record gone or
changed", set `epoch = nil` and disowned the cache until the process
restarted: no checkpoint writes or restores from that store while the model
kept serving.

Both paths now re-read through one helper, ownedRecordStillCurrentLocked,
which separates "read and refuted" from "not read". A record that is missing,
undecodable, or carries another epoch, binding or schema still disowns, and
so do readRecord's own verdicts (a non-regular entry, an oversized record). Any
other thrown error refuses that one owned operation, logs once per failure
run, keeps the epoch and the ledger entry, and lets the next owned pass
re-read. No change to the on-disk format, the file name, initialisation,
sequence issue, lock order, TTL or eviction constants.

Tests: SSDCacheEpochStoreRecoveryTests (10 tests, 20 parameterised cases):
transient failure then success keeps the epoch for retirement and rotation,
also repeated and concurrent; missing record, changed epoch, binding and
schema, malformed bytes, a record replaced by a symlink or directory, an
oversized record and an empty record all disown, before and after a failure;
no resurrection. With the fix removed the two transient tests fail at
`store.current == epoch`. `swift test --filter SSDCacheEpochStore`: 21 tests in
2 suites pass.

Reviewed independently (one major, applied: the kept class had included
readRecord's own verdicts; two minors applied).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test(preload): reconcile lifecycle fixtures with planner readiness

* test(preload): bind lifecycle fixtures to verified active sets

* docs: refresh reconciled preload test coverage stamp

* fix(cache): preserve negotiated preload incumbents and configured catalogs

* fix(cache): retain SSD epoch ownership on uncertain lookups

* test(cache): distinguish corrupt blocks from missing paths

---------

Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

5 active deployments
Preview – d-inference — 45d9923e Deployed Oct 7, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — 45d9923e Deployed Oct 7, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 45d9923e Deployed Oct 7, 2026 by vercel[bot]
benchmarks — 45d9923e Deployed Oct 7, 2026 by jonathan308 via E2E Benchmarks #2438
Preview – d-inference-landing — 45d9923e Deployed Oct 7, 2026 by vercel[bot]
Preview – darkbloom-status — 45d9923e Deployed Oct 7, 2026 by vercel[bot]
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