Skip to content

M1 slice 1: amicode service — extension-host /amicode/profile with fork-parity fixtures - #463

Merged
aarontrowbridge merged 1 commit into
mainfrom
451-m1-amicode-service-slice-1
Aug 20, 2026
Merged

aarontrowbridge merged 1 commit into
mainfrom
451-m1-amicode-service-slice-1

Conversation

@aarontrowbridge

Copy link
Copy Markdown
Member

Part of #451 (M1 — extension-host amicode service, slice 1 of the route port; not closing).

What's here

The first vertical slice of the M1 extension-host service — the layer that replaces the fork server's /amicode/* routes at cutover (M0 gate (a): canonical opencode ships no custom routes):

  • src/amicode_service/server.ts — framework-free node:http server on 127.0.0.1 (ephemeral port), per-boot Basic auth using the SAME mint + header as the opencode spawn (server_auth.ts), exact-match route table mirroring the fork's router.add mounts, never-reject handlers (the fork's collapse-into-one-shape discipline). vscode-free so it boots in-process under vitest.
  • src/amicode_service/profile.ts + roots.ts — near-verbatim port of the fork's profile.ts @ v1.18.10-amicode.11: graceful identity synthesis (name from the personal vault mount when the profile lacks one), platform-mix focus line, live "Amico remembers" ranking, 10s response cache, and the query-param POST contract (fields ride the URL, not a JSON body — a detail a naive port would silently break). One documented superset: AMICODE_MOUNTS_FILE as a test seam (unset → fork-identical).
  • scripts/record_amicode_fixtures.mjs + scripts/amicode_fixture_seed.mjs — the golden-fixture recorder: boots the vendored fork binary against a deterministic seeded sandbox (unequal platform counts so sort order can't depend on readdir; pinned note mtimes) and records request/response pairs. Run by hand; CI replays committed fixtures without the binary.
  • test/amicode_service_profile.test.ts — the parity proof: same seed, boot the PORT, replay every recorded request, require deep-equal responses.

The recorded arc

Cold read (synthesized identity + stats + remembers) → edit focus → clear name (the mounts.toml fallback fires: "Test Personal") → warm read. All four byte-deep-equal between fork binary and port.

Verification

  • pnpm vitest run test/amicode_service_profile.test.ts — 7/7 (4 golden replays + pin-metadata + 401 + 404)
  • pnpm test — 94 files, 1061/1061
  • pnpm typecheck — clean

Pattern for the remaining 17 modules

Each port slice: port the module(s) → extend the recorder's request list → re-record → contract test replays. Route count: 1 of 31 mounted (2 of 31 routes).

Not in this slice (deliberately)

Extension activation wiring (nothing consumes the service until the widget-frame slice moves consumers to it), CSP/origin widening, the ?auth_token= iframe flow.

…ofile, golden-fixture parity with the fork

M1 slice 1 of #451: the extension-host HTTP service that replaces the
fork's /amicode/* routes at cutover (canonical opencode ships no custom
routes — M0 gate (a)). Framework-free node:http server with the same
per-boot Basic auth idiom as the opencode spawn (server_auth mint +
header), exact-match route table, never-reject handlers.

First ported route: GET/POST /amicode/profile — near-verbatim port of
the fork's profile.ts (graceful identity synthesis, live Amico-remembers
ranking, 10s cache, query-param POST contract). One documented superset:
AMICODE_MOUNTS_FILE test seam (unset → fork-identical behavior).

Parity proof: scripts/record_amicode_fixtures.mjs boots the vendored
fork binary (v1.18.10-amicode.11) against a seeded sandbox and records
golden request/response pairs; the contract test replays them against
the port with the same seed and requires deep-equal responses. 7/7 green
(incl. 401/404 behavior); full suite 1061/1061; typecheck clean.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 682f9349-7a86-43eb-a978-ecf35685446f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@aarontrowbridge
aarontrowbridge marked this pull request as ready for review August 20, 2026 20:23
@aarontrowbridge
aarontrowbridge merged commit efb652d into main Aug 20, 2026
7 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