Harness Intelligence Wiki
SpecsCLICodex TypeScript MCP

Codex TypeScript MCP

Architecture: Codex TypeScript MCP

Context and Scope

  • Capability identity: apps/wiki/content/docs/project/specs/cli/codex-typescript-mcp. The capability is Baseline-delivered native TypeScript 7 semantic reads for Codex agents: the hi CLI provisions a pinned Typegraph runtime, discovers compiler projects, probes them, writes Codex MCP entries, and reports health.
  • Actors and outcome: the Codex agent working in one checkout needs definition, reference, type, export and symbol answers about TypeScript source without guessing from text. The human operator needs hi to set this up, keep it current, and say truthfully whether it works. Today the runtime is installed locally and answers through the SDK, but Codex has zero Typegraph entries (S1 "Current Round"; S4 "Runtime replay").
  • In scope: Q10 to Q20 in the grill log (S2, section "R5 — Accepted decisions"). Premises C1 to C4 (S2, "Imported direction"). Non-goals: other languages and harnesses, semantic mutations, graph and Effect diagnostics, LSP hover, an HI router server, automatic recovery, runtime pruning, changes to global Codex approval policy (S1 "Outside Active Scope").
  • Spec: sibling SPEC.md in this folder, retained in the commit that follows this architecture's retention.

Canonical Terms

Canonical terms reused unchanged from the Codex TypeScript MCP Glossary (S3): Pack, Baseline, Registry, Installed Record, Recorded Shape, Built Artifact, Authored Artifact, Software Scope, Effective Lint Policy.

Working labels, parked under Glossary Q21 and not canonical: Compiler Project (program and options of one tsconfig.json), Tool Runtime (the pinned Typegraph installation on one machine), Semantic Session (one live Typegraph process for one Compiler Project in one worktree).

Axioms used below: Pack is the only selection unit (C4); semantic reads never replace format, lint or typecheck evidence (C2); installed, registered, probe-passing and answered are four distinct facts (Q18); "compatible" means the bundled compiler loads the project (Q16); "fresh" covers source edits only (Q17).

Sources

SourceRoleExact location and anchorImmutable revision or content hash
S1Grill status and closureapps/wiki/content/docs/project/grilling/codex-typescript-mcp-grill-status.md; "Current Round", "Accepted target", "Branch Dashboard", "Working Glossary"git blob 9a750795c3a9
S2Durable grill logapps/wiki/content/docs/project/grilling/codex-typescript-mcp-grill-log.md; "R5 reset", "Brainstorm v2", "R5 — Accepted decisions" entries ### Q10 to ### Q20, "Consistency pass after R5", "Closure — 2026-09-28"; evidence ### E1 to ### E6git blob ce74df735f75
S3Published glossaryapps/wiki/content/docs/project/domains/codex-typescript-mcp-glossary.mdxgit blob 71682276290c
S4Registry research (current-source evidence)apps/wiki/content/docs/project/research/codex-typescript-mcp-registry-research-report.md; "Current source findings" A to E, "Runtime replay", "Agent trace and ten flow lenses"git blob 929091019cee
S5Local runbook (observed behavior)docs/runbooks/codex-typescript-mcp.md; "Install on this machine", "Workspace selection", "Check the connection"git blob 1c80e316fe1a
S6Tested runtime lock (observed behavior)~/.local/share/hi-tools/typegraph-mcp/0.9.56/package-lock.jsonSHA-256 3bcfab52d4ed…
S7Current Codex project config (observed behavior).codex/config.toml; no mcp_servers tablesgit blob e11a874d6fe5
S8Codex MCP configuration reference (external, mutable)https://developers.openai.com/codex/mcp, "Configure with config.toml", "Other configuration options"; read 2026-09-28not immutable; keys quoted below as read

S1 to S3 record accepted design. S4 to S7 record observed current behavior. S8 records vendor documentation, not proof of host behavior.

Source Disposition

