Files
AgentHub/docs/claude-memory/agenthub-flaky-codex-ingest-tests.md
nntrivi2001 9c573f1e3c docs: snapshot of the project's Claude Code memory
Decisions, environment quirks and pitfalls learned while working on AgentHub
(docs/claude-memory/, indexed by MEMORY.md). Notes holding personal account
details are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 15:27:35 +07:00

49 lines
6.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: agenthub-flaky-codex-ingest-tests
description: Client suite needs NODE_ENV=test in this shell; rtk wrapper hides prettier/grep output; old flaky codex-ingest tests removed 09-25
metadata:
node_type: memory
type: project
originSessionId: 073fe263-c67b-478a-860e-b8fc3028000e
modified: 2026-10-07T03:36:34.531Z
---
This shell exports `NODE_ENV=production`, which breaks the whole client suite
with "act(...) is not supported in production builds" (567 failures). Run client
tests as `cd client && NODE_ENV=test npx vitest run`. The pre-commit hook (`.husky/pre-commit`) runs the client suite too, so commit as `NODE_ENV=test git commit …` or it aborts with ~570 act() failures.
`server/__tests__/codex-ingest.test.js` used to be flaky (1–4 failures per run on
a clean tree, stage-detection cases). On 2026-09-25 codex lanes lost their
pipeline and the file was rewritten to cover only the idle↔running mirror; the
suite ran 1974/1974 green afterwards.
**Why:** a red client run here is usually the env, not the change.
**How to apply:** always set `NODE_ENV=test` for client tests; if codex-ingest
turns flaky again, treat it as a new issue — the old cause is gone.
2026-09-28: `codex-ingest.test.js` "a second pass with nothing new changes nothing" failed once in a full `npm run test:server` (1 !== 0), passed 3/3 alone and on the full rerun — still timing-flaky under load; rerun before chasing it.
2026-09-29: the shell's `rtk` wrapper hides/mangles output of `npx prettier --check`, `grep` (regex with `\|` or `(` errors) and `git diff`. Use `node node_modules/prettier/bin/prettier.cjs --list-different`, `command grep -F -e … -e …`, and python `subprocess.run(["git","diff",…])` instead.
2026-10-01: `npm install` under the shell's NODE_ENV=production PRUNES dev deps (vitest, @types → tsc breaks). Install as `NODE_ENV=development npm install --include=dev`.
2026-10-02: a preview server started from the checkout with `DASHBOARD_DATA_DIR=<tmp>` REWRITES the real `~/.claude/settings.json` hooks at startup (`installHooks` sees no `<data dir>/runtime/state.json`, so thinks no plugin). That time it only reordered existing checkout entries, but check `settings.json.agenthub-bak` after any such preview. Also never `pkill -f "<pattern>"` with a pattern typed in the same command line — it kills the calling shell (exit 144); kill the preview by its port's pid.
2026-10-02: SAFE preview recipe — run the checkout's server with HOME=<tmp>/home (plus temp DASHBOARD_DB_PATH/DATA_DIR/SETTINGS_FILE, DASHBOARD_PORT other than 4820/4899, DASHBOARD_RUN_HEAL_MS=0, AGENTHUB_PRICING_SYNC=0, AGENTHUB_AI_TOOLS_SYNC=0) so installHooks/refreshScript write into the fake home, never ~/.claude or ~/.codex. Build first: `cd client && NODE_ENV=production npx vite build`. No playwright here: screenshot with `google-chrome --headless=new --screenshot=...` or a small CDP script (Node has WebSocket) to set localStorage / click. A leftover smoke server from an earlier session listens on :4899 (DB /tmp/ahsmoke) — not the user's. Write memory files with a QUOTED heredoc (<<'EOF'): an unquoted one executed the backticks in the text.
2026-10-02: the pre-commit hook exports GIT_INDEX_FILE (and possibly GIT_DIR) into the test suites. A test git helper that inherits them acts on AgentHub's own repo, so strip every `GIT_*` variable from its env.
**Runaway vitest workers (2026-10-03):** killing a hung `vitest run` parent left its `node (vitest N)` workers spinning (load avg 60), which made the pre-commit hook fail on unrelated 5 s timeouts and made the user's dashboard lag. After any killed/timed-out vitest, `pgrep -af "node (vitest"` and kill the workers too. Run the full client suite BEFORE committing — the hook aborts on a snapshot change (Settings snapshot caught me once).
2026-10-05: `git commit -- <paths>` (partial commit) gives the hook a temp ABSOLUTE `GIT_INDEX_FILE`, so the two `POST /api/lanes/worktree` tool tests fail with "invalid object … .agents/skills/release-guard" — stage with `git add` and commit plainly. The hook also tests the WORKING TREE, not the index: with another session's WIP in the tree it fails on their files. Then verify the exact snapshot in a temp worktree (`git worktree add --detach /tmp/x HEAD`, `git apply --index` the staged patch, symlink root + client node_modules, NODE_ENV=test vitest + tsc), re-check the index is unchanged (`git diff --cached --binary | cmp - patch`), commit `--no-verify`, and say so to the user.
2026-10-07: NEVER let `.husky/pre-commit` run inside a LINKED worktree (`git worktree add`). There git exports an absolute `GIT_DIR` to the hook; `lanes-api.test.js`'s bare `execSync("git init")` then reinitialises the SHARED repo and sets `core.bare = true` in the main checkout's `.git/config` — every status/commit/pull breaks ("must be run in a work tree"). It also left stray "init" commits on the worktree HEAD. Commit in a scratch worktree only with `--no-verify`, or repro in a plain `git clone --local` (safe: GIT_INDEX_FILE is relative there).
2026-10-06: `.husky/pre-commit` now runs only RELATED tests for a small commit (≤ 10 code files, no package/config/hook/deleted file): `vitest related` for client/, server tests naming the staged module; docs-only runs nothing; `AGENTHUB_FULL_TESTS=1` forces both full suites (use it for a release commit). Its frontend run sets NODE_ENV=test itself. A locale JSON change still pulls ~50 client test files (everything imports i18n).
- Something on this host listens on :3000 (seen 2026-10-07), so 3 lane-profile tests (checkProfile, "end to end: init -> check -> real boot") fail with EADDRINUSE — environmental, not a regression. AlertsNotifications.spend.test can flake under full-suite load; passes alone.
2026-10-09: a session started from a server-mode AgentHub pane inherits `AGENTHUB_MODE=server` (+ AGENTHUB_LANE_ID/PANE_TOKEN/RUN_ID/USERS_ROOT/FILE_KEYS). Server tests then answer 401 everywhere (lanes-api: ~200 failures, log says "Server mode: every page and API call needs a login"). Run as `env -u TMUX -u AGENTHUB_MODE -u AGENTHUB_LANE_ID -u AGENTHUB_PANE_TOKEN -u AGENTHUB_RUN_ID -u AGENTHUB_USERS_ROOT -u AGENTHUB_FILE_KEYS npm run test:server`. The full server suite can exceed 15 min when other sessions test in parallel — don't wrap it in `timeout 900`. Client full-suite under that load failed 16 tests in CcConfig/AddLaneModal/DiffEditor/AiProxyConfig; all 80 passed alone.