Skip to content

fix(plugin): restore the no-../src deployment contract — lazy widget-helper import (#995) - #997

Draft
aarontrowbridge wants to merge 1 commit into
mainfrom
995-plugin-src-import-contract
Draft

fix(plugin): restore the no-../src deployment contract — lazy widget-helper import (#995)#997
aarontrowbridge wants to merge 1 commit into
mainfrom
995-plugin-src-import-contract

Conversation

@aarontrowbridge

Copy link
Copy Markdown
Member

Important

Problem — The opencode plugin that serves the entire amicode_* tool pack statically imported the widget-authoring helper from the extension service source tree. The plugin directory's own deployment contract (carried as comments by calib_chain, regime_priors, rehearsal) is "never anything from ../src/": trimmed deployments — the hub service bundle — ship only the plugin directory. The static import therefore killed module init on the hub, silently (the service runner captures engine stderr in memory and emits it only on health failure), and every amicode_* tool vanished from hub-served sessions with this morning's 04:31 bundle deployment — including amicode_session, the "spool a fresh session" verb that surfaced this.

Approach — Replace the static import with a lazy, fail-soft dynamic import inside the widget tool's execute: module init survives everywhere; where the helper is absent, that ONE tool returns an honest refusal (nothing written — the engine's built-in widget tool and the MCP transport carry authoring on those surfaces) and the rest of the pack stays registered. A floor test now scans the plugin directory for static parent-relative imports, so the contract is enforced by the suite instead of comments. Tool names/descriptions/args are untouched (core/plugin parity stays byte-pinned).

Acceptance Criteria

  • Zero static parent-relative imports across the plugin dir — floor test in the suite
  • The widget tool still authors widgets end-to-end where the helper is present (the MCP floor: carry the widget-authoring tool (fork-registry delta) #799 e2e now exercises the lazy path — green)
  • Targeted suites green locally (tools core + parity, MCP round-trip, session spawn, warrant parity: 50/50)
  • CI green

Verification honesty

pnpm --filter amicode test locally on this box carries pre-existing red in service/auth/overlay-seam tests (they bind ports that collide with the live hub on this machine) — identical failures on a clean main worktree, and CI's fast lane passes for a clean tree (PR #990's current run is all-green), so CI is the arbiter.

Notes

Two follow-up seams discovered during diagnosis, deliberately out of scope: (1) the service runner swallows engine stderr on healthy boots (engineLog is in-memory, emitted only on health failure) — that silence is why a whole tool pack could vanish unnoticed; (2) the MCP transport's session tool refuses by design (no in-process engine client) — an HTTP fallback would make the spawn verb work on every surface. Also observed: the fast suite mutates packages/app-bundle/overlay/** in the working tree as a side effect of running it (reproduced in a fresh worktree) — worth its own issue.

Closes #995

…helper import (#995)

The #799 widget twin statically imported the widget-authoring helper from
../src — the one edge the plugin dir's deployment contract forbids ('never
anything from ../src/', the clause calib_chain/regime_priors/rehearsal
carry): trimmed deployments ship only the plugin dir, so module init died
at load and EVERY amicode_* tool vanished from hub sessions (2026-09-10,
silent — the service runner captures engine stderr in memory on healthy
boots). The lazy fail-soft form keeps module init whole everywhere; where
the helper is absent the one widget tool refuses honestly (the engine
builtin carries authoring on those surfaces) and the rest of the pack
stays registered. A floor test now scans the plugin dir for static
parent-relative imports so the contract is enforced by the suite.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Static ../src import in the opencode plugin kills the whole amicode_* tool pack on trimmed deployments (hub sessions)

1 participant