Question / entryDispositionAccepted detail, replacement, or unresolved pointEvidenceParked owner / resume trigger
Q1 to Q9, Q6a (S2 "R1", "R2", "R3", "R4")supersededRetired by the user's reset; replaced by Q10 to Q20. Retired Q8 automatic restart is replaced by Q17; retired Q9 platform proof is replaced by Q19.S2 "R5 reset"none
C1 to C4 (S2 "Imported direction")acceptedTypegraph over Serena; lint authority unchanged; local first; Pack-only selection. Offered for veto at reset; not vetoed.S1 "Imported premises"none
Q10 ### Q10acceptedExisting TypeScript Pack carries Typegraph; no separate Pack or selector.S2 R5 Q10none
Q11 ### Q11acceptedPinned machine-level install with exact lock, CLI-owned, outside project dependencies.S2 R5 Q11; S6none
Q12 ### Q12acceptedAuto-discover source-bearing tsconfig.json in the current worktree; wiki and solution-only configs excluded by default; explicit override for ambiguity; real options preserved.S2 R5 Q12; E1none
Q13 ### Q13acceptedOne Typegraph server per Compiler Project; HI ships no MCP process; session cost measured, not capped.S2 R5 Q13router parked
Q14 ### Q14acceptedHI writes its entries into .codex/config.toml and restores them on update; rest of file untouched.S2 R5 Q14; S4 Anone
Q15 ### Q15accepted (user override)Five reads always approved in generated entries; global policy untouched; host refusal reported.S2 R5 Q15; E6none
Q16 ### Q16acceptedLoad probe of each tsconfig under bundled TS 7.0.2; failure means unavailable with reason.S2 R5 Q16none
Q17 ### Q17acceptedNew Codex session after tsconfig, dependency or branch change; documented limitation.S2 R5 Q17; E4automatic recovery parked with router
Q18 ### Q18acceptedhi check reports installed, registered, probe-passing per Compiler Project.S2 R5 Q18; S4 lens 10none
Q19 ### Q19accepted (user override)No per-platform test matrix; availability follows upstream packages; failures surface at runtime with reasons.S2 R5 Q19none
Q20 ### Q20acceptedRemove the repo's generated entries on deselection; keep the runtime.S2 R5 Q20none
Glossary Q21 ### Glossary Q21parkedThree working labels; not canonical.S2 "Closure"user; next grill round on this capability
K1 to K10 (S2 "Brainstorm v2" §3)unknown as candidates; accepted only through the Q aboveRouter (K4 alternative) and wrapper recovery (K7 alternative) remain unaccepted.S2as above

Whole System

The CLI is the only writer of the capability's state on a machine and in a repository. The Registry says which repositories get it (Pack). The CLI turns that into a Tool Runtime on the machine, a set of Compiler Projects in the worktree, probe results, and Codex entries. Codex owns the running Semantic Sessions and applies approval. Existing hooks keep owning formatting and lint.

Anchors: Q10 to Q20 (S2 R5); E1, E2, E5 (S2); S4 A to D; S7. Conclusion: the Pack decides who, the CLI decides what is installed, discovered, probed and written, Codex decides what runs. Nothing in the Registry or Installed Record proves semantic readiness; only ARC-006 does.

Block selector / component / levelOwnerState and authorityInterface / dependencySupported constraint and source
ARC-001 TypeScript Pack (Registry item)Registry publisherImmutable per Baseline; selection recorded in Project settings and Recorded ShapeRegistry dependency closure (registry/resolve.ts:11–42, S4 B)Every TypeScript Pack selector receives the capability; no second selector (Q10, C4)
ARC-002 Tool Runtime provisioninghi CLIMachine-level directory per pinned version with exact lock; CLI is the only writerNode >=22.18; npm ci against the Baseline-bound lock; observed tuple Typegraph 0.9.56, TS API 7.0.2, @effect/tsgo 0.36.5, MCP SDK 1.30.1 (S6, E2)Project dependencies untouched (Q11); availability follows upstream packages, no per-platform tests (Q19); retained on deselection (Q20)
ARC-003 Compiler Project discoveryhi CLIDerived per worktree at scaffold/update; not persisted as a Context PlanReads tsconfig.json files; excludes wiki (configured boundary, shape.ts:105–110) and solution-only configs; explicit override for ambiguityCoverage without an empty root (E1); real options and import closure preserved (Q12)
ARC-004 Load probehi CLIPer Compiler Project pass/fail with reason; feeds ARC-005 and ARC-006Loads each tsconfig under the bundled TS 7.0.2 API from ARC-002Unavailable with reason instead of silent fallback; lint/typecheck untouched (Q16)
ARC-005 Codex entry writerhi CLIOwns only its generated [mcp_servers.<name>] tables inside the Authored .codex/config.toml; restores them on update; removes on deselectionTOML entry fields per S8: command, args, env, enabled_tools, default_tools_approval_mode or tools.<tool>.approval_mode, startup_timeout_sec, tool_timeout_secOne entry per probe-passing Compiler Project (Q13); rest of file user-owned (Q14); five reads always approved (Q15); removal keeps runtime (Q20)
ARC-006 Health factshi checkRead-only derived facts: runtime installed, entries registered, probe passing per Compiler ProjectRuns the same probe as ARC-004; reads ARC-002 path and ARC-005 entriesOperator and agent can distinguish installed, registered and usable (Q18); current hi check cannot (S4 lens 10)
ARC-007 Semantic SessionCodex host + TypegraphSession-local process per entry; lazy native TS7 child; source watcherstdio MCP; TYPEGRAPH_PROJECT_ROOT from git rev-parse --show-toplevel, TYPEGRAPH_TSCONFIG per project (E1)Worktree-bound answers (Q12); new session after config/dependency/branch change (Q17)
ARC-008 Existing HI hooksBaseline hooksUnchangedEdit hooks write formatted/linted files to disk; watcher observes disk (E5)Semantic reads never replace quality gates (C2)

