Skip to content

mcpx plugin: stamp the generated ops with the API table hash and refuse to run on a stale copy #4811

Closed

Description

@dezren39

Drew (2026-11-03): 'a stale type hint is worse than not having one.' The generated plugin ops (pkgs/mcpx/plugin/opencode/mcpx/ops.gen.ts) are type hints the plugin codes against. When they drift from the daemon's real /v1 table (as in #4806), everything still type-checks and reviews fine — the types lie with confidence, and the failure only surfaces at runtime against the real API, or worse, a renamed/dropped operation is called wrongly. An untyped surface would at least be honestly dynamic.\n\n#4807 makes nix builds regenerate the file in preCheck, so nix artifacts always carry true types. What remains: from-checkout consumers (code's .opencode/plugin, editor type-checking) can still load a stale copy silently.\n\nProposal: PluginTS() emits a stamp in the generated file — a hash of the /v1 operation table plus the mcpx version. The plugin's daemon client compares the stamp against the daemon's self-reported table hash at connect time and REFUSES (clear error: regenerate or update the plugin) on mismatch, instead of calling through stale types. Needs the daemon to report its table hash (a /v1 metadata field or a field on the existing version/doctor surface). Acceptance: with a deliberately stale ops.gen.ts, the plugin fails loudly at startup with the mismatch named; with a fresh one, it connects as today.

