Skip to content

CONTRACT: feat(ui-sdk): read-only reference pool growth status (#3515) - #4064

Merged
schlessera merged 11 commits into
mainfrom
feat/3515-pool-growth-resume
Nov 16, 2026
Merged

schlessera merged 11 commits into
mainfrom
feat/3515-pool-growth-resume

Conversation

@schlessera

@schlessera schlessera commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #3515

Resumes the ownerless draft #3806 (its approach still matches the issue and current main), with origin/main merged and one correction. #3806 is closed in favour of this PR.

What changed

The host-only reference pool gains a read-only residual-growth status: brain-native-store pool growth <config>, the manager client's poolGrowth() and the NativePoolGrowth type.

  • Comparisons. Each worktree and each changed refresh is compared with the charge its chain's cold acquisition had when it was sealed. Sources retained under one published name (one repository and revision) are counted across views.
  • Flags. A flag fires strictly above the ruled thresholds: a worktree above 25 %, a refresh above 0.75×, or more than two retained sources. Each flag carries the observed bytes and the threshold, and nothing forecasts savings or freed capacity.
  • Unavailable, never zero. Missing accounting reads as unavailable, and a root with no recorded owner charge reports ownerBytes: null in its comparison, its retained-source group and that group's sum. So does any view name that does not resolve to a recorded sealed source in its own view: a path escape, a foreign view or a stale identity.
  • Seal-time charge. Sealing now records each root's charge, so the basis survives the cold acquisition's release.
  • Decision record. reference-pool-accounting.md records the rejection of background dedupe, with the three measured reasons.

Why this shape

  • Cold-acquisition basis. A refresh's own charge is only the extents it changed, and a released root's recorded charge shrinks to what it still shares. Comparing with a direct source's live charge would therefore misreport any chain with a refresh in it. The charge recorded when the chain's cold acquisition was sealed is the stable "cold acquisition" the ruling names. A live sealed root without that field uses its current charge, which cannot change while it is read-only and live.
  • Repository + revision identity. This is the publication name, which referenceSourceName derives from a hash of the canonical repository and revision. The pool needs no new identity channel.
  • Read-only. The status runs qualification, one observation and pure accounting, without reconcile, so it never commits an intent, removes a qgroup or deletes anything. The existing status does reconcile.
  • Reply size. Replies stay within the 64 KiB control bound by dropping unflagged detail first and counting what was left out in omitted.

Proof

Unit tests (packages/ui-sdk/tests/native-reference-pool.test.ts, 20 pass, 160 assertions) on the merged tree:

  • clean pool;
  • strict-above at the threshold, and each flag's shape;
  • unavailable-not-zero: legacy released basis, broken chain, a root with no recorded charge, refused or changing evidence; capacity refusal still measures;
  • path escape, absolute, unrecorded, foreign-view, worktree and stale publication targets refused;
  • reply bound;
  • request takes no selector.

Correction in this PR (da9a7d64d). Review of the resumed code found that a root missing from the owner accounting reported ownerBytes: 0 in its comparison and its retained-source group (owner.get(...) ?? 0). That breaks the unavailable-not-zero criterion. Those fields are now number | null, a group's sum is null when any root is unknown, and a retained-sources flag's observedBytes is null only in that case. The status is unreleased, so this amends the additive contract text in package-api.md and the decision record. Instance sweep: the only other ?? 0 in referencePoolGrowth was the source-group charge, fixed in the same commit; the reply-size and threshold paths carry no default.

Mutations re-run on the merged tree, each restored to green (file compared byte-identical afterwards):

Mutation Result Failing assertion(s)
worktree ratio 0.25 → 0.3 4 fail REFERENCE_POOL_GROWTH_WORKTREE_FLAG, _RULED_THRESHOLDS, _LIVE_SEALED_BASIS, _FLAGS_KEPT
refresh ratio 0.75 → 0.8 2 fail REFERENCE_POOL_GROWTH_REFRESH_FLAG, _RULED_THRESHOLDS
> → >= on ratio flags 1 fail REFERENCE_POOL_GROWTH_AT_THRESHOLD_IS_CLEAN
retained count > → >= 3 fail REFERENCE_POOL_GROWTH_SOURCES_PER_NAME, _AT_THRESHOLD_IS_CLEAN, _FLAGS_KEPT
missing chain basis → 0 1 fail REFERENCE_POOL_GROWTH_BROKEN_CHAIN
missing source charge → ?? 0 (the pre-fix code) 1 fail REFERENCE_POOL_GROWTH_MISSING_SOURCE_CHARGE_NOT_ZERO
missing comparison charge → ?? 0 (the pre-fix code) 1 fail REFERENCE_POOL_GROWTH_MISSING_CHARGE_NOT_ZERO

The last two are the failing-first receipts for the correction.

Native case 20 in scripts/native-proof/reference-pool.native.ts runs on owned Btrfs in hosted runtime_host, using generated Odysseus repositories:

  • a clean pool triggers no flag;
  • growth past each threshold triggers exactly that flag;
  • recovery records are unchanged by the status;
  • planted escape and non-published names are refused;
  • the CLI pool growth child exits 0 with the same flags.

Earlier hosted draft heavy feedback on #3806 (run 42652529226 at 6b8057ddd; feedback, not proof): runtime_host green with case 20. Receipts from reference-pool-receipts.json:

Step Worktree (charge / threshold) Refresh (charge / threshold) Retained sources Flags
Clean 49,152 / 2,159,616 102,400 / 6,478,848 2 none
Grown 3,194,880 / 2,159,616 14,786,560 / 6,478,848 3 (25,899,008 B) worktree, refresh, retained-sources

The cold-acquisition basis is 8,638,464 bytes. Every charge in that run is present, so the null correction does not change these receipts. The native proof cells re-run on this PR's own main squash under the hybrid ruling.

tsc --noEmit and bun run build are clean; api-report/ui-server.txt is regenerated. Moved citations in reference-pool-accounting.md are repointed and pass scripts/check-citations.ts.

Collision check at da9a7d64d (bun scripts/collisions.ts --json --pr 4064):

Refreshed at b765c7484 by merging origin/main after #4050 (#2911) landed: the contract index keeps both sections and the manager client imports both NativeTurnTree and NativePoolGrowth. Typecheck, build, the focused tests and check:pr pass on the merge; the API reports regenerate unchanged.

bun run check:pr --base origin/main
{"version":1,"kind":"brain-check-pr-receipt","head":"b765c7484a0ac13b6ccc6ddeb4b2c6bf618d15cd","base":"origin/main","mode":"focused","startedAt":"2026-11-16T10:36:00.103Z","finishedAt":"2026-11-16T10:37:35.741Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":14010.083887999997},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":137.53559200000018},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":115.56942999999956},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":34.26930899999934},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":81320.698153}]}