Critical Flows and Boundaries

FLOW-001 Scaffold or update makes the capability current

FLOW-001-STEP-001  Pack resolved: TypeScript Pack selected -> capability applies (Q10)
FLOW-001-STEP-002  provision Tool Runtime: pinned version + exact lock on the machine;
                   already present and matching -> reuse; install failure -> reason recorded (Q11, Q19)
FLOW-001-STEP-003  discover Compiler Projects in this worktree:
                   source-bearing tsconfigs; skip wiki and solution-only; ambiguous -> report, use override (Q12)
FLOW-001-STEP-004  probe each Compiler Project under bundled TS 7.0.2:
                   pass -> eligible; fail -> unavailable + reason (Q16)
FLOW-001-STEP-005  write Codex entries: one per eligible project, five reads always approved;
                   restore drifted generated entries; leave other tables untouched (Q13, Q14, Q15)
FLOW-001-STEP-006  record health facts for hi check: installed | registered | probe per project (Q18)

Anchors: Q10 to Q16, Q18 (S2 R5); S4 A to D. Conclusion: every step produces a fact the next step consumes, and every failure stops at its own step with a reason. No step changes project dependencies, tsconfig content, or unrelated Codex tables.

Side-effect boundaries: STEP-002 writes outside the repository (machine). STEP-005 writes one Authored file inside the repository. STEP-006 writes no file it does not already own. There is no cross-file transaction (S4 D); partial completion is visible through STEP-006.

FLOW-002 Codex session answers a semantic question

Anchors: E1, E3, E6 (S2); Q13, Q15 (S2 R5); S8 keys. Conclusion: the agent picks the server whose Compiler Project owns the file; approval is decided by the generated entry, not by a prompt; the answer reflects disk at call time. Observed historical values: startup timeout 20 s, tool timeout 60 s (E3); these are evidence, not accepted limits.

FLOW-003 Change and deselection lifecycle

FLOW-003-STEP-001  ordinary source edit (hook-formatted) -> watcher -> next answer fresh (E4)
FLOW-003-STEP-002  tsconfig, dependency or branch change -> documented: start a new Codex session (Q17)
FLOW-003-STEP-003  repository deselects the TypeScript Pack -> next hi update removes this repo's
                   generated entries; Tool Runtime stays on the machine (Q20)

Anchors: E4 (S2); Q17, Q20 (S2 R5). Conclusion: freshness is guaranteed only for STEP-001; STEP-002 is an operator action by decision; STEP-003 is the only removal path and it never touches the machine runtime.

Accepted Detail Coverage

