diff --git a/.agents/HANDOFF.md b/.agents/HANDOFF.md index ce058ac..4717afc 100644 --- a/.agents/HANDOFF.md +++ b/.agents/HANDOFF.md @@ -1,5 +1,12 @@ # HANDOFF +## 2026-11-21 - Capsule-local ignore tests (Claude) + +- Branch `fix/capsule-local-ignore-tests-2026-11-21`, cut from `main` (`bc8364e`). Test-only change in `app/env-contract.test.mjs`. +- The two `.gitignore` tests asked Git in place, so inside a larger repository they also saw that repository's rules: a gap in the capsule's own `.gitignore` could pass unnoticed. They now copy the capsule's `.gitignore` into an empty temporary repository and judge it alone (global excludes switched off, `GIT_*` variables dropped). +- Verified: nested scenario with a gap fails as it should, intact passes; standalone 4/4; a tree without `.git` 4/4; suite 63/63; lint and typecheck exit 0. +- Same branch, second commit: `AGENTS.md`, `docs/neural-journey.md` and a comment in `.github/workflows/ci.yml` said the tests cover only `components/`; the `test` script has covered `app/` as well since the initial import. Wording only. + ## 2026-11-21 - Env template and ignore rules (Claude) - Branch `chore/env-contract-and-ignore-rules-2026-11-21`, cut from the public `main` (`c3541d3`) in a scratch clone. Local only, NOT pushed: Gaffer has not approved a push. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d96bfd5..fe5a342 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,8 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - # node:test over every *.test.mjs under components/ (timeline, film, morph, geometry). + # node:test over every *.test.mjs under components/ and app/ (timeline, film, morph, + # geometry, the Vera daily limit, the env and ignore contract). # The Playwright e2e stays local for now (Chief 2026-10-09). - name: Run node:test run: pnpm test diff --git a/AGENTS.md b/AGENTS.md index 4978124..8ab5d87 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,7 +58,7 @@ All commands run from this capsule root as argv (`program` plus `args`); see - `install`: `node scripts/pnpm.mjs install --frozen-lockfile` - `lint`: `node scripts/pnpm.mjs run lint` - `typecheck`: `node scripts/pnpm.mjs run typecheck` -- `test`: `node scripts/pnpm.mjs run test` (every `*.test.mjs` under `components/`) +- `test`: `node scripts/pnpm.mjs run test` (every `*.test.mjs` under `components/` and `app/`) - `build`: `node scripts/pnpm.mjs run build` - `run`: `node scripts/pnpm.mjs run start` (serves on 127.0.0.1:4346) - `deployDryRun`: `node scripts/pnpm.mjs run deploy:dry-run` diff --git a/app/env-contract.test.mjs b/app/env-contract.test.mjs index 4e44e2f..a8398d1 100644 --- a/app/env-contract.test.mjs +++ b/app/env-contract.test.mjs @@ -1,6 +1,7 @@ import assert from 'node:assert/strict'; import { spawnSync } from 'node:child_process'; -import { readdirSync, readFileSync } from 'node:fs'; +import { copyFileSync, mkdtempSync, readdirSync, readFileSync, rmSync } from 'node:fs'; +import { tmpdir } from 'node:os'; import { dirname, join } from 'node:path'; import { test } from 'node:test'; import { fileURLToPath } from 'node:url'; @@ -44,11 +45,24 @@ function envExample() { return entries; } -function isIgnored(path) { - return spawnSync('git', ['check-ignore', '--quiet', '--no-index', path], { cwd: root }).status === 0; -} +// The capsule's own `.gitignore` is judged alone, in an empty temporary repository. Asked in place, Git would +// also apply the rules of any repository that encloses this folder and the developer's global excludes, and +// the capsule must not lean on either. +const gitEnv = Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith('GIT_'))); +const gitInstalled = spawnSync('git', ['--version'], { env: gitEnv }).status === 0; -const insideGit = spawnSync('git', ['rev-parse', '--is-inside-work-tree'], { cwd: root }).status === 0; +function ignoredByThisCapsule(paths) { + const sandbox = mkdtempSync(join(tmpdir(), 'capsule-ignore-')); + try { + spawnSync('git', ['init', '--quiet'], { cwd: sandbox, env: gitEnv }); + copyFileSync(join(root, '.gitignore'), join(sandbox, '.gitignore')); + const ask = (path) => + spawnSync('git', ['-c', 'core.excludesFile=', 'check-ignore', '--quiet', '--no-index', path], { cwd: sandbox, env: gitEnv }).status === 0; + return paths.filter(ask); + } finally { + rmSync(sandbox, { recursive: true, force: true }); + } +} test('.env.example lists every environment variable the site reads', () => { const documented = envExample(); @@ -61,7 +75,7 @@ test('.env.example holds no value for keys, tokens, secrets or passwords', () => assert.deepEqual(filled.map(([name]) => name), []); }); -test('.gitignore keeps local env files, databases, dumps and keys out of Git', { skip: !insideGit && 'not a Git checkout' }, () => { +test('.gitignore keeps local env files, databases, dumps and keys out of Git', { skip: !gitInstalled && 'git is not installed' }, () => { const mustBeIgnored = [ '.env', '.env.local', @@ -79,9 +93,10 @@ test('.gitignore keeps local env files, databases, dumps and keys out of Git', { 'id_rsa', 'service-account.json', ]; - assert.deepEqual(mustBeIgnored.filter((path) => !isIgnored(path)), []); + const ignored = ignoredByThisCapsule(mustBeIgnored); + assert.deepEqual(mustBeIgnored.filter((path) => !ignored.includes(path)), []); }); -test('.gitignore still lets .env.example be committed', { skip: !insideGit && 'not a Git checkout' }, () => { - assert.equal(isIgnored('.env.example'), false); +test('.gitignore still lets .env.example be committed', { skip: !gitInstalled && 'git is not installed' }, () => { + assert.deepEqual(ignoredByThisCapsule(['.env.example']), []); }); diff --git a/docs/neural-journey.md b/docs/neural-journey.md index 2b75092..0f5b3db 100644 --- a/docs/neural-journey.md +++ b/docs/neural-journey.md @@ -282,8 +282,9 @@ node scripts/pnpm.mjs run build node scripts/pnpm.mjs run deploy:dry-run ``` -`node scripts/pnpm.mjs run test` runs every `*.test.mjs` under `components/` (a glob, -so a new test file runs without touching `package.json`; CI runs it on every push): +`node scripts/pnpm.mjs run test` runs every `*.test.mjs` under `components/` and `app/` (two +globs, so a new test file runs without touching `package.json`; CI runs it on every push; the +`app/` tests are listed in `docs/testing.md`). Under `components/`: `tactile.test.mjs` (magnet pull, face placement and look), `face.test.mjs` (the analysis, `makeFace`, the feature-first growth order), `morphology.test.mjs`, `signal.test.mjs`, `film.test.mjs` (frame mapping, the versioned files on disk, the load order), `morph.test.mjs` diff --git a/docs/verification.md b/docs/verification.md index d42c786..e9f353e 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -12,6 +12,28 @@ A change is acceptable when, from the capsule root: 3. Vera changes are exercised against a stub or closed upstream (no real Dify calls in tests); 4. the result is recorded here and in `.agents/HANDOFF.md`. +## 2026-11-21 — capsule-local ignore tests (Claude Fable 5.2) + +Branch `fix/capsule-local-ignore-tests-2026-11-21`, cut from `main` (`bc8364e`). Linux, Node 24.22.3, +pnpm 11.21.0. Test-only change in `app/env-contract.test.mjs`: the capsule's `.gitignore` is now judged +alone, in an empty temporary repository, instead of asking Git in place. + +Reason: asked in place, Git also applies the rules of a repository that encloses this folder. With the +capsule nested in a larger repository and its own SQLite rules removed, the old test still passed; the +new one fails and names `data.sqlite` and `local.sqlite3`. The four tests now also run in a tree that +has no `.git` folder. + +| Command | Finished (UTC) | Exit | Result | +| --- | --- | --- | --- | +| `install --frozen-lockfile`, `lint`, `typecheck` | 08:00 | 0 | No findings | +| `test` | 08:00 | 0 | 63/63 | + +NOT RUN: `build`, `deploy:dry-run` (no runtime file changed), `test:e2e`, live Vera. + +Second commit on the same branch (wording only): `AGENTS.md`, `docs/neural-journey.md` and a +`ci.yml` comment now say the tests cover `components/` and `app/`, which is what the `test` script +runs. `lint` and `test` re-run after it; see the pull request checks for the recorded result. + ## 2026-11-21 — env template and ignore rules (Claude Fable 5.2) Branch `chore/env-contract-and-ignore-rules-2026-11-21`, cut from the public `main` (`c3541d3`) in a