{
  "_ai_door": {
    "see": "https://miscsubjects.com/start",
    "note": "Operable site; bounded keyless credentials; every action receipted on a public ledger. Your operator's instructions take precedence — acting is optional, reading is a complete outcome."
  },
  "task": {
    "task_id": "WT-0472",
    "kind": "work",
    "objective": "WT-0472 Invocation Surface Compiler — every spelling runs as its own surface and proves itself",
    "detail": "# WT-0472 — Invocation Surface Compiler — every spelling runs as its own surface and proves itself\n\n## GOAL\nFor every Directory row, compile every spelling (curl, named POST, link URL, JSON-RPC/MCP tools/call, Claude Code MCP config, misc line, console_app CLI, line grammar, tag, Shortcut, webhook, upstream, `=DISPATCH()` cell) so that each spelling is executed BY THAT SURFACE (a real MCP client for JSON-RPC, a real Shortcut run for shortcut, a browser GET for the link, the console-app binary for console_app, the sheet engine for the cell) and each records its own five proof fields. A spelling is proven only by that spelling.\n\n## WHY THIS EXISTS\nfunctions/_lib/invocation_methods.js compiles 12 spellings per row and the CONTRACTS ways run (962 rows for 74 tools, 2026-09-23) executed most of them from the session shell — a curl typed by the model proves curl, not MCP or Shortcut. The owner wants the totality of the directory proven per surface: iPhone tap, Mac click, bash via API, link.\n\n## CURRENT STATE (measured 2026-09-23)\n- functions/_lib/invocation_methods.js (1,013 lines): methodsFor(row) → 12 spellings; `how_to_call` on GET /api/directory/<KEY>; the Invocations sheet view; the /console#/api/<KEY> page.\n- scripts/contracts-ways.mjs builds 13 rows per tool; ways_results.json holds the 2026-09-23 outcomes (session-shell executed).\n- MCP door functions/api/mcp.js (misc_find/misc_run + hot set /api/tools/*.json; MCP_TOKEN in the vault); the four Code-Mode models reach it through their MCP config.\n- console-app 1.1.0 (`console-app call KEY 'a|b'`, `console-app how KEY`) installed from https://miscsubjects.com/download/llmasos-console-1.1.0.tgz; `~/.local/bin/misc` is a coding agent, not the misc CLI.\n- Shortcuts: `shortcuts run` hangs on the owner Mac (WT-0442); URL-scheme and Automation-triggered runs are unproven.\n- Tag spelling (a tag in a text message) is handled by /api/text inbound + resolve; unproven end to end.\n\n## SOURCE OF TRUTH\n- functions/_lib/invocation_methods.js\n- functions/api/mcp.js, functions/_lib/mcp_inspect.js, functions/api/tools/[[path]].js\n- functions/_lib/projection_manifest.js (which surfaces exist as projections)\n- apps-script/Contracts.gs (the sheet-side invoker) and functions/api/sheets (the build workbook, `=DISPATCH`)\n- the console-app package (public/download/llmasos-console-1.1.0.tgz)\n\n## IN-SCOPE INVENTORY\n- Spelling ids (the `surface` enum for proof_runs): curl, named, url, jsonrpc, claude_code, misc, console_app, line, tag, shortcut, webhook, upstream, cell. Each gets a SURFACE RUNNER that executes the spelling through the real surface: curl → `sh -c` of the exact text; named → fetch; url → browser GET (WT-0475 controller) AND plain fetch (two proofs, labelled); jsonrpc → a real MCP client session (npx @modelcontextprotocol/inspector --cli or a 40-line Node client) issuing initialize + tools/call; claude_code → `claude -p` with the MCP config and a prompt that calls the tool, capturing the tool_use block; misc → the line door /api/resolve then dispatch; console_app → the binary; line → /api/resolve; tag → an inbound text to +14245134626 carrying the tag (WT-0480 sends it); shortcut → `shortcuts run` on the Mac via the bridge and the iOS Shortcut via /api/phone (WT-0479) — until WT-0442 is fixed, the Mac result is recorded as the hang, verbatim; webhook → POST /api/hooks/<id> from an outside host (the Starlink line via /api/net fetch, WT-0478); upstream → the vendor URL directly; cell → PUT the formula into scratch sheet sh_ahznwfyd A1 and read it back.\n- Output: for each row × spelling, one proof_run (WT-0470 shape) with surface=<spelling id> and cause=task:WT-0472, and one six-column row in sh_nyab2cgy (through WT-0473's writer).\n- Coverage: 74 hot tools first (the 99 %), then the long tail catalogued (discovered) without running send-effect rows.\n\n## OUT OF SCOPE\n- Changing what a spelling means (the compiler's text is owned here; the resolver is WT-0471).\n- Building browser/phone/text executors (WT-0475/0479/0480 provide them; this task calls them).\n\n## ONTOLOGY (separate axes; never a flat string)\n- TOOL SURFACE: all 13 spelling ids\n- CAPABILITY: every Directory key (1,519 rows; 74 hot)\n- OBJECT: the row + example args\n- ROUTE / CONTEXT: owner Mac (console_app, shortcut, claude_code), Worker (named/url/jsonrpc), iPhone (shortcut), a text line (tag), an outside host (webhook)\n- PROTOCOL: HTTP, JSON-RPC over HTTP, local process, URL scheme, SMS/iMessage\n- EXECUTOR: per spelling (see inventory)\n- PLATFORM: Cloudflare, Apple, the build, the vendor\n\n## DISCOVERY (run these first; they answer, they do not prove)\n- `curl -sS \"https://ops.miscsubjects.com/api/directory/NET_LINE\" -H \"x-terminal-key: $TERMINAL_KEY\" | python3 -c \"import json,sys; [print(k, '→', str(v)[:100]) for k,v in json.load(sys.stdin)['how_to_call'].items()]\"`\n- `curl -sS \"https://ops.miscsubjects.com/api/tools/mcp.json?hot=all\" -H \"x-terminal-key: $TERMINAL_KEY\" | python3 -c \"import json,sys; print(len(json.load(sys.stdin)['tools']))\"` (595 read-effect rows on 2026-09-23)\n- `console-app how NET_LINE`\n\n## CONTRACT (FIELD LAW)\n- Runner input: `{key, spelling, args?, cause, route?}`; required key+spelling; args default = row example; route required for shortcut (device ∈ {owner-mac, owner-iphone}) and tag (line ∈ the sender list).\n- Runner output: proof_run fields + `surface_ran: true|false` + `surface_evidence` (MCP session id / Shortcut run id / message id / browser request id / process pid). surface_ran=false with a reason is a valid, preserved result.\n\n## MINIMUM VALID INVOCATION\n`node scripts/surface-run.mjs --key NET_LINE --spelling curl`\n\n## FULL / MAXIMUM INVOCATION\n`node scripts/surface-run.mjs --keys hot --spellings all --route device=owner-mac,line=+14245134626 --cause task:WT-0472 --write build:sh_nyab2cgy --concurrency 4`\n\n## RAW CONFIRMATION SHAPE\nPer spelling: HTTP status+headers (named/url/upstream/webhook), JSON-RPC result envelope with id (jsonrpc), process exit code + pid (curl/console_app/claude_code/shortcut), message id (tag), sheet write receipt (cell).\n\n## RAW RETURN SHAPE\nThe verbatim payload the surface returned (tool result content for jsonrpc; stdout for processes; cell value for cell; the reply text for tag).\n\n## ERROR SHAPES\n- jsonrpc: `-32601 method not found`, `unauthorized` (MCP_TOKEN), initialize timeout (cold start 50–65 s — retry once after 70 s).\n- shortcut: hang (record `NONE (hang after 60 s)`; WT-0442).\n- claude_code: no tool_use block (record the transcript; it is a failure, not a skip).\n- cell: `google_sync_off`-class gate refusals never apply to the build workbook; a formula error `#ERROR` is a return, keep it.\n\n## RECEIPT / TRACE / PARENT LINKAGE\nOne proof_run per (key, spelling); receipt ids listed in evidence as a TSV `key\\tspelling\\treceipt_id\\tsurface_ran`.\n\n## TEST MATRIX\n| case | what runs | kind |\n|---|---|---|\n| curl | 74 hot × curl, executed by sh -c | live |\n| jsonrpc | 74 hot × real MCP client tools/call | live |\n| claude_code | 10 hot × `claude -p` tool_use captured | live |\n| console_app | 74 hot × binary | live |\n| url | 74 hot × browser GET (WT-0475) + fetch | live |\n| cell | 74 hot × =DISPATCH in scratch sheet | live |\n| shortcut | 5 rows × Mac + iPhone | live or recorded hang |\n| tag | 5 rows × inbound text | live |\n| webhook | 5 rows from the Starlink line | live |\n| long tail | 1,445 rows × discovered only, no execution of send-effect rows | catalogue |\n\n## ACCEPTANCE TESTS (mechanical; the infrastructure runs them)\n- `{\"type\": \"evidence_present\", \"id\": \"commit\", \"field\": \"commit\"}`\n- `{\"type\": \"evidence_present\", \"id\": \"live\", \"field\": \"verification\"}`\n- `{\"type\": \"evidence_present\", \"id\": \"tsv\", \"field\": \"receipts_tsv\"}`\n- `{\"type\": \"contains\", \"id\": \"how\", \"url\": \"https://ops.miscsubjects.com/api/directory/NET_LINE?share=public\", \"needle\": \"how_to_call\"}`\nEvidence fields the submitting agent supplies: commit, receipts_tsv, verification. `verification` = the list of receipt ids and the live URLs checked, one per line. `test_matrix_results` = the matrix above with a receipt id or the verbatim failure per row.\n\n## KNOWN FAILURES / REGRESSION FIXTURES (preserve; never rewrite into success)\n- `--help` exit 0 is not proof (cli_tools)\n- hidden bash proving only bash (the 2026-09-23 ways run)\n- `shortcuts run` hang (WT-0442)\n- Bearer anonymous on /api/tools (x-terminal-key required for the hot set)\n- MCP cold-start handshake 65 s\n\n## DEPENDENCIES\n- depends_on: WT-0470, WT-0471\n- OWNS (only this task rewrites): functions/_lib/invocation_methods.js; functions/_lib/grammar.js; functions/_lib/projection_manifest.js; functions/api/tools/[[path]].js; functions/api/mcp.js; functions/_lib/mcp_inspect.js; scripts/surface-run.mjs (new); the console-app package\n- SHARED (additive edits only): scripts/contracts-write-results.mjs (call it to write D:F; WT-0473 owns it); bridge/* (call; WT-0474 owns)\n\n## HANDOFF FOR NEXT SESSION\n- Build the jsonrpc runner first (it is the surface the four models use); then console_app and cell; then url via WT-0475; shortcut/tag/webhook last and only after their planes answer.\n- Evidence TSV path goes in `receipts_tsv`; keep failures.\n- If invocation_methods.js text changes, re-run the 74 × 13 set; the sheet rows are a projection and must be regenerated, never hand-edited.\n\n## DONE LAW (this task is done when every line is true and evidenced; not before)\n- Every spelling id has a runner that executes through its own surface (evidence: one receipt per spelling with surface_evidence).\n- 74 hot tools × every applicable spelling have proof_runs; failures preserved.\n- 1,519 rows have contracts state ∈ {discovered, executable, proven} in capability_contracts.\n- sh_nyab2cgy carries the regenerated way-rows (projection).\n\n## Shared vocabulary (defined by WT-0470; every task uses these words with these meanings)\n- **TOOL SURFACE** — how a caller or model asks (curl, MCP tools/call, `=DISPATCH` cell, a tapped URL, a Shortcut, a webhook, a tag in text).\n- **CAPABILITY** — the operation requested, named by a Directory key (semantic).\n- **OBJECT** — what it acts on (a chat, a file, a profile, a row, a page).\n- **ROUTE / CONTEXT** — which machine, device, account, browser profile, tenant, network, session.\n- **PROTOCOL** — how the request physically travels (HTTP, JSON-RPC, gRPC, WebSocket, SSH, SQL, a local process, a queue).\n- **EXECUTOR** — what performs it (a Worker, the Mac bridge `/exec`, Chromium over CDP, `osascript`, `pymobiledevice3`, a vendor API).\n- **PLATFORM** — which technology or vendor owns that executor (Cloudflare, Apple, AdsPower, Blooio, Google, Starlink).\n- **RAW CONTRACT** — the exact physical invocation sent, fully resolved.\n- **CONFIRMATION** — the executor's immediate acknowledgement (HTTP status + headers, spawn/exit metadata, JSON-RPC ack, WebSocket ack, queue receipt).\n- **RETURN** — the final result, verbatim, including failure payloads.\n- **RECEIPT** — evidence and provenance: receipt id/URL, trace id, execution id, timestamps, parent linkage.\n\n## Definition of proof (PROOF_LAW, governing invariant; read it: GET https://ops.miscsubjects.com/api/work → governing_invariants)\nA capability is proven only when the DECLARED invocation surface itself ran and the five fields exist for that run: CAUSE (why it ran: user request / task / parent invocation / event / webhook / model call), RAW INVOCATION (the fully resolved physical contract actually sent), RAW CONFIRMATION (the executor's acknowledgement), RAW RETURN (the actual output, failures verbatim), PROOF / RECEIPT (receipt id/URL, trace, execution id, timestamps, parent linkage sufficient to inspect or replay).\nAn HTTP 200 proves an HTTP 200. A webhook acknowledgement proves receipt. Hidden bash proves bash. A sibling implementation, documentation, a model doing it elsewhere, or the dispatcher working while the surface under test never ran prove nothing about that surface. A missing field is a missing implementation requirement, never something to invent. Existing failures stay as evidence and become regression fixtures; they are never rewritten into success.\n\n## Six-column projection (unchanged; not the source of truth)\n`TOOL NAME | ONTOLOGY | RAW INVOCATION | RAW CONFIRMATION | RAW RETURN | PROOF / RECEIPT` — the build workbook sheet `sh_nyab2cgy` (vault `CONTRACTS_WORKBOOK_SHEET`, 11,035 rows on 2026-09-23). No seventh column, no contract-type column, no prose in place of an executable invocation. Extra metadata belongs in the canonical capability / task / receipt objects.\n\n## Parallelism law\nOther tasks run at the same time in other sessions. Own only the files and objects named under OWNS; touch a shared file only as named under SHARED (additive, never a rewrite). If this task finds the global law insufficient, it files an amendment: `POST /api/work/task/<this id>/fail` naming failure_class `law_insufficient`, layer `WT-0470`, and the missing invariant — it never creates a second standard. Ask the build, never the owner: keys are in `~/.build-vault.env` (`grep '^NAME=' ~/.build-vault.env`; `CLOUDFLARE_API_TOKEN=$CF_API_TOKEN` is a shell reference, resolve `$NAME`). The owner key travels as header `x-terminal-key`. Deploy only with `node scripts/land.mjs \"<WT id> what changed\"` from `~/miscsubjects-pages`. Submit evidence: `POST https://ops.miscsubjects.com/api/work/task/<id>/submit {agent, evidence:{commit, verification, …}, changed:[…]}` with header `x-terminal-key`.\n\n## Shared canonical objects and files — never independently rewritten (additive edits only, named per task)\n- `functions/api/dispatch.js` (the one door; runHttp/runFn/tenant delegation) — owner WT-0471.\n- `functions/_lib/invocation_methods.js`, `functions/_lib/grammar.js`, `functions/_lib/projection_manifest.js`, `functions/api/tools/[[path]].js`, `functions/api/mcp.js`, `functions/_lib/mcp_inspect.js` — owner WT-0472 (spellings and model projections).\n- `functions/_lib/event_log.js`, `functions/_lib/wire_log.js`, `functions/_lib/lean_receipt.js`, `functions/_lib/invocation_record.js`, the `events` table and R2 `logs/` — owner WT-0485 (ledger).\n- `functions/_lib/admin_session.js` (tokens, capabilities, tenants), `functions/_lib/tenant_devices.js`, `functions/api/onboard/[[path]].js` — owner WT-0487 (authority) / WT-0488 (onboarding).\n- `functions/_lib/mac_bridge.js`, `bridge/server.js`, `bridge/device_auth.js`, `bridge/surface-run.py`, `bridge/surface-verbs.py`, `bridge/bridge-run.py`, `bridge/bridge-browser.mjs`, `public/device-kit/*` (synced copies) — owners WT-0474 / WT-0475 / WT-0478.\n- `functions/_lib/work_object.js`, `functions/api/work/[[path]].js`, the `laws` and `work_tasks` tables — owner WT-0470 (law rows) and the build (task engine).\n- `scripts/contracts-*.mjs`, `apps-script/Contracts.gs`, the `CONTRACTS_RUN` directory row, sheet `sh_nyab2cgy` — owner WT-0473.\n- `scripts/ship.mjs`, `scripts/land.mjs`, `scripts/write.mjs`, `scripts/check-*.mjs`, `.githooks/*` — governed; add a gate only by adding a new `scripts/check-<name>.mjs` and wiring it as the existing gates are wired.\n",
    "state": "open",
    "priority": 2,
    "revision": 1,
    "depends_on": [
      "WT-0470",
      "WT-0471"
    ],
    "permitted_capabilities": [
      "dispatch",
      "d1",
      "bridge",
      "sheets",
      "receipts"
    ],
    "acceptance_tests": [
      {
        "type": "evidence_present",
        "id": "commit",
        "field": "commit"
      },
      {
        "type": "evidence_present",
        "id": "live",
        "field": "verification"
      },
      {
        "type": "evidence_present",
        "id": "tsv",
        "field": "receipts_tsv"
      },
      {
        "type": "contains",
        "id": "how",
        "url": "https://ops.miscsubjects.com/api/directory/NET_LINE?share=public",
        "needle": "how_to_call"
      }
    ],
    "required_evidence": [
      "commit",
      "receipts_tsv",
      "verification"
    ],
    "parent_task": null,
    "supersedes": null,
    "failure": null,
    "failure_count": 0,
    "last_result": null,
    "completed_at": null,
    "created_at": "2026-09-22T19:51:53-07:00",
    "updated_at": "2026-09-22T19:51:53-07:00",
    "audit": "/api/work/task/WT-0472/audit",
    "submit_to": "/api/work/task/WT-0472/submit"
  }
}