Skip to content

Commit 819b02f

Browse files
committed
fix(platform-objects,objectql): write the recycle bin's declaration in shapes the source scans read
check:keyed-text-bounds refuses a spread inside `fields` and a `name` that is not a string literal, so sys_recycle_bin now spells each spec entry through its builder (restating the two keyed text bounds) and names itself literally. The plugin test pins every entry equal to the spec's, so the restatement cannot drift. The tenancy census is regenerated for the new in-reach object, and the capture test's driver double applies a caller's bound after its filter and before it copies rows. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4czFGLnXKQd6cQjv3Pr
1 parent 136ad85 commit 819b02f

4 files changed

Lines changed: 45 additions & 8 deletions

File tree

‎packages/objectql/src/recycle-bin/capture.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ function makeDriver(opts: { transactional?: boolean; failDeleteOf?: string } = {
8181
async connect() {}, async disconnect() {}, async checkHealth() { return true; }, async execute() { return null; },
8282
async syncSchema() {},
8383
async find(o: string, ast: any) {
84-
return Array.from(storeFor(o).values()).filter((r) => matches(r, ast?.where)).map((r) => ({ ...r }));
84+
const rows = Array.from(storeFor(o).values()).filter((r) => matches(r, ast?.where));
85+
const page = typeof ast?.limit === 'number' ? rows.slice(0, ast.limit) : rows;
86+
return page.map((r) => ({ ...r }));
8587
},
8688
async findOne(o: string, ast: any) {
8789
for (const r of storeFor(o).values()) if (matches(r, ast?.where)) return { ...r };

‎packages/platform-objects/src/plugin.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { describe, it, expect } from 'vitest';
99
// why this file's `update` entry sat in the gate's DEBT ledger until #5619 sank
1010
// the predicate into a package that depends on neither side.
1111
import { assertEngineFindOnePredicate, assertEngineUpdateDispatch } from '@objectstack/metadata-core';
12+
import { ObjectSchema, RECYCLE_BIN_ENTRY_FIELDS, RECYCLE_BIN_OBJECT } from '@objectstack/spec/data';
1213
import { PlatformObjectsPlugin } from './plugin.js';
1314
import { SysExchangeRate, SysMetadataActivation, SysMigration, SysMigrationJournal, SysRecycleBin, SysSecret, SysTrustedKey } from './system/index.js';
1415

@@ -83,6 +84,18 @@ describe('PlatformObjectsPlugin: platform-infrastructure object registration (#4
8384
expect(infra.defaultDatasource).toBeUndefined();
8485
});
8586

87+
// [ADR-0148, #30237] The table and `RecycleBinEntrySchema` share one field
88+
// list. The object file spells each entry through its builder (a spread is
89+
// unreadable to the source scans), so this is what keeps it the spec's.
90+
it("sys_recycle_bin declares exactly the spec's entry fields, plus its tenant column", () => {
91+
const { organization_id, ...entryFields } = SysRecycleBin.fields as Record<string, unknown>;
92+
// Through the same factory, so both sides carry the parse's defaults.
93+
const spec = ObjectSchema.create({ name: RECYCLE_BIN_OBJECT, label: 'Recycle Bin Entry', fields: { ...RECYCLE_BIN_ENTRY_FIELDS } });
94+
expect(entryFields).toEqual(spec.fields);
95+
expect(organization_id).toMatchObject({ type: 'lookup', reference: 'sys_organization', deleteBehavior: 'cascade' });
96+
expect(SysRecycleBin.name).toBe(RECYCLE_BIN_OBJECT);
97+
});
98+
8699
/**
87100
* [#12359 ruling, 2026-08-26 — 「同意」] ADR-0126 §4's activation ledger.
88101
* Registration follows the DECLARATION: the object is declared in this

‎packages/platform-objects/src/system/sys-recycle-bin.object.ts‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

3-
import { ObjectSchema, Field, RECYCLE_BIN_ENTRY_FIELDS, RECYCLE_BIN_OBJECT } from '@objectstack/spec/data';
3+
import { ObjectSchema, Field, RECYCLE_BIN_ENTRY_FIELDS } from '@objectstack/spec/data';
44

55
/**
66
* sys_recycle_bin — the recycle bin: one entry per delete operation
@@ -16,8 +16,9 @@ import { ObjectSchema, Field, RECYCLE_BIN_ENTRY_FIELDS, RECYCLE_BIN_OBJECT } fro
1616
* ## Fields
1717
*
1818
* Built from `RECYCLE_BIN_ENTRY_FIELDS` (`@objectstack/spec/data`), the one
19-
* field list the spec's `RecycleBinEntrySchema` shares, so the table and the
20-
* contract cannot drift. Every field is read-only.
19+
* field list the spec's `RecycleBinEntrySchema` shares, key for key, plus the
20+
* tenant column below; `plugin.test.ts` pins each entry equal to the spec's,
21+
* so the table and the contract cannot drift. Every field is read-only.
2122
*
2223
* ## Writers and readers
2324
*
@@ -56,7 +57,7 @@ import { ObjectSchema, Field, RECYCLE_BIN_ENTRY_FIELDS, RECYCLE_BIN_OBJECT } fro
5657
* @namespace sys
5758
*/
5859
export const SysRecycleBin = ObjectSchema.create({
59-
name: RECYCLE_BIN_OBJECT,
60+
name: 'sys_recycle_bin', // RECYCLE_BIN_OBJECT; a literal, so the source scans can attribute this declaration
6061
label: 'Recycle Bin Entry',
6162
pluralLabel: 'Recycle Bin',
6263
icon: 'trash-2',
@@ -69,7 +70,21 @@ export const SysRecycleBin = ObjectSchema.create({
6970
highlightFields: ['object_name', 'record_id', 'record_count', 'deleted_by', 'deleted_at', 'purge_after'],
7071

7172
fields: {
72-
...RECYCLE_BIN_ENTRY_FIELDS,
73+
// One entry per key of RECYCLE_BIN_ENTRY_FIELDS, each spelled through its
74+
// builder rather than spread in: `check:keyed-text-bounds` reads `fields`
75+
// from source and refuses an entry it cannot attribute to a column, and it
76+
// reads a keyed text column's bound only from a literal `maxLength`, so the
77+
// two keyed text columns restate theirs. `plugin.test.ts` pins every entry
78+
// equal to the spec's, so the restatement cannot drift.
79+
id: Field.text({ ...RECYCLE_BIN_ENTRY_FIELDS.id }),
80+
object_name: Field.text({ ...RECYCLE_BIN_ENTRY_FIELDS.object_name, maxLength: 255 }),
81+
record_id: Field.text({ ...RECYCLE_BIN_ENTRY_FIELDS.record_id, maxLength: 255 }),
82+
record_count: Field.number({ ...RECYCLE_BIN_ENTRY_FIELDS.record_count }),
83+
snapshot: Field.json({ ...RECYCLE_BIN_ENTRY_FIELDS.snapshot }),
84+
deleted_by: Field.lookup('sys_user', { ...RECYCLE_BIN_ENTRY_FIELDS.deleted_by }),
85+
deleted_at: Field.datetime({ ...RECYCLE_BIN_ENTRY_FIELDS.deleted_at }),
86+
retention_days: Field.number({ ...RECYCLE_BIN_ENTRY_FIELDS.retention_days }),
87+
purge_after: Field.datetime({ ...RECYCLE_BIN_ENTRY_FIELDS.purge_after }),
7388

7489
organization_id: Field.lookup('sys_organization', {
7590
label: 'Organization',

‎scripts/platform-object-tenancy-census.json‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"predicate": "resolveTenantFieldName(registered schema) !== null, where the registered schema is the authored schema plus the columns resolveInjectedSystemColumns says the registration injects (the applySystemFields pass). Both functions are loaded from source and executed; neither is re-spelled here.",
2727
"population": "every object registered by a tracked packages/**/*.object.ts module whose name carries a platform prefix (sys_ / cloud_ / ai_). The cloud repository's own cloud_ objects are not in this tree and so not in this census.",
2828
"totals": {
29-
"registered": 93,
30-
"inReach": 47,
29+
"registered": 94,
30+
"inReach": 48,
3131
"outOfReach": 46
3232
},
3333
"reasonTotals": {
@@ -564,6 +564,13 @@
564564
"tenantField": "organization_id",
565565
"reasons": []
566566
},
567+
{
568+
"name": "sys_recycle_bin",
569+
"file": "packages/platform-objects/src/system/sys-recycle-bin.object.ts",
570+
"reach": "in",
571+
"tenantField": "organization_id",
572+
"reasons": []
573+
},
567574
{
568575
"name": "sys_scim_connection_binding",
569576
"file": "packages/platform-objects/src/identity/sys-scim-connection-binding.object.ts",

0 commit comments

Comments
 (0)