Index string provenance with metered image and session tables

This commit is contained in:
2026-10-14 13:55:16 +01:00
parent bb6f212779
commit 3f9d235546
16 changed files with 848 additions and 15 deletions
@@ -234,6 +234,23 @@ Image constants and session-created strings are separate accounting domains; cha
Each domain tracks UTF-8 bytes and allocation count using a bounded Weak<str> ledger without a strong accounting owner. Reads remain direct Arc accesses, not handle-table lookups. Reconcile dead entries at safepoints and before quota refusal, release Weak plus charge then; Weak may retain native allocation after last strong drop, so no immediate-release promise. Keep accounting domains alive while tracked allocations survive, including host/tool retention. Import untracked native strings as charged new allocations; explicit session transfer copies into the destination domain, while shared-image constants remain shared.
Provenance keys include both allocation data address and UTF-8 length. Image
Weak records are sorted once during sealed loading by a bounded in-place heap
sort, with record comparisons/reads/writes charged before work through LoadBudget;
binary search serves native boundary identity queries. This does not reorder
constants, exports or lease indices. Record capacities remain part of the
existing image payload accounting.
Session provenance uses a precharged open-addressed BudgetVec table with at most
50% live occupancy, geometric growth and explicit tombstones. Charge retained
capacity through AuxiliaryBytes and old/new capacity coexistence through
TemporaryBytes before rehashing. Reserve content and bucket growth before
materialization; refusal must not publish content or an entry and must refund
provisional reservations. Remove stale keys before releasing their Weak ownership;
reuse tombstones and rebuild under the same capacity accounting. Queries allocate
nothing, ordinary reads do not query the index, and resource ceilings and
reconciliation safepoints are unchanged.
Check result sizes/overflow and reserve before materializing; roll back reservations and initialized state on failure. Charge transient buffer/result coexistence. No hidden unmetered concatenation/native result paths. Do not introduce reentrant GC or scheduling at arbitrary allocation points to satisfy quotas; dead guest objects stay charged until safe sweep. Layout headers, metadata, payload capacities, native ownership, auxiliary buffers and temporary storage must have explicit nonduplicated domains. Limits are not RSS or upfront reservations.
LoadLimits uses the same defaults on hosts; cartridges cannot raise them. Test configurations may lower limits. MiB=1,048,576 bytes.