@bongos/core 1.19.653 → 1.19.655
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bongos-core.json +58 -53
- package/.env.local.example +3 -3
- package/config/branding.neutral.json +1 -1
- package/docker-compose.yml +1 -1
- package/docs/branding-contract.md +1 -1
- package/docs/copy-inventory.md +26 -26
- package/docs/copy-registry.json +32 -32
- package/docs/module-api-changelog.md +4 -0
- package/docs/recipes/self-host.md +3 -3
- package/docs/recipes/standalone-live-docs.md +1 -1
- package/docs/recipes/upgrading-the-core.md +1 -1
- package/modules/dev-box/routes/box.js +4 -2
- package/modules/hall-ui/public/watch.js +38 -14
- package/modules/ideas/routes/inbox.js +22 -3
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/scripts/gds/box.js +3 -3
- package/scripts/gds/claude-materialize.js +1 -1
- package/scripts/gds/init.js +2 -2
- package/scripts/gds/main-audit.js +22 -8
- package/scripts/gds/module.js +3 -2
- package/scripts/gds/oauth-secret.js +6 -3
- package/scripts/gds/provision-units.js +3 -2
- package/scripts/gds/seed-bongos-coreB-tranche1-tasks.js +1 -1
- package/scripts/gds/seed-bongos-coreB-tranche2-tasks.js +1 -1
- package/scripts/gds/seed-provisioning-tasks.js +1 -1
- package/scripts/gds/spark.js +26 -1
- package/scripts/gds/status.js +3 -2
- package/scripts/gds/upgrade.js +3 -3
- package/scripts/hall-preview/server.js +1 -1
- package/src/bongos/routes/auth.js +3 -2
- package/src/bongos/routes/backup.js +8 -4
- package/src/bongos/routes/security.js +2 -1
- package/src/bongos/serve-internal.js +2 -2
- package/src/branding.js +24 -7
- package/src/instance-config.js +74 -13
- package/src/module-api.js +1 -1
- package/src/modules.js +15 -7
- package/tests/claude_materialize.mjs +1 -1
- package/tests/cli_exit_no_abort.mjs +109 -2
- package/tests/cloud_bongos_pack.mjs +1 -1
- package/tests/idea_develop_spark.mjs +43 -0
- package/tests/idea_resubmit.mjs +7 -3
- package/tests/init.mjs +1 -1
- package/tests/instance_config.mjs +98 -2
- package/tests/upgrade.mjs +3 -3
- package/tests/watch_applications_queue.mjs +13 -1
- package/tests/watch_sealed_floor.mjs +241 -0
|
@@ -8,7 +8,7 @@ import ic from '../src/instance-config.js';
|
|
|
8
8
|
|
|
9
9
|
const {
|
|
10
10
|
configDirName, envPrefix, configHome, configReadDirs, configReadPaths,
|
|
11
|
-
resolveEnv, FALLBACK_DIR, FALLBACK_ENV_PREFIX,
|
|
11
|
+
resolveEnv, FALLBACK_DIR, FALLBACK_ENV_PREFIX, LEGACY_ENV_PREFIXES,
|
|
12
12
|
resolveInstanceRootExplicit, resolveDocsRoot, resolveCoreRoot,
|
|
13
13
|
} = ic;
|
|
14
14
|
|
|
@@ -22,7 +22,10 @@ test('configDirName: from branding, else the vanilla fallback (never OTB)', () =
|
|
|
22
22
|
test('envPrefix: from branding, else the vanilla fallback', () => {
|
|
23
23
|
assert.equal(envPrefix({ envPrefix: 'OTB' }), 'OTB');
|
|
24
24
|
assert.equal(envPrefix({}), FALLBACK_ENV_PREFIX);
|
|
25
|
-
|
|
25
|
+
// BONGOS since task 1003703 (criterion C3a). CLOUDBONGOS did not disappear —
|
|
26
|
+
// it moved into LEGACY_ENV_PREFIXES, which the fallback tests below pin.
|
|
27
|
+
assert.equal(FALLBACK_ENV_PREFIX, 'BONGOS');
|
|
28
|
+
assert.ok(LEGACY_ENV_PREFIXES.includes('CLOUDBONGOS'), 'the previous canonical prefix must stay readable');
|
|
26
29
|
});
|
|
27
30
|
|
|
28
31
|
test('configHome: ~/.config/<dir>', () => {
|
|
@@ -61,6 +64,99 @@ test('resolveEnv: legacy PMS prefix still honored (original-name back-compat)',
|
|
|
61
64
|
assert.equal(resolveEnv('GITHUB_CLIENT_ID', { prefix: 'CLOUDBONGOS', env: { PMS_GITHUB_CLIENT_ID: 'old' } }), 'old');
|
|
62
65
|
});
|
|
63
66
|
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// The legacy-prefix DEPRECATION WARNING (task 1003703 / criterion C3a).
|
|
69
|
+
//
|
|
70
|
+
// These assert the fallback FIRES, not merely that the new spelling works. A
|
|
71
|
+
// happy-path-only test would still pass with the whole legacy path deleted,
|
|
72
|
+
// which is exactly the regression task 1003706 (C3d) exists to catch when it
|
|
73
|
+
// removes the fallback on purpose — at which point these tests must be inverted,
|
|
74
|
+
// not quietly dropped.
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
// Collects warn() payloads instead of printing, so a case can assert on shape.
|
|
78
|
+
function capture() {
|
|
79
|
+
const calls = [];
|
|
80
|
+
return { calls, warn: (payload) => { calls.push(payload); return true; } };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Runs fn with console.warn captured, so a case can assert on the REAL default
|
|
84
|
+
// warn path rather than a hand-called helper. resolveEnv's `warn` option is the
|
|
85
|
+
// only seam the module exports; the renderer and its warn-once ledger are
|
|
86
|
+
// internals, reached here exactly the way production reaches them.
|
|
87
|
+
function captureConsole(fn) {
|
|
88
|
+
const lines = [];
|
|
89
|
+
const real = console.warn;
|
|
90
|
+
console.warn = (m) => lines.push(String(m));
|
|
91
|
+
try { fn(); } finally { console.warn = real; }
|
|
92
|
+
return lines;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
test('resolveEnv: ONLY the old spelling set — resolves, and warns naming old, new and the sunset', () => {
|
|
96
|
+
const { calls, warn } = capture();
|
|
97
|
+
const v = resolveEnv('API_BASE', { prefix: 'BONGOS', env: { GDS_API_BASE: 'legacy' }, warn });
|
|
98
|
+
assert.equal(v, 'legacy', 'the legacy spelling must still resolve — boxes still export it');
|
|
99
|
+
assert.equal(calls.length, 1, 'exactly one warning for the one legacy name that was read');
|
|
100
|
+
assert.deepEqual(calls[0], { legacyName: 'GDS_API_BASE', canonicalName: 'BONGOS_API_BASE', shadowed: false, differs: false });
|
|
101
|
+
|
|
102
|
+
// …and the DEFAULT renderer puts all three facts an operator needs on the line.
|
|
103
|
+
// A suffix used by no other case, so the process-global warn-once ledger cannot
|
|
104
|
+
// have already spent this name.
|
|
105
|
+
const lines = captureConsole(() => {
|
|
106
|
+
resolveEnv('C3A_RENDER_PROBE', { prefix: 'BONGOS', env: { CLOUDBONGOS_C3A_RENDER_PROBE: 'legacy' } });
|
|
107
|
+
});
|
|
108
|
+
assert.equal(lines.length, 1);
|
|
109
|
+
assert.match(lines[0], /CLOUDBONGOS_C3A_RENDER_PROBE/, 'names the old spelling');
|
|
110
|
+
assert.match(lines[0], /BONGOS_C3A_RENDER_PROBE/, 'names the new spelling');
|
|
111
|
+
assert.match(lines[0], /stops being read in core 1\.21/, 'names the release it stops working in');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('resolveEnv: ONLY the new spelling set — resolves, and is SILENT', () => {
|
|
115
|
+
const { calls, warn } = capture();
|
|
116
|
+
assert.equal(resolveEnv('API_BASE', { prefix: 'BONGOS', env: { BONGOS_API_BASE: 'new' }, warn }), 'new');
|
|
117
|
+
assert.deepEqual(calls, [], 'the canonical spelling must never warn');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('resolveEnv: BOTH set and disagreeing — the new one wins, and the warning says so', () => {
|
|
121
|
+
const { calls, warn } = capture();
|
|
122
|
+
const v = resolveEnv('API_BASE', { prefix: 'BONGOS', env: { BONGOS_API_BASE: 'new', GDS_API_BASE: 'legacy' }, warn });
|
|
123
|
+
assert.equal(v, 'new', 'an operator who sets the new name expects it to take effect');
|
|
124
|
+
assert.equal(calls.length, 1, 'a SHADOWED legacy name still earns its one warning — it is set on some box');
|
|
125
|
+
assert.equal(calls[0].shadowed, true);
|
|
126
|
+
assert.equal(calls[0].differs, true);
|
|
127
|
+
const lines = captureConsole(() => {
|
|
128
|
+
resolveEnv('C3A_DISAGREE_PROBE', { prefix: 'BONGOS', env: { BONGOS_C3A_DISAGREE_PROBE: 'new', CLOUDBONGOS_C3A_DISAGREE_PROBE: 'legacy' } });
|
|
129
|
+
});
|
|
130
|
+
assert.match(lines[0], /ALSO set to a different value and WINS/, 'the disagreement is spelled out, not implied');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('resolveEnv: both set to the SAME value — warns, but does not claim a disagreement', () => {
|
|
134
|
+
const { calls, warn } = capture();
|
|
135
|
+
resolveEnv('API_BASE', { prefix: 'BONGOS', env: { BONGOS_API_BASE: 'same', GDS_API_BASE: 'same' }, warn });
|
|
136
|
+
assert.equal(calls[0].shadowed, true);
|
|
137
|
+
assert.equal(calls[0].differs, false);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('resolveEnv: every legacy spelling set gets its OWN warning, and the first one wins', () => {
|
|
141
|
+
const { calls, warn } = capture();
|
|
142
|
+
const v = resolveEnv('API_BASE', { prefix: 'BONGOS', env: { CLOUDBONGOS_API_BASE: 'a', OTB_API_BASE: 'b', PMS_API_BASE: 'c' }, warn });
|
|
143
|
+
assert.equal(v, 'a', 'LEGACY_ENV_PREFIXES order decides: CLOUDBONGOS before OTB before PMS');
|
|
144
|
+
assert.deepEqual(calls.map((c) => c.legacyName), ['CLOUDBONGOS_API_BASE', 'OTB_API_BASE', 'PMS_API_BASE']);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('the deprecation warning is once per NAME per process, not once per read', () => {
|
|
148
|
+
const env = { CLOUDBONGOS_C3A_ONCE_PROBE: 'x', CLOUDBONGOS_C3A_ONCE_OTHER: 'y' };
|
|
149
|
+
const lines = captureConsole(() => {
|
|
150
|
+
resolveEnv('C3A_ONCE_PROBE', { prefix: 'BONGOS', env });
|
|
151
|
+
resolveEnv('C3A_ONCE_PROBE', { prefix: 'BONGOS', env }); // same name again
|
|
152
|
+
resolveEnv('C3A_ONCE_PROBE', { prefix: 'BONGOS', env });
|
|
153
|
+
resolveEnv('C3A_ONCE_OTHER', { prefix: 'BONGOS', env }); // a DIFFERENT name
|
|
154
|
+
});
|
|
155
|
+
assert.equal(lines.length, 2, 'three reads of one name warn once; a second name warns again');
|
|
156
|
+
assert.match(lines[0], /CLOUDBONGOS_C3A_ONCE_PROBE/);
|
|
157
|
+
assert.match(lines[1], /CLOUDBONGOS_C3A_ONCE_OTHER/);
|
|
158
|
+
});
|
|
159
|
+
|
|
64
160
|
// task 2051: docs+client are per-instance artifacts written to the instance root when
|
|
65
161
|
// it is EXPLICITLY pointed at (a consumer running `bongos upgrade`), else the coreRoot.
|
|
66
162
|
test('resolveInstanceRootExplicit: env pointer (branded or fallback prefix), else null', () => {
|
package/tests/upgrade.mjs
CHANGED
|
@@ -211,7 +211,7 @@ t('regenerateApiArtifacts: spawns docs then client from the new core, targeting
|
|
|
211
211
|
assert.equal(c.cmd, process.execPath, 'runs node');
|
|
212
212
|
assert.equal(c.opts.cwd, '/inst', 'cwd is the instance');
|
|
213
213
|
// the env points the generators OUTPUT at the instance repo, not node_modules
|
|
214
|
-
assert.equal(c.opts.env.
|
|
214
|
+
assert.equal(c.opts.env.BONGOS_INSTANCE_ROOT, '/inst');
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
217
|
|
|
@@ -805,7 +805,7 @@ t('regenerateNavDocs: default set is the whole-file nav docs (session-index only
|
|
|
805
805
|
assert.deepEqual(u.NAV_WHOLE_FILE_GENERATORS, ['gen-session-index.js']);
|
|
806
806
|
});
|
|
807
807
|
|
|
808
|
-
t('regenerateNavDocs: spawns each generator from the CORE against the INSTANCE root (cwd +
|
|
808
|
+
t('regenerateNavDocs: spawns each generator from the CORE against the INSTANCE root (cwd + BONGOS_INSTANCE_ROOT), ok when all succeed', () => {
|
|
809
809
|
const calls = [];
|
|
810
810
|
const run = (cmd, args, opts) => { calls.push({ cmd, arg0: args[0], cwd: opts && opts.cwd, env: opts && opts.env }); return { status: 0 }; };
|
|
811
811
|
const fsImpl = { existsSync: () => true };
|
|
@@ -815,7 +815,7 @@ t('regenerateNavDocs: spawns each generator from the CORE against the INSTANCE r
|
|
|
815
815
|
assert.deepEqual(res.failed, []);
|
|
816
816
|
assert.equal(calls.length, 1);
|
|
817
817
|
assert.equal(calls[0].cwd, '/inst', 'runs with cwd = the instance dir');
|
|
818
|
-
assert.equal(calls[0].env.
|
|
818
|
+
assert.equal(calls[0].env.BONGOS_INSTANCE_ROOT, '/inst', 'sets the instance-root env so the generator writes into the instance');
|
|
819
819
|
assert.equal(calls[0].arg0, join('/core', 'scripts', 'gds', 'gen-session-index.js'), 'spawns the generator from the CORE package');
|
|
820
820
|
});
|
|
821
821
|
|
|
@@ -368,8 +368,20 @@ await test('an empty view still offers the invite form and the switch out of it'
|
|
|
368
368
|
});
|
|
369
369
|
|
|
370
370
|
await test('a 403 seals the section rather than blanking the page', async () => {
|
|
371
|
+
// This used to assert the literal "Archons only". Task 1003449 removed that
|
|
372
|
+
// sentence from the page: the floor is read off the denial's `details.floors`
|
|
373
|
+
// now, because ADR 0157 moved most of this surface to metic and a page must
|
|
374
|
+
// not name a floor its gate does not enforce. THIS harness answers 403 with a
|
|
375
|
+
// null body, so there is no floor to name and the honest render is the subject
|
|
376
|
+
// clause alone. What the test was really pinning — the section seals, the page
|
|
377
|
+
// does not blank — is unchanged and is what it asserts.
|
|
378
|
+
//
|
|
379
|
+
// The floor-derivation itself is executed in tests/watch_sealed_floor.mjs,
|
|
380
|
+
// which scripts real envelopes at both floors.
|
|
371
381
|
const h = await boot({ queueStatus: 403 });
|
|
372
|
-
assert.match(h.gate().textContent, /
|
|
382
|
+
assert.match(h.gate().textContent, /not visible at your rank/);
|
|
383
|
+
assert.doesNotMatch(h.gate().textContent, /Archon|Metic/,
|
|
384
|
+
'a denial with no floor in its body must name no rank');
|
|
373
385
|
assert.equal(h.rows().length, 0);
|
|
374
386
|
});
|
|
375
387
|
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// tests/watch_sealed_floor.mjs — a sealed panel names the floor the SERVER
|
|
2
|
+
// enforced, EXECUTED (task 1003449).
|
|
3
|
+
//
|
|
4
|
+
// THE DEFECT. Every panel on /watch answered a 403 with the literal string
|
|
5
|
+
// "Archons only." ADR 0157 moved most of this surface to metic — five of the
|
|
6
|
+
// atoms behind these panels carry "(ADR 0157, was archon)" in their own catalog
|
|
7
|
+
// entry — so the page was teaching a permission model the server had stopped
|
|
8
|
+
// implementing. The hall audit filed it against watch.html:30 and sessions.html:27;
|
|
9
|
+
// both of those lines are gone (the page heads were rewritten by task 1003307) and
|
|
10
|
+
// scouting.js was deleted by task 1003440, so the copy actually lived in the
|
|
11
|
+
// fourteen `sealedMsg` strings in watch.js. The reported symptom was real; the
|
|
12
|
+
// reported location was not.
|
|
13
|
+
//
|
|
14
|
+
// WHY THE FIX IS NOT "CHANGE archon TO metic". The floors are MIXED, and a blanket
|
|
15
|
+
// rewrite would have been wrong in the other direction:
|
|
16
|
+
//
|
|
17
|
+
// access_request.review → archon ("Archons only" was CORRECT here)
|
|
18
|
+
// override_request.decide → metic (ADR 0157, was archon)
|
|
19
|
+
// builder.roster.read → metic (ADR 0157, was archon)
|
|
20
|
+
// session.search → metic (ADR 0157, was archon)
|
|
21
|
+
// audit_log.read → metic (ADR 0157, was archon)
|
|
22
|
+
// box.fleet.manage → metic (ADR 0157, was archon)
|
|
23
|
+
//
|
|
24
|
+
// A hardcoded 'metic' is the same defect one ADR later, which is why the fix reads
|
|
25
|
+
// the floor off the DENIAL: requirePermission already rides `details.floors` on
|
|
26
|
+
// every 403, and its own comment in src/bongos/auth.js names hardcoded prose as
|
|
27
|
+
// "the D-16/N-3 failure shape ADR 0157 left behind". The page just never read it.
|
|
28
|
+
//
|
|
29
|
+
// These run the real watch.js in a vm against the real watch.html — the harness
|
|
30
|
+
// tests/watch_applications_queue.mjs established — because the claim under test is
|
|
31
|
+
// what a denied builder READS. A source grep can see that the string changed; it
|
|
32
|
+
// cannot see which sentence a 403 actually paints.
|
|
33
|
+
//
|
|
34
|
+
// Run: node tests/watch_sealed_floor.mjs
|
|
35
|
+
|
|
36
|
+
import { strict as assert } from 'node:assert';
|
|
37
|
+
import fs from 'node:fs';
|
|
38
|
+
import path from 'node:path';
|
|
39
|
+
import vm from 'node:vm';
|
|
40
|
+
import { fileURLToPath } from 'node:url';
|
|
41
|
+
import { makeRunner, makeEl, parseInto } from './helpers.mjs';
|
|
42
|
+
|
|
43
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
44
|
+
const HALL = path.join(ROOT, 'modules/hall-ui/public');
|
|
45
|
+
const SRC = fs.readFileSync(path.join(HALL, 'watch.js'), 'utf8');
|
|
46
|
+
const PAGE = fs.readFileSync(path.join(HALL, 'watch.html'), 'utf8');
|
|
47
|
+
|
|
48
|
+
const { test, summary } = makeRunner();
|
|
49
|
+
|
|
50
|
+
const escapeHtml = (s) => String(s == null ? '' : s).replace(/[&<>"']/g,
|
|
51
|
+
(c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
52
|
+
|
|
53
|
+
const tick = () => new Promise((r) => setTimeout(r, 0));
|
|
54
|
+
async function settle() { for (let i = 0; i < 40; i++) await tick(); }
|
|
55
|
+
|
|
56
|
+
const ok = (data) => ({ status: 200, ok: true, data });
|
|
57
|
+
|
|
58
|
+
// The ADR 0116 envelope requirePermission actually sends: the sentence, plus
|
|
59
|
+
// `details.floors` mapping each MISSING permission key to its catalog floor.
|
|
60
|
+
const denied = (floors) => ({
|
|
61
|
+
status: 403,
|
|
62
|
+
ok: false,
|
|
63
|
+
data: {
|
|
64
|
+
error: {
|
|
65
|
+
code: 'permission_forbidden',
|
|
66
|
+
message: 'missing permission',
|
|
67
|
+
details: { required: Object.keys(floors || {}), held: [], floors: floors || null },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// The label the page is expected to render the rank THROUGH. Distinct from the
|
|
73
|
+
// bare rank key on purpose: if a test passed when the page printed the raw key,
|
|
74
|
+
// it would also pass on an instance that renamed its ranks and got the old word.
|
|
75
|
+
const LABELS = { archon: 'Archon', metic: 'Metic', thetes: 'Thetes', xenos: 'Xenos' };
|
|
76
|
+
|
|
77
|
+
// ===========================================================================
|
|
78
|
+
// Boot the real page, scripting one answer per route.
|
|
79
|
+
// ===========================================================================
|
|
80
|
+
|
|
81
|
+
async function boot({ answers = {}, fallback = ok({}) } = {}) {
|
|
82
|
+
const api = {
|
|
83
|
+
async request(method, p) {
|
|
84
|
+
const url = String(p).replace('/api/bongos', '');
|
|
85
|
+
const route = url.split('?')[0];
|
|
86
|
+
if (method === 'GET' && route === '/me') {
|
|
87
|
+
return ok({ builder: { id: 1, rank: 'metic', github_login: 'someone' } });
|
|
88
|
+
}
|
|
89
|
+
if (Object.prototype.hasOwnProperty.call(answers, route)) return answers[route];
|
|
90
|
+
return fallback;
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const documentObj = {
|
|
95
|
+
readyState: 'complete',
|
|
96
|
+
body: makeEl('body'),
|
|
97
|
+
documentElement: makeEl('html'),
|
|
98
|
+
createElement: (tag) => makeEl(tag),
|
|
99
|
+
getElementById(id) { return this.body.querySelector(`#${id}`); },
|
|
100
|
+
querySelector(sel) { return this.body.querySelector(sel); },
|
|
101
|
+
querySelectorAll(sel) { return this.body.querySelectorAll(sel); },
|
|
102
|
+
addEventListener() {},
|
|
103
|
+
};
|
|
104
|
+
parseInto(documentObj.body, PAGE);
|
|
105
|
+
|
|
106
|
+
const locationObj = { hostname: 'builders.example.test', pathname: '/builders/watch', search: '', hash: '', assign() {} };
|
|
107
|
+
|
|
108
|
+
const kit = {
|
|
109
|
+
makeTabs: () => ({}),
|
|
110
|
+
makeLedger: () => ({ render() {} }),
|
|
111
|
+
makePager: () => ({ page: 1, perPage: 25 }),
|
|
112
|
+
emptyStateHtml: (msg) => `<div class="empty-state"><p>${escapeHtml(msg)}</p></div>`,
|
|
113
|
+
makeFilterBar: (o) => ({ el: o.mount, values: () => ({}) }),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const windowObj = {
|
|
117
|
+
__BRANDING__: { project: { joinability: 'apply' } },
|
|
118
|
+
OTB: {
|
|
119
|
+
escapeHtml,
|
|
120
|
+
$: (sel) => documentObj.querySelector(sel),
|
|
121
|
+
num: (v) => Number(v),
|
|
122
|
+
fmtInt: (n) => String(n),
|
|
123
|
+
fmtCompact: (n) => String(n),
|
|
124
|
+
fmtDate: (iso) => String(iso).slice(0, 10),
|
|
125
|
+
rankLabel: (r) => LABELS[String(r)] || '',
|
|
126
|
+
toast: () => {},
|
|
127
|
+
},
|
|
128
|
+
OTBKit: kit,
|
|
129
|
+
OTBBranding: { currencyLabel: () => 'Credits' },
|
|
130
|
+
BongosClient: { createClient: () => api },
|
|
131
|
+
location: locationObj,
|
|
132
|
+
addEventListener() {},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const sandbox = {
|
|
136
|
+
window: windowObj, document: documentObj, location: locationObj,
|
|
137
|
+
console: { log() {}, warn() {}, error() {} },
|
|
138
|
+
setTimeout, clearTimeout, Promise, Date, Math, JSON, Error, isNaN,
|
|
139
|
+
Number, String, Object, Array, Boolean, Set, Map, RegExp,
|
|
140
|
+
encodeURIComponent, decodeURIComponent, parseInt, parseFloat,
|
|
141
|
+
};
|
|
142
|
+
sandbox.globalThis = sandbox;
|
|
143
|
+
vm.createContext(sandbox);
|
|
144
|
+
vm.runInContext(SRC, sandbox, { filename: 'watch.js' });
|
|
145
|
+
await settle();
|
|
146
|
+
|
|
147
|
+
const sealed = (id) => {
|
|
148
|
+
const el = documentObj.getElementById(id);
|
|
149
|
+
const p = el && el.querySelector('.watch-unavailable');
|
|
150
|
+
return p ? p.textContent : null;
|
|
151
|
+
};
|
|
152
|
+
return { sealed, documentObj };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ===========================================================================
|
|
156
|
+
// The floor comes from the denial
|
|
157
|
+
// ===========================================================================
|
|
158
|
+
|
|
159
|
+
await test('an archon-floored panel still says Archon', async () => {
|
|
160
|
+
// access_request.review really is archon-floored, so the old copy happened to
|
|
161
|
+
// be right HERE. The fix must not "correct" a sentence that was already true.
|
|
162
|
+
const h = await boot({ answers: { '/access-requests': denied({ 'access_request.review': 'archon' }) } });
|
|
163
|
+
const msg = h.sealed('gate-body');
|
|
164
|
+
assert.ok(msg, 'the access-requests panel rendered no sealed message');
|
|
165
|
+
assert.match(msg, /^Archon and up\./, `expected the archon floor, got: ${msg}`);
|
|
166
|
+
assert.match(msg, /Access requests are not visible at your rank\./, `the subject clause was lost: ${msg}`);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
await test('a metic-floored panel says Metic — the defect, in one assertion', async () => {
|
|
170
|
+
// This is the sentence a metic used to read as "Archons only" on a page they
|
|
171
|
+
// could open, having been told the ladder was something it is not.
|
|
172
|
+
const h = await boot({ answers: { '/audit-log': denied({ 'audit_log.read': 'metic' }) } });
|
|
173
|
+
const msg = h.sealed('audit-body');
|
|
174
|
+
assert.ok(msg, 'the audit-log panel rendered no sealed message');
|
|
175
|
+
assert.match(msg, /^Metic and up\./, `expected the metic floor, got: ${msg}`);
|
|
176
|
+
assert.doesNotMatch(msg, /Archon/, `the retired floor came back: ${msg}`);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
await test('two panels denied at DIFFERENT floors say different things', async () => {
|
|
180
|
+
// The whole reason the floor is read rather than written: one page, two true
|
|
181
|
+
// answers. A blanket rewrite in either direction fails this test.
|
|
182
|
+
const h = await boot({
|
|
183
|
+
answers: {
|
|
184
|
+
'/access-requests': denied({ 'access_request.review': 'archon' }),
|
|
185
|
+
'/builders/roster': denied({ 'builder.roster.read': 'metic' }),
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
assert.match(h.sealed('gate-body'), /^Archon and up\./);
|
|
189
|
+
assert.match(h.sealed('roster-body'), /^Metic and up\./);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// ===========================================================================
|
|
193
|
+
// The honest silences
|
|
194
|
+
// ===========================================================================
|
|
195
|
+
|
|
196
|
+
await test('a denial carrying NO floor names no rank at all', async () => {
|
|
197
|
+
// The government port is optional (ADR 0083), so `floors` can legitimately be
|
|
198
|
+
// absent. Naming a rank anyway is guessing, and guessing is what this task is.
|
|
199
|
+
const h = await boot({ answers: { '/audit-log': { status: 403, ok: false, data: null } } });
|
|
200
|
+
const msg = h.sealed('audit-body');
|
|
201
|
+
assert.equal(msg, 'The audit log is not visible at your rank.',
|
|
202
|
+
`a floorless denial must render the subject alone, got: ${msg}`);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
await test('a denial on keys with CONFLICTING floors names no rank', async () => {
|
|
206
|
+
// A multi-atom gate can deny on two keys with different floors. There is no
|
|
207
|
+
// single honest sentence, so the panel says none rather than picking the one
|
|
208
|
+
// that happens to sort first.
|
|
209
|
+
const h = await boot({
|
|
210
|
+
answers: { '/audit-log': denied({ 'audit_log.read': 'metic', 'something.else': 'archon' }) },
|
|
211
|
+
});
|
|
212
|
+
const msg = h.sealed('audit-body');
|
|
213
|
+
assert.equal(msg, 'The audit log is not visible at your rank.',
|
|
214
|
+
`an ambiguous floor must not be resolved by guessing, got: ${msg}`);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// ===========================================================================
|
|
218
|
+
// The literal cannot come back
|
|
219
|
+
// ===========================================================================
|
|
220
|
+
|
|
221
|
+
await test('no sealed message on this page hardcodes a rank name', async () => {
|
|
222
|
+
// The source half of the claim: a future edit that re-writes "Archons only."
|
|
223
|
+
// into a sealedMsg reds here even if it never renders in a test.
|
|
224
|
+
const strings = [...SRC.matchAll(/sealedMsg:\s*'([^']*)'/g)].map((m) => m[1]);
|
|
225
|
+
assert.ok(strings.length >= 10, `expected the page's sealed messages, found ${strings.length}`);
|
|
226
|
+
for (const s of strings) {
|
|
227
|
+
assert.doesNotMatch(s, /Archon|Metic|Thetes|Xenos/i,
|
|
228
|
+
`a sealed message names a rank in its own text: "${s}". The rank comes from `
|
|
229
|
+
+ 'the 403, or the sentence does not claim one.');
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
await test('the 403 path carries the floor rather than discarding the body', async () => {
|
|
234
|
+
// fetchJson used to throw a bare { kind: '403' }, which is what made every
|
|
235
|
+
// panel's sentence a guess. Pin the shape, not just the rendered output.
|
|
236
|
+
assert.match(SRC, /details\.floors/,
|
|
237
|
+
'fetchJson must read details.floors off the denial — otherwise the page is '
|
|
238
|
+
+ 'back to writing the floor itself');
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
summary('watch sealed floor (task 1003449)');
|