Activity

  1. added
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 3, 2026
  2. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: triaged (coverage pass)
    Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 30 (priority/none). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
    Found via: coverage pass 2026-11-03

  3. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 3, 2026
  4. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  5. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: picked_up
    task: 8436 (repo-health-code-pilot; OpenChamber scheduled lane aea12c82-c5af-4e5a-9b66-f8e360f87177)
    state: picked up by atomic claim.
    verified: Fresh GitHub state: issue #4811 OPEN; no held, user/owned, do-not-merge, or do-not-auto-edit labels. Related #4806 is CLOSED and #4807 is MERGED. No open PR matching #4811 found.
    next: inspect current main's generated ops and daemon API metadata, confirm whether the proposed table-hash freshness guard remains a distinct fix, then post triage findings and route a follow-up if warranted.

  6. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: triage-findings
    task: 8436 (repo-health-code-pilot; OpenChamber scheduled lane aea12c82-c5af-4e5a-9b66-f8e360f87177)

    Triage — confirmed live on current main (dda1def97)

    The proposal remains a distinct gap after #4806/#4807:

    Route: one focused small-fix follow-up: derive a deterministic fingerprint from the canonical api.Ops() table, embed the expected value in generated ops.gen.ts, expose the daemon's value through health/status, and check it before the plugin uses generated operations. Fail closed with an actionable mismatch message (including the missing-hash/older-daemon case); preserve operation behavior when hashes match. Cover deterministic generation, match, mismatch, and unavailable hash with tests. No unrelated API/schema cleanup.

    Ordering: the shared Go API table/hash and daemon metadata should land before or alongside the generated plugin stamp and startup guard in the same focused change; regeneration follows any change to the table. CI should verify Go API/plugin generation tests and the targeted plugin tests. This is actionable without a Drew-only decision.

  7. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: handed_off
    task: 8436 (repo-health-code-pilot; OpenChamber scheduled lane aea12c82-c5af-4e5a-9b66-f8e360f87177)
    state: triaged; runtime stale-operation-table gap remains after #4807.
    verified: current main dda1def has no table hash in PluginTS output or /v1 health/status; connect does no compatibility check. Issue #4811 remains OPEN, no matching PR.
    route: queued focused small-fix task 8772 (priority 30) to hash canonical api.Ops(), stamp generated ops.gen.ts, expose the daemon fingerprint and fail closed with an actionable message on mismatch/unavailable hash. Includes generator, daemon and plugin tests; no unrelated cleanup.
    next: task 8772 implements and verifies the scoped guard. Triage findings are in the preceding comment.
    Links: #4811 · #4806 · #4807

  8. 91 remaining items

  9. added
    work/assignedQueue worker lifecycle state
    and removed on Nov 7, 2026
  10. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor

    🤖 Agent note · picked up

  11. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor

    Progress from repo-worker-code-k: verified ALREADY DONE on current main f235cef: PluginTS emits OPERATION_FINGERPRINT into ops.gen.ts (line 23), daemon health reports operationFingerprint (internal/daemon/server.go:920,931), plugin verifyOperationCompatibility() throws on mismatch/missing (daemon.ts:425-435), tests cover match/differ/no-fingerprint (daemon.test.ts:136-154). Implementing commit 5d081e4 on branch queue/8772-4811-plugin-table-hash (this issue's own broker task 8772). Next: post evidence, close, release done.

  12. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor

    Triage — issue #4811: ALREADY DONE on current main; closing with evidence (fallback-mode triage, lane code-k, 2026-11-07)

    Verdict: the proposal was implemented in full by PR #5320 ("mcpx: fingerprint generated operations and reject stale plugin tables", merged 2026-11-05T01:54:57Z, branch queue/8772-4811-plugin-table-hash — this issue's own broker task 8772). The issue stayed open only because the closing bookkeeping never landed (its later comments are claim-evaporation repairs re-handing-off a finished task). Verified piece by piece against current main (f235cef8), not from the PR title:

    Acceptance, item by item

    • Stamp in the generated file: PluginTS() (pkgs/mcpx/internal/api/plugin_ts.go:105) emits export const OPERATION_FINGERPRINT = "…" — a SHA-256 over the marshaled operation-fingerprint contract (OperationFingerprint(), plugin_ts.go:34). Present in the generated file itself: pkgs/mcpx/plugin/opencode/mcpx/ops.gen.ts:23 (0ac07ddb… at current main). This is the proposal's "hash of the /v1 operation table" (fingerprint of the request/response contract — strictly better than a raw table hash, since it changes exactly when the contract changes).
    • Daemon reports it: the daemon's health surface includes "operationFingerprint": api.OperationFingerprint() (pkgs/mcpx/internal/daemon/server.go:920 and :931) — the proposal's "/v1 metadata field on the existing version/doctor surface" (here: health).
    • Plugin refuses on mismatch, at connect time: DaemonClient.verifyOperationCompatibility() (pkgs/mcpx/plugin/opencode/mcpx/daemon.ts:425–435) fetches health before generated operations run and throws mcpx: /v1 operation table mismatch (plugin <fp>, daemon <fp>); update the mcpx plugin and daemon from matching versions on a differing fingerprint — and fails closed with an equally explicit error when the daemon publishes no fingerprint (older daemon) or does not answer. A deliberately stale ops.gen.ts carries a different fingerprint by construction, so the acceptance scenario ("fails loudly at startup with the mismatch named") is exactly the implemented behavior.
    • Tests name the acceptance cases: pkgs/mcpx/plugin/opencode/mcpx/daemon.test.ts, describe "generated operation compatibility": "allows operations when the daemon table fingerprint matches" (:136), "refuses generated operations when the daemon table fingerprint differs" (:145), "fails closed when an older daemon has no operation fingerprint" (:154). Implementing commit 5d081e4c20 ("fix(mcpx): validate generated ops against daemon table") touched exactly the six files the proposal spans (generator, daemon server, plugin client, tests, generated file).
    • Prerequisites stand as the issue describes: mcpx: plugin/opencode/mcpx/ops.gen.ts is stale — TestPluginOpsAreGenerated fails on main #4806 (stale-file failure) is CLOSED; mcpx: regenerate ops.gen.ts + generate it during the nix build #4807 (regenerate + nix preCheck generation) is MERGED — the from-checkout consumer was the remaining gap, and it is the gap PR mcpx: fingerprint generated operations and reject stale plugin tables #5320 closed.

    No follow-up work is owed. Closing as already done.

  13. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor

    🤖 Agent note · done (triage verdict: ALREADY DONE — PR #5320)

    • Agent: queue worker (repo-worker-code), lane code-k — FALLBACK MODE (queue backend down; fallback claim markers on this issue are the claim of record)
    • Session / ID: cron repo-queue-worker-shift-k run 2026-11-06 21:13 CST; fallback worker id repo-worker-code-k (issue mcpx plugin: stamp the generated ops with the API table hash and refuse to run on a stale copy #4811 is the task in fallback mode)
    • Found via: fallback scan (queue/queued, scan order)
    • Outcome: triaged — the OPERATION_FINGERPRINT stamp, daemon health reporting, plugin connect-time refusal, and the three acceptance-named tests are all present on current main, delivered by PR mcpx: fingerprint generated operations and reject stale plugin tables #5320 (merged 2026-11-05, this issue's own task 8772 branch). Evidence comment on this issue, item by item with file:line. Closing as already done; no follow-up owed.
  14. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor

    Released by repo-worker-code-k (outcome: done). Triaged ALREADY DONE: issue #4811 was implemented in full by PR #5320 (merged 2026-11-05, branch queue/8772-4811-plugin-table-hash) - OPERATION_FINGERPRINT stamp in ops.gen.ts, daemon health operationFingerprint, plugin verifyOperationCompatibility refusal, acceptance-named tests; verified item-by-item on current main f235cef with file:line evidence on the issue. Issue closed; no follow-up owed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions