okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-clean-3 (321794636): docs and history (cleanup step 3, items 3.0-3.10); release manifest and capability table with checks, history/ with pointers, link check, tools/ split, bench index; owner OK'd the wording 11-082b36e8a02

main
76.8 KiB1260 linesraw

Strata rebuild — implementation status

Requirement/checklist IDs follow the handoff packet in /Users/nikoveit/Documents/deepseek-harness/ENDING PLAN (work plan M0–M8, acceptance checklist P/R/A/S/T/U rows). This file is the resume point: it records what is implemented, what is proven, what is not proven, and the exact commands.

Phase: A (Mac-first). Host tested on: Apple M4, 16 GiB, macOS 26 (Darwin 25.5.0), 228 GiB volume with ~22 GiB free at the time of writing.


0. Where everything is

PathWhat it is
/Users/nikoveit/Documents/deepseek-harness/ENDING PLANThe handoff packet (authoritative inputs). Manifest verified: shasum -a 256 -c MANIFEST.sha256 → all OK.
…/deepseek-harness/strata-work/strata-rebuildThe integration checkout. Branch strata/rebuild-2026-10. This is where implementation happens.
…/strata-work/StrataPristine reference checkout of Niko1221/Strata at main (= reviewed pin 296b59d2). Do not edit.
…/strata-work/deepseek-harnessPristine clone of deepseek-ai/deepseek-harness at 57190202 (= reviewed pin).
…/strata-work/HyperCore-TunePristine clone at 4f9ab7fa (= reviewed pin).
…/strata-work/handover/uiExtracted authoritative UI ZIP (14 Oct).
…/strata-work/handover/tuiExtracted terminal ZIP. The older UI it contains is parked in ui/legacy-tui-ui-snapshot/old-ui-2026-10-11 and must not replace the 14 Oct UI.
…/strata-work/toolchainBuild toolchain: venv (cmake 4.4.4, ninja 1.13.2), llama.cpp at pinned 3cf03257, metal-cpp (SHA-256 verified against metal/setup_mac.py's pin).
…/strata-work/python311Python 3.11.15 venv with runtime + test dependencies. The system python3 is 3.9.6, below Strata's 3.10 floor.
…/strata-work/evidenceRetained raw evidence (logs, results).

Source revisions actually selected

InputReviewed pinSelected revisionNote
Strata296b59d2f73c8f04a805df29c2fa97655adace78same (HEAD of main, no drift)Base of strata/rebuild-2026-10.
DeepSeek Harness571902028a75c64c1d767f4ae5fd099485f0ddf0same (HEAD of master, no drift)
HyperCore-Tune4f9ab7fa689771b0f44a251475d8911ef42057acsame (HEAD of main, no drift)
Terminal checkpoint29b577b2 (not an upstream branch)reconstructed (2a9e0024)See §2.
llama.cpp (ggml)3cf03257f219afbe7334045ff7c6a06ac68c627dsamePinned by metal/CMakeLists.txt and setup.py.
metal-cppmetal-cpp_26.zip, SHA-256 4df3c078…85a3a4same, hash verified

Upstream drift check (re-run with git ls-remote): all three repositories were still at the reviewed commits, so no newer upstream change had to be reconciled. Only the terminal checkpoint is behind.


1. Completed and proven

1.1 The macOS Metal engine builds from source and runs (R02, R05, P01 groundwork)

This was the largest unknown and it is now closed: the engine is not aspirational. It builds from the pinned sources on this Mac and the binary runs.

cd …/strata-work/strata-rebuild
…/toolchain/venv/bin/cmake -S metal -B build-metal -G Ninja -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_MAKE_PROGRAM=…/toolchain/venv/bin/ninja \
    -DMETAL_CPP_DIR=…/toolchain/metal-cpp \
    -DSTRATA_GGML_DIR=…/toolchain/llama.cpp
…/toolchain/venv/bin/ninja -C build-metal strata -j 6
./build-metal/strata --version     # -> strata 0.1.44.1-metal
file ./build-metal/strata          # -> Mach-O 64-bit executable arm64
  • ggml version 0.24.0, commit 3cf03257f (matches the pin).
  • The kernel-parity tree builds separately with -DSTRATA_METAL_ENGINE=OFF and needs no model.

Evidence: …/strata-work/evidence/metal-parity/*.log.

1.2 Metal kernel parity on real GPU hardware (M0.2)

metal/tests/* run on the real Metal device (not a simulator). 27 of 28 suites pass on Apple M4:

SuiteResult
gemv_parity100 PASS, 0 fail
mma_parity91 PASS
dense_mm_parity67 PASS
gdn_prompt_parity29 PASS
pair_parity26 PASS
fuse_parity17 PASS
gr2_parity13 PASS
gr_parity7 PASS
qsa_prompt_parity6 PASS
gdn_parity, qsa_parity, prompt_parity5 PASS each
expert_parity, route_parity, sample_parity1 PASS each
arena_budget_test, coop_layoutexit 0
moe_mm_parityFAILS — see §3.1

rt_bench reports the real device: device: Apple M4 apple9 … metal4 … working set 11.8 GiB, measured device read bandwidth up to 96.1 GB/s.

1.3 Terminal layer integrated onto current Strata (M0.1)

The supplied terminal checkpoint is not an upstream branch, so it was reconstructed exactly from the supplied cumulative patch rather than copied:

  1. git checkout -b terminal/reconstructed 61b3fb5d (the patch's declared merge base).
  2. git apply --index of Handover/tui/patches/strata-terminal-current-29b577b2-from-61b3fb5.patch → applied clean, 380 files.
  3. Verified byte-identical to the extracted snapshot: diff -rq --exclude=.git against handover/tui/source/strata-terminal-current-29b577b2 reported only the two build directories I had created. Commit 2a9e0024.
  4. Merged onto current main as 05bfff68.

The numeral patch was not applied: the cumulative patch already contains it (handoff rule "never apply both").

The merge is a real reconciliation, not a copy. 24 upstream commits had touched serve/server.py, producing 8 overlapping hunks. Each was resolved as a union of both sides because in every case the two sides had added different things:

#Resolution
1Keep HEAD's per-request _last_done reset and the terminal's queue-deadline guard.
2Keep HEAD's slot admission (ask()/on_quiet + the #1994 BGEN refusal retry) and restore the terminal's live prompt_read reporting that HEAD had dropped.
3Keep HEAD's image_generation status; use the terminal's finer running count for activity; keep last_request_at.
4Keep both the client-gone check and the offline image-URL refusal.
5One _json signature carrying both headers and retry_after.
6Emit the caller's headers, then Retry-After.
7Keep HEAD's FAMILY_MODEL_NAMES (incl. qwen35moe) and the terminal's richer main() signature.
8Keep the terminal's ready-file removal and exit-code accounting, with HEAD's opt-in cache drop inside the same try/finally.

src/program/generate.cpp conflicted only on two includes (both kept). README.md conflicted on two documentation sections (both kept).

Note on merge mechanics: git merge-file emitted both sides' def _json and both def main signatures because each branch had edited the same base line differently; those were rewritten into single definitions before committing. The final file compiles (py_compile) and passes the full suite below.

1.4 Test suites pass on the merged tree (M0.2 gate)

SuiteCommandResult
Terminal…/python311/bin/python -m unittest discover -s tests/terminal -t tests/terminal -p 'test_*.py'Ran 222 tests — OK
Server/API…/python311/bin/python -m unittest discover -s serve -p 'test_*.py'Ran 801 tests in 304.819s — OK (skipped=11)

These run without a GPU or model weights (the server suite uses MockEngine). They are contract and behaviour tests, not inference evidence.

Evidence: …/strata-work/evidence/terminal-suite.txt, …/strata-work/evidence/serve-suite.txt.

1.5 The real Strata engine is reachable end to end (M1.1 groundwork)

The App Host, the Strata API worker and the terminal client were exercised against each other:

  • serve/server.py starts, serves /health, /v1/status, /v1/telemetry, /v1/chat/completions (SSE) and the three dialects.
  • strata.py status in the terminal renders the six-view monitor against that live worker (Sample age 0.0 s Source server-v1), i.e. the terminal layer and the server layer agree on the telemetry contract after the merge.
  • The App Host's inference bridge was pointed at that worker and detected it correctly (kind: "strata", modelId: "qwen3.8-flash-next", context: 32768, three dialects), then streamed a completion through it and reported real usage (usageSource: "reported", 249 prompt / 34 completion tokens).

This proves the Python worker ↔ Node App Host contract. It does not prove real inference: the worker was driven by its built-in MockEngine because no model fits this machine (§3.2).

1.6 The supplied UI runs as a macOS application — Tauri (Desktop, M4.1/M7.1 groundwork)

The desktop shell is Tauri 2, not Electron. This is a direct product decision and it supersedes the architecture plan's "Electron is the recommended baseline" line; the plan marks Tauri as the accepted alternative if a spike shows it can carry the design without duplicating the host, and it does.

apps/desktop/
  src-tauri/            Rust shell — a carrier only
    src/main.rs         starts the host, opens one window on its origin, stops the host on exit
    tauri.conf.json     bundle config (resources, macOS bundle settings)
    resources/node/node the private Node runtime (pinned standalone Node 24.12.0)
    icons/              generated from the supplied brand masters by `tauri icon`
  package.json          build scripts only; no runtime dependencies
apps/host/              App Host + the supplied UI, carrier-neutral and shared with Terminal
  server/               the Node host (as supplied, plus STRATA_DIST)
  dist/                 the built supplied UI

Why Tauri is the better carrier here, in evidence:

  • The shell cannot own anything. main.rs starts the host, opens a window, stops the host. There is no natural place for a second supervisor, a second conversation store or an agent loop to appear by accident — which is exactly the ownership boundary the architecture demands.
  • The webview is the system WKWebView, so there is no bundled Chromium. The artifact is much smaller and the renderer is the same code the browser build already ships.
  • The private runtime is an explicit sidecar. resources/node/node is a pinned standalone Node runtime, so an end user needs no development checkout, no global Node, no npm, no pip and no compiler — without depending on a shell's own embedded Node.
  • The UI is not re-platformed. The window loads http://127.0.0.1:<port> from the host, so the renderer and the API share an origin exactly as in the browser build, and the supplied UI's relative /api/... calls work unchanged. Layout, components, themes, localization, animations and accessibility behaviour are untouched.

1.6a The macOS artifact (internal development candidate, unsigned)

ArtifactPathSizeSHA-256
DMGapps/desktop/src-tauri/target/release/bundle/dmg/Strata_0.1.0_aarch64.dmg43 MiB``
.appapps/desktop/src-tauri/target/release/bundle/macos/Strata.app—

hdiutil verify reports the checksum VALID, the image mounts read-only, and it contains Strata.app plus the Applications drop link.

The app was verified from inside the mounted DMG — a read-only install path, which is the closest thing to a clean-user launch available without a second machine. The shell's self-test passed all eight steps there:

StepWhat it proves
resources-packagedthe shell found Contents/Resources in a real bundle
host-entry-presentthe App Host shipped
ui-dist-presentthe built supplied UI shipped
private-node-runtimethe bundled Node runs (node --version succeeds)
host-spawnedthe host starts from the bundle with that Node
host-healthy/api/health answered 2xx
ui-served/ served the UI
api-reachable-on-same-originthe renderer's API is on the same origin

A real GUI launch was also exercised: open -a Strata.app started both the shell process and the sidecar host listening on loopback, and quitting removed both processes with none left behind.

Headless DMG builds. Tauri's default DMG step runs an AppleScript that asks Finder to arrange the window; Finder AppleEvents time out outside a GUI session (AppleEvent timed out. (-1712)). apps/desktop/scripts/make-dmg.sh therefore calls the vendored create-dmg with --skip-jenkins, which is upstream's supported path for exactly this case and produces a plain, correct image. Use it rather than cargo tauri build --bundles dmg in automation.

Not signed or notarized. It must not be published or advertised as a release. D04/D05 (signing access; font and asset redistribution evidence) still need owner input. The icon is generated from the supplied brand masters by cargo tauri icon, so it is the real design rather than a default.

The Electron implementation was removed, not left behind: main.cjs, preload.cjs, build-resources/, scripts/smoke.mjs and the Electron dependency tree are gone. The UI host moved from apps/desktop/renderer to apps/host so Desktop and Terminal can share one runtime rather than one per client, which is what the architecture's artifact rules ask for.

1.7 No demo path in a packaged build (U12)

The supplied host fabricates monitor readings (randomised GPU utilisation, temperature, VRAM, and promptTps = 1400 + rand*500) whenever STRATA_REAL_ENGINE !== '1' — and that was the default. It also fell back to a token-streaming "demo engine" for chat.

That is a production success path built from simulated data, which acceptance row U12 forbids. It is now closed at three points:

  1. server/inference.mjs probes Strata's own API worker first and adopts an endpoint only after /v1/status identifies it (service === "strata") — an unrelated OpenAI-compatible listener is no longer adopted just because it holds a port.
  2. requiresRealEngine() returns true for a packaged build unconditionally. When no engine answers, the backend becomes kind: "unavailable" with a typed, actionable error; the demo branch is unreachable. STRATA_FORCE_DEMO=1 can only select demo mode in an unpackaged run.
  3. The Tauri shell sets STRATA_PACKAGED=1 and STRATA_REAL_ENGINE=1 on the host process, so the monitor's derived fields report none rather than invented numbers.

Verified behaviour:

ConditionBackend kind
STRATA_PACKAGED=1, no engine runningunavailable + typed error (no simulation)
development, no engine runningdemo (labelled simulated: true)
STRATA_PACKAGED=1, Strata worker livestrata (real, with model/context/dialects)

1.8 The agent bridge works end to end (A01/A03 groundwork)

integrations/harness/ carries the pinned Harness integration. profile/cordis.patch.yml is a patch layer over the shipped base + web-app bundles that points the agent at a local route and declares no cloud route at all, so local use needs no DeepSeek account and cannot silently fall back to a hosted model.

integrations/harness/bridge_tests.py proves the path without model weights. Against the pinned, installed Harness CLI (0.2.0-rc.2, from the DeepSeek Harness app bundle):

CaseResult
completionPASS — one turn reached the Strata worker and completed; the durable assistant message records provider: strata-local, model: qwen3.8-flash-next; the worker independently recorded the requests
cancelINCONCLUSIVE on this host — see below
approvalNOT EXERCISED — no tool in this session's set required approval
python311/bin/python integrations/harness/bridge_tests.py --all

Four real integration defects were found and fixed by this test, none of which a config review would have caught. They are recorded because they will recur on the real machines:

  1. The provider schema is nested. llm-pi-ai's config is { providers: { "<route>": {...} } }, not route keys at the top level. A top-level route key is silently ignored, and the failure appears much later as no adapter registered for provider "strata-local".
  2. Naming a credential reference is not the same as needing a credential. apiKeyEnv: STRATA_LOCAL_API_KEY fails with no credential for provider route when the variable is unset, before the request reaches the worker.
  3. But omitting the credential entirely also fails. pi-ai's OpenAI-compatible client insists on a key before it will send anything (No API key for provider, PI_AI_ERROR). The route therefore carries a literal loopback placeholder Authorization: Bearer strata-local — not a secret, scoped to 127.0.0.1 by baseURL, and it must become an apiKeyEnv reference if the worker is ever started with --api-key.
  4. The output budget must fit the whole request. The Harness system prompt plus its tool definitions is already ~29K tokens of a 32K window, so the 8K default made every turn fail with the worker's request exceeds the context window … requests are never truncated. The worker is right not to truncate silently; the route declares maxTokens: 2048 so it fits. On a real machine, either raise the engine's context or set the engine config's fit_max_tokens so the server trims with a label instead of refusing.

Why cancel is inconclusive here, stated plainly. session/cancel returns {"accepted": true} immediately, which is admission and not settlement. Against the built-in MockEngine a turn finishes in milliseconds, so the cancel arrives after the turn has already completed — the test reports that rather than claiming a pass or a failure. A decisive test needs a model whose decode takes long enough to observe, which is exactly the real-model machine. The assertion is already written against the durable terminal state (turn/end), not against the acknowledgement, so it will be meaningful there.

Why approval was not exercised. The session's tool set raised no approval request, so the outbound approval/request waterfall was never used. The case asserts the vocabulary of any decision it does see (allowed-once | rejected | cancelled | unavailable) and reports honestly when nothing was asked. Covering it needs a tool the policy actually gates; the qualification kit lists this as a required Phase B observation.

1.9 Real Time-skip replaces the scripted flow (S01–S05 groundwork)

The supplied Time-skip was a 28-second scripted animation: nine fixed moments, three sample documents chosen by regex, and a text table labelled "Simulated comparison checks". It is now a real state machine in strata_control/time_skip.py, driven from the CLI and shared by Desktop and Terminal:

queued -> checkpointing -> generating -> checking -> decision -> completed
plus cancelled | failed | interrupted | needs_user_review
strata timeskip run   --workspace DIR --prompt "..." [--attempts N] [--revise-command CMD]
strata timeskip list
strata timeskip status RUN_ID
strata timeskip apply  RUN_ID [--dry-run] [--restore]
python -m unittest discover -s tests/time_skip -t tests/time_skip   # 24 tests, OK

The rules that make it honest, and the test that holds each one:

RuleWhy it mattersTest
A check that did not run is unknown, never passedA missing check must not become evidence of successtest_missing_program_is_unknown_not_passed
A check that cannot be launched is unknown tooBlaming a candidate for a declaration mistake is wrong; passing it would be worseshell exits 126/127 map to unknown
A previously passing check that now fails rejects the candidateThis is the specification's non-regression gatetest_regression_rejects_and_keeps_last_good
Nothing improved → inconclusive, not successAbsence of evidence is not evidencetest_unchanged_candidate_is_inconclusive
A model's opinion never gatesCritique can advise but cannot assert objective correctnesstest_advice_alone_cannot_keep_a_candidate
The workspace is never written during a runSpeculative work must be isolatedtest_the_workspace_is_never_written_during_a_run
Cancel/crash retains the last complete checkpoint"Preserve the last good result"test_cancel_retains_checkpoint
A concurrent user edit makes apply refuse, exit 6Never overwrite someone's work silentlytest_apply_is_refused_after_a_concurrent_user_edit
Apply is explicit, previewable and reversibleApplying is a separate, verified step--dry-run, rollback copy, --restore
A rejected candidate stays on diskThe user must be able to inspect what was triedtest_rejected_candidate_stays_inspectable
Attempts are bounded and each starts from the retained checkpointA rejected candidate must not seed the next attempttest_later_attempt_starts_from_a_kept_candidate

Demonstrated end to end on a fixture workspace: the baseline failed a declared grep -q three check, the revision added the line, attempt 1 was keep with reason "every deterministic check passed; newly passing: has-three", the decision was accepted, --dry-run reported would write: doc.txt without touching anything, apply wrote it (keeping a rollback copy), --restore put the original back, and a subsequent apply on a user-edited workspace was refused.

1.10 The Time-skip revision step is a real, bounded Harness turn

integrations/harness/revise_once.py is the --revise-command that turns one Time-skip attempt into one bounded agent turn:

strata timeskip run --workspace DIR --prompt "..." --attempts 1 \
    --revise-command "<python> <abs>/integrations/harness/revise_once.py --deadline 200"

It runs with the candidate directory as its cwd, takes the prompt from STRATA_TIMESKIP_PROMPT and the attempt number from STRATA_TIMESKIP_ATTEMPT, and returns when the turn reaches a terminal state. Its contract with Time-skip is narrow on purpose: exit 0 means an attempt was made, not that it succeeded. Whether it improved anything is decided by the checks, never by the runner.

"Bounded" means all three of: a wall-clock deadline, a per-attempt Harness home (so a crashed attempt cannot corrupt the next one), and a Harness that is stopped when the deadline passes — a stuck agent cannot hold a run open.

Demonstrated end to end with the real Harness CLI driving the real worker:

ObservationValue
baseline checkpointcp1-baseline digest 75069f85862a, has-status=failed, has-title=passed
attempt 1reject — deterministic check(s) failed: has-status
decisioninconclusive — every candidate was rejected, the baseline is retained
retainedcp1-baseline, flagged needs user review
the user's workspaceunchanged (title: notes / owner: nik)
the rejected candidatekept on disk for inspection
worker2 requests served by the local Strata worker

The candidate was correctly rejected because the engine on this Mac is the built-in MockEngine, which returns a fixed reply and cannot actually edit a file. That is the point of the result: a revision that achieved nothing was rejected and the good version was kept, rather than a plausible summary being presented as progress. On a machine with a real model the same run becomes a real revision attempt, and nothing about the gate changes.

Evidence: docs/work/evidence/timeskip-harness.txt.

What remains: wiring this into the App Host's /api/chat/stream and the supplied TimeSkipPanel so the UI drives it, and replacing the panel's scripted moments with the real event stream. The backend contract the UI needs is the timeskip CLI's JSON output and run.json.

1.11 Windows owner transport (R03/R04 groundwork)

strata_control/runtime.py was POSIX-only: _supported() raised on Windows, so strata runtime refused everything there and the terminal had no managed-owner mode at all. That is now a real transport with an explicit, honest difference between the platforms.

strata_control/owner_transport.py provides the two operations the runtime needs (listen, connect) plus addressing and state-file validation:

PlatformMechanismWhat the channel's security rests on
macOS / LinuxAF_UNIX stream socket in the owner's 0700 runtime directory, socket at 0600the filesystem: another user cannot open the path
Windowsloopback-only TCP listener (127.0.0.1, OS-assigned port)the owner's 256-bit control token compared in constant time, plus a 0700-equivalent private state directory

The Windows path is weaker and is recorded as such. The Python standard library cannot create a named pipe with a security descriptor (CreateNamedPipe is not exposed), so an owner-only pipe ACL is not available without a native extension. A loopback port is reachable by another local user who guesses it and has the token. Three things narrow that: the listener never binds anything but 127.0.0.1, the token is 256 bits and compared with compare_digest, and the state file is validated (regular file, owned by this user, no group/world bits, size-bounded) before a client will use it. This is the same security model as any loopback-authenticated local service. A native CreateNamedPipe implementation with an SDDL restricting the pipe to the owner is a scoped improvement and is tracked as the remaining difference, not presented as already done.

serve/winjob.py already solves the other half of Windows process ownership — engine children are placed in a kill-on-close job object so they cannot outlive the server, and test_winjob.py covers it.

15 transport tests pass, and the Windows branch is exercised on macOS: the loopback listener, the round trip, the "a second owner cannot share the port" check and the "it must not be reachable off-loopback" check are ordinary Python and run everywhere, so the platform branch is verified rather than deferred. The state-file validation tests cover symlink, wrong-mode, directory and oversized inputs. The POSIX stale-socket recovery keeps its existing checks unchanged.

Evidence: python -m unittest discover -s tests/terminal -t tests/terminal → 237 tests, OK.

1.12 Engine tuning: the job contract, and the HyperCore-Tune decision (T01–T08 groundwork)

strata_control/tuning.py implements the tuning job: a bounded search over runtime configuration that produces a recommendation, never an automatic change. strata tune plan|status|list is the interface, shared by Desktop and Terminal. 31 tests pass.

Decision D07 — HyperCore-Tune is a candidate optimizer, not the optimizer. The handoff asks for it to be adapted and tested rather than assumed portable. The evidence, from the pinned checkout (4f9ab7fa) and this machine's engine:

FindingEvidence
Its search space is CUDA/HIP engine flagssearch_space.py names --vram-reserve-mib, --pcie-frac, --pool-workers, --host-core, --pool-affinity, --ple-io, --kv, --kv-grow, --prompt-cache-tail, --spec-min-p
Two of those do not exist on Apple Siliconthe Metal engine's --help lists neither --vram-reserve-mib nor --pcie-frac — they are NVIDIA/AMD device concepts, so a HyperCore sweep on Metal could only record FAIL_BOOT rows
It finds Strata by walking up from its own directorystrata_env.py; unacceptable for a packaged app, where the component registry must name an exact engine build
It writes deliverables next to that rootmax_run_<model>.json/.sh/.bat; the active profile must not be mutated by a search
Its README claims Linux/Windows, its tests use stub enginesa claim about the harness, not a qualification of any GPU

So Strata owns the job, the lease, the evidence and the apply step, and HyperCore-Tune remains a candidate optimizer behind that job for the backends whose flags it actually targets. If it is later qualified on CUDA, it plugs in where the measurement function is; nothing about the contract below changes.

The dimension table is what makes a sweep safe. A dimension is offered only when every flag it drives is both a concept of the selected backend and accepted by the actual engine binary — engine_flag_inventory() runs strata --help and the result decides. Anything else is excluded with its reason, so a sweep can never "measure" a configuration the engine would refuse. For this machine's Metal engine the plan reports exactly that:

searches:  ple_io, kv, kv_grow, spec_min_p
excluded:  vram_reserve, pcie_frac, expert_cache   (not Apple Silicon concepts)
           host_core, pool_affinity, pool_workers  (flag parses, kernel unported)
           prompt_cache_tail                       (not a Metal setting)

What the contract guarantees, each held by a test:

  • A candidate that failed to boot, timed out, produced no tokens, or failed a correctness check is recorded with its status and excluded from selection. Tokens/s alone is never acceptance.
  • Selection compares the candidate's worst run against the baseline's worst run, so a candidate whose best run is faster but whose bad runs are worse cannot win on noise.
  • The baseline is measured again after the sweep, and the drift is reported. A report never claims a comparison it cannot support.
  • The sweep holds an exclusive device lease (O_EXCL marker) and a second job is refused by name; a crashed job's stale lease is reported rather than ignored; the lease is released even when the job fails.
  • A cancelled sweep recommends nothing, however good its partial numbers look.
  • A benchmark-only lever (prompt_cache_tail) is measured but never exported, and verify_exported() re-measures the configuration as it would actually be written — if the advantage came from a lever that gets stripped, the recommendation is withdrawn.
  • Applying is a separate step. The sweep never writes the active profile.

1.12a The measurement harness (T04 groundwork)

strata_control/tune_engine.py is the measure callable the job needs: it boots the engine with one candidate's flags, sends the declared workload, reads the engine's own protocol output, and returns measurements. 26 tests pass against a stub engine that speaks the real protocol.

The protocol it reads is the engine's, not an invention — READY <ctx>, PP <processed> <total> <ms> [<tok_s>], T <id>, and DONE <produced> <prompt_tokens> <prompt_ms> <decode_ms> <finish> … from src/program/generate.cpp. Rates come from the engine's own prompt/decode milliseconds; client-observed timings are recorded separately and labelled, because they answer a different question.

What it refuses to score, each held by a test:

CaseWhy it is not a measurement
finish is cancel or nonfinitethe run did not complete
produced is 0a configuration that generates nothing is broken, not slow
the streamed token count disagrees with DONEneither number can be trusted for a rate
the engine reports ERRthe engine's own words are the result
the engine exits before READYreported with its exit code
the boot or request deadline passesreported as a timeout, not as a slow result

A missing metric stays missing rather than becoming zero, so an unmeasurable prompt rate cannot be mistaken for a very slow one. The workload is fixed (greedy, seed 1) so every candidate does the same work — a "faster" configuration that quietly did less is the classic tuning failure.

One real defect the tests caught, worth recording because of how it presented. The harness read the engine with readline() inside a while time.monotonic() < deadline loop. readline() on a pipe has no timeout, so the deadline bounded nothing: an engine that started and then said nothing would hang the measurement forever, and the boot-timeout path was unreachable. It surfaced as a test hanging rather than failing, and the first two attempts to fix it (blaming the stub's sleep child, then a shell quoting detail) were wrong — the instrumented reproduction showed the hang was in start() itself. The fix is a daemon reader thread and a queue the caller polls with a deadline it actually enforces, plus reaping the exit status before reporting it, because a reader can observe end-of-stream before poll() has reaped and "exited with code None" is useless exactly when the code matters.

What is still not done: no sweep has been run against a real model, because no supported pack fits this Mac. The harness is now complete enough that a sweep is a configuration step on a machine that has one; docs/work/QUALIFICATION-KIT.md section 9 lists the observations to make there.

1.13 Time-skip reaches the UI, without redesigning it

The supplied Time-skip design is preserved exactly. What changed is where its numbers come from.

apps/host/src/lib/time-skip.ts already exported timeSkipResultState(run, now), and TimeSkipPanel renders from what that returns. A run now optionally carries a job — the App Host's projection of Strata Control's durable record — and when it is present the result state is derived from the job's phase, decision and check outcomes instead of from elapsed time:

ValuePreview runReal run
statusa scripted captionthe job's actual phase, and it says "the checks were inconclusive" when they were
keptthe scripted 'a'/'b' choicethe job's decision.improvements
frame.indexelapsed millisecondsthe job's phase

The scripted moments are still used — for motion and layout — but they no longer decide anything. That is what keeps the delivered design intact while removing the fake result: the animation is the design, the verdict is the job's.

Absent job is what makes a run a preview. There is no mode flag a caller can forget to clear, so a production run cannot accidentally render as a demo.

The App Host never invents a status. /api/timeskip* starts the job, follows it and applies its result; the projection is copied from run.json. It does not compute a percentage, a score or a progress fraction — the job's phases are coarse and a check can take minutes with nothing to say, so the UI shows a phase. needsUserReview and unknown check outcomes survive the round trip unchanged, because a caller that renders either as a pass would be the bug they exist to prevent.

Verified over HTTP: a run started and completed, its attempt was rejected with the reason and per-check outcomes recorded, needsUserReview was true, a dry-run reported nothing to write, and an apply after a user edit returned 409 and left the workspace byte-identical. The revision command is a configured path rather than an HTTP parameter, so a remote caller cannot request command execution.

1.14 One pre-existing flaky UI test (found, not caused, not yet fixed)

apps/host/tests/request-flow.test.mjs — "Serving cancellation stops active and queued demo requests" — fails consistently on this machine: 187 pass, 1 fail. It is pre-existing, proven by stashing the only file this round touched (apps/host/server/index.mjs) and re-running: the same 187/1. The assertion that fails is assert.ok(active) after two chat streams start 100 ms apart and the test then waits another 100 ms.

It is a race in the test, not in the product: the demo stream emits chunks on a ~26 ms cadence, so by the time the test looks, the first request can already have moved past generating. A reliable version would poll for the two states with a deadline instead of assuming 200 ms is inside the window. Recorded here rather than papered over, because "one test is red" is exactly the kind of thing that becomes permanent when it is not written down.

1.15 Tuning reaches the UI, as a review surface (item 6's UI leg)

apps/host/src/components/TunePanel.tsx renders the tuning job contract inside the supplied design system — the kit's Panel, Metric, Pill, Select, Empty and tokens, with a new styles/tuning.css written against those tokens so themes, localization and reduced-motion all follow. #/tuning now renders it instead of the model-run screen; the route is unchanged, so existing navigation keeps working.

It is a review surface, not a run button, and that is deliberate. The plan is fetched from /api/tune/plan, computed from the selected engine binary's own flags, and every excluded dimension is shown with its reason — a dimension missing silently would be a defect, so the panel makes the exclusions as visible as the search. /api/tune/engine reports whether a binary exists at all, so the panel says "install a model first" rather than offering a plan about a guessed path.

There is no Start button. A sweep boots the engine once per candidate and needs the measurement harness wired to the UI; that wiring does not exist, so a Start button would be exactly the kind of fake affordance this rebuild exists to remove. The panel says what is missing instead. The report view is complete for when a job does exist: baseline median with its repeat count, the recommendation with the exported args, an explicit "no change recommended" when that is the outcome (the most common honest result of a tuning run, and not something to render as a blank), the drift warning, and the candidates that could not be measured with their reasons.

Seven new route tests pass, covering both features as contracts rather than as numbers:

TestWhat it holds
unconfigured enginereported unavailable rather than guessed at
the plan comes from the binarya stub engine accepting exactly --kv and --ple-io yields exactly those two dimensions, and every NVIDIA-only dimension is excluded with a reason
a plan without engine/backend400 with a reason
unknown or malformed job id404, and ../../etc/passwd cannot escape the store
an empty Time-skip listhonest, and reports where the store is
applying an unknown runrefused, never reported as success
an HTTP caller cannot supply a revision commandthe injected command is never run — reviseCommand is configured, not requested

UI suite: 194 pass / 1 fail (195 total); the single failure is the pre-existing request-flow flake recorded in §1.14, unchanged by this work.

1.16 strata tune run — a real sweep, end to end

strata tune run performs the whole job: it plans from the engine binary's own flags, measures the baseline, enumerates candidates, measures each with paired repeats, re-measures the baseline, and writes a report. 63 tuning tests pass. Verified end to end against a stub engine that speaks the real serve protocol and makes its decode speed depend on one flag:

$ strata tune run --engine tests/tuning/stub_engine.sh --backend metal --model stub \
      --trials 4 --repeats 3 --hold ple_io --hold kv_grow --hold spec_min_p
sweeping kv
  baseline  median 20.0 over 3 runs
  trials    4 of 4
  recommend index 2: --kv int8
            median 24.0 against a baseline of 20.0

Nothing was written to any profile, and the command says so.

Two honesty defects surfaced while testing this, and both are now held by tests.

  1. A bounded sweep looked like a complete one. The report said "trials 4 of 4" while the grid had 96 combinations — so "no candidate beat the baseline" read as a conclusion when it was an artefact of stopping early. The report now carries combinations_total and trials_are_a_prefix, and the CLI prints "6 of 6 allowed, from 96 possible combinations (a prefix of the enumeration)". This is the difference between a partial search and a complete one.
  2. The drift warning fired at +0.0%. Printing "the comparison is weaker than the repeat count suggests" when nothing drifted trains a reader to ignore the warning. Drift is now graded (drift_material at a 2% threshold) and negligible drift prints "within noise".

Stated limitations, printed with every sweep rather than buried:

  • the winner is measured through the engine's own serve protocol, not through the full HTTP API the agent uses, so the exported-configuration retest in QUALIFICATION-KIT.md §9 is still required before a recommendation is trusted;
  • the stub's numbers say nothing about any hardware. No sweep has run against a real model because no supported pack fits this Mac, and the strings that would have to be fabricated to pretend otherwise are exactly what the handoff forbids.

Evidence: docs/work/evidence/tuning-sweep.txt.

1.17 Acceptance evidence matrix, and tuning history (T06)

docs/work/ACCEPTANCE-EVIDENCE.md now maps all 67 requirement rows of the handoff's acceptance checklist to an explicit result. packaging/acceptance_matrix.py --check fails if a row is missing, so a gap is a build error rather than an oversight. Current standing:

ResultCount
passed35
failed9
pending-hardware15
pending-release1
unsupported3
not-implemented4

The statuses are deliberately conservative, and the rule that matters is: failed is an implementation gap and is never recorded as pending-hardware. Deferring a defect to another machine is how a defect becomes permanent. The nine failures are named in the matrix with what is missing.

T06 closed — tuning history. strata_control/tune_history.py makes identity a content digest rather than a label: a re-quantised model with the same filename is a different model. The comparison key is the engine digest, model digest, digest method, backend, workload, context and machine; a completed sweep records itself, and its report states how many earlier sweeps are comparable and, for each that is not, the reason in plain words — a report has to be able to say "the model changed", not merely "no". An unknown identity is never treated as a match, and incomparable history is retained rather than deleted, because an earlier sweep may still answer a question. 21 new tests, each element of the key covered separately.

Hashing a multi-gigabyte pack on every CLI invocation would be its own bug, so identity is sampled (head, middle, tail plus exact size) by default and the method travels with the digest — two records hashed differently can never be compared as though they were the same. --full-digests is available where the cost is acceptable.

Also this round: A02 verified with byte-level stream-framing tests (apps/host/tests/stream-framing.test.mjs) — a multi-byte character split across reads survives with no replacement character, an SSE line split mid-JSON is reassembled, a stream ending without a trailing newline still yields its last delta, a malformed frame is skipped without losing its neighbours, and an error frame reaches the caller in the provider's own words.

1.18 strata tune apply and rollback — explicit, verified, reversible (T07 closed)

The sweep recommends and never writes; applying is now a separate deliberate command. 115 tuning tests pass. Verified end to end:

$ strata tune apply <job> --config strata-demo.json          # no model identity -> REFUSED
strata: the sweep recorded no model digest, so its recommendation cannot be matched to the
        installed weights; re-run the sweep with --model-path and apply that result instead
config byte-identical: yes

$ strata tune apply <job> --config strata-demo.json --model-path model.gguf --state-dir state
applied to strata-demo.json
  + --kv int8
  - --kv fp16
  rollback: strata tune rollback 20261015T052436Z-aa873d11c569

$ strata tune rollback 20261015T052436Z-aa873d11c569
restored strata-demo.json          # exact previous bytes

env.STRATA_TOKEN and aliases survive the edit — an apply that dropped a user's token would be worse than no apply at all. Every refusal leaves the configuration byte-identical, which the tests assert directly rather than inferring from a return value.

The real defect testing found, and it was the dangerous shape. A sweep planned without --model-path records model_digest: null. The library refused that correctly — but the CLI re-derived its own identity, whose model digest was also null, and null == null matched. So the apply proceeded, on a recommendation that could never be matched to the installed weights, and the output looked completely normal. Two unknowns compared equal.

That is exactly the failure mode the identity work exists to prevent, arriving through the one door the library did not control. The fix keys the refusal on the recorded sweep carrying a real digest, before anything else is considered. Three tests pin it down, including one that asserts an identity with a null model digest is never treated as the same model.

The one honest gap, printed by the command itself: the candidate start is not verified against a running model, because no supported model fits this Mac. --verify is implemented and tested (a verification failure or a zero-token candidate writes nothing), but the CLI passes None and says so rather than implying a verification that did not happen.

Evidence: docs/work/evidence/tuning-apply.txt.

1.19 Two measurement modes, and memory (T04 closed)

Checklist T04 asks for the full API/Harness workload plus memory, not only engine tokens/s. There are now two modes, deliberately separate because they answer different questions:

ModeWhat it measuresCost
protocolthe engine's own serve protocol (READY/PP/T/DONE)cheap; every candidate in a sweep
apithe real worker, started from the candidate's configuration, driven over HTTP with a streamed chat completionthe full path a user waits for; the confirmation

Neither is presented as the other: every measurement carries its mode, and the CLI says which one produced the numbers and that a protocol result should be confirmed with --mode api before it is trusted. 126 tuning tests pass.

Both modes now record peak resident memory of the process tree, so a speed win bought by spilling is visible rather than hidden. Memory is summed over the tree because a backend may spawn workers, and an unreadable value is absent — never a zero, which would look like a measurement.

--mode api requires --api-expect, and refuses without it: "without an expectation a fast wrong answer cannot be told from a fast right one." That refusal is the point of the mode.

Three real defects this found, all in code I had just written:

  1. The worker never started. I passed --profile, which is the terminal launcher's flag. The worker's own spelling is --engine {mock,strata} --config <path>. It exited 2 with a usage message — and my first instinct was to blame the config file rather than read the flag list.
  2. Reasoning streams were measured as nothing. The worker streams reasoning into reasoning_content and the answer into content; I read only content, so a reasoning model reported "no content". Worse, had I read only content after reasoning, first-token time would have been whenever the thinking finished — a configuration that thinks longer would have looked faster. Both fields are now treated as output, and the first of either is the wait.
  3. A reasoning-only stream must not be a rate. An engine that only thinks has not generated. That case is now refused with a reason rather than scored.

The third is the same class as the null == null defect from §1.18: the harness was happy, the output looked normal, and the number was meaningless.

Labelled honestly: the API mode's tests run against a scripted fixture and against the real worker's --engine mock. They prove the harness, not any hardware's performance. A real API-mode sweep needs a model that fits a machine, which this one is not.

1.20 Component packages: manifests, safe unpacking, atomic activation (P06, P07, P11, P12, P13)

Five requirement rows shared one missing root: there was no component package system. There is now — strata_control/components.py, 47 tests — and the rows are closed together because they are one mechanism seen from five angles.

What a component is. A manifest declares its kind (application, runtime, agent-runtime, tuning, engine, prepared-data), its platform list, its backend, its artifacts with a SHA-256 and byte count each, and what it requires. Parsing is strict: a missing digest, an unknown kind, a non-hex digest, an artifact name that is a path, or a manifest that does not state its platforms is refused. That last one matters — an unstated platform would read as every platform.

The backend matrix is the packet's own, and it is a refusal gate:

cpu    macos-arm64, macos-x86_64, windows-x86_64, linux-x86_64
cuda   windows-x86_64, linux-x86_64
hip    windows-x86_64, linux-x86_64
metal  macos-arm64
sycl   linux-x86_64

So Windows SYCL and Intel-Mac Metal are refused as unsupported, not attempted and not left ambiguous — which is what the packet asks for.

Unpacking cannot escape. The attack shapes are refused individually, with the real shapes rather than a generic bad path: ../, nested a/b/../../../, a leading /, C:\Windows, ..\ with a backslash, //server/share, a NUL byte, symlinks and hard links, device and FIFO members. A symlink matters most because its name is innocent — only refusing links catches it. Every member is validated before any is written, so a refusal leaves the destination empty, and the tests assert emptiness rather than trusting the exception. Setuid bits from an archive are never trusted; the executable bit is preserved because a bundled runtime needs it.

Identity is the bytes, not the version. The cache key is the digest of the artifact set, so a rebuilt artifact with an unchanged version number is a different entry, and a cache hit is a statement about content. Activation copies rather than consuming the cache — a compatible application update reusing an installed engine depends on that payload still being there.

Reversal is exact. Activation moves the displaced version aside rather than deleting it, and the rollback record is written before the activation, so a crash between the two cannot leave it pointing at the version being installed. rollback refuses when there is nothing to restore, so "rollback succeeded" and "the component is gone" are never the same outcome.

Interrupted transfers are normal. Partial bytes are kept for a resume; a range request the server ignores restarts rather than appending to a prefix (which would produce a corrupt file that only fails at verification, much later); a partial larger than the declared size is discarded as stale; and the .complete marker is written last so an interrupted install is never mistaken for a finished one.

Two CLI surfaces, both read-only: strata components plan <manifest> says whether a package may be used here, and strata components backends prints the matrix. Verified that a Metal engine manifest is usable on this Mac and refused for linux-x86_64 with both reasons named.

1.21 Offline policy: two claims, tested separately (U08)

The checklist asks for two things that are easy to conflate, so strata_control/offline.py keeps them apart and they are tested separately — because a passing runtime-only test says nothing about the strict one. The first is about the server's own code paths; the second is about every process it can start.

ClaimMeaningHow
runtime_only_no_downloadserving fetches nothing; downloads elsewhere are permittedthe server runs from local files
strict_offlinenothing in the process tree reaches the networkenvironment + one predicate + preflight

Strict offline reaches children through the environment, applied last so a profile cannot remove the policy by naming the same variable:

offline=True:  HF_HUB_OFFLINE=1  TRANSFORMERS_OFFLINE=1  PIP_NO_INDEX=1  NO_PROXY=*  STRATA_OFFLINE=1
               HTTP_PROXY/HTTPS_PROXY emptied so an accidental call fails fast rather than hanging
profile asked HF_HUB_OFFLINE=0 -> '1'   (the policy wins)

Verified against a real child process, not by reading the dict.

One predicate decides every fetch. check_url allows local schemes and loopback — talking to this machine is not a download, and forbidding it would break the local API the product is built on — and refuses anything else with the host named in the reason.

A preflight refuses before the server starts. A profile declaring MCP servers, a before_load command or remote image sources cannot be strict-offline, and saying so up front beats failing on the first request. The refusal names which part of the profile is the problem.

A test that asserts the wiring caught a real leak. test_every_child_environment_call_passes_the_policy checks that every child_env call passes the server's offline state — and it found one that did not: the engine's own environment. The flag was being honoured for replicas but not for the engine, so a model loader could have fetched a missing shard under a flag that promised it would not. A guard that is not wired in is decoration; asserting the wiring is what makes it real.

The limit is stated, not hidden. limits() records what this does not enforce: a child that ignores the environment and opens a socket directly is not stopped, because that needs an OS sandbox this product does not have on all three platforms. The qualification kit asks for the network-isolated run that would settle it. Claiming enforcement we do not have would be exactly the kind of thing this rebuild exists to remove.

26 tests, and the serve suite is unchanged at 801 pass / 11 skip.

Evidence: docs/work/evidence/offline.txt.

1.22 Tool execution and approval, end to end (A04 closed; A03/A05 in progress)

integrations/harness/tool_flow_e2e.py drives the real path: a scripted Strata worker emits a bash tool call, the Harness agent loop executes it against a real workspace, and the turn is recorded in a durable session. The model is scripted — writing a file via bash is deterministic, and a scripted tool call exercises the same code as a model-chosen one (the worker's parser, the Harness tool executor, the approval gate, the durable record). It does not prove a real model chooses tools well, and the script says so.

A04 passes — an unanswerable approval fails closed. The agent is started without interactions=answer, so no peer can answer; the approval resolves to unavailable (the Harness vocabulary is allowed-once | rejected | cancelled | unavailable, and callers fail closed on the last), the tool does not run, the marker file does not exist, and the turn still reaches a terminal state instead of hanging.

A05 also passes, and it took a second attempt to make it mean anything. The first run passed trivially: the scripted turn finished in milliseconds, Stop arrived after turn/end, and the run proved nothing while printing PASS. The fix was to make the window real — --script-delay was added to serve/server.py so the mock waits between tokens (it already honoured cancellation between them), and the test now waits for turn/start and fails if the turn was not live before cancelling. With a live turn: Stop is acknowledged as {accepted: true} (admission only, as documented), the turn settles as aborted in the durable record, and the tool does not run.

That is the second time in this build that a check passed for the wrong reason, and both times the tell was the same: the assertion would have held even if the feature were absent.

A03 is implemented and not yet passing. The tool call is recognised — tool events appear in the session — but the tool does not execute. It is the last open requirement row.

Four defects were found and fixed in the test harness itself. Every one of them had produced a run that looked fine:

  1. A stale worker was answering. A mock worker left over from the Time-skip round an hour earlier was holding port 8095 — the port the profile names — so every request went to it and its scripted reply ("I made the change you asked for") came back as if the agent had produced it. The first A03 run "passed" the turn and failed only on the marker, which is what a real tool failure would look like. Fixed: the profile is rewritten per run with that run's worker port, and start_worker now refuses a port already in use.

  2. urllib followed the agent's 303 and discarded the set-cookie on it, so the next request 401'd. That reads as an authentication bug rather than a client one. Fixed: http.client, which returns the response as sent.

  3. The gateway needs its own envelope (type: client-request, rpcId, method, payload.args). Posting args directly is answered with a schema-issue list that reads like a malformed session.

  4. The scripted reply must close its thinking block. Without </think> the server treats the whole reply as reasoning, so the tool-call block lands in the reasoning field and is never executed — while the turn completes normally. Silent.

And one hazard that cost the most time, now a supported option. The worker's scripts are consumed in order, one per request, and the Harness makes requests the script author does not plan for: a session title request before the turn, and a re-ask after a tool result. One extra request shifts every later reply, and the symptom is a run that looks like a model which chose not to use a tool — indistinguishable from the real failure being investigated. --script-cycle was added to serve/server.py so a scripted sequence is chosen by request position instead of a counter; the serve suite is unchanged at 801 pass / 11 skip.

Evidence: docs/work/evidence/tool-flow.txt.

1.23 A04's pass was vacuous; the row is reopened

A04 was marked passed on evidence that did not support it. The run asserted that an unanswerable approval fails closed, but nothing in it was actually unanswerable. Three findings, each verified in the DSH source rather than inferred:

ClaimWhereConsequence
interactions defaults to 'answer'packages/client/connection/src/peer.ts:40omitting the launch-URL parameter removed no answerer
it is parsed only on /connectbrowser-auth.ts:309,321the launch-URL parameter was decorative
approval is consulted only for a sandbox escalationshell/tool-bash/src/index.ts:218,241a plain workspace-write command is not gated at all

So the tool did not run in that earlier A04 run because the scripted tool call was malformed — a missing required description argument — and not because approval denied it. Every line of output looked right, and the row was written into the matrix as verified.

And the mechanism A04 assumed does not exist. What genuinely makes an approval unanswerable is that no client holds the $events stream. With an escalating call and no peer, the request does not fail closed: it stays pending indefinitely, the session records approval/asked with no approval/decided, and the turn never ends. The documented unavailable fall-through happens in ApprovalService.decide() only once the waterfall actually runs.

The rewritten test uses an escalating call and a peer that receives the approval and answers next ("no available answerer"), then asserts the recorded decision is the fail-closed unavailable, the turn completes, no grant is recorded and the marker does not exist. Same scripted call as A03; only the peer's decision differs.

This is the third time in this build that a check passed for a reason unrelated to the feature, and the first one that was mine rather than a harness defect. The pattern is consistent: the output looks right, the assertion is about the absence of something, and nothing forces the mechanism to have been exercised. The discipline that catches it is asking, of every passing check, "would this also pass if the feature did nothing?"

A03 now passes for a real reason — PASS A03, with the peer's own record that it answered one approval as allowed-once, the marker written exactly once, and the worker recording two requests while executing nothing itself.

1.24 A03 and A04 pass with the mechanism actually exercised — no failed rows remain

All three agent-integration flows pass, each --only exits 0, and the combined run exits 0.

[A03] turn completed; 2 tool events; marker has 1 line; peer answered 1 of 1 approval(s):
      ['allowed-once']; worker recorded 2 request(s) and executed nothing itself     PASS A03
[A04] turn completed; marker exists: False; escalation asked 1 time(s), decided ['unavailable']
                                                                                    PASS A04
[A05] cancel acknowledged {accepted: true}; turn ended 'aborted'                    PASS A05

A03's assertions make a replayed effect impossible to hide: the marker has exactly one line, an approval was asked and answered with the recorded outcome allowed-once, and the worker recorded two requests while executing nothing itself — so the tool ran in the Harness and the transcript, not the tool, went to the API.

A04 does not assume the denial; it observes it. The peer answers next (do not decide, delegate), which is this vocabulary's "no available answerer", and the test asserts the escalation reached the gate, every recorded decision is the fail-closed unavailable, zero grants were recorded, the turn settled, and the marker does not exist. Each assertion fails for a different way the flow could otherwise pass while proving nothing: the tool never reaching the gate, the gate granting, or the turn hanging with the request pending.

Four defects had to be cleared, each hiding the next. The session-title request consumed the scripted tool call, so the turn never emitted one; then the call failed argument validation for a missing required description; then it emerged that the launch-URL interactions parameter is decorative (parsed only on /connect, and the peer default is answerable); and finally that a plain workspace-write command is not gated at all — approval is consulted only for a sandbox escalation, so the scripted call now requests one. That is what makes A03 and A04 about the approval gate rather than about a malformed call.

A correction to my own record. §1.23 reopened A04 after its first pass was found vacuous. This section closes it again on evidence that names the mechanism, and the earlier reasoning was wrong in a way worth keeping: --script-cycle does not fix a request the script author did not plan for — with two scripts an inserted request swaps the replies. Removing the unplanned request is what aligns the sequence. I had that backwards, and it cost a round.

A process note. While fixing this I committed the subagent's in-progress edit to the product profile with a git add -A, which put a test's need into a shipped file. It is reverted: the title-model row now lives in a separate test-only overlay (integrations/harness/profile/scripted-worker.cordis.patch.yml) applied as a second --patch, and the product profile is unchanged. git add -A while another agent is editing the tree is the cause; staging explicitly is the fix.

Evidence: docs/work/evidence/tool-flow.txt.


2. Deviations and decisions (material)

D01 — Merge strategy for the terminal checkpoint. The handoff says to port terminal changes "in small commits" onto current Strata. The terminal branch is not fetchable upstream, so the only faithful reproduction is to rebuild it from the supplied cumulative patch at its declared merge base and merge that. This is recorded here because it is a deviation from the literal "small commits" instruction, made to avoid copying an old engine tree over current Strata. Preserved: all current engine/server behaviour — verified by the 801-test server suite.

D02 — Python interpreter. The system python3 is 3.9.6; Strata requires 3.10+. setup.sh downloads a pinned standalone CPython 3.12 into .python on macOS for exactly this case. For development and testing I used the Homebrew python3.11 in a venv. The shipped runtime must use the setup path (bundled interpreter), not a developer interpreter — that work is still open (§4).

D03 — Harness embedding surface is the Gateway, not the SDK. Reconnaissance (…/strata-work/RECON-HARNESS.md, every claim cited to file:line) shows the handoff's two stated gaps are scoped to the SDK wire only:

Surfacecancelapproval out/in
Gateway / remote (dsh web + /api + WS /api/remote.mux)yes (session/cancel)yes (approval/request waterfall + POST /api/$events/result)
ACP (dsh --profile acp)yes (session/cancel)yes (session/request_permission)
SDK (dsh --profile sdk)nono

So the App Host will drive the Gateway surface, which satisfies integration spec §2 without a custom bridge plugin. session/cancel returns {accepted:true} as admission only; quiescence must be waited for via api-session/status(sessionId, running:false) or the durable aborted turn/end. The answering peer must be principal.kind === 'owner' and interactions === 'answer' — /connect?...&interactions=answer is required because it defaults to none.

D04 — Private Node runtime. The App Host needs a Node runtime, and the packaging requirement is that an end user supplies none. The shell therefore ships a pinned standalone Node as a sidecar (apps/desktop/src-tauri/resources/node/node, Node 24.12.0 — matching the host's own engines.node >= 24.12.0). This is deliberately a real Node binary rather than a desktop shell's embedded one: the runtime is then explicit, version-pinned, recorded in the artifact manifest, and independent of the carrier. (An earlier Electron attempt used the shell's embedded Node with ELECTRON_RUN_AS_NODE; it worked, but the runtime was implicit in the shell version, and the carrier has since been replaced anyway.) The Harness monorepo is not built: the agent backend is consumed as a pinned external dependency over its Gateway surface (D03).


3. Blockers and known failures

3.1 moe_mm_parity fails on the M4 — a real defect, not a packaging issue

mtl: no function mm_gu_42_16_64_16_2  Function mm_gu_42_16_64_16_2 was not found in the library
device Apple M4; Q2_0/Q2_0, T 256, 64 experts, tile TM 16 TN 64 TK 16 SG 2
exit=3

The mm_gu_* kernel family is templated over (format, M, N, K, SG) and this (42 = Q2_0, 16, 64, 16, 2) instantiation is missing from the Metal library that the test requests. Status: open. It must be diagnosed before any claim of Q2_0 MoE support on Metal. Every other kernel family passes, so this is a narrow gap rather than a broken backend.

3.2 No real-model inference is possible on this machine — hardware limitation

This is the precise limitation the goal anticipates. The evidence:

  • The Mac engine runs exactly one model family. include/strata/core/geometry.hpp fixes the shape the kernels are compiled for — n_embd 2560, n_layers 48, n_expert 512, n_vocab 248320, n_ff 640 — and a model file of another shape is refused at load with the differing metadata key. There is no smaller-model fallback to substitute, and substituting a different engine to get a passing demo is explicitly forbidden by the goal.
  • The smallest supported pack does not fit. metal/setup_mac.py offers Q2_0 (37.6 GB mapped file) as the floor; docs/MAC.md tabulates 37.6–114.8 GB packs plus a 28.8 GB n-gram table, with a 66–84 GB download. This Mac has ~22 GiB free of 228 GiB. The repack step alone needs the download plus the repacked copy plus 10 GB headroom.
  • The memory floor is below the tested minimum. docs/MAC.md measures a 32 GB M4 Mac mini streaming experts from SSD as the smallest tested configuration (arena_budget_test even has a "16 GB Mac" row). 16 GiB is untested, not supported.
  • A synthetic tiny model is not possible without an engine change (see the first point), so "real Metal inference on a toy model" is not an available shortcut.

Consequence: no real-model, no TTFT/tokens-per-second, and no end-to-end agent-quality evidence can be produced here. Everything in §1 is model-independent and is labelled as such. The tests that need a real model are prepared in the qualification kit (§5) and must run on a machine with ≥64 GB unified memory and ≥200 GB free disk (or a 32 GB M4 with the streaming path).

3.3 The packaged app's host does not start yet — RESOLVED by the Tauri carrier

Under Electron the packaged bundle started but its host never ran, with no output anywhere. The investigation is kept here because the lessons are carrier-independent and cost real time:

  1. A packaged macOS GUI app has no attached stdout. Adding a boot trace that writes to a file (STRATA_BOOT_TRACE) was the prerequisite for every later finding. Before it the app simply hung with no evidence at all. Any future packaging work should make the packaged app self-report first.
  2. The host cannot be a child process of a packaged Electron bundle, but it can be loaded in-process. utilityProcess.fork would not start the host from app.asar; unpacking the host fixed the path but the child still never ran; spawn(process.execPath, …) with ELECTRON_RUN_AS_NODE reported ENOTDIR for the packaged executable. Loading the host in the main process resolved it, and the packaged app then passed its full self-test.
  3. ElectronAsarIntegrity did not match the asar electron-builder produced (recorded 30dca368…, actual b6faa7b9…). Ruled out as the cause, but worth re-checking whenever a carrier validates its own archive.
  4. utilityProcess.fork must not receive ELECTRON_RUN_AS_NODE (the opposite of a plain spawn), because it starts a Node service process that then rejects the shell's own switches.

None of this carries over to Tauri: the shell starts the host as an ordinary child process with an explicit Node binary, so there is no archive-internal entry point and no carrier-specific runtime mode. The Tauri build is verified in §1.6a.

3.4 ELECTRON_RUN_AS_NODE (superseded carrier — kept for the record)

With the Electron carrier, a launching shell that exported ELECTRON_RUN_AS_NODE=1 (easy to inherit after running the App Host's Node) turned Electron into plain Node before main.cjs loaded, so require('electron') yielded the npm shim and the app died with Cannot read properties of undefined (reading 'requestSingleInstanceLock'). It could not be undone from user code. This no longer applies now that the carrier is Tauri, but the general lesson holds for any future child-process work: do not inherit a runtime-mode variable into a spawned runtime.

3.4b The terminal distribution has no bundled runtime — RESOLVED

release/artifacts/strata-terminal-0.1.44.1-darwin-arm64.tar.gz (42 MB, sha256 fafa0076fd30f9fa3d3f1250d8afbf39225bddb80e07a3d818bae2b01e2814d8, 42480892 bytes) is a self-contained terminal distribution: it carries a pinned standalone CPython 3.12.15 and its runtime dependencies, so a user needs no Python, pip, Node, compiler or checkout.

Built reproducibly by packaging/package_terminal.py, which:

  • downloads the same pinned interpreter setup.sh uses and refuses to package it if the SHA-256 does not match — one pin, two consumers, so the terminal and the installer cannot drift;
  • installs requirements.txt into that interpreter;
  • ships the application and only the tools/ modules the terminal paths import, keeping engine installation and preparation code out of the serving import graph;
  • deliberately excludes the engine (a separate, independently versioned component), model weights, prepared data and the UI;
  • writes a manifest next to the archive with the bundle and interpreter digests.

Verified as a clean user would experience it: extracted to an unrelated path, moved again to a different path, and run with env -i PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME=/Users/nikoveit. The only Python on that PATH is macOS's own 3.9, which the launcher correctly rejects as below the 3.10 floor — so everything below ran on the bundled interpreter:

CommandResult
./bin/strata --helpthe full command set, including timeskip and tune
./bin/strata status --url <dead>exit 3, the documented "control unreachable" code
./bin/strata timeskip list{"schema_version":1,"ok":true,"runs":[]}
./bin/strata tune plan --engine <metal>read the real engine's flags and planned the sweep
./python/bin/python3 -m serve.server --engine mock/health ok, a chat completion returned, and the bundled CLI showed it LIVE

That last row is also the R02 evidence asked for: pure serving ran with no agent runtime, no Tuning packages, no Textual and no UI present. The import graph of serve/ remains stdlib plus relative serve.* modules, verified both by inspection and by importing strata_control.management and strata_cli.cli on a bare interpreter.

One defect was found and fixed by this test: the launcher looked for the bundled runtime at /python/bin/python3 while the distribution puts it at /../python/bin/python3. That failure is silent — the launcher simply falls through to whatever Python is on PATH and the bundle quietly stops being self-contained — which is exactly why the clean-environment test exists.

Evidence: docs/work/evidence/terminal-dist.txt.

3.5 Not yet done

  • Fix §3.3, then produce the DMG (npm run package:mac:unsigned).
  • App Host ↔ Harness Gateway bridge (the vertical slice's agent half).
  • Time-skip: replace the scripted 28-second flow with a real checkpoint/candidate/check/decision state machine (S01–S05).
  • Tuning: the Strata job contract plus a bounded search adapter, and a HyperCore-Tune evaluation (T01–T08).
  • Acquisition/component/update ownership per M3 (the reuse contract: app-only update transfers zero engine/model bytes).
  • Windows and Linux package preparation (installer and AppImage recipes, dependency locks, Windows named-pipe owner transport — none of which exists upstream yet).

4. Next actions (ordered)

  1. Build the App Host bridge onto the Harness Gateway (integrations/harness/), proving: prompt → stream → tool approval/denial → per-run cancel → persisted session → terminal resume without replaying completed tool effects (A01–A08). Use a stub OpenAI-compatible endpoint for the model-independent contract tests; the real-model leg belongs to Phase B.
  2. Give the Host a server-side tool executor so useTools is real rather than a UI affordance, with the approval policy in the backend (A03/A04), and prove a denial never executes.
  3. Replace Time-skip's scripted flow (S01–S05).
  4. Implement the tuning job contract with a Strata-owned bounded search adapter and evaluate HyperCore-Tune against it (T01–T08).
  5. Windows/Linux packaging recipes and dependency locks.
  6. Signing/notarization and a compiled .icns from the supplied brand masters (blocked on owner credentials and font/asset redistribution evidence — D04/D05).

5. Phase B qualification kit

Written: QUALIFICATION-KIT.md — prerequisites, exact commands, assertions with requirement IDs, the result-record template, and the evidence rules.

Headline prerequisite (from §3.2): an Apple Silicon Mac with macOS ≥15 and either ≥64 GiB unified memory and ≥200 GiB free disk for a resident pack, or ≥32 GiB accepting the SSD-streaming path. This development Mac (16 GiB, ~22 GiB free) is below the tested floor.


6. Reproducing everything in §1 from scratch

ROOT=/Users/nikoveit/Documents/deepseek-harness/strata-work
cd "$ROOT/strata-rebuild"

# 1. Engine (needs the toolchain venv, llama.cpp at the pin, metal-cpp)
"$ROOT/toolchain/venv/bin/cmake" -S metal -B build-metal -G Ninja -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_MAKE_PROGRAM="$ROOT/toolchain/venv/bin/ninja" \
  -DMETAL_CPP_DIR="$ROOT/toolchain/metal-cpp" \
  -DSTRATA_GGML_DIR="$ROOT/toolchain/llama.cpp"
"$ROOT/toolchain/venv/bin/ninja" -C build-metal strata -j 6
./build-metal/strata --version

# 2. Metal kernel parity (no model needed)
"$ROOT/toolchain/venv/bin/cmake" -S metal -B build-metal-kern -G Ninja \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="$ROOT/toolchain/venv/bin/ninja" \
  -DSTRATA_METAL_ENGINE=OFF
"$ROOT/toolchain/venv/bin/ninja" -C build-metal-kern -j 8
for t in gemv_parity mma_parity dense_mm_parity expert_parity gdn_parity gdn_prompt_parity \
         qsa_parity qsa_prompt_parity prompt_parity gr_parity gr2_parity fuse_parity \
         pair_parity route_parity sample_parity arena_budget_test coop_layout; do
  ./build-metal-kern/$t > /dev/null || echo "FAILED: $t"
done

# 3. Python suites (need the python311 venv with jinja2 regex pyyaml tqdm requests pillow psutil numpy textual rich)
"$ROOT/python311/bin/python" -m unittest discover -s tests/terminal -t tests/terminal -p 'test_*.py'
"$ROOT/python311/bin/python" -m unittest discover -s serve -p 'test_*.py'
1# Strata rebuild — implementation status
2
3Requirement/checklist IDs follow the handoff packet in
4`/Users/nikoveit/Documents/deepseek-harness/ENDING PLAN` (work plan M0–M8, acceptance checklist
5P/R/A/S/T/U rows). This file is the resume point: it records what is implemented, what is proven,
6what is **not** proven, and the exact commands.
7
8**Phase:** A (Mac-first). **Host tested on:** Apple M4, 16 GiB, macOS 26 (Darwin 25.5.0), 228 GiB
9volume with ~22 GiB free at the time of writing.
10
11---
12
13## 0. Where everything is
14
15| Path | What it is |
16| --- | --- |
17| `/Users/nikoveit/Documents/deepseek-harness/ENDING PLAN` | The handoff packet (authoritative inputs). Manifest verified: `shasum -a 256 -c MANIFEST.sha256` → all OK. |
18| `…/deepseek-harness/strata-work/strata-rebuild` | **The integration checkout.** Branch `strata/rebuild-2026-10`. This is where implementation happens. |
19| `…/strata-work/Strata` | Pristine reference checkout of `Niko1221/Strata` at `main` (= reviewed pin `296b59d2`). Do not edit. |
20| `…/strata-work/deepseek-harness` | Pristine clone of `deepseek-ai/deepseek-harness` at `57190202` (= reviewed pin). |
21| `…/strata-work/HyperCore-Tune` | Pristine clone at `4f9ab7fa` (= reviewed pin). |
22| `…/strata-work/handover/ui` | Extracted authoritative UI ZIP (14 Oct). |
23| `…/strata-work/handover/tui` | Extracted terminal ZIP. The older UI it contains is parked in `ui/legacy-tui-ui-snapshot/old-ui-2026-10-11` and **must not** replace the 14 Oct UI. |
24| `…/strata-work/toolchain` | Build toolchain: `venv` (cmake 4.4.4, ninja 1.13.2), `llama.cpp` at pinned `3cf03257`, `metal-cpp` (SHA-256 verified against `metal/setup_mac.py`'s pin). |
25| `…/strata-work/python311` | Python 3.11.15 venv with runtime + test dependencies. The system `python3` is 3.9.6, below Strata's 3.10 floor. |
26| `…/strata-work/evidence` | Retained raw evidence (logs, results). |
27
28### Source revisions actually selected
29
30| Input | Reviewed pin | Selected revision | Note |
31| --- | --- | --- | --- |
32| Strata | `296b59d2f73c8f04a805df29c2fa97655adace78` | same (HEAD of `main`, no drift) | Base of `strata/rebuild-2026-10`. |
33| DeepSeek Harness | `571902028a75c64c1d767f4ae5fd099485f0ddf0` | same (HEAD of `master`, no drift) | |
34| HyperCore-Tune | `4f9ab7fa689771b0f44a251475d8911ef42057ac` | same (HEAD of `main`, no drift) | |
35| Terminal checkpoint | `29b577b2` (not an upstream branch) | reconstructed (`2a9e0024`) | See §2. |
36| llama.cpp (ggml) | `3cf03257f219afbe7334045ff7c6a06ac68c627d` | same | Pinned by `metal/CMakeLists.txt` and `setup.py`. |
37| metal-cpp | `metal-cpp_26.zip`, SHA-256 `4df3c078…85a3a4` | same, hash verified | |
38
39Upstream drift check (re-run with `git ls-remote`): all three repositories were still at the
40reviewed commits, so **no newer upstream change had to be reconciled**. Only the terminal
41checkpoint is behind.
42
43---
44
45## 1. Completed and proven
46
47### 1.1 The macOS Metal engine builds from source and runs (R02, R05, P01 groundwork)
48
49This was the largest unknown and it is now closed: the engine is **not** aspirational. It builds
50from the pinned sources on this Mac and the binary runs.
51
52```
53cd …/strata-work/strata-rebuild
54…/toolchain/venv/bin/cmake -S metal -B build-metal -G Ninja -DCMAKE_BUILD_TYPE=Release \
55    -DCMAKE_MAKE_PROGRAM=…/toolchain/venv/bin/ninja \
56    -DMETAL_CPP_DIR=…/toolchain/metal-cpp \
57    -DSTRATA_GGML_DIR=…/toolchain/llama.cpp
58…/toolchain/venv/bin/ninja -C build-metal strata -j 6
59./build-metal/strata --version     # -> strata 0.1.44.1-metal
60file ./build-metal/strata          # -> Mach-O 64-bit executable arm64
61```
62
63* ggml version 0.24.0, commit `3cf03257f` (matches the pin).
64* The kernel-parity tree builds separately with `-DSTRATA_METAL_ENGINE=OFF` and needs no model.
65
66**Evidence:** `…/strata-work/evidence/metal-parity/*.log`.
67
68### 1.2 Metal kernel parity on real GPU hardware (M0.2)
69
70`metal/tests/*` run on the **real Metal device** (not a simulator). 27 of 28 suites pass on
71Apple M4:
72
73| Suite | Result |
74| --- | --- |
75| `gemv_parity` | 100 PASS, 0 fail |
76| `mma_parity` | 91 PASS |
77| `dense_mm_parity` | 67 PASS |
78| `gdn_prompt_parity` | 29 PASS |
79| `pair_parity` | 26 PASS |
80| `fuse_parity` | 17 PASS |
81| `gr2_parity` | 13 PASS |
82| `gr_parity` | 7 PASS |
83| `qsa_prompt_parity` | 6 PASS |
84| `gdn_parity`, `qsa_parity`, `prompt_parity` | 5 PASS each |
85| `expert_parity`, `route_parity`, `sample_parity` | 1 PASS each |
86| `arena_budget_test`, `coop_layout` | exit 0 |
87| **`moe_mm_parity`** | **FAILS — see §3.1** |
88
89`rt_bench` reports the real device: `device: Apple M4 apple9 … metal4 … working set 11.8 GiB`,
90measured device read bandwidth up to **96.1 GB/s**.
91
92### 1.3 Terminal layer integrated onto current Strata (M0.1)
93
94The supplied terminal checkpoint is **not** an upstream branch, so it was reconstructed exactly
95from the supplied cumulative patch rather than copied:
96
971. `git checkout -b terminal/reconstructed 61b3fb5d` (the patch's declared merge base).
982. `git apply --index` of `Handover/tui/patches/strata-terminal-current-29b577b2-from-61b3fb5.patch`
99   → applied clean, 380 files.
1003. **Verified byte-identical** to the extracted snapshot: `diff -rq --exclude=.git` against
101   `handover/tui/source/strata-terminal-current-29b577b2` reported only the two build directories
102   I had created. Commit `2a9e0024`.
1034. Merged onto current `main` as `05bfff68`.
104
105The numeral patch was **not** applied: the cumulative patch already contains it (handoff rule
106"never apply both").
107
108**The merge is a real reconciliation, not a copy.** 24 upstream commits had touched
109`serve/server.py`, producing 8 overlapping hunks. Each was resolved as a *union* of both sides
110because in every case the two sides had added different things:
111
112| # | Resolution |
113| --- | --- |
114| 1 | Keep HEAD's per-request `_last_done` reset **and** the terminal's queue-deadline guard. |
115| 2 | Keep HEAD's slot admission (`ask()`/`on_quiet` + the #1994 `BGEN` refusal retry) **and** restore the terminal's live `prompt_read` reporting that HEAD had dropped. |
116| 3 | Keep HEAD's `image_generation` status; use the terminal's finer `running` count for `activity`; keep `last_request_at`. |
117| 4 | Keep both the client-gone check and the offline image-URL refusal. |
118| 5 | One `_json` signature carrying both `headers` and `retry_after`. |
119| 6 | Emit the caller's headers, then `Retry-After`. |
120| 7 | Keep HEAD's `FAMILY_MODEL_NAMES` (incl. `qwen35moe`) **and** the terminal's richer `main()` signature. |
121| 8 | Keep the terminal's ready-file removal and exit-code accounting, with HEAD's opt-in cache drop inside the same `try/finally`. |
122
123`src/program/generate.cpp` conflicted only on two includes (both kept). `README.md` conflicted on
124two documentation sections (both kept).
125
126**Note on merge mechanics:** `git merge-file` emitted *both* sides' `def _json` and *both* `def
127main` signatures because each branch had edited the same base line differently; those were
128rewritten into single definitions before committing. The final file compiles (`py_compile`) and
129passes the full suite below.
130
131### 1.4 Test suites pass on the merged tree (M0.2 gate)
132
133| Suite | Command | Result |
134| --- | --- | --- |
135| Terminal | `…/python311/bin/python -m unittest discover -s tests/terminal -t tests/terminal -p 'test_*.py'` | **Ran 222 tests — OK** |
136| Server/API | `…/python311/bin/python -m unittest discover -s serve -p 'test_*.py'` | **Ran 801 tests in 304.819s — OK (skipped=11)** |
137
138These run without a GPU or model weights (the server suite uses `MockEngine`). They are contract
139and behaviour tests, **not** inference evidence.
140
141**Evidence:** `…/strata-work/evidence/terminal-suite.txt`, `…/strata-work/evidence/serve-suite.txt`.
142
143### 1.5 The real Strata engine is reachable end to end (M1.1 groundwork)
144
145The App Host, the Strata API worker and the terminal client were exercised against each other:
146
147* `serve/server.py` starts, serves `/health`, `/v1/status`, `/v1/telemetry`, `/v1/chat/completions`
148  (SSE) and the three dialects.
149* `strata.py status` in the terminal renders the six-view monitor against that live worker
150  (`Sample age 0.0 s   Source server-v1`), i.e. the terminal layer and the server layer agree on
151  the telemetry contract after the merge.
152* The App Host's inference bridge was pointed at that worker and detected it correctly
153  (`kind: "strata"`, `modelId: "qwen3.8-flash-next"`, `context: 32768`, three dialects), then
154  streamed a completion through it and reported real usage
155  (`usageSource: "reported"`, 249 prompt / 34 completion tokens).
156
157This proves the Python worker ↔ Node App Host contract. It does **not** prove real inference: the
158worker was driven by its built-in `MockEngine` because no model fits this machine (§3.2).
159
160### 1.6 The supplied UI runs as a macOS application — **Tauri** (Desktop, M4.1/M7.1 groundwork)
161
162The desktop shell is **Tauri 2**, not Electron. This is a direct product decision and it supersedes
163the architecture plan's "Electron is the recommended baseline" line; the plan marks Tauri as the
164accepted alternative if a spike shows it can carry the design without duplicating the host, and it
165does.
166
167```text
168apps/desktop/
169  src-tauri/            Rust shell — a carrier only
170    src/main.rs         starts the host, opens one window on its origin, stops the host on exit
171    tauri.conf.json     bundle config (resources, macOS bundle settings)
172    resources/node/node the private Node runtime (pinned standalone Node 24.12.0)
173    icons/              generated from the supplied brand masters by `tauri icon`
174  package.json          build scripts only; no runtime dependencies
175apps/host/              App Host + the supplied UI, carrier-neutral and shared with Terminal
176  server/               the Node host (as supplied, plus STRATA_DIST)
177  dist/                 the built supplied UI
178```
179
180Why Tauri is the better carrier here, in evidence:
181
182* **The shell cannot own anything.** `main.rs` starts the host, opens a window, stops the host.
183  There is no natural place for a second supervisor, a second conversation store or an agent loop
184  to appear by accident — which is exactly the ownership boundary the architecture demands.
185* **The webview is the system WKWebView**, so there is no bundled Chromium. The artifact is much
186  smaller and the renderer is the same code the browser build already ships.
187* **The private runtime is an explicit sidecar.** `resources/node/node` is a pinned standalone Node
188  runtime, so an end user needs no development checkout, no global Node, no npm, no pip and no
189  compiler — without depending on a shell's own embedded Node.
190* **The UI is not re-platformed.** The window loads `http://127.0.0.1:<port>` from the host, so the
191  renderer and the API share an origin exactly as in the browser build, and the supplied UI's
192  relative `/api/...` calls work unchanged. Layout, components, themes, localization, animations and
193  accessibility behaviour are untouched.
194
195### 1.6a The macOS artifact (internal development candidate, **unsigned**)
196
197| Artifact | Path | Size | SHA-256 |
198| --- | --- | --- | --- |
199| DMG | `apps/desktop/src-tauri/target/release/bundle/dmg/Strata_0.1.0_aarch64.dmg` | 43 MiB | `` |
200| `.app` | `apps/desktop/src-tauri/target/release/bundle/macos/Strata.app` |  | — |
201
202`hdiutil verify` reports the checksum **VALID**, the image mounts read-only, and it contains
203`Strata.app` plus the `Applications` drop link.
204
205**The app was verified from inside the mounted DMG** — a read-only install path, which is the
206closest thing to a clean-user launch available without a second machine. The shell's self-test
207passed all eight steps there:
208
209| Step | What it proves |
210| --- | --- |
211| `resources-packaged` | the shell found `Contents/Resources` in a real bundle |
212| `host-entry-present` | the App Host shipped |
213| `ui-dist-present` | the built supplied UI shipped |
214| `private-node-runtime` | the bundled Node runs (`node --version` succeeds) |
215| `host-spawned` | the host starts from the bundle with that Node |
216| `host-healthy` | `/api/health` answered 2xx |
217| `ui-served` | `/` served the UI |
218| `api-reachable-on-same-origin` | the renderer's API is on the same origin |
219
220A real GUI launch was also exercised: `open -a Strata.app` started both the shell process and the
221sidecar host listening on loopback, and quitting removed **both** processes with none left behind.
222
223**Headless DMG builds.** Tauri's default DMG step runs an AppleScript that asks Finder to arrange
224the window; Finder AppleEvents time out outside a GUI session (`AppleEvent timed out. (-1712)`).
225`apps/desktop/scripts/make-dmg.sh` therefore calls the vendored `create-dmg` with
226`--skip-jenkins`, which is upstream's supported path for exactly this case and produces a plain,
227correct image. Use it rather than `cargo tauri build --bundles dmg` in automation.
228
229**Not signed or notarized.** It must not be published or advertised as a release. D04/D05 (signing
230access; font and asset redistribution evidence) still need owner input. The icon is generated from
231the supplied brand masters by `cargo tauri icon`, so it is the real design rather than a default.
232
233The Electron implementation was **removed, not left behind**: `main.cjs`, `preload.cjs`,
234`build-resources/`, `scripts/smoke.mjs` and the Electron dependency tree are gone. The UI host
235moved from `apps/desktop/renderer` to `apps/host` so Desktop and Terminal can share one runtime
236rather than one per client, which is what the architecture's artifact rules ask for.
237
238
239### 1.7 No demo path in a packaged build (U12)
240
241The supplied host fabricates monitor readings (randomised GPU utilisation, temperature, VRAM, and
242`promptTps = 1400 + rand*500`) whenever `STRATA_REAL_ENGINE !== '1'` — and that was the **default**.
243It also fell back to a token-streaming "demo engine" for chat.
244
245That is a production success path built from simulated data, which acceptance row U12 forbids. It
246is now closed at three points:
247
2481. `server/inference.mjs` probes **Strata's own API worker first** and adopts an endpoint only after
249   `/v1/status` identifies it (`service === "strata"`) — an unrelated OpenAI-compatible listener is
250   no longer adopted just because it holds a port.
2512. `requiresRealEngine()` returns true for a packaged build unconditionally. When no engine
252   answers, the backend becomes `kind: "unavailable"` with a typed, actionable error; the demo
253   branch is unreachable. `STRATA_FORCE_DEMO=1` can only select demo mode in an **unpackaged**
254   run.
2553. The Tauri shell sets `STRATA_PACKAGED=1` and `STRATA_REAL_ENGINE=1` on the host process, so the
256   monitor's derived fields report `none` rather than invented numbers.
257
258Verified behaviour:
259
260| Condition | Backend kind |
261| --- | --- |
262| `STRATA_PACKAGED=1`, no engine running | `unavailable` + typed error (no simulation) |
263| development, no engine running | `demo` (labelled `simulated: true`) |
264| `STRATA_PACKAGED=1`, Strata worker live | `strata` (real, with model/context/dialects) |
265
266### 1.8 The agent bridge works end to end (A01/A03 groundwork)
267
268`integrations/harness/` carries the pinned Harness integration. `profile/cordis.patch.yml` is a
269patch layer over the shipped `base` + `web-app` bundles that points the agent at a **local** route
270and declares no cloud route at all, so local use needs no DeepSeek account and cannot silently fall
271back to a hosted model.
272
273`integrations/harness/bridge_tests.py` proves the path without model weights. Against the pinned,
274installed Harness CLI (`0.2.0-rc.2`, from the DeepSeek Harness app bundle):
275
276| Case | Result |
277| --- | --- |
278| `completion` | **PASS** — one turn reached the Strata worker and completed; the durable assistant message records `provider: strata-local`, `model: qwen3.8-flash-next`; the worker independently recorded the requests |
279| `cancel` | **INCONCLUSIVE on this host** — see below |
280| `approval` | **NOT EXERCISED** — no tool in this session's set required approval |
281
282```
283python311/bin/python integrations/harness/bridge_tests.py --all
284```
285
286**Four real integration defects were found and fixed by this test, none of which a config review
287would have caught.** They are recorded because they will recur on the real machines:
288
2891. **The provider schema is nested.** `llm-pi-ai`'s config is `{ providers: { "<route>": {...} } }`,
290   not route keys at the top level. A top-level route key is *silently ignored*, and the failure
291   appears much later as `no adapter registered for provider "strata-local"`.
2922. **Naming a credential reference is not the same as needing a credential.**
293   `apiKeyEnv: STRATA_LOCAL_API_KEY` fails with `no credential for provider route` when the
294   variable is unset, *before* the request reaches the worker.
2953. **But omitting the credential entirely also fails.** pi-ai's OpenAI-compatible client insists on
296   a key before it will send anything (`No API key for provider`, `PI_AI_ERROR`). The route
297   therefore carries a literal loopback placeholder `Authorization: Bearer strata-local` — not a
298   secret, scoped to `127.0.0.1` by `baseURL`, and it must become an `apiKeyEnv` reference if the
299   worker is ever started with `--api-key`.
3004. **The output budget must fit the *whole* request.** The Harness system prompt plus its tool
301   definitions is already ~29K tokens of a 32K window, so the 8K default made every turn fail with
302   the worker's `request exceeds the context window … requests are never truncated`. The worker is
303   right not to truncate silently; the route declares `maxTokens: 2048` so it fits. On a real
304   machine, either raise the engine's context or set the engine config's `fit_max_tokens` so the
305   server trims *with a label* instead of refusing.
306
307**Why `cancel` is inconclusive here, stated plainly.** `session/cancel` returns
308`{"accepted": true}` immediately, which is admission and not settlement. Against the built-in
309`MockEngine` a turn finishes in milliseconds, so the cancel arrives after the turn has already
310completed — the test reports that rather than claiming a pass or a failure. A decisive test needs a
311model whose decode takes long enough to observe, which is exactly the real-model machine. The
312assertion is already written against the *durable* terminal state (`turn/end`), not against the
313acknowledgement, so it will be meaningful there.
314
315**Why `approval` was not exercised.** The session's tool set raised no approval request, so the
316outbound `approval/request` waterfall was never used. The case asserts the vocabulary of any
317decision it does see (`allowed-once | rejected | cancelled | unavailable`) and reports honestly
318when nothing was asked. Covering it needs a tool the policy actually gates; the qualification kit
319lists this as a required Phase B observation.
320
321### 1.9 Real Time-skip replaces the scripted flow (S01–S05 groundwork)
322
323The supplied Time-skip was a 28-second scripted animation: nine fixed moments, three sample
324documents chosen by regex, and a text table labelled "Simulated comparison checks". It is now a real
325state machine in `strata_control/time_skip.py`, driven from the CLI and shared by Desktop and
326Terminal:
327
328    queued -> checkpointing -> generating -> checking -> decision -> completed
329    plus cancelled | failed | interrupted | needs_user_review
330
331```
332strata timeskip run   --workspace DIR --prompt "..." [--attempts N] [--revise-command CMD]
333strata timeskip list
334strata timeskip status RUN_ID
335strata timeskip apply  RUN_ID [--dry-run] [--restore]
336python -m unittest discover -s tests/time_skip -t tests/time_skip   # 24 tests, OK
337```
338
339**The rules that make it honest, and the test that holds each one:**
340
341| Rule | Why it matters | Test |
342| --- | --- | --- |
343| A check that did not run is `unknown`, never `passed` | A missing check must not become evidence of success | `test_missing_program_is_unknown_not_passed` |
344| A check that cannot be *launched* is unknown too | Blaming a candidate for a declaration mistake is wrong; passing it would be worse | shell exits 126/127 map to `unknown` |
345| A previously passing check that now fails **rejects** the candidate | This is the specification's non-regression gate | `test_regression_rejects_and_keeps_last_good` |
346| Nothing improved → `inconclusive`, not success | Absence of evidence is not evidence | `test_unchanged_candidate_is_inconclusive` |
347| A model's opinion never gates | Critique can advise but cannot assert objective correctness | `test_advice_alone_cannot_keep_a_candidate` |
348| The workspace is never written during a run | Speculative work must be isolated | `test_the_workspace_is_never_written_during_a_run` |
349| Cancel/crash retains the last complete checkpoint | "Preserve the last good result" | `test_cancel_retains_checkpoint` |
350| A concurrent user edit makes apply **refuse**, exit 6 | Never overwrite someone's work silently | `test_apply_is_refused_after_a_concurrent_user_edit` |
351| Apply is explicit, previewable and reversible | Applying is a separate, verified step | `--dry-run`, rollback copy, `--restore` |
352| A rejected candidate stays on disk | The user must be able to inspect what was tried | `test_rejected_candidate_stays_inspectable` |
353| Attempts are bounded and each starts from the *retained* checkpoint | A rejected candidate must not seed the next attempt | `test_later_attempt_starts_from_a_kept_candidate` |
354
355Demonstrated end to end on a fixture workspace: the baseline failed a declared `grep -q three`
356check, the revision added the line, attempt 1 was `keep` with reason *"every deterministic check
357passed; newly passing: has-three"*, the decision was `accepted`, `--dry-run` reported `would write:
358doc.txt` without touching anything, apply wrote it (keeping a rollback copy), `--restore` put the
359original back, and a subsequent apply on a user-edited workspace was refused.
360
361### 1.10 The Time-skip revision step is a real, bounded Harness turn
362
363`integrations/harness/revise_once.py` is the `--revise-command` that turns one Time-skip attempt into
364one bounded agent turn:
365
366```
367strata timeskip run --workspace DIR --prompt "..." --attempts 1 \
368    --revise-command "<python> <abs>/integrations/harness/revise_once.py --deadline 200"
369```
370
371It runs with the **candidate directory** as its cwd, takes the prompt from `STRATA_TIMESKIP_PROMPT`
372and the attempt number from `STRATA_TIMESKIP_ATTEMPT`, and returns when the turn reaches a terminal
373state. Its contract with Time-skip is narrow on purpose: **exit 0 means an attempt was made, not that
374it succeeded.** Whether it improved anything is decided by the checks, never by the runner.
375
376"Bounded" means all three of: a wall-clock deadline, a per-attempt Harness home (so a crashed
377attempt cannot corrupt the next one), and a Harness that is stopped when the deadline passes — a
378stuck agent cannot hold a run open.
379
380**Demonstrated end to end** with the real Harness CLI driving the real worker:
381
382| Observation | Value |
383| --- | --- |
384| baseline checkpoint | `cp1-baseline` digest `75069f85862a`, `has-status=failed, has-title=passed` |
385| attempt 1 | **reject** — `deterministic check(s) failed: has-status` |
386| decision | `inconclusive` — every candidate was rejected, the baseline is retained |
387| retained | `cp1-baseline`, flagged `needs user review` |
388| the user's workspace | **unchanged** (`title: notes / owner: nik`) |
389| the rejected candidate | kept on disk for inspection |
390| worker | 2 requests served by the local Strata worker |
391
392The candidate was correctly rejected because the engine on this Mac is the built-in `MockEngine`,
393which returns a fixed reply and cannot actually edit a file. **That is the point of the result**: a
394revision that achieved nothing was rejected and the good version was kept, rather than a plausible
395summary being presented as progress. On a machine with a real model the same run becomes a real
396revision attempt, and nothing about the gate changes.
397
398**Evidence:** `docs/work/evidence/timeskip-harness.txt`.
399
400**What remains:** wiring this into the App Host's `/api/chat/stream` and the supplied `TimeSkipPanel`
401so the UI drives it, and replacing the panel's scripted moments with the real event stream. The
402backend contract the UI needs is the `timeskip` CLI's JSON output and `run.json`.
403
404### 1.11 Windows owner transport (R03/R04 groundwork)
405
406`strata_control/runtime.py` was POSIX-only: `_supported()` raised on Windows, so `strata runtime`
407refused everything there and the terminal had no managed-owner mode at all. That is now a real
408transport with an explicit, honest difference between the platforms.
409
410`strata_control/owner_transport.py` provides the two operations the runtime needs (listen, connect)
411plus addressing and state-file validation:
412
413| Platform | Mechanism | What the channel's security rests on |
414| --- | --- | --- |
415| macOS / Linux | `AF_UNIX` stream socket in the owner's `0700` runtime directory, socket at `0600` | the filesystem: another user cannot open the path |
416| Windows | loopback-only TCP listener (`127.0.0.1`, OS-assigned port) | the owner's 256-bit control token compared in constant time, plus a `0700`-equivalent private state directory |
417
418**The Windows path is weaker and is recorded as such.** The Python standard library cannot create a
419named pipe with a security descriptor (`CreateNamedPipe` is not exposed), so an owner-only pipe ACL
420is not available without a native extension. A loopback port is reachable by another local user who
421guesses it *and* has the token. Three things narrow that: the listener never binds anything but
422`127.0.0.1`, the token is 256 bits and compared with `compare_digest`, and the state file is
423validated (regular file, owned by this user, no group/world bits, size-bounded) before a client will
424use it. This is the same security model as any loopback-authenticated local service. A native
425`CreateNamedPipe` implementation with an SDDL restricting the pipe to the owner is a scoped
426improvement and is tracked as the remaining difference, not presented as already done.
427
428`serve/winjob.py` already solves the *other* half of Windows process ownership — engine children are
429placed in a kill-on-close job object so they cannot outlive the server, and `test_winjob.py` covers
430it.
431
432**15 transport tests pass, and the Windows branch is exercised on macOS**: the loopback listener,
433the round trip, the "a second owner cannot share the port" check and the "it must not be reachable
434off-loopback" check are ordinary Python and run everywhere, so the platform branch is verified
435rather than deferred. The state-file validation tests cover symlink, wrong-mode, directory and
436oversized inputs. The POSIX stale-socket recovery keeps its existing checks unchanged.
437
438**Evidence:** `python -m unittest discover -s tests/terminal -t tests/terminal` → 237 tests, OK.
439
440### 1.12 Engine tuning: the job contract, and the HyperCore-Tune decision (T01–T08 groundwork)
441
442`strata_control/tuning.py` implements the tuning job: a bounded search over runtime configuration
443that produces a **recommendation**, never an automatic change. `strata tune plan|status|list` is the
444interface, shared by Desktop and Terminal. **31 tests pass.**
445
446**Decision D07 — HyperCore-Tune is a candidate optimizer, not the optimizer.** The handoff asks for
447it to be adapted and tested rather than assumed portable. The evidence, from the pinned checkout
448(`4f9ab7fa`) and this machine's engine:
449
450| Finding | Evidence |
451| --- | --- |
452| Its search space is CUDA/HIP engine flags | `search_space.py` names `--vram-reserve-mib`, `--pcie-frac`, `--pool-workers`, `--host-core`, `--pool-affinity`, `--ple-io`, `--kv`, `--kv-grow`, `--prompt-cache-tail`, `--spec-min-p` |
453| Two of those do not exist on Apple Silicon | the Metal engine's `--help` lists neither `--vram-reserve-mib` nor `--pcie-frac` — they are NVIDIA/AMD device concepts, so a HyperCore sweep on Metal could only record `FAIL_BOOT` rows |
454| It finds Strata by walking up from its own directory | `strata_env.py`; unacceptable for a packaged app, where the component registry must name an exact engine build |
455| It writes deliverables next to that root | `max_run_<model>.json/.sh/.bat`; the active profile must not be mutated by a search |
456| Its README claims Linux/Windows, its tests use stub engines | a claim about the harness, not a qualification of any GPU |
457
458So Strata owns the job, the lease, the evidence and the apply step, and HyperCore-Tune remains a
459candidate optimizer behind that job for the backends whose flags it actually targets. If it is later
460qualified on CUDA, it plugs in where the measurement function is; nothing about the contract below
461changes.
462
463**The dimension table is what makes a sweep safe.** A dimension is offered only when *every* flag it
464drives is both a concept of the selected backend and accepted by the actual engine binary —
465`engine_flag_inventory()` runs `strata --help` and the result decides. Anything else is excluded
466**with its reason**, so a sweep can never "measure" a configuration the engine would refuse. For this
467machine's Metal engine the plan reports exactly that:
468
469```
470searches:  ple_io, kv, kv_grow, spec_min_p
471excluded:  vram_reserve, pcie_frac, expert_cache   (not Apple Silicon concepts)
472           host_core, pool_affinity, pool_workers  (flag parses, kernel unported)
473           prompt_cache_tail                       (not a Metal setting)
474```
475
476**What the contract guarantees, each held by a test:**
477
478* A candidate that failed to boot, timed out, produced no tokens, or failed a **correctness** check is
479  recorded with its status and excluded from selection. Tokens/s alone is never acceptance.
480* Selection compares the candidate's **worst** run against the baseline's **worst** run, so a
481  candidate whose best run is faster but whose bad runs are worse cannot win on noise.
482* The baseline is measured again *after* the sweep, and the drift is reported. A report never claims
483  a comparison it cannot support.
484* The sweep holds an **exclusive device lease** (`O_EXCL` marker) and a second job is refused by
485  name; a crashed job's stale lease is reported rather than ignored; the lease is released even when
486  the job fails.
487* A cancelled sweep recommends **nothing**, however good its partial numbers look.
488* A benchmark-only lever (`prompt_cache_tail`) is measured but never exported, and
489  `verify_exported()` re-measures the configuration *as it would actually be written* — if the
490  advantage came from a lever that gets stripped, the recommendation is withdrawn.
491* Applying is a separate step. The sweep never writes the active profile.
492
493### 1.12a The measurement harness (T04 groundwork)
494
495`strata_control/tune_engine.py` is the `measure` callable the job needs: it boots the engine with one
496candidate's flags, sends the declared workload, reads the engine's own protocol output, and returns
497measurements. **26 tests pass against a stub engine that speaks the real protocol.**
498
499The protocol it reads is the engine's, not an invention — `READY <ctx>`, `PP <processed> <total>
500<ms> [<tok_s>]`, `T <id>`, and `DONE <produced> <prompt_tokens> <prompt_ms> <decode_ms> <finish> …`
501from `src/program/generate.cpp`. Rates come from the engine's **own** prompt/decode milliseconds;
502client-observed timings are recorded separately and labelled, because they answer a different
503question.
504
505What it refuses to score, each held by a test:
506
507| Case | Why it is not a measurement |
508| --- | --- |
509| `finish` is `cancel` or `nonfinite` | the run did not complete |
510| `produced` is 0 | a configuration that generates nothing is broken, not slow |
511| the streamed token count disagrees with `DONE` | neither number can be trusted for a rate |
512| the engine reports `ERR` | the engine's own words are the result |
513| the engine exits before `READY` | reported with its exit code |
514| the boot or request deadline passes | reported as a timeout, not as a slow result |
515
516A missing metric stays **missing** rather than becoming zero, so an unmeasurable prompt rate cannot
517be mistaken for a very slow one. The workload is fixed (greedy, seed 1) so every candidate does the
518same work — a "faster" configuration that quietly did less is the classic tuning failure.
519
520**One real defect the tests caught, worth recording because of how it presented.** The harness read
521the engine with `readline()` inside a `while time.monotonic() < deadline` loop. `readline()` on a
522pipe has no timeout, so **the deadline bounded nothing**: an engine that started and then said
523nothing would hang the measurement forever, and the boot-timeout path was unreachable. It surfaced
524as a test hanging rather than failing, and the first two attempts to fix it (blaming the stub's
525`sleep` child, then a shell quoting detail) were wrong — the instrumented reproduction showed the
526hang was in `start()` itself. The fix is a daemon reader thread and a queue the caller polls with a
527deadline it actually enforces, plus reaping the exit status before reporting it, because a reader can
528observe end-of-stream before `poll()` has reaped and "exited with code None" is useless exactly when
529the code matters.
530
531**What is still not done:** no sweep has been run against a real model, because no supported pack
532fits this Mac. The harness is now complete enough that a sweep is a configuration step on a machine
533that has one; `docs/work/QUALIFICATION-KIT.md` section 9 lists the observations to make there.
534
535### 1.13 Time-skip reaches the UI, without redesigning it
536
537The supplied Time-skip design is preserved exactly. What changed is where its numbers come from.
538
539`apps/host/src/lib/time-skip.ts` already exported `timeSkipResultState(run, now)`, and
540`TimeSkipPanel` renders from what that returns. A run now optionally carries a `job` — the App Host's
541projection of Strata Control's durable record — and when it is present the result state is derived
542from the **job's phase, decision and check outcomes** instead of from elapsed time:
543
544| Value | Preview run | Real run |
545| --- | --- | --- |
546| `status` | a scripted caption | the job's actual phase, and it says "the checks were inconclusive" when they were |
547| `kept` | the scripted `'a'`/`'b'` choice | the job's `decision.improvements` |
548| `frame.index` | elapsed milliseconds | the job's phase |
549
550The scripted `moments` are still used — for motion and layout — but they no longer *decide*
551anything. That is what keeps the delivered design intact while removing the fake result: the
552animation is the design, the verdict is the job's.
553
554**Absent `job` is what makes a run a preview.** There is no mode flag a caller can forget to clear,
555so a production run cannot accidentally render as a demo.
556
557**The App Host never invents a status.** `/api/timeskip*` starts the job, follows it and applies its
558result; the projection is copied from `run.json`. It does not compute a percentage, a score or a
559progress fraction — the job's phases are coarse and a check can take minutes with nothing to say, so
560the UI shows a phase. `needsUserReview` and `unknown` check outcomes survive the round trip
561unchanged, because a caller that renders either as a pass would be the bug they exist to prevent.
562
563Verified over HTTP: a run started and completed, its attempt was rejected with the reason and
564per-check outcomes recorded, `needsUserReview` was true, a dry-run reported nothing to write, and an
565apply after a user edit returned **409** and left the workspace byte-identical. The revision command
566is a configured path rather than an HTTP parameter, so a remote caller cannot request command
567execution.
568
569### 1.14 One pre-existing flaky UI test (found, not caused, not yet fixed)
570
571`apps/host/tests/request-flow.test.mjs` — *"Serving cancellation stops active and queued demo
572requests"* — fails consistently on this machine: 187 pass, 1 fail. It is **pre-existing**, proven by
573stashing the only file this round touched (`apps/host/server/index.mjs`) and re-running: the same
574187/1. The assertion that fails is `assert.ok(active)` after two chat streams start 100 ms apart and
575the test then waits another 100 ms.
576
577It is a race in the test, not in the product: the demo stream emits chunks on a ~26 ms cadence, so
578by the time the test looks, the first request can already have moved past `generating`. A reliable
579version would poll for the two states with a deadline instead of assuming 200 ms is inside the
580window. Recorded here rather than papered over, because "one test is red" is exactly the kind of
581thing that becomes permanent when it is not written down.
582
583### 1.15 Tuning reaches the UI, as a review surface (item 6's UI leg)
584
585`apps/host/src/components/TunePanel.tsx` renders the tuning job contract inside the supplied design
586system — the kit's `Panel`, `Metric`, `Pill`, `Select`, `Empty` and tokens, with a new
587`styles/tuning.css` written against those tokens so themes, localization and reduced-motion all
588follow. `#/tuning` now renders it instead of the model-run screen; the route is unchanged, so
589existing navigation keeps working.
590
591**It is a review surface, not a run button, and that is deliberate.** The plan is fetched from
592`/api/tune/plan`, computed from the selected engine binary's own flags, and every excluded dimension
593is shown **with its reason** — a dimension missing silently would be a defect, so the panel makes the
594exclusions as visible as the search. `/api/tune/engine` reports whether a binary exists at all, so
595the panel says "install a model first" rather than offering a plan about a guessed path.
596
597**There is no Start button.** A sweep boots the engine once per candidate and needs the measurement
598harness wired to the UI; that wiring does not exist, so a Start button would be exactly the kind of
599fake affordance this rebuild exists to remove. The panel says what is missing instead. The report
600view is complete for when a job does exist: baseline median with its repeat count, the recommendation
601with the exported args, an explicit **"no change recommended"** when that is the outcome (the most
602common honest result of a tuning run, and not something to render as a blank), the drift warning, and
603the candidates that could not be measured with their reasons.
604
605**Seven new route tests pass**, covering both features as contracts rather than as numbers:
606
607| Test | What it holds |
608| --- | --- |
609| unconfigured engine | reported unavailable rather than guessed at |
610| the plan comes from the binary | a stub engine accepting exactly `--kv` and `--ple-io` yields exactly those two dimensions, and every NVIDIA-only dimension is excluded **with a reason** |
611| a plan without engine/backend | 400 with a reason |
612| unknown or malformed job id | 404, and `../../etc/passwd` cannot escape the store |
613| an empty Time-skip list | honest, and reports where the store is |
614| applying an unknown run | refused, never reported as success |
615| **an HTTP caller cannot supply a revision command** | the injected command is never run — `reviseCommand` is configured, not requested |
616
617UI suite: **194 pass / 1 fail** (195 total); the single failure is the pre-existing
618`request-flow` flake recorded in §1.14, unchanged by this work.
619
620### 1.16 `strata tune run` — a real sweep, end to end
621
622`strata tune run` performs the whole job: it plans from the engine binary's own flags, measures the
623baseline, enumerates candidates, measures each with paired repeats, re-measures the baseline, and
624writes a report. **63 tuning tests pass.** Verified end to end against a stub engine that speaks the
625real serve protocol and makes its decode speed depend on one flag:
626
627```
628$ strata tune run --engine tests/tuning/stub_engine.sh --backend metal --model stub \
629      --trials 4 --repeats 3 --hold ple_io --hold kv_grow --hold spec_min_p
630sweeping kv
631  baseline  median 20.0 over 3 runs
632  trials    4 of 4
633  recommend index 2: --kv int8
634            median 24.0 against a baseline of 20.0
635```
636
637Nothing was written to any profile, and the command says so.
638
639**Two honesty defects surfaced while testing this, and both are now held by tests.**
640
6411. **A bounded sweep looked like a complete one.** The report said "trials 4 of 4" while the grid had
642   96 combinations — so *"no candidate beat the baseline"* read as a conclusion when it was an
643   artefact of stopping early. The report now carries `combinations_total` and
644   `trials_are_a_prefix`, and the CLI prints *"6 of 6 allowed, from 96 possible combinations (a
645   prefix of the enumeration)"*. This is the difference between a partial search and a complete one.
6462. **The drift warning fired at +0.0%.** Printing *"the comparison is weaker than the repeat count
647   suggests"* when nothing drifted trains a reader to ignore the warning. Drift is now graded
648   (`drift_material` at a 2% threshold) and negligible drift prints "within noise".
649
650**Stated limitations, printed with every sweep rather than buried:**
651
652* the winner is measured through the engine's **own serve protocol**, not through the full HTTP API
653  the agent uses, so the exported-configuration retest in `QUALIFICATION-KIT.md` §9 is still required
654  before a recommendation is trusted;
655* the stub's numbers say nothing about any hardware. No sweep has run against a real model because
656  no supported pack fits this Mac, and the strings that would have to be fabricated to pretend
657  otherwise are exactly what the handoff forbids.
658
659**Evidence:** `docs/work/evidence/tuning-sweep.txt`.
660
661### 1.17 Acceptance evidence matrix, and tuning history (T06)
662
663**`docs/work/ACCEPTANCE-EVIDENCE.md`** now maps all **67 requirement rows** of the handoff's
664acceptance checklist to an explicit result. `packaging/acceptance_matrix.py --check` fails if a row
665is missing, so a gap is a build error rather than an oversight. Current standing:
666
667| Result | Count |
668| --- | --- |
669| passed | 35 |
670| failed | 9 |
671| pending-hardware | 15 |
672| pending-release | 1 |
673| unsupported | 3 |
674| not-implemented | 4 |
675
676The statuses are deliberately conservative, and the rule that matters is: **`failed` is an
677implementation gap and is never recorded as `pending-hardware`.** Deferring a defect to another
678machine is how a defect becomes permanent. The nine failures are named in the matrix with what is
679missing.
680
681**T06 closed — tuning history.** `strata_control/tune_history.py` makes identity a content digest
682rather than a label: a re-quantised model with the same filename is a different model. The comparison
683key is the engine digest, model digest, digest method, backend, workload, context and machine; a
684completed sweep records itself, and its report states how many earlier sweeps are comparable and, for
685each that is not, **the reason in plain words** — a report has to be able to say "the model changed",
686not merely "no". An unknown identity is never treated as a match, and incomparable history is
687retained rather than deleted, because an earlier sweep may still answer a question. **21 new tests**,
688each element of the key covered separately.
689
690Hashing a multi-gigabyte pack on every CLI invocation would be its own bug, so identity is sampled
691(head, middle, tail plus exact size) by default and the **method travels with the digest** — two
692records hashed differently can never be compared as though they were the same. `--full-digests` is
693available where the cost is acceptable.
694
695Also this round: **A02 verified** with byte-level stream-framing tests
696(`apps/host/tests/stream-framing.test.mjs`) — a multi-byte character split across reads survives with
697no replacement character, an SSE line split mid-JSON is reassembled, a stream ending without a
698trailing newline still yields its last delta, a malformed frame is skipped without losing its
699neighbours, and an error frame reaches the caller in the provider's own words.
700
701### 1.18 `strata tune apply` and `rollback` — explicit, verified, reversible (T07 closed)
702
703The sweep recommends and never writes; applying is now a separate deliberate command. **115 tuning
704tests pass.** Verified end to end:
705
706```
707$ strata tune apply <job> --config strata-demo.json          # no model identity -> REFUSED
708strata: the sweep recorded no model digest, so its recommendation cannot be matched to the
709        installed weights; re-run the sweep with --model-path and apply that result instead
710config byte-identical: yes
711
712$ strata tune apply <job> --config strata-demo.json --model-path model.gguf --state-dir state
713applied to strata-demo.json
714  + --kv int8
715  - --kv fp16
716  rollback: strata tune rollback 20261015T052436Z-aa873d11c569
717
718$ strata tune rollback 20261015T052436Z-aa873d11c569
719restored strata-demo.json          # exact previous bytes
720```
721
722`env.STRATA_TOKEN` and `aliases` survive the edit — an apply that dropped a user's token would be
723worse than no apply at all. Every refusal leaves the configuration **byte-identical**, which the
724tests assert directly rather than inferring from a return value.
725
726**The real defect testing found, and it was the dangerous shape.** A sweep planned without
727`--model-path` records `model_digest: null`. The library refused that correctly — but the CLI
728re-derived its own identity, whose model digest was *also* null, and `null == null` matched. So the
729apply **proceeded**, on a recommendation that could never be matched to the installed weights, and the
730output looked completely normal. Two unknowns compared equal.
731
732That is exactly the failure mode the identity work exists to prevent, arriving through the one door
733the library did not control. The fix keys the refusal on the *recorded sweep* carrying a real digest,
734before anything else is considered. Three tests pin it down, including one that asserts an identity
735with a null model digest is never treated as the same model.
736
737**The one honest gap, printed by the command itself:** the candidate start is not verified against a
738running model, because no supported model fits this Mac. `--verify` is implemented and tested (a
739verification failure or a zero-token candidate writes nothing), but the CLI passes `None` and says
740so rather than implying a verification that did not happen.
741
742**Evidence:** `docs/work/evidence/tuning-apply.txt`.
743
744### 1.19 Two measurement modes, and memory (T04 closed)
745
746Checklist T04 asks for the full API/Harness workload plus memory, not only engine tokens/s. There are
747now two modes, deliberately separate because they answer different questions:
748
749| Mode | What it measures | Cost |
750| --- | --- | --- |
751| `protocol` | the engine's own serve protocol (`READY`/`PP`/`T`/`DONE`) | cheap; every candidate in a sweep |
752| `api` | the real worker, started from the candidate's configuration, driven over HTTP with a streamed chat completion | the full path a user waits for; the confirmation |
753
754Neither is presented as the other: every measurement carries its `mode`, and the CLI says which one
755produced the numbers and that a `protocol` result should be confirmed with `--mode api` before it is
756trusted. **126 tuning tests pass.**
757
758Both modes now record **peak resident memory** of the process tree, so a speed win bought by spilling
759is visible rather than hidden. Memory is summed over the tree because a backend may spawn workers,
760and an unreadable value is absent — never a zero, which would look like a measurement.
761
762`--mode api` requires `--api-expect`, and refuses without it: *"without an expectation a fast wrong
763answer cannot be told from a fast right one."* That refusal is the point of the mode.
764
765**Three real defects this found, all in code I had just written:**
766
7671. **The worker never started.** I passed `--profile`, which is the *terminal launcher's* flag. The
768   worker's own spelling is `--engine {mock,strata} --config <path>`. It exited 2 with a usage
769   message — and my first instinct was to blame the config file rather than read the flag list.
7702. **Reasoning streams were measured as nothing.** The worker streams reasoning into
771   `reasoning_content` and the answer into `content`; I read only `content`, so a reasoning model
772   reported "no content". Worse, had I read only `content` *after* reasoning, first-token time would
773   have been whenever the thinking finished — **a configuration that thinks longer would have looked
774   faster**. Both fields are now treated as output, and the first of either is the wait.
7753. **A reasoning-only stream must not be a rate.** An engine that only thinks has not generated.
776   That case is now refused with a reason rather than scored.
777
778The third is the same class as the `null == null` defect from §1.18: the harness was happy, the
779output looked normal, and the number was meaningless.
780
781**Labelled honestly:** the API mode's tests run against a scripted fixture and against the real
782worker's `--engine mock`. They prove the harness, not any hardware's performance. A real
783API-mode sweep needs a model that fits a machine, which this one is not.
784
785### 1.20 Component packages: manifests, safe unpacking, atomic activation (P06, P07, P11, P12, P13)
786
787Five requirement rows shared one missing root: there was no component package system. There is now —
788`strata_control/components.py`, **47 tests** — and the rows are closed together because they are one
789mechanism seen from five angles.
790
791**What a component is.** A manifest declares its kind (`application`, `runtime`, `agent-runtime`,
792`tuning`, `engine`, `prepared-data`), its platform list, its backend, its artifacts with a SHA-256 and
793byte count each, and what it requires. Parsing is strict: a missing digest, an unknown kind, a
794non-hex digest, an artifact name that is a path, or **a manifest that does not state its platforms**
795is refused. That last one matters — an unstated platform would read as *every* platform.
796
797**The backend matrix is the packet's own, and it is a refusal gate:**
798
799```
800cpu    macos-arm64, macos-x86_64, windows-x86_64, linux-x86_64
801cuda   windows-x86_64, linux-x86_64
802hip    windows-x86_64, linux-x86_64
803metal  macos-arm64
804sycl   linux-x86_64
805```
806
807So Windows SYCL and Intel-Mac Metal are refused *as unsupported*, not attempted and not left
808ambiguous — which is what the packet asks for.
809
810**Unpacking cannot escape.** The attack shapes are refused individually, with the real shapes rather
811than a generic bad path: `../`, nested `a/b/../../../`, a leading `/`, `C:\Windows`, `..\` with a
812backslash, `//server/share`, a NUL byte, symlinks and hard links, device and FIFO members. A symlink
813matters most because its *name* is innocent — only refusing links catches it. Every member is
814validated **before any is written**, so a refusal leaves the destination empty, and the tests assert
815emptiness rather than trusting the exception. Setuid bits from an archive are never trusted; the
816executable bit is preserved because a bundled runtime needs it.
817
818**Identity is the bytes, not the version.** The cache key is the digest of the artifact set, so a
819rebuilt artifact with an unchanged version number is a different entry, and a cache hit is a
820statement about content. Activation **copies** rather than consuming the cache — a compatible
821application update reusing an installed engine depends on that payload still being there.
822
823**Reversal is exact.** Activation moves the displaced version aside rather than deleting it, and the
824rollback record is written *before* the activation, so a crash between the two cannot leave it
825pointing at the version being installed. `rollback` refuses when there is nothing to restore, so
826*"rollback succeeded"* and *"the component is gone"* are never the same outcome.
827
828**Interrupted transfers are normal.** Partial bytes are kept for a resume; a range request the server
829ignores restarts rather than appending to a prefix (which would produce a corrupt file that only
830fails at verification, much later); a partial larger than the declared size is discarded as stale; and
831the `.complete` marker is written last so an interrupted install is never mistaken for a finished one.
832
833**Two CLI surfaces, both read-only:** `strata components plan <manifest>` says whether a package may
834be used here, and `strata components backends` prints the matrix. Verified that a Metal engine
835manifest is *usable* on this Mac and refused for `linux-x86_64` with both reasons named.
836
837### 1.21 Offline policy: two claims, tested separately (U08)
838
839The checklist asks for two things that are easy to conflate, so `strata_control/offline.py` keeps
840them apart and they are tested separately — because a passing runtime-only test says **nothing** about
841the strict one. The first is about the server's own code paths; the second is about every process it
842can start.
843
844| Claim | Meaning | How |
845| --- | --- | --- |
846| `runtime_only_no_download` | serving fetches nothing; downloads elsewhere are permitted | the server runs from local files |
847| `strict_offline` | nothing in the process tree reaches the network | environment + one predicate + preflight |
848
849**Strict offline reaches children through the environment**, applied *last* so a profile cannot remove
850the policy by naming the same variable:
851
852```
853offline=True:  HF_HUB_OFFLINE=1  TRANSFORMERS_OFFLINE=1  PIP_NO_INDEX=1  NO_PROXY=*  STRATA_OFFLINE=1
854               HTTP_PROXY/HTTPS_PROXY emptied so an accidental call fails fast rather than hanging
855profile asked HF_HUB_OFFLINE=0 -> '1'   (the policy wins)
856```
857
858Verified against a **real child process**, not by reading the dict.
859
860**One predicate decides every fetch.** `check_url` allows local schemes and loopback — talking to this
861machine is not a download, and forbidding it would break the local API the product is built on — and
862refuses anything else with the host named in the reason.
863
864**A preflight refuses before the server starts.** A profile declaring MCP servers, a `before_load`
865command or remote image sources cannot be strict-offline, and saying so up front beats failing on the
866first request. The refusal names which part of the profile is the problem.
867
868**A test that asserts the wiring caught a real leak.** `test_every_child_environment_call_passes_the_policy`
869checks that *every* `child_env` call passes the server's offline state — and it found one that did
870not: **the engine's own environment**. The flag was being honoured for replicas but not for the
871engine, so a model loader could have fetched a missing shard under a flag that promised it would not.
872A guard that is not wired in is decoration; asserting the wiring is what makes it real.
873
874**The limit is stated, not hidden.** `limits()` records what this does *not* enforce: a child that
875ignores the environment and opens a socket directly is not stopped, because that needs an OS sandbox
876this product does not have on all three platforms. The qualification kit asks for the
877network-isolated run that would settle it. Claiming enforcement we do not have would be exactly the
878kind of thing this rebuild exists to remove.
879
880**26 tests**, and the serve suite is unchanged at **801 pass / 11 skip**.
881
882**Evidence:** `docs/work/evidence/offline.txt`.
883
884### 1.22 Tool execution and approval, end to end (A04 closed; A03/A05 in progress)
885
886`integrations/harness/tool_flow_e2e.py` drives the real path: a scripted Strata worker emits a bash
887tool call, the Harness agent loop executes it against a real workspace, and the turn is recorded in a
888durable session. The model is scripted — writing a file via bash is deterministic, and a scripted tool
889call exercises the same code as a model-chosen one (the worker's parser, the Harness tool executor,
890the approval gate, the durable record). It does **not** prove a real model chooses tools well, and the
891script says so.
892
893**A04 passes — an unanswerable approval fails closed.** The agent is started *without*
894`interactions=answer`, so no peer can answer; the approval resolves to `unavailable` (the Harness
895vocabulary is `allowed-once | rejected | cancelled | unavailable`, and callers fail closed on the
896last), the tool does not run, the marker file does not exist, and the turn still reaches a terminal
897state instead of hanging.
898
899**A05 also passes, and it took a second attempt to make it mean anything.** The first run passed
900trivially: the scripted turn finished in milliseconds, Stop arrived *after* `turn/end`, and the run
901proved nothing while printing PASS. The fix was to make the window real — `--script-delay` was added
902to `serve/server.py` so the mock waits between tokens (it already honoured cancellation between
903them), and the test now waits for `turn/start` and **fails if the turn was not live** before
904cancelling. With a live turn: Stop is acknowledged as `{accepted: true}` (admission only, as
905documented), the turn settles as **`aborted`** in the durable record, and the tool does not run.
906
907That is the second time in this build that a check passed for the wrong reason, and both times the
908tell was the same: the assertion would have held even if the feature were absent.
909
910**A03 is implemented and not yet passing.** The tool call is recognised — tool events appear in the
911session — but the tool does not execute. It is the last open requirement row.
912
913**Four defects were found and fixed in the test harness itself. Every one of them had produced a
914run that looked fine:**
915
9161. **A stale worker was answering.** A mock worker left over from the Time-skip round an hour earlier
917   was holding port 8095 — the port the *profile* names — so every request went to it and its
918   scripted reply ("I made the change you asked for") came back as if the agent had produced it. The
919   first A03 run "passed" the turn and failed only on the marker, which is what a real tool failure
920   would look like. Fixed: the profile is rewritten per run with that run's worker port, and
921   `start_worker` now refuses a port already in use.
922
9232. **`urllib` followed the agent's 303 and discarded the `set-cookie` on it**, so the next request
924   401'd. That reads as an authentication bug rather than a client one. Fixed: `http.client`, which
925   returns the response as sent.
926
9273. **The gateway needs its own envelope** (`type: client-request`, `rpcId`, `method`,
928   `payload.args`). Posting `args` directly is answered with a schema-issue list that reads like a
929   malformed *session*.
930
9314. **The scripted reply must close its thinking block.** Without `</think>` the server treats the
932   whole reply as reasoning, so the tool-call block lands in the reasoning field and is never
933   executed — while the turn completes normally. Silent.
934
935**And one hazard that cost the most time, now a supported option.** The worker's scripts are consumed
936in order, one per request, and the Harness makes requests the script author does not plan for: a
937session *title* request before the turn, and a re-ask after a tool result. One extra request shifts
938every later reply, and the symptom is a run that looks like **a model which chose not to use a
939tool** — indistinguishable from the real failure being investigated. `--script-cycle` was added to
940`serve/server.py` so a scripted sequence is chosen by request position instead of a counter; the
941serve suite is unchanged at **801 pass / 11 skip**.
942
943**Evidence:** `docs/work/evidence/tool-flow.txt`.
944
945### 1.23 A04's pass was vacuous; the row is reopened
946
947**A04 was marked passed on evidence that did not support it.** The run asserted that an unanswerable
948approval fails closed, but nothing in it was actually unanswerable. Three findings, each verified in
949the DSH source rather than inferred:
950
951| Claim | Where | Consequence |
952| --- | --- | --- |
953| `interactions` defaults to `'answer'` | `packages/client/connection/src/peer.ts:40` | omitting the launch-URL parameter removed **no** answerer |
954| it is parsed only on `/connect` | `browser-auth.ts:309,321` | the launch-URL parameter was **decorative** |
955| approval is consulted only for a sandbox escalation | `shell/tool-bash/src/index.ts:218,241` | a plain workspace-write command is **not gated at all** |
956
957So the tool did not run in that earlier A04 run because **the scripted tool call was malformed** — a
958missing required `description` argument — and not because approval denied it. Every line of output
959looked right, and the row was written into the matrix as verified.
960
961**And the mechanism A04 assumed does not exist.** What genuinely makes an approval unanswerable is
962that no client holds the `$events` stream. With an escalating call and no peer, the request does not
963fail closed: it stays **pending indefinitely**, the session records `approval/asked` with no
964`approval/decided`, and the turn never ends. The documented `unavailable` fall-through happens in
965`ApprovalService.decide()` only once the waterfall actually runs.
966
967The rewritten test uses an escalating call and a peer that receives the approval and answers `next`
968("no available answerer"), then asserts the recorded decision is the fail-closed `unavailable`, the
969turn completes, no grant is recorded and the marker does not exist. Same scripted call as A03; only
970the peer's decision differs.
971
972**This is the third time in this build that a check passed for a reason unrelated to the feature, and
973the first one that was mine rather than a harness defect.** The pattern is consistent: the output
974looks right, the assertion is about the *absence* of something, and nothing forces the mechanism to
975have been exercised. The discipline that catches it is asking, of every passing check, *"would this
976also pass if the feature did nothing?"*
977
978A03 now passes for a real reason — `PASS A03`, with the peer's own record that it answered one
979approval as `allowed-once`, the marker written exactly once, and the worker recording two requests
980while executing nothing itself.
981
982### 1.24 A03 and A04 pass with the mechanism actually exercised — no failed rows remain
983
984All three agent-integration flows pass, each `--only` exits 0, and the combined run exits 0.
985
986```
987[A03] turn completed; 2 tool events; marker has 1 line; peer answered 1 of 1 approval(s):
988      ['allowed-once']; worker recorded 2 request(s) and executed nothing itself     PASS A03
989[A04] turn completed; marker exists: False; escalation asked 1 time(s), decided ['unavailable']
990                                                                                    PASS A04
991[A05] cancel acknowledged {accepted: true}; turn ended 'aborted'                    PASS A05
992```
993
994**A03's assertions** make a replayed effect impossible to hide: the marker has **exactly one** line,
995an approval was **asked and answered** with the recorded outcome `allowed-once`, and the worker
996recorded two requests while **executing nothing itself** — so the tool ran in the Harness and the
997transcript, not the tool, went to the API.
998
999**A04 does not assume the denial; it observes it.** The peer answers `next` (do not decide,
1000delegate), which is this vocabulary's "no available answerer", and the test asserts the escalation
1001reached the gate, every recorded decision is the fail-closed `unavailable`, **zero grants** were
1002recorded, the turn settled, and the marker does not exist. Each assertion fails for a different way
1003the flow could otherwise pass while proving nothing: the tool never reaching the gate, the gate
1004granting, or the turn hanging with the request pending.
1005
1006**Four defects had to be cleared, each hiding the next.** The session-title request consumed the
1007scripted tool call, so the turn never emitted one; then the call failed argument validation for a
1008missing required `description`; then it emerged that the launch-URL `interactions` parameter is
1009decorative (parsed only on `/connect`, and the peer default is answerable); and finally that a plain
1010workspace-write command **is not gated at all** — approval is consulted only for a sandbox
1011escalation, so the scripted call now requests one. That is what makes A03 and A04 about the approval
1012gate rather than about a malformed call.
1013
1014**A correction to my own record.** §1.23 reopened A04 after its first pass was found vacuous. This
1015section closes it again on evidence that names the mechanism, and the earlier reasoning was wrong in
1016a way worth keeping: `--script-cycle` does **not** fix a request the script author did not plan for —
1017with two scripts an inserted request swaps the replies. Removing the unplanned request is what aligns
1018the sequence. I had that backwards, and it cost a round.
1019
1020**A process note.** While fixing this I committed the subagent's in-progress edit to the *product*
1021profile with a `git add -A`, which put a test's need into a shipped file. It is reverted: the
1022title-model row now lives in a separate test-only overlay
1023(`integrations/harness/profile/scripted-worker.cordis.patch.yml`) applied as a second `--patch`, and
1024the product profile is unchanged. `git add -A` while another agent is editing the tree is the cause;
1025staging explicitly is the fix.
1026
1027**Evidence:** `docs/work/evidence/tool-flow.txt`.
1028
1029---
1030
1031## 2. Deviations and decisions (material)
1032
1033**D01 — Merge strategy for the terminal checkpoint.** The handoff says to port terminal changes
1034"in small commits" onto current Strata. The terminal branch is not fetchable upstream, so the
1035only faithful reproduction is to rebuild it from the supplied cumulative patch at its declared
1036merge base and merge that. This is recorded here because it is a deviation from the literal
1037"small commits" instruction, made to avoid copying an old engine tree over current Strata.
1038*Preserved:* all current engine/server behaviour — verified by the 801-test server suite.
1039
1040**D02 — Python interpreter.** The system `python3` is 3.9.6; Strata requires 3.10+. `setup.sh`
1041downloads a pinned standalone CPython 3.12 into `.python` on macOS for exactly this case. For
1042development and testing I used the Homebrew `python3.11` in a venv. The shipped runtime must use
1043the setup path (bundled interpreter), not a developer interpreter — that work is still open (§4).
1044
1045**D03 — Harness embedding surface is the Gateway, not the SDK.** Reconnaissance
1046(`…/strata-work/RECON-HARNESS.md`, every claim cited to `file:line`) shows the handoff's two
1047stated gaps are **scoped to the SDK wire only**:
1048
1049| Surface | cancel | approval out/in |
1050| --- | --- | --- |
1051| Gateway / remote (`dsh web` + `/api` + WS `/api/remote.mux`) | **yes** (`session/cancel`) | **yes** (`approval/request` waterfall + `POST /api/$events/result`) |
1052| ACP (`dsh --profile acp`) | yes (`session/cancel`) | yes (`session/request_permission`) |
1053| SDK (`dsh --profile sdk`) | **no** | **no** |
1054
1055So the App Host will drive the Gateway surface, which satisfies integration spec §2 without a
1056custom bridge plugin. `session/cancel` returns `{accepted:true}` as *admission only*; quiescence
1057must be waited for via `api-session/status(sessionId, running:false)` or the durable aborted
1058`turn/end`. The answering peer must be `principal.kind === 'owner'` **and**
1059`interactions === 'answer'` — `/connect?...&interactions=answer` is required because it defaults
1060to `none`.
1061
1062**D04 — Private Node runtime.** The App Host needs a Node runtime, and the packaging requirement is
1063that an end user supplies none. The shell therefore ships a **pinned standalone Node** as a sidecar
1064(`apps/desktop/src-tauri/resources/node/node`, Node 24.12.0 — matching the host's own
1065`engines.node >= 24.12.0`). This is deliberately a real Node binary rather than a desktop shell's
1066embedded one: the runtime is then explicit, version-pinned, recorded in the artifact manifest, and
1067independent of the carrier. (An earlier Electron attempt used the shell's embedded Node with
1068`ELECTRON_RUN_AS_NODE`; it worked, but the runtime was implicit in the shell version, and the
1069carrier has since been replaced anyway.) The Harness monorepo is *not* built: the agent backend is
1070consumed as a pinned external dependency over its Gateway surface (D03).
1071
1072---
1073
1074## 3. Blockers and known failures
1075
1076### 3.1 `moe_mm_parity` fails on the M4 — a real defect, not a packaging issue
1077
1078```
1079mtl: no function mm_gu_42_16_64_16_2  Function mm_gu_42_16_64_16_2 was not found in the library
1080device Apple M4; Q2_0/Q2_0, T 256, 64 experts, tile TM 16 TN 64 TK 16 SG 2
1081exit=3
1082```
1083
1084The `mm_gu_*` kernel family is templated over (format, M, N, K, SG) and this (42 = Q2_0, 16, 64,
108516, 2) instantiation is missing from the Metal library that the test requests. **Status: open.**
1086It must be diagnosed before any claim of Q2_0 MoE support on Metal. Every other kernel family
1087passes, so this is a narrow gap rather than a broken backend.
1088
1089### 3.2 No real-model inference is possible on this machine — **hardware limitation**
1090
1091This is the precise limitation the goal anticipates. The evidence:
1092
1093* **The Mac engine runs exactly one model family.** `include/strata/core/geometry.hpp` fixes the
1094  shape the kernels are *compiled* for — `n_embd 2560`, `n_layers 48`, `n_expert 512`,
1095  `n_vocab 248320`, `n_ff 640` — and a model file of another shape is refused at load with the
1096  differing metadata key. There is no smaller-model fallback to substitute, and substituting a
1097  different engine to get a passing demo is explicitly forbidden by the goal.
1098* **The smallest supported pack does not fit.** `metal/setup_mac.py` offers Q2_0 (37.6 GB mapped
1099  file) as the floor; `docs/MAC.md` tabulates 37.6–114.8 GB packs plus a 28.8 GB n-gram table,
1100  with a 66–84 GB download. This Mac has **~22 GiB free of 228 GiB**. The repack step alone needs
1101  the download plus the repacked copy plus 10 GB headroom.
1102* **The memory floor is below the tested minimum.** `docs/MAC.md` measures a 32 GB M4 Mac mini
1103  streaming experts from SSD as the smallest tested configuration (`arena_budget_test` even has a
1104  "16 GB Mac" row). 16 GiB is *untested*, not supported.
1105* **A synthetic tiny model is not possible without an engine change** (see the first point), so
1106  "real Metal inference on a toy model" is not an available shortcut.
1107
1108**Consequence:** no real-model, no TTFT/tokens-per-second, and no end-to-end agent-quality
1109evidence can be produced here. Everything in §1 is model-independent and is labelled as such.
1110The tests that need a real model are prepared in the qualification kit (§5) and must run on a
1111machine with ≥64 GB unified memory and ≥200 GB free disk (or a 32 GB M4 with the streaming path).
1112
1113### 3.3 ~~The packaged app's host does not start yet~~ — **RESOLVED by the Tauri carrier**
1114
1115Under Electron the packaged bundle started but its host never ran, with no output anywhere. The
1116investigation is kept here because the lessons are carrier-independent and cost real time:
1117
11181. **A packaged macOS GUI app has no attached stdout.** Adding a boot trace that writes to a file
1119   (`STRATA_BOOT_TRACE`) was the prerequisite for every later finding. Before it the app simply
1120   hung with no evidence at all. Any future packaging work should make the packaged app
1121   self-report first.
11222. **The host cannot be a child process of a packaged Electron bundle, but it can be loaded
1123   in-process.** `utilityProcess.fork` would not start the host from `app.asar`; unpacking the host
1124   fixed the path but the child still never ran; `spawn(process.execPath, …)` with
1125   `ELECTRON_RUN_AS_NODE` reported `ENOTDIR` for the packaged executable. Loading the host in the
1126   main process resolved it, and the packaged app then passed its full self-test.
11273. **`ElectronAsarIntegrity` did not match the asar electron-builder produced** (recorded
1128   `30dca368…`, actual `b6faa7b9…`). Ruled out as the cause, but worth re-checking whenever a
1129   carrier validates its own archive.
11304. **`utilityProcess.fork` must not receive `ELECTRON_RUN_AS_NODE`** (the opposite of a plain
1131   `spawn`), because it starts a Node service process that then rejects the shell's own switches.
1132
1133None of this carries over to Tauri: the shell starts the host as an ordinary child process with an
1134explicit Node binary, so there is no archive-internal entry point and no carrier-specific runtime
1135mode. The Tauri build is verified in §1.6a.
1136
1137### 3.4 `ELECTRON_RUN_AS_NODE` (superseded carrier — kept for the record)
1138
1139With the Electron carrier, a launching shell that exported `ELECTRON_RUN_AS_NODE=1` (easy to
1140inherit after running the App Host's Node) turned Electron into plain Node *before* `main.cjs`
1141loaded, so `require('electron')` yielded the npm shim and the app died with
1142`Cannot read properties of undefined (reading 'requestSingleInstanceLock')`. It could not be undone
1143from user code. This no longer applies now that the carrier is Tauri, but the general lesson holds
1144for any future child-process work: **do not inherit a runtime-mode variable into a spawned
1145runtime.**
1146
1147### 3.4b ~~The terminal distribution has no bundled runtime~~ — **RESOLVED**
1148
1149`release/artifacts/strata-terminal-0.1.44.1-darwin-arm64.tar.gz` (42 MB, sha256
1150`fafa0076fd30f9fa3d3f1250d8afbf39225bddb80e07a3d818bae2b01e2814d8`, 42480892 bytes) is a **self-contained** terminal distribution: it carries a pinned standalone CPython
11513.12.15 and its runtime dependencies, so a user needs no Python, pip, Node, compiler or checkout.
1152
1153Built reproducibly by `packaging/package_terminal.py`, which:
1154
1155* downloads the same pinned interpreter `setup.sh` uses and **refuses to package it if the SHA-256
1156  does not match** — one pin, two consumers, so the terminal and the installer cannot drift;
1157* installs `requirements.txt` *into* that interpreter;
1158* ships the application and only the `tools/` modules the terminal paths import, keeping engine
1159  installation and preparation code out of the serving import graph;
1160* deliberately excludes the engine (a separate, independently versioned component), model weights,
1161  prepared data and the UI;
1162* writes a manifest next to the archive with the bundle and interpreter digests.
1163
1164**Verified as a clean user would experience it**: extracted to an unrelated path, moved *again* to a
1165different path, and run with `env -i PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME=/Users/nikoveit`. The only
1166Python on that PATH is macOS's own 3.9, which the launcher correctly rejects as below the 3.10 floor
1167— so everything below ran on the **bundled** interpreter:
1168
1169| Command | Result |
1170| --- | --- |
1171| `./bin/strata --help` | the full command set, including `timeskip` and `tune` |
1172| `./bin/strata status --url <dead>` | exit **3**, the documented "control unreachable" code |
1173| `./bin/strata timeskip list` | `{"schema_version":1,"ok":true,"runs":[]}` |
1174| `./bin/strata tune plan --engine <metal>` | read the real engine's flags and planned the sweep |
1175| `./python/bin/python3 -m serve.server --engine mock` | `/health` ok, a chat completion returned, and the bundled CLI showed it LIVE |
1176
1177That last row is also the R02 evidence asked for: pure serving ran with **no agent runtime, no
1178Tuning packages, no Textual and no UI present**. The import graph of `serve/` remains stdlib plus
1179relative `serve.*` modules, verified both by inspection and by importing
1180`strata_control.management` and `strata_cli.cli` on a bare interpreter.
1181
1182One defect was found and fixed by this test: the launcher looked for the bundled runtime at
1183`/python/bin/python3` while the distribution puts it at `/../python/bin/python3`. That
1184failure is *silent* — the launcher simply falls through to whatever Python is on PATH and the bundle
1185quietly stops being self-contained — which is exactly why the clean-environment test exists.
1186
1187**Evidence:** `docs/work/evidence/terminal-dist.txt`.
1188
1189### 3.5 Not yet done
1190
1191* **Fix §3.3**, then produce the DMG (`npm run package:mac:unsigned`).
1192* App Host ↔ Harness Gateway bridge (the vertical slice's agent half).
1193* Time-skip: replace the scripted 28-second flow with a real checkpoint/candidate/check/decision
1194  state machine (S01–S05).
1195* Tuning: the Strata job contract plus a bounded search adapter, and a HyperCore-Tune evaluation
1196  (T01–T08).
1197* Acquisition/component/update ownership per M3 (the reuse contract: app-only update transfers
1198  zero engine/model bytes).
1199* Windows and Linux package preparation (installer and AppImage recipes, dependency locks,
1200  Windows named-pipe owner transport — none of which exists upstream yet).
1201
1202---
1203
1204## 4. Next actions (ordered)
1205
12061. Build the App Host bridge onto the Harness Gateway (`integrations/harness/`), proving:
1207   prompt → stream → tool approval/denial → per-run cancel → persisted session → terminal resume
1208   without replaying completed tool effects (A01–A08). Use a stub OpenAI-compatible endpoint for
1209   the model-independent contract tests; the real-model leg belongs to Phase B.
12102. Give the Host a **server-side tool executor** so `useTools` is real rather than a UI affordance,
1211   with the approval policy in the backend (A03/A04), and prove a denial never executes.
12123. Replace Time-skip's scripted flow (S01–S05).
12134. Implement the tuning job contract with a Strata-owned bounded search adapter and evaluate
1214   HyperCore-Tune against it (T01–T08).
12155. Windows/Linux packaging recipes and dependency locks.
12166. Signing/notarization and a compiled `.icns` from the supplied brand masters (blocked on owner
1217   credentials and font/asset redistribution evidence — D04/D05).
1218
1219---
1220
1221## 5. Phase B qualification kit
1222
1223Written: **[QUALIFICATION-KIT.md](QUALIFICATION-KIT.md)** — prerequisites, exact commands,
1224assertions with requirement IDs, the result-record template, and the evidence rules.
1225
1226**Headline prerequisite** (from §3.2): an Apple Silicon Mac with macOS ≥15 and either ≥64 GiB
1227unified memory and ≥200 GiB free disk for a resident pack, or ≥32 GiB accepting the SSD-streaming
1228path. This development Mac (16 GiB, ~22 GiB free) is below the tested floor.
1229
1230---
1231
1232## 6. Reproducing everything in §1 from scratch
1233
1234```sh
1235ROOT=/Users/nikoveit/Documents/deepseek-harness/strata-work
1236cd "$ROOT/strata-rebuild"
1237
1238# 1. Engine (needs the toolchain venv, llama.cpp at the pin, metal-cpp)
1239"$ROOT/toolchain/venv/bin/cmake" -S metal -B build-metal -G Ninja -DCMAKE_BUILD_TYPE=Release \
1240  -DCMAKE_MAKE_PROGRAM="$ROOT/toolchain/venv/bin/ninja" \
1241  -DMETAL_CPP_DIR="$ROOT/toolchain/metal-cpp" \
1242  -DSTRATA_GGML_DIR="$ROOT/toolchain/llama.cpp"
1243"$ROOT/toolchain/venv/bin/ninja" -C build-metal strata -j 6
1244./build-metal/strata --version
1245
1246# 2. Metal kernel parity (no model needed)
1247"$ROOT/toolchain/venv/bin/cmake" -S metal -B build-metal-kern -G Ninja \
1248  -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="$ROOT/toolchain/venv/bin/ninja" \
1249  -DSTRATA_METAL_ENGINE=OFF
1250"$ROOT/toolchain/venv/bin/ninja" -C build-metal-kern -j 8
1251for t in gemv_parity mma_parity dense_mm_parity expert_parity gdn_parity gdn_prompt_parity \
1252         qsa_parity qsa_prompt_parity prompt_parity gr_parity gr2_parity fuse_parity \
1253         pair_parity route_parity sample_parity arena_budget_test coop_layout; do
1254  ./build-metal-kern/$t > /dev/null || echo "FAILED: $t"
1255done
1256
1257# 3. Python suites (need the python311 venv with jinja2 regex pyyaml tqdm requests pillow psutil numpy textual rich)
1258"$ROOT/python311/bin/python" -m unittest discover -s tests/terminal -t tests/terminal -p 'test_*.py'
1259"$ROOT/python311/bin/python" -m unittest discover -s serve -p 'test_*.py'
1260```