Skip to content

refactor(build): consolidate zigts_expert_examples module registration (Unit C) - #10

Merged
srdjan merged 1 commit into
mainfrom
refactor/unit-c-examples-embedding
Apr 20, 2026
Merged

refactor(build): consolidate zigts_expert_examples module registration (Unit C)#10
srdjan merged 1 commit into
mainfrom
refactor/unit-c-examples-embedding

Conversation

@srdjan

@srdjan srdjan commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Moves zigts_expert_examples module declaration from root build.zig into packages/tools/build.zig, alongside the sibling zigts_expert_skill registration.
  • Root build.zig now pulls the module via pi_host_tools_dep.module("zigts_expert_examples"), matching the existing skill-module pattern.
  • Collapses the duplicate b.createModule that previously existed for pi_tests into a single shared declaration consumed by both pi_app_mod and pi_tests.
  • examples/data.zig stays in place so @embedFile("handler/handler.ts") and friends keep resolving. The new registration uses ../../examples/data.zig to reach the same file from packages/tools/.

Part of Batch 2 of the lockdown-first pi roadmap.

Test plan

  • zig build test-expert-app passes (exercises expert_persona.zig which imports both skill and examples modules)
  • zig build compiles cleanly
  • zig build test green (1433/1439 pass, 4 skipped, known flake feat(pi): session persister — entry-to-event mapping + capped writer (Batch 4 Unit 1) #15 on retry)
  • E2E: zigts expert prints registered tools and /meta returns compiler_version
  • grep -c "zigts_expert_examples" build.zig = 3 (all dep-pull / addImport, zero addModule)
  • grep -n "b.addModule.*zigts_expert_examples" packages/tools/build.zig yields exactly one match

Generated with Claude Code

…es/tools/build.zig (Unit C)

Unifies embedded-content module registration so both zigts_expert_skill
and zigts_expert_examples are declared in packages/tools/build.zig. Root
build.zig now pulls zigts_expert_examples via the same pi_host_tools_dep
pattern already used for the skill module, eliminating the duplicate
b.createModule call that existed for pi_tests.

examples/data.zig stays put so its @embedfile references keep resolving.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@srdjan
srdjan merged commit a110235 into main Apr 20, 2026
@srdjan
srdjan deleted the refactor/unit-c-examples-embedding branch April 20, 2026 12:56
srdjan added a commit that referenced this pull request Jun 8, 2026
Code-review cleanup follow-ups (#10, #11, #14) plus one fidelity fix (#2).

#10 - extract replayRecordedEntry(state, ctx, entry): the result-parse +
parse-failure divergence heuristic now has a single owner, shared by
makeReplayStub and makeReplayStubWithFallback instead of being copy-pasted.

#14 - add ReplayState.consumeHead(): the fallback trusts a prior peekMatches
and advances without re-checking bounds/names, dropping the redundant nextIO
re-scan and its dead orelse branch.

#2 - add ReplayState.hasEntryAhead(): when a pure call's recorded entry is not
at the head but exists further on, the fallback counts a divergence (structural
drift) before running real, so replay verification still fails closed; a
genuinely-new call with no recording stays silent. modules_all (entry at head)
and validate-external (no entries) are unaffected.

#11 - add trace.unescapeBody(allocator, body) -> {slice, owned}: test_runner
and replay_runner share it for request-body unescaping, replacing the
duplicated unescape-with-guarded-free idiom (the owned flag also retires the
misleading .ptr re-check).

New unit test covers consumeHead/hasEntryAhead. Verified: test-zigts, test-cli
(497), test-examples 23/23, test-zruntime clean; env exclusion and validate
passthrough intact.

Note: #4 (env fallback under restrictive policy) is already moot - env has
replay_pure=false and never falls through. #5 (matched-path arg checking) is
deferred: it needs the recorder's JSValue serializer extracted and reused for
byte-identical arg comparison, with real risk of false divergences against
existing fixtures; better as a dedicated, test-gated change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
srdjan added a commit that referenced this pull request Jun 28, 2026
…high #10/#13)

Two lower-severity cleanups from the xhigh review:

- pool.zig deinit ran an O(n^2) scan of all later slots for a duplicate
  publication on every shutdown. That case is a poisoned slot table that
  runtime-safety release() already rejects, so gate the scan behind
  std.debug.runtime_safety like the sibling poison checks: a release-build pool
  (esp. a large `-n N`) no longer pays N^2/2 atomic loads to guard an unchecked
  precondition.
- smt_solver tmpQueryPath keyed the query file only on pid, so it was not safe to
  parallelize the obligation loop (the natural optimization, since the z3 calls
  dominate runtime): two concurrent solve() calls would clobber one file. Add a
  monotonic per-call suffix so each query gets a unique path.

spec-check --audit green; pool and zigts-cli tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
srdjan added a commit that referenced this pull request Jul 12, 2026
#10 Cap a tool_result body at 32 KB before it enters the transcript, with a
marker pointing the model at a workspace_read_file range re-read. A single large
output (a full-file read, a long diagnostic blob) no longer inflates the input
token count of every subsequent roundtrip in the turn.

#12 Auto-compact after each RPC turn, mirroring the interactive REPL, so a
long-lived IDE session on the RPC surface never dead-ends on a PromptTooLong the
machine client cannot resolve with /compact. A notification is emitted when
compaction fires.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant