Skip to content

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

address review: widen the inert-bound detector, exclude the guard's own probes, and hash the rebuild premise into the client cache key

[._.]/ Adam Eivyf2ce2f34fb7b
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1e0a89eebf..0bdeb6abb6 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -365,13 +365,17 @@ jobs:
# No rebuild half, unlike the server: client/.npmrc pins
# ignore-scripts=true AND `scripts/trusted-rebuilds.js` deliberately lists
# nothing for this workspace, so a restored tree is usable as-is and the
- # install can be skipped outright on a hit.
+ # install can be skipped outright on a hit. That premise is HASHED, not
+ # assumed: `trusted-rebuilds.js` is in the key, so the day a client
+ # dependency does need a rebuild the key moves and no job can keep
+ # restoring a never-rebuilt tree on an exact hit — which neither job here
+ # has a stamp check to notice.
- name: Cache client node_modules
id: client-modules
uses: actions/cache@v6
with:
path: client/node_modules
- key: client-modules-${{ runner.os }}-${{ runner.arch }}-node24-${{ hashFiles('client/package-lock.json', 'client/package.json', 'client/.npmrc') }}
+ key: client-modules-${{ runner.os }}-${{ runner.arch }}-node24-${{ hashFiles('client/package-lock.json', 'client/package.json', 'client/.npmrc', 'scripts/trusted-rebuilds.js') }}
- name: Install client dependencies
if: steps.client-modules.outputs.cache-hit != 'true'
@@ -462,13 +466,17 @@ jobs:
# No rebuild half, unlike the server: client/.npmrc pins
# ignore-scripts=true AND `scripts/trusted-rebuilds.js` deliberately lists
# nothing for this workspace, so a restored tree is usable as-is and the
- # install can be skipped outright on a hit.
+ # install can be skipped outright on a hit. That premise is HASHED, not
+ # assumed: `trusted-rebuilds.js` is in the key, so the day a client
+ # dependency does need a rebuild the key moves and no job can keep
+ # restoring a never-rebuilt tree on an exact hit — which neither job here
+ # has a stamp check to notice.
- name: Cache client node_modules
id: client-modules
uses: actions/cache@v6
with:
path: client/node_modules
- key: client-modules-${{ runner.os }}-${{ runner.arch }}-node24-${{ hashFiles('client/package-lock.json', 'client/package.json', 'client/.npmrc') }}
+ key: client-modules-${{ runner.os }}-${{ runner.arch }}-node24-${{ hashFiles('client/package-lock.json', 'client/package.json', 'client/.npmrc', 'scripts/trusted-rebuilds.js') }}
- name: Install client dependencies
if: steps.client-modules.outputs.cache-hit != 'true'
diff --git a/client/src/components/meatspace/post/WordplayTrainer.test.jsx b/client/src/components/meatspace/post/WordplayTrainer.test.jsx
index 03f0583bab..287e7d49ee 100644
--- a/client/src/components/meatspace/post/WordplayTrainer.test.jsx
+++ b/client/src/components/meatspace/post/WordplayTrainer.test.jsx
@@ -41,14 +41,17 @@ function wordplayScore(score, feedback, response = {}) {
};
}
-// Vitest's default per-test timeout is also 5s, so a `waitFor` bounded at
+// Vitest's default per-test timeout was also 5s, so a `waitFor` bounded at
// GENERATED_DRILL_TIMEOUT was allowed to consume the entire test budget: the
// inner bound could never actually report its own failure, and a test with work
// left after that wait had nothing left to spend on it. The premature-submit
// test has eight awaited transitions after its drill wait and died on CI at
// 5011ms with a bare "Test timed out" pointing at the `it(` line rather than the
// step that stalled. Derive the per-test budget from the inner bound so the two
-// can't drift back into equality.
+// can't drift back into equality. The suite-wide budget in src/test/timeouts.js
+// now clears 5s by the same 3x rule, so this happens to agree with it today —
+// it is kept because this file's bound is its OWN constant, and pinning it here
+// is what keeps the two independent of each other.
vi.setConfig({ testTimeout: GENERATED_DRILL_TIMEOUT * 3 });
// The selected mode now lives in the URL (`/post/wordplay/:mode`) — PostTab
diff --git a/client/src/test/timeouts.test.js b/client/src/test/timeouts.test.js
index 4b72069c1a..f5f2587d94 100644
--- a/client/src/test/timeouts.test.js
+++ b/client/src/test/timeouts.test.js
@@ -11,15 +11,30 @@ import { ASYNC_UTIL_TIMEOUT_MS, TEST_TIMEOUT_MS } from './timeouts.js';
import vitestConfig from '../../vitest.config.js';
const CLIENT_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
+/** This file's own path, as `trackedTestFiles` spells it. */
+const SELF = 'src/test/timeouts.test.js';
+/** A brace-delimited object literal with no nested braces, and its `key:` names. */
+const FLAT_OBJECT = /\{([^{}]*)\}/g;
+const OBJECT_KEYS = /(?:^|,)\s*([A-Za-z_$][\w$]*)\s*:/g;
+/** `timeout: <number>` inside such an object. */
+const TIMEOUT_KEY = /(?:^|,)\s*timeout:\s*([\d_]+)\s*(?:,|$)/;
/**
- * A lone-key `{ timeout: N }` — the shape `waitFor(fn, { timeout })` and
- * `findBy*(text, {}, { timeout })` take. Deliberately does NOT match a fixture
- * object carrying a `timeout` field beside other keys (the provider records in
- * `src/utils/providers.test.js` hold `{ id, timeout }`), which is data rather
- * than an async bound.
+ * Every option `waitFor` / `findBy*` accept. An object whose keys are all in
+ * here is an async bound; one carrying anything else is fixture data that
+ * happens to hold a `timeout` field (`src/utils/providers.test.js` has
+ * `{ id, timeout }`, `ProviderConnections.test.jsx` has `{ args, timeout, … }`).
*/
-const LONE_TIMEOUT_OPTION = /\{\s*timeout:\s*([\d_]+)\s*\}/g;
+const WAIT_FOR_OPTIONS = new Set([
+ 'timeout', 'interval', 'onTimeout', 'container', 'mutationObserverOptions',
+ 'ignore', 'showOriginalStackTrace', 'asyncUtilTimeout',
+]);
+/**
+ * A file raising its own per-test budget. Matched on the `testTimeout` key
+ * rather than the bare call, so a file that merely MENTIONS `vi.setConfig` — in
+ * a comment, or in this file's own probes — is not silently exempted.
+ */
+const RAISES_OWN_BUDGET = /vi\.setConfig\(\s*\{[^{}]*\btestTimeout\b/;
/**
* Inline async bounds in `source` that the enclosing budget would cut short —
@@ -28,18 +43,17 @@ const LONE_TIMEOUT_OPTION = /\{\s*timeout:\s*([\d_]+)\s*\}/g;
* fires; a guard whose detector has quietly stopped matching passes forever.
*
* Scope is deliberately one-sided. A bound TIGHTER than the suite-wide async
- * budget is a legitimate (if easy to forget) local choice — several tests assert
- * that something settles fast — while a bound at or above the enclosing budget
- * is inert in every case, which is the one that actually shipped.
- *
- * A file that raises its own budget with `vi.setConfig` is skipped: its real
- * ceiling is a per-file expression this cannot evaluate.
+ * budget is a legitimate local choice — several tests assert that something
+ * settles fast — while a bound at or above the enclosing budget is inert in
+ * every case, which is the one that actually shipped.
*/
export function inertTimeoutBounds(source, budgetMs = TEST_TIMEOUT_MS) {
- if (source.includes('vi.setConfig(')) return [];
- return [...source.matchAll(LONE_TIMEOUT_OPTION)]
- .map(([, digits]) => digits)
- .filter((digits) => Number(digits.replace(/_/g, '')) >= budgetMs);
+ if (RAISES_OWN_BUDGET.test(source)) return [];
+ return [...source.matchAll(FLAT_OBJECT)]
+ .map(([, body]) => body)
+ .filter((body) => [...body.matchAll(OBJECT_KEYS)].every(([, key]) => WAIT_FOR_OPTIONS.has(key)))
+ .map((body) => TIMEOUT_KEY.exec(body)?.[1])
+ .filter((digits) => digits && Number(digits.replace(/_/g, '')) >= budgetMs);
}
describe('client suite time budgets', () => {
@@ -57,9 +71,10 @@ describe('client suite time budgets', () => {
it('has no inline async bound the enclosing budget would cut short', () => {
// `BeeperTab.test.jsx` carried `{ timeout: 15000 }` against a 5000ms budget
// for exactly this reason (#7448) — it read as a fix and was not one.
- const files = trackedTestFiles(CLIENT_ROOT);
+ const files = trackedTestFiles(CLIENT_ROOT).filter((file) => file !== SELF);
// A broken `git ls-files` would otherwise make this guard pass by scanning
- // nothing at all.
+ // nothing at all. Self is excluded above because the probes below are
+ // deliberate offenders.
expect(files.length).toBeGreaterThan(500);
const offenders = files.flatMap((file) => (
@@ -69,12 +84,19 @@ describe('client suite time budgets', () => {
expect(offenders).toEqual([]);
});
- it('still detects an inert bound, a tight one, and an opted-out file', () => {
+ it('still detects an inert bound however the option object is written', () => {
// The bypass probe: without it, a detector that stopped matching anything
// would report a clean tree forever.
expect(inertTimeoutBounds('await waitFor(fn, { timeout: 15000 });')).toEqual(['15000']);
+ // `interval` is the common co-key on a raised bound — a sole-key pattern
+ // missed exactly the shape most likely to appear.
+ expect(inertTimeoutBounds('await waitFor(fn, { timeout: 20000, interval: 50 });')).toEqual(['20000']);
+ expect(inertTimeoutBounds('await waitFor(fn, { interval: 50, timeout: 20000 });')).toEqual(['20000']);
expect(inertTimeoutBounds('await waitFor(fn, { timeout: 2000 });')).toEqual([]);
+ // A file that genuinely raises its own budget is exempt; merely naming the
+ // call in prose is not.
expect(inertTimeoutBounds('vi.setConfig({ testTimeout: 60000 });\nwaitFor(fn, { timeout: 30000 });')).toEqual([]);
+ expect(inertTimeoutBounds('// vi.setConfig( is discussed here\nwaitFor(fn, { timeout: 30000 });')).toEqual(['30000']);
// Fixture data that merely carries a `timeout` field is not an async bound.
expect(inertTimeoutBounds("const p = { id: 'p1', timeout: 300000 };")).toEqual([]);
});
diff --git a/docs/GITHUB_ACTIONS.md b/docs/GITHUB_ACTIONS.md
index 762027c0e4..04ab86994d 100644
--- a/docs/GITHUB_ACTIONS.md
+++ b/docs/GITHUB_ACTIONS.md
@@ -240,10 +240,13 @@ budget enclosing it can never report its own failure: the test dies first with a
bare "test timed out" naming nothing it was waiting on. That has shipped twice —
`WordplayTrainer`'s 5 s drill bound against Vitest's 5 s default, and a
`{ timeout: 15000 }` in `BeeperTab.test.jsx` that could never wait past 5 s and
-so never helped. `client/src/test/timeouts.test.js` fails CI on any inline
-`{ timeout: N }` at or above the per-test budget, and asserts the EFFECTIVE
-runtime values rather than the constants, so a `configure()` that stopped being
-applied is caught too.
+so never helped. `client/src/test/timeouts.test.js` fails CI on an inline
+`waitFor`/`findBy*` bound at or above the per-test budget — recognised by the
+option object's keys, so `{ timeout, interval }` counts and a fixture record
+that merely holds a `timeout` field does not. It asserts the EFFECTIVE runtime
+values rather than the module constants, so a `configure()` that stopped being
+applied is caught too. A file that raises its own budget with
+`vi.setConfig({ testTimeout })` is exempt.
5000 ms because Testing Library's 1000 ms default, and the 3000 ms this suite
ran at before #7448, both sat under what a 2-vCPU public runner needs: shard 1