Question + exact entry/evidence anchorExact accepted choice and supplied detailProvided rationale / alternativesArchitecture selector + applicable visualSystem constraint served
Q10; S2 R5 ### Q10Existing TypeScript Pack carries TypegraphAlt rejected: separate opt-in Pack. Rationale: no second selector (C4)ARC-001; system map; FLOW-001-STEP-001Selection stays Pack-only
Q11; S2 R5 ### Q11; E2; S6Pinned machine-level install, exact lock, CLI-owned; observed tuple Typegraph 0.9.56, TS API 7.0.2, @effect/tsgo 0.36.5, MCP SDK 1.30.1; Node >=22.18Alt rejected: devDependency, on demand. Rationale: exact lock is what made TS7 work; global/latest installer cannot reproduce it (S4 C)ARC-002; FLOW-001-STEP-002Project compiler and lint dependencies untouched
Q12; S2 R5 ### Q12; E1Auto-discover source-bearing tsconfigs in current worktree; exclude wiki (configured boundary) and solution-only configs; override for ambiguity; preserve options, exclusions, import closureAlt rejected: explicit list only. Rationale: root config yields zero coverageARC-003; FLOW-001-STEP-003Coverage without inventing a root program
Q12 worktree binding; E1Root from git rev-parse --show-toplevel into TYPEGRAPH_PROJECT_ROOT; one TYPEGRAPH_TSCONFIG per entryObserved working mechanismARC-007; FLOW-002-STEP-001Worktree-bound answers; external install dir never mistaken for project root
Q13; S2 R5 ### Q13One server per Compiler Project; HI ships no MCP process; measure startup, memory, tool countAlt parked: HI router server. Rationale: per-project is provenARC-005, ARC-007; system map; FLOW-002No new HI runtime to maintain
Q14; S2 R5 ### Q14; S4 AHI writes its [mcp_servers.<name>] tables into .codex/config.toml, restores them on update, leaves the rest byte-preservedAlt rejected: print instructions. Rationale: entries vanished with unknown cause; Registry preserves Authored bytes onlyARC-005; FLOW-001-STEP-005Entry-scoped ownership inside an Authored file
Q15; S2 R5 ### Q15; E6; S8ts_find_symbol, ts_definition, ts_references, ts_type_info, ts_module_exports always approved in generated entries via default_tools_approval_mode or tools.<tool>.approval_mode; exact value giving no prompt not recorded (S8 lists auto, prompt, writes, approve); global policy untouched; host refusal reportedUser override of "where host allows". Alt rejected: Codex defaultsARC-005; FLOW-002-STEP-004Unattended reads without touching global policy
Q16; S2 R5 ### Q16Load probe per tsconfig under bundled TS 7.0.2; fail -> unavailable with reason; no version match; project compiler never changedAlt rejected: version match, no gate. Rationale: Typegraph analyses with its own compilerARC-004; FLOW-001-STEP-004Honest activation; lint/typecheck unaffected
Q17; S2 R5 ### Q17; E4New Codex session after tsconfig, dependency or branch change; documented; no wrapperAlt parked: automatic recovery (needs router). Rationale: no HI process between Codex and TypegraphFLOW-003-STEP-002No stale answers claimed fresh
Q18; S2 R5 ### Q18; S4 lens 10hi check reports installed, registered, probe-passing as three facts per Compiler ProjectAlt rejected: leave as is. Rationale: check says current with zero entriesARC-006; FLOW-001-STEP-006Four-facts axiom observable
Q19; S2 R5 ### Q19No per-platform test matrix; availability follows upstream packages (macOS arm64/x64, Linux arm/arm64/x64, Windows arm64/x64 at this lock); failures reported via install, probe, checkUser override of "macOS arm64 + Linux x64 first". Rationale: not recorded beyond "we are not testing individual platforms"ARC-002, ARC-004, ARC-006Runtime reporting replaces CI matrix
Q20; S2 R5 ### Q20Deselection removes this repo's generated entries; machine runtime stays; no pruningAlt rejected: remove runtimeARC-005; FLOW-003-STEP-003Other repositories keep working
C2; S2 "Imported direction"; E5Existing format/lint/typecheck hooks unchanged; MCP output is not lint evidenceImported premiseARC-008; system mapQuality gates unaffected
E3 excluded surfaceLSP hover, graph, mutation, Effect diagnostics tools excluded (enabled_tools allowlist)Stale hover after dependency edit (E4)ARC-005 enabled_tools; FLOW-002-STEP-002Only proven reads exposed

Spec Traceability

  • State: complete. Spec codes OUT-001 to OUT-010 and AC-001 to AC-032 from the sibling SPEC.md (sections "Requirements and Outcomes" and "Acceptance Criteria") map below. Completed by create-spec on 2026-09-28 without changing accepted design.
