Repository navigation
Description
Child of #481 (economic-mechanism A/B testing). The synthesis cache is fully implemented in the runtime and wired in desktop, but not in headless — so Terminal-Bench runs recompute synthesis blocks instead of reusing them. This slice wires it into headless and measures the token/cost effect via runtime-policy-ab-run.
Design decisions from #481 (thanks @Astro-Han) are baked into the plan below.
Plan
-
Lift the artifact glue to a shared package.
loadSynthesisCacheBlocksFromArtifacts/persistSynthesisCacheBlocksToArtifactscurrently live inapps/desktop/src/main/synthesis-cache-artifacts.ts, which headless can't import. Their block logic (buildSynthesisCacheBlocksFromHydratedArchives,estimateTokens,validateSynthesisCacheBlockShape) is already in@maka/runtime; only the two artifact-store glue functions need lifting. Move them to@maka/storage(they depend only on@maka/runtime+ theArtifactStoreinterface) and re-import from desktop so there's a single implementation. -
Persistence (headless). Use
createArtifactStore(storageRoot)with the run-scoped root harbor-cell already resolves —env.MAKA_STORAGE_ROOT ?? join(outputDir, 'maka-storage')(harbor-cell.ts:392-394). Blocks land at{storageRoot}/artifacts/{sessionId}/…, run- and session-scoped, with no collision with the flat tool-result archives under{outputDir}/tool-result-archives/. No new dir or env. -
Toggle. Build the
synthesisCachesub-policy inbuildHarborCellContextBudgetBackendOptions, gated byMAKA_CONTEXT_SYNTHESIS_CACHE(+_MODE/_MAX_BLOCKS/_MAX_TOKENS/_MAX_BLOCK_TOKENS), mirroring desktop'sbuildSynthesisCachePolicy. Add the keys toHARBOR_CELL_CONTEXT_ENV_KEYSand theruntime-policy-ab-runarm-localcontextEnvallowlist so it's A/B-toggleable. -
Callbacks. Inject
loadSynthesisCache/writeSynthesisCacheinto harbor-cell'snew AiSdkBackend({…}), backed by the store from step 2. -
Smoke. Single-task run proving the cache activates (read/write +
synthesisCacheWriteSkipped*counts inmaka-cell-output.json) and that the baseline vs arm configs actually differ. -
A/B + doc. Baseline vs arm on
terminal-bench-sample; first entry indocs/economic-mechanisms-benchmark.md(Phase 4 of feat(benchmark): extend economic mechanism A/B testing beyond PR #340 active tool prune #481): date, model, sample size, arm env, input/cache/output tokens, cost, pass rate, steps, interpretation.
Scope
Wiring + measurement only — no changes to synthesis-cache behavior (the runtime logic is unchanged). Verification: unit tests for the lifted glue + the env → policy parsing, the single-task smoke, then the A/B run.
Related: #481
Activity
Astro-Han commentedon Jul 6, 2026
Let's see how the A/B run goes!
feat(headless): wire synthesis cache into Harbor + benchmark it (#976)
docs: realign documentation set with the authority map (#1060)
Astro-Han commentedon Jul 16, 2026
Closing: PR #976 delivered the full plan — synthesis cache lifted to
@maka/runtime, wiredMAKA_CONTEXT_SYNTHESIS_CACHE*into Harbor, and measured −72.9% replay tokens. All plan steps complete.