|
34 | 34 | // an older release left it, and the restart is refused; |
35 | 35 | // - CONTROL: stored definitions under two built-in position names — the |
36 | 36 | // platform's own declaration sits beside them (ADR-0005), and the restart |
37 | | -// boots; |
| 37 | +// boots. The save door refuses that write now, with the hatch set too |
| 38 | +// (ADR-0131 D6: managed content is sealed), so the rows are written at the |
| 39 | +// driver the way an older release left them; |
38 | 40 | // - CONTROL: a package whose names the environment does not hold boots on a |
39 | 41 | // database whose environment holds others, and restarts. |
40 | 42 | // |
@@ -115,7 +117,9 @@ describe('ADR-0048 N.3: a package-held position or permission-set name the envir |
115 | 117 | }); |
116 | 118 |
|
117 | 119 | // The built-in control saves under two built-in position names, which the |
118 | | - // platform's package registers, so the save needs the documented hatch. The |
| 120 | + // platform's package registers. Before ADR-0131 D6 that save needed the |
| 121 | + // documented hatch; the hatch no longer opens an item a managed package |
| 122 | + // ships, and the control pins that it stays shut with the hatch set. The |
119 | 123 | // protocol reads `OS_METADATA_WRITABLE` ONCE per process and memoises it, so |
120 | 124 | // it is set for the whole file, before the first boot: set inside the one |
121 | 125 | // case, a save in an earlier case would already have memoised it closed. No |
@@ -204,9 +208,22 @@ describe('ADR-0048 N.3: a package-held position or permission-set name the envir |
204 | 208 | const db = databaseFile(); |
205 | 209 | stack = await bootStack(baseApp, { databaseFile: db }); |
206 | 210 | const saveToken = await stack.signIn(); |
| 211 | + // [ADR-0131 D6] The save door refuses the write, with the hatch set too... |
207 | 212 | for (const name of ['org_admin', 'everyone']) { |
208 | | - const saved = await stack.apiAs(saveToken, 'PUT', `/meta/position/${name}`, { name, label: `Repurposed ${name}` }); |
209 | | - expect(saved.status, JSON.stringify(await saved.clone().json().catch(() => ({})))).toBe(200); |
| 213 | + const refused = await stack.apiAs(saveToken, 'PUT', `/meta/position/${name}`, { name, label: `Repurposed ${name}` }); |
| 214 | + const envelope: any = await refused.clone().json().catch(() => ({})); |
| 215 | + expect(refused.status, JSON.stringify(envelope)).toBe(403); |
| 216 | + expect(envelope?.code ?? envelope?.error?.code).toBe('NOT_OVERRIDABLE'); |
| 217 | + } |
| 218 | + // ...so the rows are written the way an older release left them: active, |
| 219 | + // environment-wide, bound to no package. |
| 220 | + const ql: any = await stack.kernel.getServiceAsync('objectql'); |
| 221 | + const now = new Date().toISOString(); |
| 222 | + for (const name of ['org_admin', 'everyone']) { |
| 223 | + await ql.insert('sys_metadata', { |
| 224 | + type: 'position', name, organization_id: null, package_id: null, state: 'active', version: 1, checksum: null, |
| 225 | + created_at: now, updated_at: now, metadata: JSON.stringify({ name, label: `Repurposed ${name}` }), |
| 226 | + }, SYS); |
210 | 227 | } |
211 | 228 | await stack.stop(); |
212 | 229 | stack = undefined; |
|
0 commit comments