Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Save the memo only after a green test step and keep the store out of nested Vitest runs
[._.]/ Adam Eivy7a0241764946
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 2fde6b13fc..c218a398dc 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -370,6 +370,7 @@ jobs:test-memo-${{ runner.os }}-${{ runner.arch }}-server-${{ matrix.shard }}of${{ strategy.job-total }}-- name: Run server tests+ id: server-testsif: needs.impact.outputs.server_mode != 'skip'env:PORTOS_TEST_MEMO_DIR: ${{ runner.temp }}/portos-test-memo@@ -387,10 +388,11 @@ jobs:PGPASSWORD: portosrun: node scripts/run-ci-tests.js server- # Only trusted full runs on the default/release branches seed the memo;- # a red shard still saves the files that passed (entries are per file).+ # Only trusted full runs on the default/release branches seed the memo,+ # and only from a green test step: the runner writes no entry from a+ # red process, and a step that never ran has nothing to save.- name: Save the test memo- if: github.event_name != 'pull_request' && !cancelled()+ if: steps.server-tests.outcome == 'success' && github.event_name != 'pull_request'uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: ${{ runner.temp }}/portos-test-memo@@ -492,6 +494,7 @@ jobs:test-memo-${{ runner.os }}-${{ runner.arch }}-client-${{ matrix.shard }}of${{ strategy.job-total }}-- name: Run client tests+ id: client-testsif: needs.impact.outputs.client_mode != 'skip'env:PORTOS_TEST_MEMO_DIR: ${{ runner.temp }}/portos-test-memo@@ -502,7 +505,7 @@ jobs:run: node scripts/run-ci-tests.js client- name: Save the test memo- if: needs.impact.outputs.client_mode != 'skip' && github.event_name != 'pull_request' && !cancelled()+ if: steps.client-tests.outcome == 'success' && github.event_name != 'pull_request'uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: ${{ runner.temp }}/portos-test-memo@@ -903,6 +906,7 @@ jobs:# throw (see server/lib/browserSuiteGate.js) when Chrome, ffmpeg or the# client bundler is missing, so a skip can never pass this step.- name: Run cross-workspace browser suites+ id: browser-tests# The independent supervisor emits progress and owns a 12m deadline;# this 15m step limit is only a fallback before the 20m job boundary.timeout-minutes: 15@@ -917,7 +921,7 @@ jobs:run: node scripts/watch-ci-tests.js server- name: Save the test memo- if: github.event_name != 'pull_request' && !cancelled()+ if: steps.browser-tests.outcome == 'success' && github.event_name != 'pull_request'uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: ${{ runner.temp }}/portos-test-memo@@ -1059,6 +1063,7 @@ jobs:test-memo-${{ runner.os }}-${{ runner.arch }}-windows-server-${{ matrix.shard }}of${{ strategy.job-total }}-- name: Run server tests on Windows+ id: windows-tests# A step timeout FAILS the step (log kept, `if: failure()` reporting# runs); the job-level timeout would cancel the job and lose the log# (#10415). Observed healthy runs take 2-10 minutes.@@ -1079,7 +1084,7 @@ jobs:run: node scripts/run-ci-tests.js server- name: Save the test memo- if: github.event_name != 'pull_request' && !cancelled()+ if: steps.windows-tests.outcome == 'success' && github.event_name != 'pull_request'uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: ${{ runner.temp }}/portos-test-memodiff --git a/client/vitest.config.js b/client/vitest.config.jsindex 36d8402429..16fbc0d844 100644--- a/client/vitest.config.js+++ b/client/vitest.config.js@@ -30,6 +30,8 @@ const config = defineConfig({// The runner's selection is for THIS Vitest process only: a suite that// spawns a nested Vitest on a fixture must not inherit it.PORTOS_CI_TEST_SELECTION: '',+ // Same for the memo store: a nested Vitest must point at its own directory or stay off.+ PORTOS_TEST_MEMO_DIR: '',},// Four DOM workers exhausted Testing Library's async budget on the public// runner before ChiefOfStaff's config panel settled. Keep the provendiff --git a/docs/GITHUB_ACTIONS.md b/docs/GITHUB_ACTIONS.mdindex 79e4697583..5a583a5f77 100644--- a/docs/GITHUB_ACTIONS.md+++ b/docs/GITHUB_ACTIONS.md@@ -799,10 +799,15 @@ gets two content-addressed keys (`scripts/lib/testMemo.js`):with literal specifiers);- the **recorded** key hashes the modules the file actually loaded in thegreen run that produced its entry (Vitest's- `experimental.recordDependencies` depfile). A module the test mocks away or- never reaches cannot change its outcome, so a change to the lazily- imported server cluster invalidates only the suites that loaded it; a new- edge still invalidates because the importer's own bytes changed.+ `experimental.recordDependencies` depfile, cleared before each run so only+ this run's records count). A module the test mocks away or never reaches+ cannot change its outcome, so a change to the lazily imported server+ cluster invalidates only the suites that loaded it; a new edge still+ invalidates because the importer's own bytes changed. Only plain import+ edges are narrowed this way: JS a member reads as text, spawns, loads+ with `require()`/`createRequire` or runs as a worker, and JS named through+ `readServerSource`/`readClientSource`, is a side module that stays in+ every key together with its own closure.Both keys also cover: every non-JS file a member names through a literal pathanchored at `import.meta.url`, `__dirname`, `process.cwd()` or an identifier@@ -810,46 +815,65 @@ bound to one of those (a literal directory contributes its whole tree, up to400 files; snapshot files and the planner's `FIXTURE_OWNERS` directories areadded for the test itself); the installed version of every package themembers reach (so a lockfile bump invalidates exactly the suites that reach-the bumped packages); the workspace Vitest config closure, setup files,-`scripts/vitestCiPool.js`, `package.json` and lockfile; the Node major,-`process.platform`, `process.arch`; and `TEST_MEMO_ENV` (`CI`, `NODE_ENV`,-`PORTOS_BROWSER_TEST_PROFILE`, `PORTOS_CI_BROWSER_OWNER`,+the bumped packages); a Python sidecar's resolvable sibling imports; the+version of an external program a member reaches (`TEST_MEMO_TOOLS`: the+python the sidecar tests spawn, ffmpeg/ffprobe, and Chrome for the browser+suites); the workspace Vitest config closure, setup files,+`scripts/vitestCiPool.js`, `package.json` and lockfile; the full Node+version, `process.platform`, `process.arch`; and `TEST_MEMO_ENV` (`CI`,+`NODE_ENV`, `PORTOS_BROWSER_TEST_PROFILE`, `PORTOS_CI_BROWSER_OWNER`,`PORTOS_REQUIRE_BROWSER_SUITES`, `PORTOS_REQUIRE_LINUX_CONTAINMENT`,-`PORTOS_TEST_QUIET`, `CI_EXPECT_SLASHDO_SUBMODULE`, …).+`PORTOS_TEST_QUIET`, `PORTOS_TEST_PYTHON`, `CHROME_PATH`, `TZ`, `LANG`,+`LC_ALL`, `CI_EXPECT_SLASHDO_SUBMODULE`, …).**Never memoized (fails closed).** A file in the planner's `ALWAYS_RUN_TESTS`or in `TEST_MEMO_NEVER` (the tree-wide convention and catalog scanners); afile whose closure contains the `// test-memo: never` marker; a test file or`scripts/` module that spawns `git` (repository state is not in the key —product modules that run git on their own targets are under the test's-control); a member that reads a path the analyzer cannot resolve-(`import.meta.glob`, anything under `.git/`, a literal directory with more-than 400 files); a bare specifier that resolves to no installed package; and,-for the floor key only, a non-literal `import()`/`require()` or an-unparseable member. A recorded set that reaches outside the repository is-not memoizable either. Every unknown construct lands in one of those buckets-rather than silently narrowing the key.+control); a test file or `scripts/` member that reads machine-local state+(`data/`, the home directory); a member that reads a path the analyzer+cannot resolve (`import.meta.glob`, anything under `.git/`, a non-literal+`readServerSource`/`readClientSource`, a literal directory with more than+400 files); a bare specifier that resolves to no installed package; and, for+the floor key only, a non-literal `import()`/`require()` or an unparseable+member. A recorded set that reaches outside the repository is not memoizable+either. Every unknown construct lands in one of those buckets rather than+silently narrowing the key.**Store.** `~/.portos/test-memo/` (override with `PORTOS_TEST_MEMO_DIR`):`entries/<key[0..2]>/<key>.json` holds `{ test, workspace, verifiedAt,source: 'local'|'ci', commit }`, `records/<workspace>/<sha256(test)>.json`the loaded-module list. Writes are temp-file-plus-rename so concurrent-worktree pregates never tear a file; any read error is a miss. Entries are-written only for files Vitest's JSON report shows passed with no failed and-no skipped case (a browser profile's name pattern is the one accepted skip-reason). The runner prints one line —+worktree pregates never tear a file; any read error is a miss, and so is an+entry older than 14 days, so the nightly re-verifies what it keeps skipping.+Entries are written only from a Vitest process that exited 0 whose run-level+report (`scripts/vitestRunDiagnostics.js`) ended `passed` with no unhandled+error — a rejection after the last test still marks every file `passed` in+the JSON report — and only for files that report shows passed with no failed+and no skipped case (a browser profile's name pattern is the one accepted+skip reason). Every key is recomputed after the run and written only when it+still matches, so a file edited while Vitest ran is never attributed to the+verdict. The runner prints one line —`🧠 Test memo: skipped N of M selected files (closure unchanged); running K.`— and lists the skipped files under `PORTOS_TEST_MEMO_VERBOSE=1`. When everyselected file is memoized nothing is launched and the job exits 0.+**Shards.** A matrix shard takes its slice of the FULL selected list with+Vitest's own hash-sort-and-range algorithm (`vitestShardSlice`, pinned+against a real `vitest run --shard`) before the memo subtracts anything, so+every file lands in exactly one shard whatever each shard's store holds;+Vitest itself is never given `--shard`.+**CI seeding.** The server, client, browser and Windows jobs restore`${{ runner.temp }}/portos-test-memo` with `actions/cache/restore` under aper-job, per-shard key prefix (`test-memo-<os>-<arch>-<job>-<shard>of<n>-`).Pull requests only read. The scheduled nightly, `workflow_dispatch` and`workflow_call` runs on the default/release branches save a new entry keyed-by run id, so the cache holds nothing a pull-request branch wrote and every-PR restores the newest trusted lineage. The DB job does not go through-`run-ci-tests.js` and is not memoized.+by run id, and only when the test step itself succeeded, so the cache holds+nothing a pull-request branch or a red run wrote and every PR restores the+newest trusted lineage. The DB job does not go through `run-ci-tests.js`+and is not memoized.**Disable.** `PORTOS_TEST_MEMO=off` turns reads and writes off together andrestores the pre-memo behavior. A test spawned under Vitest (`VITEST` set)diff --git a/scripts/repo-scan-guards.test.js b/scripts/repo-scan-guards.test.jsindex dc9c310971..e14c37f0aa 100644--- a/scripts/repo-scan-guards.test.js+++ b/scripts/repo-scan-guards.test.js@@ -101,7 +101,7 @@ const TRACKED_HELPER = /from\s+['"](?:[^'"]*\/)?trackedFiles\.js['"]/;* Matched against comment-stripped source so a comment describing a walk* does not register one.*/-const SHARED_WALKER_CALL = /\bcollect(?:Server|Client)Sources\s*\(/;+const SHARED_WALKER_CALL = /\bcollect(?:Server|Client)Sources\s*\(|\bread(?:Server|Client)Source\s*\(\s*[^'"`)\s]/;const RECURSIVE_READDIR = /readdirSync\s*\([^)]*\brecursive\s*:\s*true/;const stripLineComments = (source) => source.replace(/^\s*(?:\/\/|\*|\/\*).*$/gm, '');diff --git a/server/vitest.config.js b/server/vitest.config.jsindex 029a18d7f1..6bb84d6d97 100644--- a/server/vitest.config.js+++ b/server/vitest.config.js@@ -63,6 +63,8 @@ const config = defineConfig({// The runner's selection is for THIS Vitest process only: a suite that// spawns a nested Vitest on a fixture must not inherit it.PORTOS_CI_TEST_SELECTION: '',+ // Same for the memo store: a nested Vitest must point at its own directory or stay off.+ PORTOS_TEST_MEMO_DIR: '',},// 30s on every platform (#7951). This WAS 10s off Windows, and the split// has always been a fiction: the cost it budgets for is vitest's transform