Candid cache cleanup before KEEP

The SDK lifecycle correction is selected at main commits 1d722b23 and e3a34291. The focused wasm64 IC regression passes all six checks. This record qualifies lifecycle correctness; it makes no performance claim. Exact source, artifact and evidence hashes are in receipt.json. The evidence manifest pins durable copies of the results, logs, failures and compressed build manifests by both stored and uncompressed hashes.

The separate matched Wire protection finds unchanged ordinary instructions and page costs across both populated fixtures and records the added KEEP cost. That comparison preserves the original forum business source.

The original Candid forum artifact passed Small population and business conformance, then its old-code pre-upgrade hook trapped with 491 transient allocations remaining. Its failure is retained here. The frozen Wasm and earlier read-only plan remain optional local playground extras. The aggregate count does not attribute every allocation to an individual cache; the plan records the complete owning-cache inventory.

The fix releases HEADER_CACHE, LAST_HEADER, ENV, DOC_ENV, ID and both maps in NAME. Cache initializers register one nonowning provider through the existing lower executor lifecycle. Its TLS links need no allocated registry backing and remain registered after explicit resets. Owners are detached before destruction; callbacks execute outside TLS access closures. Ordinary env_clear() semantics, Candid bytes and SDK persisted layouts are unchanged. Core and Wire retain their Candid-free dependency closures.

Cleanup follows application, timer and executor teardown. The final check rechecks application roots and providers, then uses the unchanged real live-allocation gate before publishing the clean marker. No allocator counter is reset and no readiness gate is bypassed. New-code startup cannot repair old-code owners after statics are replayed and runtime pages are recovered.

The canonical fixture artifacts were built at isolated-worktree commit 4df0aa5a with nightly-2026-10-15, then cherry-picked to main. Independent review verified each artifact's 332 archived source files and 14 output hashes; all 332 source hashes also match merged ver1/. The runner hash matches the recorded result. The IC checks cover:

  • Committed updates populate every cache root and complete a real management raw_rand; update reset/refill traps restore sentinels, cache counts and module.
  • A failure after provider cleanup restores the old image and usable codec.
  • Two same-code KEEP upgrades preserve retained data and allow cold/warm codec reuse and management calls through the unchanged allocator gate.
  • Admitted restoration that traps after app save restores old state and caches; a subsequent KEEP succeeds.
  • A timer future's destructor can first initialize Candid during teardown.
  • An unresolved physical callback rejects KEEP, then the original request completes once through a live peer and drained KEEP succeeds.

The merged workspace's compressed native test log completed with exit 0: 445 reported test passes, zero failures and nine ignored tests, plus the successful harness-free allocation-counting executable. Coverage includes cold independent registration paths, repeated reset/reuse, live external aliases, public-byte conformance and stricter decoder limits after reset. The unchanged package-boundary checker also passed. These results do not claim that the entire check.sh passed; the whole-workspace formatting check reported pre-existing formatting differences in unrelated files.

The initial fixture attempt used a stopped peer and failed its original-callback completion assertion. It is preserved and excluded from the selected qualification. The replacement fixture keeps the original peer request live through self-calls; this repair changed only the fixture and runner.

Read-only review of the dirty IC checkout at ee8086a9 confirms that failed pre-upgrade and post-upgrade stages return the clean canister image, and KEEP preserves memory after old-code pre-upgrade. Those source findings are separate from the actual PocketIC binary evidence (2e1dae35…, version 16.1.0); no source-to-binary equality is established. The fixture disables management's separate transform-closure feature. Candid's warmed lazy-TLS guard cost was not isolated. Wire protection and the newly rebuilt heavy forum artifacts have their own evidence rather than inheriting an earlier artifact's qualification.