Skip to content

Commit 349df5b

Browse files
committed
test(dogfood): take the admin search terms from rows the stock admin is served
The term was the object_name of an unsorted first row read under the system context. That row varied between boots, and one boot row (the MCP endpoint's sys_oauth_resource registration) is about an object the data API does not expose, so the activity read gate serves it to no one and the search on its name matched nothing. Read each term through the admin's own data door, newest first. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM
1 parent 2797f81 commit 349df5b

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)