Repository navigation
feat: add pluggable local inference backends - #25
Conversation
d2b006f to
22f393d
Compare
Load trusted provider plugins through the DSH host without bundling runtimes into Core, add oMLX and Anthropic adapters, and make configuration and gateway lifecycles reversible. Run product tests in a disposable offline Docker boundary and harden CI, generated bindings, diagnostics, and host-state isolation.
22f393d to
8b12a0a
Compare
CodeQL: 7 new alerts, all in the committed bundle — needs a policy callThe Zero are in any workspace
Verified by grepping the identifiers against Why it appears nowThis is new because the branch commits The bundle is not optional: Why I did not just fix itADR-0001 says rule-wide exclusions belong in Options
Flagging rather than choosing — this is a security-policy decision. |
…t suppressed Committing `packages/maximal-core/dist/` makes every bundled dependency's source into repo content that CodeQL analyzes as if we wrote it. Seven alerts on #25 are entirely that: execa's escapedCommand formatter, turndown's markdown link escaping, and hono's RFC 6265 cookie charset. ADR-0001 prescribes inline `// codeql[...]` for by-design alerts, and that mechanism cannot reach here -- the bundle is regenerated from node_modules on every Core build, so a hand-added comment is erased and `bindings:check` then fails on the diff. Its `query-filters` fallback has nowhere to live either: monimal runs CodeQL default setup, which reads no in-repo config, and the ADR's `links.codeql_config` pointer is inherited from the maximal repo and dead here. So the alerts are dismissed per-alert and the rationale lives in the tree, which is what the ADR's original Context asked for. Records the per-alert assessment, why the two existing mechanisms don't apply, and the advanced-setup `paths-ignore` escape hatch that is deliberately not taken.
CodeQL: investigated, decision recorded, dismissals pendingAll seven alerts are third-party code inside
Why this branch and not main
Why dismissal, and not one of ADR-0001's mechanisms
e97fe74 records all of the above as an amendment to maximal-core ADR-0001, so the What still needs doingThe seven dismissals themselves. They are a |
The bundle was force-added so that `bun add github:stuffbucket/maximal-core` yields a working `maximal` command with no toolchain: `bin` points at the committed bytes, and Bun's installer blocks dependency lifecycle scripts, so an install-time build leaves a dangling symlink. That reasoning is sound and it belongs to the standalone maximal-core repo. It does not reach monimal — the package sits at packages/maximal-core/, and no package manager's git specifier addresses a subdirectory, so the install path it exists to serve cannot be exercised against this repo at all. The commits check-bindings.ts cites as the decision's origin, f79f7b6 and d607485, are not in this repository's history. monimal had already taken this position once. SOURCES.md records that `build` was extended with `build:lib` "so the subpath exports in its `exports` map resolve without committing `dist/lib`", and maximal-electron dropped its own committed dist. maximal-core was the last package in the workspace carrying one: 46 files, 95,509 lines, 7.4 MB, roughly 5 MB of it gpt-tokenizer BPE tables. Nothing ever verified against it. `.dockerignore` excludes dist, and the image build runs `turbo run build`, so the container suite has always tested a freshly built bundle rather than the committed one. Retires `bindings:check`, which compared a committed copy against a fresh build and has nothing left to compare. `scripts/ops/check-bindings.ts` itself stays: nine modules import ARTIFACTS, MAIN_BUILD_ARGV, GitRunner and realGit from it. Publishing is unchanged. `files`, `exports` and `bin` still name dist/, and `prepack` builds into it before packing, so the GitHub Package Registry path is untouched. This also removes the seven CodeQL alerts on this PR at the source rather than dismissing them. All were third-party code the bundler had inlined — execa's escapedCommand formatter, turndown's markdown link escaping, hono's RFC 6265 cookie charset — and none was in a workspace src/. ADR-0001's amendment now records that, in place of the dismissal policy it briefly carried.
Resolved — superseding the dismissal plan aboveBoth earlier comments asked for seven alerts to be dismissed. Don't; that is no The seven alerts existed only because this branch committed
Result — all seven alerts closed as Every check is green. Verified before push: Still open and unrelated: #28 (three CodeQL alerts on |
What this adds
Pluggable local inference backends, loaded as trusted external plugins rather than compiled into the engine.
packages/maximal-provider-contract— side-effect-free HTTP gateway contract. Core depends on this and nothing else.packages/maximal-dsh-host— generic in-process DeepSeek Harness (DSH) host that loads Cordis/DSH plugins from a user-managed profile directory.packages/anthropic-provider,packages/omlx— independently installable stock adapters.packages/llama-server— private descriptor scaffold, deliberately separate frommaximal-electron's embeddednode-llama-cpputility process.Rollout is reversible: the built-in Anthropic passthrough stays the default
legacymode;dshmode is opt-in viaproviderHost.mode. Maximal never installs, upgrades, or rewrites profile packages. Composition is documented inpackages/maximal/docs/provider-profiles.md.Cordis supplies plugin lifecycle and dependency scoping — it is not a security boundary. Every package in a provider profile is trusted in-process code with Maximal's full filesystem, network, environment, and OS-user authority. That is stated in the docs rather than implied.
Also in scope: the workspace test graph moves behind a mountless, offline Docker boundary (
pnpm test,docs/testing-in-docker.md) — no bind mount, no Docker socket, no forwarded host environment,--network=none, non-root, with host-state canaries verified after each run.scripts/verify-workspace.mjsgains check 7, asserting provider package dependency boundaries so a concrete adapter can never be compiled into Core, the DSH host, or the composition root.Resync with main
Rebased onto
62572b9. Three conflicts needed hand resolution:untrusted-framemove. This branch movessrc/routes/untrusted-frame.tstosrc/lib/http/untrusted-frame.ts;62572b9landed a new importer of the old path inroutes/responses/handler.ts. Git's rename detection carried it — verified zero remaining references to~/routes/untrusted-frame, and all importers resolve to the new path.scripts/verify-workspace.mjs. Both sides added a check numbered 7. Kept this branch's provider-architecture check as 7 and took main's newer header text for the lockfile check, now 8. Sections renumber cleanly 1–9.packages/maximal-core/package.json. Took main's dependabot pins (@hono/zod-openapi1.6.0,citty^0.2.2) alongside this branch's new@stuffbucket/maximal-provider-contractworkspace dep.The lockfile was regenerated from the merged manifests rather than hand-merged: +234 lines, exactly the five new importer entries, no churn elsewhere.
packages/maximal-core/dist/is no longer committed (fdc8cb3). It was force-added here to servebun add github:stuffbucket/maximal-core, an install path that belongs to the standalone repo — monimal's copy sits atpackages/maximal-core/, and no package manager's git specifier addresses a subdirectory.SOURCES.mdhad already recorded the monorepo's position, andmaximal-electronhad already dropped its own. 46 files, 95,509 lines, 7.4 MB removed;bindings:checkretired with them.Fixed during the rebase
Four defects that only surface once the branch meets main's newer pins and a real CI run:
.github/workflows/ci.yml— this branch replacedpnpm run checkwith a bareturbo run build typecheck lint.turbois a root devDependency and is not onPATHin a workflowrun:block, so the step died withexit 127before anything ran. Nowpnpm exec turbo ..., matching every other step in the file.packages/maximal-core/scripts/ops/check-ci-coverage.ts— the fix above then trippedci:check, whoserunsTurboTaskonly accepted a command starting literally withturbo run. That matcher is why the workflow used the bare form in the first place. It now unwraps apnpm execprefix, which is a direct invocation, while still failing closed on shell composition. Covered by new cases in its own test, including thatpnpm run,pnpm dlx,npx, andpnpm exec echoare not accepted.packages/maximal-core/tests/cli-composition.test.ts— the branch's new test built aParsedArgsfixture against citty^0.1.6. Taking main's^0.2.2means the type also requires the alias keys (p,v,a,r,w,g,c); added them.turbo.json—lintdepended only ontopo, so type-aware rules raced the build.packages/maximal/src/provider-gateway.tsimports types from@stuffbucket/maximal-provider-contractand@stuffbucket/maximal-dsh-host, neither of which commits build output, so on a cold checkout lint saw unresolved types and emittedno-unsafe-*errors.lintnow carries the same^builddependencytypecheckalready had. Verified this is still required with Core'sdist/present: 53 errors without it.Verification
Full graph in the container boundary — 15/15 tasks, exit 0, 0 failures:
maximal-coremaximalmaximal-electronmaximal-clientmaximal-dsh-hostanthropic-provideromlxmaximal-sitemaximal-provider-contractllama-serverturbo run build typecheck lint— 29/29, exit 0, from a cold state (nodist/for the new packages, no turbo cache) so the lint ordering fix is actually exercised.check:deep:host— exit 0, includingcasts:check,knip,deps:check,dupes:check,ci:check, andtypecheck:downstream.verify:workspace— 14 assertions over 2700 things, 0 failed.Note for reviewers running this locally
pnpm testmay fail on a warm checkout withERR_PNPM_TARBALL_URL_MISMATCH. Anypnpm run <script>re-resolves and writes ~1610 rotatingms-feed-Nshard hosts intopnpm-lock.yamlbefore the script body runs; the Docker context then carries that poisoned lockfile into a--frozen-lockfileinstall that rejects it.This is pre-existing environment behavior, not introduced here — main reproduces it identically (1602 entries) and its CI is green. The new harness just turns previously-invisible local churn into a hard failure, because it copies the working tree into the build context. Tracked in #26.
Workaround that produced the green runs above:
node scripts/strip-lockfile-hosts.mjs && node scripts/docker-test.mjsInvoking the harness directly skips pnpm's pre-run re-resolution and keeps the context clean.