Skip to content

Commit 8fdf25a

Browse files
test(dogfood): take the admin search terms from rows the stock admin is served (#33449)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DXuamRUC67fx2TTYrFfyuSH)_ Fixes #33429 Clause-②: no — a test-only change in the private `@objectstack/dogfood` package; nothing publishes. Metadata-protocol: none ## Maintainer quick read - What changes: one dogfood test now picks its search words from rows the admin can actually see, so it stops failing at random in the merge queue. - Why: it ejected #33364 and #33409 from the queue. It is not a product bug. Sometimes the word it picked came from an activity row about an internal object (`sys_oauth_resource`) that no one is allowed to read through the data API, so the admin's search correctly found nothing. - Risk and rollback: test only. Rollback is a revert. - Needed from you: nothing. ## Cause (measured locally on the stock showcase boot) - The test took its term from `ql.find(table, { limit: 1 })` under the system context, with no sort. That row varied between boots: four boots gave `showcase_invoice_line`, `showcase_expense_line`, `showcase_task` and `sys_oauth_resource`. - The boot writes one `sys_activity` row about `sys_oauth_resource` (the MCP resource registration, no actor). `GET /data/sys_oauth_resource` answers 404 `OBJECT_API_DISABLED`, and the activity read gate serves a row only to a reader who can read its parent, so the stock admin is served none of that object's activity rows. - A probe over every `object_name` the boot wrote: the admin's `$search` and its `$filter` on the name both answer more than 0 rows for every name except `sys_oauth_resource`, where both answer 0. When that row came first, line 96 saw 0. Both victims failed on that assertion, not on a timeout. No wait or retry is added. ## What changes - `packages/qa/dogfood/test/audit-log-admin-search.dogfood.test.ts`: each term is the `object_name` of the newest row the stock admin reads through the same data door (`$orderby=created_at desc` on `sys_audit_log`, `timestamp desc` on `sys_activity`, `$top=1`). The armed control and the comment say so. ## Verification - The changed file, run 3 times on a built tree: 3/3 passed each run. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (Nothing publishes here.) - [x] 6. `packages/spec` is not touched. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM Co-authored-by: Claude <noreply@anthropic.com>
1 parent b392ff7 commit 8fdf25a

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎packages/qa/dogfood/test/audit-log-admin-search.dogfood.test.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ describe('[#21154] the stock admin searches the ledger and the activity stream w
4343
let stack: VerifyStack;
4444
let ql: any;
4545
let adminToken = '';
46-
/** A term each table's own rows contain, read at rest under the system context. */
46+
/**
47+
* A term each table's own rows contain, read from a row the stock admin is
48+
* served through the same data door, newest first (#33429). Read at rest
49+
* under the system context, an unsorted first row varied between boots, and
50+
* one boot row (the MCP endpoint's `sys_oauth_resource` registration) is
51+
* about an object the data API does not expose, so the activity read gate
52+
* serves it to no one: a term taken from it matched nothing the admin reads.
53+
*/
4754
const term: Record<'sys_audit_log' | 'sys_activity', string> = { sys_audit_log: '', sys_activity: '' };
4855

4956
const list = async (path: string): Promise<Answer> => {
@@ -61,14 +68,17 @@ describe('[#21154] the stock admin searches the ledger and the activity stream w
6168
});
6269
adminToken = await stack.signIn();
6370
ql = await stack.kernel.getServiceAsync('objectql');
71+
const newest = { sys_audit_log: 'created_at desc', sys_activity: 'timestamp desc' } as const;
6472
for (const table of Object.keys(term) as Array<keyof typeof term>) {
65-
const rows: Row[] = await ql.find(table, { limit: 1, context: SYS.context });
73+
const res = await stack.apiAs(adminToken, 'GET', `/data/${table}?$orderby=${encodeURIComponent(newest[table])}&$top=1`);
74+
const json: any = await res.json().catch(() => undefined);
75+
const rows: Row[] = json?.records ?? json?.data ?? [];
6676
term[table] = String(rows[0]?.object_name ?? '');
6777
}
6878

6979
await assertArmed([
7080
armedWhen({
71-
control: 'the boot wrote ledger and activity rows, and each carries a term its own search can match',
81+
control: 'the boot wrote ledger and activity rows the stock admin is served, and each carries a term its own search can match',
7282
disarmedBy: 'an empty table would answer every search with no rows, and an answered search would prove nothing',
7383
observe: async () => ({ ledger: term.sys_audit_log, activity: term.sys_activity }),
7484
armed: (o) => o.ledger.length > 0 && o.activity.length > 0,

0 commit comments

Comments
 (0)