Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# typed-error — Codex implementation thread
- **Thread / session id:** `01a006f3-ae2d-7941-bd17-2ac71dd3d0f0`
- **Rollout:** `/home/codex/.codex/sessions/2026/08/15/rollout-2026-08-15T21-43-48-01a006f3-ae2d-7941-bd17-2ac71dd3d0f0.jsonl`
- **Worktree:** `/home/codex/repos/netscript-007-leaf-typed-error`
- **Branch:** `fix/sdk-typed-error-channel` @ `0ef48c2ec` (NO upstream by design).
- **Push rule:** explicit refspec only — `git push origin HEAD:refs/heads/fix/sdk-typed-error-channel`.
- **Requested route:** provider=openai · model=gpt-5.6-sol · effort=medium
- **Observed route:** provider=openai · model=gpt-5.6-sol · effort=medium
- **Route verdict:** matched
- **Runtime:** approval=never · sandbox=dangerFullAccess
- **Brief (staged):** `/home/codex/typed-error-brief.md`
## Steering (same thread — never a second send-message-v2 at this worktree)
```bash
codex exec resume 01a006f3-ae2d-7941-bd17-2ac71dd3d0f0 -- "<follow-up>"
```
_Written by `.llm/tools/agentic/codex/launch-codex-slice.ts`._
106 changes: 106 additions & 0 deletions .llm/runs/fix-sdk-typed-error-channel--0.0.7-wave1/context-pack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Context Pack: sdk-typed-error-channel (#1350)

## Run Metadata

| Field | Value |
| -------------- | ---------------------------------------------------------- |
| Run ID | `fix-sdk-typed-error-channel--0.0.7-wave1` |
| Branch | `fix/sdk-typed-error-channel` |
| Current phase | `implementation` — S4 stopped; S4-R amended with finding→correction mapping, 1 finding unresolved |
| Archetype | `1 — Small Contract` slice |
| Scope overlays | `docs` |

## Current state

PLAN-EVAL is terminal PASS at evaluator commit `f76a3c45b`; S1-S3 each passed fresh Tier-A. The
delivered product preserves the exact six-key contract error union through the real `ServiceClient`
promise marker, `safe()`, and `isDefinedError()`, and the two published docs pages carry one
compile-accurate narrative. S4 root check/test, scoped lint/format, quality, architecture, docs,
surface attribution, and publish dry-runs completed. Raw doc lint then proved new leaf-owned
private-type-reference findings (Contracts 9 -> 11; SDK 3 -> 13), so S4 stopped without product
changes. #1466 still owns metadata definition/export; no metadata vocabulary or acceptance claim was
introduced.

## Completed

- Required skill/harness/doctrine/RFC/issue reading.
- `deno doc` public-surface inspection before source inspection.
- Focused source map and executed whole-repo consumer search.
- Exact RED and JSR/publish baseline inspection.
- Research, plan, design, risk/gate set, docs dispositions, and rescope report.
- Separate-session PLAN-EVAL PASS with advisories A1-A5 incorporated.
- S1 builder annotation and real-export regression fixture using contracts-exported schemas.
- S1 structured check/test/lint/format gates.
- S1 fresh Tier-A PASS at `dc034d680`.
- S2 uses upstream public `ClientPromiseResult`, `ErrorFromErrorMap`, and `ThrowableError` types to
carry the procedure error map without a local schema shim or ambient declaration.
- S2 literal failure arms, real positive assertions, runtime identity test, and focused consumer
compatibility checks/tests.

## Next steps

1. S4-R (separate plan-only Claude session, `worklog.md` § S4-R) mapped all 13 new findings to
corrections; 12 of 13 resolve cleanly (all 10 SDK; `BaseContractErrors` and `Schema` in contracts).
`baseContract → ContractBuilder` is unresolved and needs a coordinator ruling: authorize a narrow
`src/public/mod.ts` re-export of `ContractBuilder`/`Schema`, or accept it as permanent leaf-owned
known-red debt.
2. Once the coordinator rules on `ContractBuilder`, the correction is a fresh authorized product slice
over the same three files (`contract-primitives.ts`, `errors.ts`, `service-client.ts`); S4-R itself
remains run-artifact-only, same as S4.
3. Two items are flagged as "reasoned, not `deno check`-proven" in S4-R and need verification at
implementation time: (a) `oc.errors(commonErrorMap)` still type-checks once `commonErrorMap` is
built from the public `ContractSchema`-typed schema aliases instead of the private Zod-typed ones;
(b) `ContractBuilder`'s generic constraint accepts `ContractSchema<unknown,unknown>` in the
pre-`.input()`/`.output()` position.
4. After the repair lands, rerun the incomplete final matrix (JSR audits, specifier/export guards)
at a newly locked immutable content head.

## Key decisions

- Exact six-key `typeof commonErrorMap`; never open `ErrorMap`.
- `SafeResult` gains literal defined/non-defined failure arms and failure `data: undefined`.
- No broad fallback error union; error identity must originate in the real client promise.
- Breaking published change, not patch-level.
- No new export. The empty fourth metadata generic remains explicit; all metadata vocabulary belongs
to #1466.
- The exact six-path ceiling is locked; any seventh product/test/docs path requires a fresh ruling.

## Files changed

- `packages/contracts/src/application/contract-primitives.ts`
- `packages/sdk/src/client/errors.ts`
- `packages/sdk/src/ports/service-client.ts`
- `packages/sdk/tests/readme-doctest_test.ts`
- existing files under `.llm/runs/fix-sdk-typed-error-channel--0.0.7-wave1/`

No docs/S3-S4 product file was modified.

## Gates

- PLAN-EVAL: PASS (`plan-eval.md`, `f76a3c45b`).
- S1 RED: expected FAIL with exactly TS18046 and TS2339, captured once.
- S1 focused check/test/lint/format: PASS; full JSON is in `worklog.md`.
- S2 focused check: PASS, 15 affected source/test/type-fixture files, 0 diagnostics.
- S2 consumer tests: PASS, 12/12 results across SDK doctest/query/desktop and Fresh extraction.
- S2 lint and format: PASS after correcting two type-only imports; the initial lint red is retained
in `worklog.md`.
- S4 root check/test, scoped lint/format, quality, architecture, docs, and publish dry-runs: PASS.
- S4 raw `surface:diff`: known base RED plus exactly 15 authorized signature changes; after
subtracting those changes the 972-finding base/head sets have identical SHA-256 digests.
- S4 raw doc lint: blocking new RED; Contracts 9 -> 11 and SDK 3 -> 13.
- JSR audits and selected specifier/export guards: NOT RUN after the mandated S4 stop.
- S4-R (plan-only): 12/13 findings mapped to type-safe corrections (SDK 10/10, contracts 2/3);
`baseContract -> ContractBuilder` unresolved pending coordinator ruling. No gate was (re-)executed;
this is a mapping, not a rerun.

## Open questions

- Live service integration tests requiring a runtime lease were not run because this slice forbids a
lease. Benchmark reference prose remains coordinator-owned follow-up debt.

## Drift and debt

- Drift: earlier scope/ownership conflicts and the README research correction are recorded in the
append-only `drift.md`.
- Debt: no new debt accepted.
- Commit trail: draft PR commit list plus phase comment; no `commits.md`.
105 changes: 105 additions & 0 deletions .llm/runs/fix-sdk-typed-error-channel--0.0.7-wave1/drift.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Drift Log: sdk-typed-error-channel (#1350)

## 2026-08-15 — Real client error loss is outside the declared surface

- **What:** Exact procedure error identity is erased in `packages/sdk/src/ports/service-client.ts`,
which is not one of the five declared files.
- **Source:** Executed `deno doc`, source map, and TS2339 RED.
- **Expected:** The declared surface was sufficient for an end-to-end `safe()` repair.
- **Actual:** `ServiceClientMethod` returns plain `Promise<TOutput>` before `safe()` sees the value;
editing `errors.ts` alone cannot recover the missing type.
- **Severity:** significant
- **Action:** rescope; request topic-orchestrator authorization and stop product work.
- **Evidence:** `packages/sdk/src/ports/service-client.ts:165-196`;
`packages/sdk/src/client/service-client.ts:41-65`; `research.md` §§1,3.

## 2026-08-15 — Procedure metadata ownership and barrel scope conflict

- **What:** The lane brief assigns procedure-metadata preservation to #1350, while live #1466 owns
metadata initialization/export and #1350's existing maintainer comment explicitly excludes it.
- **Source:** RFC 0001, issues #1348/#1350/#1466 fetched on 2026-08-15, and declared file surface.
- **Expected:** Stage 0 had settled one unambiguous owner and the declared files could publish it.
- **Actual:** RFC 0001 says Stage 0 must choose; #1348 contains internally conflicting wording;
#1466 is open; and the required curated root barrel is outside scope.
- **Severity:** architectural
- **Action:** rescope; brief treated as latest planning instruction, but implementation blocked for
topic-orchestrator ruling.
- **Evidence:** `rfcs/0001-sdk-client-contributions.md:347-370,1267-1277`;
`packages/contracts/src/public/mod.ts:1-6`; `research.md` “Re-baseline and authority.”

## 2026-08-15 — Out-of-scope published prose already describes the erasure

- **What:** Contracts/benchmark prose outside the two authorized docs pages explicitly says the
public base contract is erased; a successful repair makes that prose false.
- **Source:** Executed whole-repo consumer search.
- **Expected:** The two declared docs pages were the complete affected narrative.
- **Actual:** Additional published/reference consumers exist.
- **Severity:** significant
- **Action:** request scope disposition; do not edit without authorization.
- **Evidence:** `packages/bench/tasks/t1-storefront-api/reference/README.md:45-47`;
`packages/bench/tasks/t1-storefront-api/reference/netscript/router.ts:7-8`;
`packages/contracts/README.md:13-76`.

## 2026-08-15 — Coordinator resolution locks six paths and #1466 metadata ownership

- **What:** The coordinator corrected the original brief after reconciling #1348's amendment and
#1350 comment 5227724542.
- **Resolution:** `packages/sdk/src/ports/service-client.ts` is authorized as the sixth and final
product path. Any seventh product/test/docs path requires a fresh ruling.
- **Metadata:** #1466 owns definition, initialization, export, and semantic proof. #1350 retains
only the explicit fourth generic slot as `Record<never, never>` and introduces no vocabulary.
- **Denied:** The contracts public barrel and all metadata export work.
- **Deferred:** Stale contracts/benchmark prose remains tracked follow-up debt outside this leaf.
- **Phase effect:** The plan has no remaining must-resolve decision, but fresh Tier-A review and a
separate PLAN-EVAL `PASS` remain hard stops before implementation.

## 2026-08-15 — PLAN-EVAL corrects the out-of-scope prose classification

- **What:** Original research grouped `packages/contracts/README.md` with benchmark prose that
describes the old erasure.
- **Actual:** The contracts README says the common error map is applied, which remains true. Only
the benchmark reference README/router contain the stale erasure claim.
- **Action:** Corrected existing research/plan/context artifacts. No new file or debt entry was
created; the coordinator owns any later issue for the benchmark prose.
- **Scope:** Both locations remain outside the exact six-path ceiling; no product/docs edit here.

## 2026-08-15 — S4 raw doc-lint findings exceed the pinned baselines

- **What:** The plan-locked raw Contracts and SDK `deno doc --lint` gates are still red and now
contain leaf-owned private-type-reference findings beyond their base sets.
- **Source:** Executed raw lint at immutable head `c7cba6d9b`, then executed the same commands over
an archive of `main@0ef48c2e`; exact identity deltas are recorded in `worklog.md`.
- **Expected:** Pinned raw reds remain red with no new leaf-owned findings.
- **Actual:** Contracts changes from 9 to 11 (three additions, one removal); SDK changes from 3 to
13 (ten additions). The additions name `baseContract`, `ServiceClientMethod`,
`ServiceClientShape`, `SafeFailure`, `SafeResult`, `isDefinedError`, and `safe`.
- **Severity:** blocking final-gate regression.
- **Action:** Stop S4. Do not edit S1/S2 product files in the run-artifact-only slice. Remaining JSR
and specifier/export guards are not run or claimed pending coordinator disposition.
- **Scope:** A correction necessarily returns to already-landed product paths and therefore needs a
fresh authorized implementation slice; no seventh path is implied or authorized here.

## 2026-08-15 — S4-R amends the stop with a finding→correction mapping; one finding unresolved

- **What:** A separate, plan-only Claude session (native route, quota-exhausted Codex route excluded
per `CLAUDE.md`'s documentation-authoring exception) mapped all 13 new leaf-owned `private-type-ref`
findings (contracts 3, SDK 10) to individual type-safe corrections, verified against isolated
scratch probes of `deno doc --lint`'s actual resolution rules and against the real installed
`@orpc/*` `.d.ts` files. Full mapping is in `worklog.md` § S4-R.
- **Result:** 12 of 13 findings resolve cleanly (all 10 SDK findings; 2 of 3 contracts findings —
`BaseContractErrors` and `Schema`). One contracts finding — `baseContract → ContractBuilder` — does
**not** resolve within the three-file/no-new-export ceiling: it requires either re-exporting
`ContractBuilder`/`Schema` from `src/public/mod.ts` (the forbidden fourth path), duplicating oRPC's
entire builder class locally (rejected as an AP-1/AP-9 violation and a drift/maintenance hazard), or
reverting to an inference-erasing annotation (rejected — it reintroduces the exact "six codes erase
to open `ErrorMap`" regression #1350 exists to fix).
- **Severity:** significant — narrows the S4 blocker from 2 files/13 findings to 1 file/1 finding, but
does not close it; a coordinator ruling is still required before the repair slice can proceed.
- **Action:** Coordinator must choose: (a) authorize a narrow `src/public/mod.ts` re-export of
`ContractBuilder`/`Schema` type names as a scope amendment, or (b) accept `baseContract →
ContractBuilder` as permanent, irreducible, leaf-owned known-red debt alongside the existing pinned
baseline (contracts would then land at 9 base + 1 new = 10 total findings, down from today's 11,
with the 1 remaining new finding explicitly justified rather than silently carried).
- **Scope:** No product/test/docs/lock file was touched to produce this mapping. `#1348`/`#1466`
untouched. The repair itself remains a fresh, separately authorized implementation slice; this
session did not implement it.
Loading