Spec code / section selectorArchitecture selectorsAccepted grill Q / exact log-entry and evidence anchorsCoverage explanation
OUT-001; AC-001, AC-002ARC-001; system map; FLOW-001-STEP-001Q10 S2 R5 ### Q10; C4Pack selection is the only trigger; absence of the Pack means absence of every effect
OUT-002; AC-003, AC-004, AC-006ARC-002; FLOW-001-STEP-002Q11 ### Q11; E2; S6Exact pinned tuple, project dependencies untouched, idempotent reuse
OUT-002; AC-005ARC-002, ARC-004, ARC-006; FLOW-001-STEP-002Q19 ### Q19; Q16 ### Q16Platform or install failure surfaces as a reason, no entries, lint unaffected
OUT-002; AC-007ARC-002; FLOW-003-STEP-003Q20 ### Q20Runtime retention on deselection
OUT-003; AC-008, AC-009, AC-010, AC-011ARC-003; FLOW-001-STEP-003Q12 ### Q12; E1; S4 B (shape.ts:105–110)Source-bearing discovery, wiki and root excluded, override for ambiguity, no rewrites
OUT-004; AC-012, AC-013, AC-014ARC-004; FLOW-001-STEP-004Q16 ### Q16Load probe decides; version string does not
OUT-005; AC-015, AC-016, AC-017, AC-018ARC-005; FLOW-001-STEP-005; FLOW-003-STEP-003Q13 ### Q13; Q14 ### Q14; Q20 ### Q20; S4 AOne table per eligible project; restore on update; remove on deselection; other bytes untouched
OUT-005; AC-019ARC-007; FLOW-002-STEP-001Q12 ### Q12 worktree binding; E1Root and tsconfig bound at launch per worktree
OUT-006; AC-020ARC-005 enabled_tools; FLOW-002-STEP-002Q15 ### Q15; E3Exactly five reads exposed
OUT-006; AC-021, AC-022, AC-023ARC-005; FLOW-002-STEP-004Q15 ### Q15; E6; S8Always-approved in generated entries; global policy untouched; host refusal reported
OUT-007; AC-024, AC-025, AC-026ARC-006; FLOW-001-STEP-006Q18 ### Q18; S4 lens 10Three facts distinct from Registry currency
OUT-008; AC-027, AC-028, AC-029ARC-007; FLOW-002-STEP-003, STEP-005; FLOW-003-STEP-001E1, E3, E4, E6; S5 "Check the connection"Current-source witnesses and source freshness
OUT-009; AC-030, AC-031FLOW-003-STEP-002; ARC-007Q17 ### Q17; Q13 ### Q13; E4Documented new-session limitation; no HI process
OUT-010; AC-032ARC-005, ARC-007; Parked Work row "startup grace"Q13 ### Q13Cost measured, not capped
Spec "Constraints" C1–C4ARC-008; Canonical Terms axiomsS2 "Imported direction"; E5Hooks unchanged; Pack-only selection

Retired or Superseded Selectors

SelectorDispositionReplacement / reasonSource
none—First compilation; no prior selectors—

Flow Failure Coverage

