Skip to content

fix(runtime): bundle engine daemon for packed consumers - #218

Merged
Looted merged 4 commits into
developfrom
fix/runtime-packed-engine-daemon
Aug 21, 2026
Merged

fix(runtime): bundle engine daemon for packed consumers#218
Looted merged 4 commits into
developfrom
fix/runtime-packed-engine-daemon

Conversation

@Looted

@Looted Looted commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Problem

First-party MCP hosts that install the published-shaped packages under pnpm isolated mode (or any layout without a nested kibi-cli) fail on first engine use:

Error: The Kibi engine is not built. Run `npm run build:cli` before using the CLI engine.

Root cause: the runtime bundle inlines kibi-cli/operations code, including EngineClient and its daemonEntry() lookup. That lookup checks:

  1. <runtime>/dist/engine-daemon.js — never shipped
  2. <runtime>/dist/../dist/engine-daemon.js — same path
  3. <runtime>/node_modules/kibi-cli/dist/engine-daemon.js — only resolves in the kibi monorepo workspace

Published consumers have none of these, so EngineClient.start() always throws.

Fix

The kibi-runtime build now also bundles packages/cli/src/engine-daemon.ts into dist/engine-daemon.js (--packages bundle --external kibi-core, same strategy as the existing index bundle). Candidate 1 then resolves in every consumer shape with no new dependencies and no lookup changes.

Verification

  • Built runtime; spawned the bundled daemon against a real workspace: socket created, branch KB attached, kb_storage_status/1 query returns success.
  • Packed kibi-runtime + kibi-core tarballs, installed them into a clean npm prefix, and ran EngineClient from the installed tree: daemon auto-starts and serves queries.
  • Reproduced the original failure with the previous tarball to confirm the before/after.

Notes

  • Includes a patch changeset for kibi-runtime.
  • No changes to lookup order, CLI package, or protocol.

Looted added 2 commits August 21, 2026 11:17
The runtime bundle inlines kibi-cli operation code whose daemon lookup
expects engine-daemon.js beside the bundle or under a nested kibi-cli
install. Published-shaped installs have neither, so first-party MCP
hosts failed with "The Kibi engine is not built" on first engine use.

Bundle packages/cli/src/engine-daemon.ts into runtime dist so the
existing lookup resolves without adding dependencies.
Give the bundled engine daemon fix the full Kibi chain:

- REQ-runtime-packed-engine-daemon with two advisor-grounded predicate
  facts (kibi.runtime logical_requirement_rule lane)
- SCEN + TEST-runtime-packed-engine-daemon with a consumer-perspective
  verification contract registered in the proof registry
- Packed E2E test installing published tarballs into a clean prefix and
  starting EngineClient from the installed kibi-runtime, proving daemon
  resolution and typed query service without a nested kibi-cli
- Config-granularity production symbol (implements + covered_by) and
  behavioral test symbol (executable_for) with fresh coordinates

Also repair REQ-kibi-verification-evidence-contract ingestion: the
advisor now segments its second sentence as one proposition
(CLAIM-6C829C8424C2387C), so merge the two stale grounding facts into
FACT-REQ-PROOF-VERIFICATION-NON-PROOF-OUTCOMES and refresh the
inventory contract; this unblocks sync for every branch.

Local run: proof contract passed and REQ-runtime-packed-engine-daemon
reports proofStatus=proven with all nine stages green.
@Looted

Looted commented Aug 21, 2026

Copy link
Copy Markdown
Owner Author

CI triage: the red Kibi strict requirement proof job is inherited from develop, not caused by this branch. The same workflow fails on develop's last three pushes (run 32443928265, 32408967719, 32379293691); the last success predates the two requirements added after the baseline ratchet in 45e4881 (proof/baseline.json expects 91 requirements / ≤70 unproven; the branch compiles 93 / 71). This branch's own commit only touches packages/runtime/package.json + a changeset, and all other checks (build-and-test, packed-e2e, publish-dry-run) pass.

Also pushed b18aa02, which gives the fix full Kibi traceability and proof:

  • REQ-runtime-packed-engine-daemon → SCEN → TEST-runtime-packed-engine-daemon with both normative clauses grounded as kibi.runtime predicate facts
  • New packed E2E (documentation/tests/e2e/packed/runtime-engine-daemon.test.ts) that installs the published tarballs into a clean prefix and starts EngineClient from the installed runtime — proving daemon resolution + typed query service without a nested kibi-cli
  • Contract registered in proof/verification-registry.json; local contract run passes and coverage reports the requirement proven (all nine stages green)
  • Repairs REQ-kibi-verification-evidence-contract ingestion (stale proposition segmentation) which was blocking kibi sync on every branch

Looted added 2 commits August 21, 2026 15:17
…itted advisor

The previous commit repaired this requirement against a local CLI build
carrying uncommitted semantic-advisor changes that segment the second
sentence as one proposition. The committed advisor still produces three
propositions (CLAIM-B82AFD45D25355EB, CLAIM-1A610F01C3FDD6FD,
CLAIM-B605A89256E0CEF1), so CI sync failed on the repaired file.

Restore the original inventory and grounding facts; drop
FACT-REQ-PROOF-VERIFICATION-NON-PROOF-OUTCOMES. The re-segmentation
repair belongs with the advisor change that introduces it.
…-engine-daemon

# Conflicts:
#	.kb/symbol-coordinates.yaml
#	.kb/symbols.yaml
#	.kb/tests/TEST-runtime-packed-engine-daemon.md
#	documentation/tests/e2e/packed/runtime-engine-daemon.test.ts
#	proof/verification-registry.json
@Looted

Looted commented Aug 21, 2026

Copy link
Copy Markdown
Owner Author

Consolidation update (4fa9901c): merged develop and resolved all conflicts.

  • Took develop's refined copies of the shared files (hardened packed test with KIBI_NODE_PATH/stop(false), receipt-free TEST source, registry, test-symbol entries).
  • Preserved the one piece develop had dropped: SYM-runtime-packed-daemon-build (config-granularity production symbol + coordinates + implements/covered_by shards) — without it the requirement loses production-symbol coverage.
  • Validated the merge locally under committed code: full sync clean, contract re-run passed, REQ-runtime-packed-engine-daemon proven with zero gaps, kb_check 0 violations.
  • PR diff vs develop is now just those 3 files / 35 lines; GitHub reports MERGEABLE.

Remaining CI reds on this branch are inherited from develop tip (run 32489557724): the same TEST-kibi-consumer-local-plugin-launcher-ontology-v1 contract failure and the baseline ratchet — both belong to the consolidation work as planned.

@Looted
Looted merged commit 3c340b0 into develop Aug 21, 2026
8 of 9 checks passed
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