# DS4 Context Engine 0.3.0-alpha.5

Status: published prerelease on 2026-09-02; tag `v0.3.0-alpha.5`.

This coordinated prerelease adds overflow-safe hierarchical compaction for discarded source that cannot fit in one active-model summary request. It preserves strict summary validation, privacy sanitization, canonical Pi JSONL semantics, one final Pi compaction entry, and fail-closed fallback to Pi default compaction.

## Added

- Preflights the complete sanitized compaction prompt against the calibrated active-model input budget.
- Partitions oversized discarded source at contiguous message boundaries while keeping matching tool calls and results in the same atomic group.
- Generates and validates each segment only against that segment's sanitized source and deterministic file inventory.
- Recursively aggregates ordered child summaries when one fan-in request cannot fit, preserving cumulative provenance and graph topology.
- Bounds work to 32 segment requests, 64 aggregate requests, and 16 aggregate passes.
- Exposes metadata-only diagnostics for input budget, whole-source prompt estimate, segment count, and aggregate-call count.
- Categorizes provider failures as `input-limit`, `usage-limit`, `rate-limit`, `authentication`, `transport`, `aborted`, or `provider-error` without surfacing provider payloads.

## Safety and compatibility

An individual message, atomic tool exchange, aggregate pair, or total operation that cannot fit within the bounded limits fails closed to Pi default compaction. Generated segment and aggregate summaries retain strict structural and exact-value validation; bounded unsupported-exact-value bullet repair remains unchanged. Rejected exact values and raw provider error details are never emitted in diagnostics.

Pi receives one final canonical compaction entry. The complete prepared summary-graph batch is committed only after Pi installs that entry; failed attempts remain non-destructive. Pi JSONL stays canonical and append-only, while SQLite remains a disposable projection. Schema 15, migrations 1–15, `ds4-context-config-v1`, `runtime-adapter-v1`, `ds4-context-persistence-tool-v1`, and `ds4-context-persistence-result-v1` are unchanged.

## Package/version policy

The coordinated version is `0.3.0-alpha.5` for:

```text
ds4-context-core
ds4-context-reference-adapter
ds4-context-engine
```

Both adapters depend exactly on `ds4-context-core@0.3.0-alpha.5`. The packages were published manually under the explicit npm `alpha` dist-tag while `latest` remains `0.2.0`. GitHub Actions remains validation-only with OIDC and package-write permissions denied.

## Validation evidence

Local candidate verification on Node.js `26.5.1`:

- `npm run check`: 65 files and 297 tests passed.
- Focused compaction coverage includes three-segment fan-out, recursive fan-in, tool-exchange atomicity, exact contiguous source slicing, oversized indivisible-source fallback, and privacy-safe provider input-limit categorization.
- `npm run quality:compare`: candidate quality `0.9875` versus baseline `0.808156`.
- `npm run schema:context-persistence`: 1,266 bytes and 317 estimated tokens; below the 1,500 absolute and 320 relative limits.
- `npm run latency:check -- <exact ds4-context-core@0.1.2>`: isolated clean-checkout retry passed with ratio `1.041564`, at or below `1.10`; an immediately preceding noisy sample measured `1.157479`, while the pre-commit local sample measured `0.939056`.
- `npm run pack:check`: verified core (207 files), reference adapter (7 files), and Pi adapter (62 files) in a clean consumer.
- `npm pack --dry-run --json` for all three packages passed with the same bounded inventories and no forbidden local/session files.
- The committed candidate was replayed from detached clean checkout `8b609c0`; `npm ci`, the 65-file/297-test suite, quality, schema, package verification, tarball review, latency retry, and `git diff --check` passed.
- `git diff --check`: passed.
- Validation-only CI passed on Node.js `22.19.0` and `24.x`; an initial unrelated schema-v10 upgrade-test timeout on Node 22 passed three isolated local reruns and the failed-job retry.
- Protected CI, compatibility golden, Pi fixture, migration, canonical Pin/Memory, persistence confirmation, and persistence result-contract files are unchanged.
- `npm run registry:check -- 0.3.0-alpha.5`: passed against all three exact published versions; `alpha` resolves to `0.3.0-alpha.5` and `latest` remains `0.2.0` for every package.

Exact registry verification passed before the annotated tag and GitHub prerelease were created.

## Documentation

- [`../COMPACTION.md`](../COMPACTION.md)
- [`../ARCHITECTURE.md`](../ARCHITECTURE.md)
- [`../PRIVACY.md`](../PRIVACY.md)
- [`../RELEASING.md`](../RELEASING.md)
- [`0.3.0-alpha.4.md`](0.3.0-alpha.4.md)