LensEvidence / unknown / justified not applicableGuarantee at stakeMaterial unresolved gap
1. Entry points and path convergenceScaffold and update converge on one install path (S4 D); FLOW-001 runs the same steps from both. hi check is a separate read-only path (ARC-006).Same entries whether first install or update (Q14)None
2. Critical execution pathsFLOW-001 order fixed: runtime -> discovery -> probe -> entries -> health. Probe depends on runtime; entries depend on probe.No entry without a passing probe (Q16)None
3. State ownership and authorityRegistry: Pack selection. CLI: runtime, discovery result, probe result, generated entries, health facts. User: rest of .codex/config.toml. Codex: sessions and approval.Single writer per state (Q14, Q11)None
4. Transaction and side-effect boundariesMachine write (STEP-002), repo Authored write (STEP-005), no cross-file transaction (S4 D). Intermediate states visible via ARC-006.Honest partial results (Q18)None
5. Concurrency and stale stateTwo worktrees each get their own entries and sessions (E1 root binding); shared runtime is read-only after install. Unknown: concurrent hi update in two checkouts installing the same runtime version. Non-material: same lock, same bytes.Worktree-bound answers (Q12)None material
6. Idempotency and retriesRe-running FLOW-001 reuses a matching runtime, re-derives the same entries, restores drift (Q14). Deterministic rendering (S4 lens 6).Repeated setup yields one entry per projectNone
7. Partial failure and recoveryRuntime install failure, probe failure, or write failure each stop with a reason and appear in ARC-006. Unknown: cause of the historical entry disappearance (S4 "Runtime replay"); Q14 restore covers the symptom regardless of cause.Unavailable with reason, never silent (Q16)None material
8. Execution lifetime and durabilitySessions are Codex-session-local; normal close left no children (E6). Crash, SIGKILL, hanging query untested (E6). By decision no HI process owns unfinished work (Q13, Q17).No stale-as-fresh claim (Q17)None; documented limitation accepted
9. Lifecycle and dependency transitionsUpdate restores entries; deselection removes entries and keeps runtime (Q20); new Baseline may pin a new runtime version alongside the old (Q11). Unknown: pruning of old versions is out of scope by decision.Other repositories unaffected (Q20)None
10. Completion and observabilityARC-006 three facts per Compiler Project; today hi check says current with zero entries (S4 lens 10).Four-facts axiom (Q18)None

Parked Work and Non-material Unknowns

Question / sourceDisposition and scope consequenceOwner / resume triggerWhy current guarantees remain closed
Glossary Q21 (S2 "Closure")Parked; working labels used, none canonicalUser; next grill round on this capabilityNo accepted guarantee depends on the label names
HI router server (K4 alternative)Parked; per-project topology accepted (Q13)User; when session cost measurement or agent server-choice errors justify itQ13 accepted the cost as measured, not capped
Automatic recovery (K7 alternative)Parked with router; Q17 documents new-session limitationSame as routerQ17 is the accepted behavior
Cause of registration disappearance (S4)Unknown; Q14 restore covers the symptomDelivery validation if it changes behaviorRestore-on-update guarantees presence regardless of cause
Codex mcp_optional_startup_grace_ms default 1000 ms (S8)Unknown whether eleven servers appear in the initial tool catalog within that grace; required = true or a different grace are host settings HI does not ownDelivery validationQ13 measures startup cost; outcome reported through ARC-006 and session observation
Exact approval value that yields no prompt (S8 auto vs approve)Unknown; key names documented, semantics unverified on desktopDelivery validationQ15 fixes the requirement; the value is implementation evidence
Platform behavior beyond macOS arm64 (E2, Q19)Unknown by decision; no per-platform testsRuntime reports per machineQ19 accepted runtime reporting instead of proof
Historical timeouts 20 s / 60 s (E3)Evidence only; no accepted limitPlanningNo requirement names a numeric limit

Validation

  • Decision/source/glossary reconciliation: S1 status shows R5 closed with Q10 to Q20 answered and Q21 parked; S2 log entries under "R5 — Accepted decisions" match S1 row by row; S3 glossary reuses existing canonical terms and marks the three labels as working. Retired Q1 to Q9 appear only in Source Disposition.
  • Exact-detail and cross-level coverage: every Q10 to Q20 row in Accepted Detail Coverage names a selector and a served constraint; user overrides Q15 and Q19 are marked as such with their recorded wording.
  • Relative links, selector targets, and visual source/order checks: all links use routed /docs/project/... paths that exist in the working tree; ARC-001 to ARC-008, FLOW-001 to FLOW-003 and their steps are defined once each; the system map and sequence diagram carry selector labels and Q anchors.
  • Spec-code -> architecture -> grill coverage: complete; every OUT-001 to OUT-010 and AC-001 to AC-032 maps to at least one architecture selector and an accepted R5 entry (validated by script on 2026-09-28).
  • Mermaid parsing/rendering: mermaid@11.15.0 parse() under a jsdom shim on 2026-09-28 accepted both blocks (flowchart-v2, sequence) after replacing a statement-splitting semicolon in FLOW-002-STEP-005. No rendered image was produced; the wiki app renders at build time.
  • Existing spec agreement: sibling SPEC.md compiled from the same R5 entries; no conflicting constraint found.
  • Remaining limits: unknowns listed above are non-material; no approval stamp is implied by status: compiled.

On this page