fix(sdk): preserve context across writer recovery, extension output and errors
CLI and SDK hosts preserve actionable context across crashed writers, malformed extension output, expected refusals and unexpected faults. This combines the implementation and PM closeout from #1623 into one delivery.
- Recover proven-dead writer-gate owners with token fencing and bounded transient-read retries; use monotonic elapsed lock waits. Strengthen native merge-receipt and Windows atomic-publication regressions.
- Preserve structured JSON preflight warnings across output-selector aliases. Recalculate token receipts after attaching all diagnostic fields using the shared SDK accounting primitive.
- Expose SDK Unicode validation and repair helpers. Native JSON and TOON render one validated serialization snapshot, including nested
toJSON()results and cross-realm boxed primitives, while preserving valid pairs, sparse-array length and caller data. - Preserve separately bundled expected refusals and retain unexpected handler causes locally through a shared CLI/action/template error factory. Sentry excludes retained cause payload fields, records command owner/version/source metadata and keeps sequential embedded-host logs and exceptions correctly attributed.
- Update SDK contracts, generated catalogs/surfaces and documentation; adopt the cooled-down Sentry CLI 3.8.2 dependency.
Validation includes three pre-fix refusal-byte failures, malformed-output and SDK-fault negative controls, real Node/Bun loopback collectors, and clean installed packed-SDK probes. Latest linked cohorts pass 13 Unicode tests, 687 SDK/CLI/observability tests, and the original delivery's five verification commands, including 451 tests and all four TypeScript projects. These cohorts overlap and are not summed as a repository-wide test count.
Immutable head 4b3371685 passes the full static pipeline and 11,606 tests with exact 100/100/100/100 full-source coverage, including unchanged SDK/CLI budgets and mutation verification (345 killed / 7 documented equivalents / zero unexplained survivors). Subsequent importer/exporter provenance and boxed-primitive corrections pass 687 linked observability tests, 13 Unicode tests, all four TypeScript projects and the complete static pipeline. The final local full run retained 11,605 passing tests / two failures / three intentional skips: global npm lookup required the documented Homebrew NODE_PATH setup, and one deps-query case timed out. Both affected suites subsequently pass 42/42 tests unchanged with the corrected npm lookup, including packed Node/Bun SDK consumers. The unsuccessful full-run receipt is retained; exact updated-head hosted coverage remains mandatory for merge. Updated package budgets and npx/bunx smoke across all nine packages pass. Independent feeds cover all 567 locked packages, with zero registry vulnerabilities at every severity. Required hosted checks certify the updated delivery head before merge.
The changelog is generated and checked through the latest pm-changelog package, 2026.10.28. The terminal defect gate passes 477 governed defects / 30 recurrence families / zero findings. New reports and UX follow-ups remain open and unclaimed with duplicate-check and relationship evidence.
Daily publication remains gated by the upstream SDK-loading fault tracked in pm-gh1622. Packed source acceptance and registry publication are separate receipts.
Tracking: pm-gh1609, pm-gh1558, pm-native-index-proof, pm-gh1602, pm-sentry-cli-382, pm-gh1624, pm-gh1625.