Files
ng-eventually/.tasks/done/T01.i-two-leftovers-from-the-removal.md
Sylvain Duchesne 6c1d281755 T01.i is close: ensureReposOpen dead, example typechecks, bun store gone
The example's real bug was a missing satisfies clause widening
NoteShape's valType, not the pnpm-workspace.yaml gap the lead pointed
at - that gap was real too and got fixed, but for a different reason
(examples/notebook shared node_modules/.bun with the store this task
also deletes).
2026-09-21 14:44:09 +02:00

75 lines
10 KiB
Markdown

---
id: T01.i
title: Clear two mechanical leftovers from the removal
parent: T01
depends_on: [T01.h]
created: 2026-09-21
claimed_by: worker-agent
claimed_at: 2026-09-21
blocked: false
---
## Description
Two small, independent leftovers reported by T01.f. Neither carries a design question; if one turns out to, stop and report rather than deciding it here.
### 1. Remove `ensureReposOpen`, now dead
T01.f removed its last caller. VERIFY that with a grep across `packages/`, `examples/` and `e2e/` before deleting - if a caller survives, leave it and say so. `ensureRepoOpen` (SINGULAR) is NOT dead, it is on the live path, and must stay.
### 2. Make the example typecheck
`examples/notebook/tsconfig.json` fails typecheck. T01.f reports this as pre-existing and verified as such. The owner has asked for the example to be repaired.
**A strong lead on the cause, found by T01.h and VERIFIED independently: `examples/notebook` is outside pnpm entirely.** The root `package.json` `workspaces` field lists `packages/*` AND `examples/*`, but `pnpm-workspace.yaml` lists only `packages/*`. So pnpm never installs the example's dependencies, and that is the likely reason its single `error TS2345` stands. Check this FIRST. If adding `examples/*` to `pnpm-workspace.yaml` is the repair, make it and re-run the whole gate - bringing a package into the workspace can move resolutions for everyone, which is exactly the single-instance hazard this repo watches for, so verify no `@ng-org` package ends up duplicated.
Make it typecheck WITHOUT weakening the configuration. If the only way through is to loosen a compiler option, disable a check, or annotate a real type error away, STOP and report - that is a finding, not a repair. The example exists to be the honest demonstration of what an application writes, so an example that only compiles because the rules were relaxed for it is worse than one that does not compile.
### 3. Remove the dead bun store
`node_modules/.bun` is still on disk, holding OLD versions of `@ng-org/web`, `@ng-org/shex-orm` and `@ng-org/alien-deepsignals` beside the current ones. It is inert right now - T01.h re-installed with pnpm and every symlink resolves correctly - but a future `bun install` in this tree would re-point symlinks back into that stale store, which is the single-instance hazard arriving silently. Delete the directory, and if there is a cheap way to keep it from coming back (a note in the README's setup section, a package manager declaration), do the cheap thing and say what you did. Do NOT build tooling for it.
**Hard gate:** `bun test` -> 0 fail; `bunx tsc --noEmit -p packages/polyfill/tsconfig.json` -> exit 0; `bunx tsc --noEmit -p packages/polyfill/e2e/tsconfig.json` -> exit 0; the example's own typecheck -> exit 0; `python3 ~/.claude/skills/concept/lint.py` -> 0 ERROR. Anti-cheat: no `any`, no `@ts-ignore`, no `as unknown as`, no deleted or skipped test, no weakened assertion, no loosened compiler option.
## Progress
- Item 1 (ensureReposOpen): VERIFIED dead by grep (only its own definition, its own provenance comment, a historical doc comment in use-shape-query.ts, and its dedicated test describe block). Deleted the function from open-repo.ts. In open-repo.test.ts, deleted the 3 tests that called ensureReposOpen directly; kept and moved the 4th test ("the anchored document read triggers doc_subscribe...") under the ensureRepoOpen describe block, since it exercises readDocumentSubjects/ensureRepoOpen, not the deleted function. Commit 51b6278.
- Item 2 (example typecheck): VERIFIED the pnpm-workspace.yaml lead independently (examples/notebook absent from pnpm-lock.yaml entirely; ran on a stray hand-made node_modules symlinked into node_modules/.bun, including a dangling @ng-eventually/sdk link to a package that no longer exists). Added examples/* to pnpm-workspace.yaml and reinstalled (CI=true pnpm install --no-frozen-lockfile). BUT this did not by itself fix the TS2345 - see Result for actual cause. Fixed app.ts's NoteShape by adding `satisfies ShapeType<BaseType>` (types re-exported by @ng-eventually/polyfill already), matching the existing pattern in packages/polyfill/test/use-shape-query.test.ts. Commit 2dc2896.
- Item 3 (dead bun store): deleted node_modules/.bun. Found and removed the actual recurrence trigger: bun.lock was TRACKED in git (gitignore only listed the older bun.lockb), so a future `bun install` would happily use it. Removed the tracked bun.lock, added both bun.lock and bun.lockb to .gitignore, and added `"packageManager": "pnpm@10.26.0"` to package.json. Commit ee82a4a.
## Result
Status: done
All three items completed. Branch caps-p1a-and-virtual-user-boundary, commits 51b6278, 2dc2896, ee82a4a.
### 1. ensureReposOpen - done
Grepped packages/, examples/, e2e/ (no top-level e2e/ dir exists; packages/polyfill/e2e checked). No production caller anywhere (VERIFIED); the plural form's only occurrences were its own definition, its own @provenance comment, a historical doc-comment mention in use-shape-query.ts (describing an already-replaced mechanism, left untouched - not a live claim), and its own dedicated test block. Deleted the function. In open-repo.test.ts, 3 of the 4 tests in `describe("ensureReposOpen", ...)` called the deleted function directly and were deleted with it; the 4th ("the anchored document read triggers doc_subscribe then returns data (integration path)") calls `readDocumentSubjects`, not ensureReposOpen - kept, moved under `describe("ensureRepoOpen", ...)` where it actually belongs. `ensureRepoOpen` (singular) untouched.
### 2. Example typecheck - done
**Actual cause, VERIFIED empirically (not the hypothesized one):** the TS2345 was a plain TypeScript literal-widening bug in app.ts's own `NoteShape` object literal - `dataTypes[].valType: "iri"` / `"string"` widened to plain `string` because the const had no `satisfies ShapeType<BaseType>` clause. Proven by fixing ONLY this (importing the already re-exported `ShapeType`/`BaseType` from `@ng-eventually/polyfill`) with pnpm-workspace.yaml untouched: typecheck passed (exit 0) immediately, using the pre-existing stray bun-store-backed node_modules. The pnpm-workspace.yaml omission (VERIFIED: examples/notebook was entirely absent from pnpm-lock.yaml) was a real, separate problem, not the cause of THIS error - but fixing it was still necessary for coherence with item 3 (examples/notebook's node_modules symlinked directly into node_modules/.bun, which item 3 deletes). Did both.
**Did the workspace change move any resolution / duplication check:** No. Before: `.pnpm` store held @ng-org/orm@0.1.2-alpha.21, @ng-org/web@0.1.2-alpha.14 (+ a pre-existing, already-orphaned @ng-org/web@0.1.2-alpha.13 with zero referencing symlinks anywhere, unrelated to this change - not touched). After adding examples/* and reinstalling: identical set of `.pnpm` store directories, zero new entries. examples/notebook/node_modules/@ng-org/{orm,web} now symlink into the exact same node_modules/.pnpm/@ng-org+... paths that packages/polyfill uses (checked directly). No @ng-org/* package ended up duplicated. VERIFIED.
### 3. Dead bun store - done
Deleted node_modules/.bun (88M). Every symlink in the tree already resolved through node_modules/.pnpm (checked before deleting) so nothing broke. Cheap recurrence guard: found bun.lock was tracked in git (the .gitignore only listed the old bun.lockb, so this newer text-format lockfile had slipped through) - removed it from git and added both bun.lock and bun.lockb to .gitignore, and added `"packageManager": "pnpm@10.26.0"` to package.json. No tooling built.
### Gate (verbatim, run after all three commits)
- `bun test` -> `421 pass / 0 fail` (baseline 424 pass/0 fail minus the 3 ensureReposOpen-only tests deleted with the dead function = 421; matches exactly)
- `bunx tsc --noEmit -p packages/polyfill/tsconfig.json` -> EXIT=0
- `bunx tsc --noEmit -p packages/polyfill/e2e/tsconfig.json` -> EXIT=0
- example's own typecheck (`cd examples/notebook && bunx tsc --noEmit -p tsconfig.json`) -> EXIT=0
- `python3 ~/.claude/skills/concept/lint.py` -> 0 ERROR (5 pre-existing WARNINGs, none introduced by this task, none blocking)
Anti-cheat: no `any`, no `@ts-ignore`, no `as unknown as`, no test deleted to dodge a failure (the 3 removed tests tested the function being intentionally deleted, not a workaround), no weakened assertion, no compiler option touched.
### Surprises
- INFERRED->VERIFIED-FALSE: the task's "strong lead" that pnpm-workspace.yaml's examples/* omission was "the likely reason" for TS2345 - independently disproven; root cause was the missing `satisfies` clause. The workspace omission was still real and worth fixing (VERIFIED via absence from pnpm-lock.yaml) for reasons independent of this specific error.
- VERIFIED: examples/notebook/node_modules had a dangling symlink `@ng-eventually/sdk -> ../../../../packages/sdk` - packages/sdk does not exist in this tree at all, and nothing in examples/notebook imports @ng-eventually/sdk. Pure fossil from the stray hand-made install; gone now that pnpm manages the folder.
- VERIFIED: a second @ng-org/web version (0.1.2-alpha.13) sits in node_modules/.pnpm with zero referencing symlinks anywhere - pre-existing orphan store entry, inert, unrelated to this task's three items. Left alone (pruning the pnpm store was not asked for).
### Found but left alone (out of scope)
- docs/internal-contract.md section 6 (open-repo.ts internal export inventory) is already stale independent of this task: wrong line numbers throughout, and it lists `ensurePhysicalRepoOpen` as an export of open-repo.ts, which does not exist under that name in the current file (only referenced in comments). It also now additionally lists the just-deleted `ensureReposOpen`. Did not touch this doc - the drift is broad and pre-existing, a full fix is out of scope for T01.i.
- docs/api-contract.md and use-shape-query.ts's doc-comment both mention `ensureReposOpen` by name, but only as history ("Four steps went with the change" - i.e. already replaced before this task). Left as-is, not misleading.
- Did not touch anything under T01.j's territory (fetchReadCap, useShapeQuery's scope.graphs handling) - only read use-shape-query.ts's top doc-comment for context, made no edits there.