Checklist

  • Focused local preflight/behavioral receipts and complete selected hosted proof passed; actual head/base/job checkout evidence is in Proof.
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • The PR and completed/advanced issues have verified release milestones under docs/process/github.md.
  • A changeset is included, or this changes nothing a consumer can see.
  • No personal data anywhere in the diff — the leakage gate covers the whole tree.
  • The integration contract index or relevant component is updated in this same commit, or nothing in the machine surface moved.
  • Docs under docs/ reflect the change, or nothing documented moved.
  • Provider history stays append-only (docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.

Anything left open

Nothing. #3513 remains open for its own criteria; none of them is an input to this status.

🤖 Generated with Claude Code

schlessera and others added 10 commits November 9, 2026 16:04
Background deduplication is rejected on the measured evidence of #3514, so
residual growth is reported instead. `brain-native-store pool growth` and the
manager client's `poolGrowth()` compare each worktree and each changed
refresh with its chain's cold acquisition, and count the sources retained
under one published name across views. Flags fire strictly above the ruled
thresholds (25 %, 0.75x, more than two) and carry the measured bytes and
the threshold.

The status reads one stable observation without reconciling, so it commits,
deletes, resets and reserves nothing. A basis it cannot read is unavailable,
never zero, and a view name that resolves anywhere but a recorded sealed
source in that view makes the whole status unavailable. Sealing now records
each root's charge, so the basis survives the cold acquisition's release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Case 20 acquires a generated Odysseus repository cold into two views, keeps a
worktree and a changed refresh within the thresholds (no flag), then grows
each past its threshold and publishes a third copy (exactly three flags). It
checks the recovery records are unchanged, the CLI projection matches, and
planted view names that escape or point at a non-published root are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce (#3515)

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

# Conflicts:
#	docs/integration-contract.md
…-resume

# Conflicts:
#	docs/decisions/reference-pool-accounting.md
#	docs/integration-contract.md
#	packages/ui-sdk/src/server/native-reference-pool.ts
#	scripts/native-proof/reference-pool.native.ts
#3515)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ro (#3515)

A root the owner accounting has no charge for reported ownerBytes 0 in its
comparison and in its retained-source group, contradicting the issue's
unavailable-not-zero rule. Comparisons, source roots and their sums now
carry null, and a retained-sources flag's observedBytes is null when its
sum includes an unknown charge. The package-api component records the
nullable fields; the growth status is still unreleased.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 15, 2026
@schlessera schlessera added type: feat A new capability or a change in user-visible behaviour. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. labels Nov 15, 2026
…-resume

# Conflicts:
#	docs/integration-contract.md
#	packages/ui-sdk/src/server/native-brain-manager-client.ts
@schlessera
schlessera marked this pull request as ready for review November 16, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. type: feat A new capability or a change in user-visible behaviour.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ui-sdk: add the selected bounded repository-storage maintenance safeguard

1 participant