Files
leleka/docs/experiments/codex-compare-nestng-task-notes.md
T

6.9 KiB

nestng-crm: notes for the orchestrator (never sent to Codex)

Written 2026-11-05 on the laptop (Windows 11, Node 22.16.0, npm 10.9.2, Python 3.9.13). Nothing here was run on the server.

Pinned versions (exact, package.json and package-lock.json are in seed/)

backend (seed/backend/package.json): @nestjs/common, core, platform-express, testing 11.2.8; @nestjs/cli 11.0.24; @nestjs/schematics 11.1.0; class-validator 0.15.1; class-transformer 0.5.1; reflect-metadata 0.2.2; rxjs 7.8.2; jest 29.7.0; ts-jest 29.4.15; supertest 7.3.1; typescript 5.9.3; @types/express 5.0.6, jest 29.5.14, node 22.20.5, supertest 6.0.3. 579 packages after npm ci, node_modules about 214 MB, about 28,000 files. Scaffold is hand-made (no nest new, so no git init and no eslint/prettier): classic CommonJS tsconfig (no module: nodenext/isolatedModules, which make decorator metadata imports awkward), nest build to dist/main.js, no incremental. The seed has an EMPTY AppModule, a main.ts that listens on 3000 (the agent must add PORT and 127.0.0.1), the jest config for unit tests (in package.json, src/**/*.spec.ts) and test/jest-e2e.json (*.e2e-spec.ts), and no tests.

frontend (seed/frontend/package.json): @angular/common, compiler, core, forms, platform-browser, router 20.3.35; @angular/build, cli 20.3.42; @angular/compiler-cli 20.3.35; rxjs 7.8.2; tslib 2.8.1; zone.js 0.15.1; typescript 5.9.3. 410 packages, node_modules about 218 MB, about 19,000 files. Angular 20, not the 22.x that is current on the registry (22.x needs Node >= 22.22.3; the laptop has 22.16 and Angular 20 accepts ^22.12). Standalone components, esbuild @angular/build:application, strict TS and strict templates, the dev server target exists, no test target (Karma/Jasmine removed), cli.analytics=false.

Lockfile digests (sha256): seed/backend/package-lock.json 23a3084dc848bf127f97696563cab0ec113358585df6245d270b1f123c7fd533, seed/frontend/package-lock.json 87f8dc2edd3bb892330bb23ea3675dc2e173cbafbd35865fccc9168a58bca72c (the manifest records them with the other seed files). npm ci on both from a clean directory works and the reference then passes 56/56 (checked 2026-11-05).

Installing node_modules on the server (once, by the main session, network is available there)

One shared tree per project outside any workspace, for example /data/leleka-e2e/codex-compare/node_modules-nestng/{backend,frontend}/node_modules. Install from the frozen seed lockfiles, low priority, because the root NVMe stalls under sustained writes (about 430 MB, 47,000 small files, about 45 s on the laptop):

for d in backend frontend; do
  mkdir -p $NM/$d && cp $TASKS/nestng-crm/seed/$d/package.json $TASKS/nestng-crm/seed/$d/package-lock.json $NM/$d/
  ( cd $NM/$d && nice -n 19 ionice -c3 npm ci --ignore-scripts=false --no-audit --no-fund )
done

then chmod -R a-w $NM and record find $NM -type f | sort | sha256sum-style digest in the run metadata (it is not part of the task manifest). Node 22 itself: a pinned tarball (the version and its sha256 recorded) in the same directory, put on PATH for Codex's shell and for accept.py (NESTNG_NODE_BIN=<dir with node and npm>). Angular 20 needs Node >= 20.19 or >= 22.12; any 22.x LTS from this year is fine.

What accept.py needs

  • python3 accept.py WORKSPACE, stdlib only, 56 checks, prints PASS/FAIL name :: detail and SUMMARY n/m. Nothing in WORKSPACE is modified (the self-test confirms it).
  • node_modules: WORKSPACE/<dir>/node_modules if present, else $NESTNG_NM_ROOT/<dir>/node_modules (a directory holding backend/node_modules and frontend/node_modules). It symlinks them (junction on Windows) into a temp copy that excludes node_modules, dist, .angular, coverage, out-tsc, *.tsbuildinfo and .git. The runner's workspace copy of node_modules is therefore never copied or written.
  • Node and npm from PATH, or $NESTNG_NODE_BIN. It sets CI=1, NG_CLI_ANALYTICS=false, NG_DISABLE_VERSION_CHECK=1 for its own children.
  • The backend is started with node dist/main.js on a free port in PORT; a server that ignores PORT fails the whole REST group (35 checks).
  • Time on the laptop: reference 22-24 s; bare seed 79 s (30 s of waiting for a server that never listens on PORT). Worst case with a slow agent solution well below 300 s. On the server expect 2-3x the CPU-bound parts (ng build, tsc, jest).
  • Groups: 7 structure, 2 backend build/listen, 35 REST, 3 own tests (npm test, npm run test:e2e, >= 15 cases in total), 1 frontend build, 9 static frontend checks.
  • Does NOT check the UI in a browser (none on the server). A later laptop check with Playwright over the stored workspaces is possible (serve frontend/dist/frontend/browser with the backend on 3000 and a proxy), not written.

Laptop timings (reference solution)

npm run build backend 3.7 s; npm test 5.9 s (15 tests); npm run test:e2e 5.4 s (15 tests); ng build production 5.4 s; whole accept.py 22 s (seed + overlay self-test: seed rc=1 79 s, overlay rc=0 22 s).

Gotchas for the server and the Codex sandbox

  • The runner must copy the seed FIRST, check SEEDTREE (taskfile.workspace_lines) and only then add the hard-linked node_modules; workspace_lines would otherwise hash 47,000 files of node_modules (cell.py does it again after the run for workspace.sha256: exclude node_modules, dist, .angular there, or it reads 430 MB per cell).
  • Hard-linked files are shared: make the shared tree read-only (chmod -R a-w) so an agent cannot edit a package of every later cell. cp -al (hard links) writes no data. A symlinked node_modules also works with accept.py, but Angular/Jest under a symlink inside a Codex sandbox was not tried; hard links are what the prompt promises.
  • esbuild and the Angular CLI fetch platform-specific optional dependencies (@esbuild/linux-x64, @parcel/watcher-linux-x64-glibc, lmdb prebuilds for the Angular cache) at npm ci time from the registry. Install on the server (linux-x64), never copy the laptop's tree. Check npm ls @esbuild/linux-x64 after the install.
  • The agent's ng build writes frontend/.angular/cache into its workspace (fine); jest/ts-jest write a cache under the OS temp dir: the Codex workspace-write sandbox allows the temp dir, but confirm once with a smoke cell. If HOME is not writable, ng may try to write ~/.angular-config.json (analytics is disabled in the seed angular.json).
  • ng serve and nest start --watch need a listening port and file watching; Codex may start them. cell.py kills the process group at the end, accept.py uses a random port, so a leftover server on 3000 does not disturb the acceptance, but check that 3000 is free before the first cell (the agent's own tests use supertest, no port).
  • Round estimate 30-70 is the author's guess; the prompt is a single phase and the seed has no tests, so the agent must create about 15+ test cases.
  • After the main session freezes MANIFEST.sha256 do not edit any file in this directory (including this one): TASK/SEEDTREE digests cover it.