diff --git a/docs/SESSIONS.md b/docs/SESSIONS.md index 0eee225a1..979b074a1 100644 --- a/docs/SESSIONS.md +++ b/docs/SESSIONS.md @@ -2105,3 +2105,4 @@ are never rewritten or removed; corrections are new entries. 2026-11-06 UTC | Codex implementation sub-agent | #797 Files heading and remount polish on files-polish from 4cc3d05b3 | Single caller heading and fenced sign-out-cleared DOM cache; Node 26 authorized browser gates 91/0/0/0, exact-base behavioral controls and fixture correction recorded in /mnt/storage/scratch/mosaic-lead/mvp3/files-polish-report.md. Queue refused linked worktree; canonical queue reported nothing for this seat. One local candidate for independent review; no push, merge or deployment. 2026-11-06 UTC | mvp3-lead-797 (Claude, #797 lane) | files-polish r2 on 86383a9d1 for Sol r1 F1/F2 | Per-key commit order fences live paints and caches the newest completed result; reviewer probes ported; r1 negative 11/2, w15-files 13/13, caller browser gate 93/0/0/0. Evidence: /mnt/storage/scratch/mosaic-lead/mvp3/files-polish-r2-evidence/. 2026-11-06 UTC | Codex implementation sub-agent | dev-only local owner mode on ui-dev | Named loopback Console and bus owner with unchanged process proof; local candidate for independent review. Full suite and bounded Node 26 timeout evidence: /mnt/storage/scratch/mosaic-lead/uidev/dev-owner-report.md. Queue refused linked worktree; no push, merge or deployment. +2026-11-06 UTC | Codex implementation sub-agent | dev local owner named data-root claim correction on ui-dev | Both entry points use the existing named-instance validator; missing, mismatched and hard-linked claims refuse before startup. Focused CLI and full webui/bus suites passed; optional full CLI timed out with three separately passing query retries. Evidence: /mnt/storage/scratch/mosaic-lead/uidev/dev-owner-report.md. Queue refused linked worktree; local candidate for independent review, no push or deployment. diff --git a/packages/cli/src/cli.mjs b/packages/cli/src/cli.mjs index 4c0e3f50d..e9e0e3672 100644 --- a/packages/cli/src/cli.mjs +++ b/packages/cli/src/cli.mjs @@ -555,7 +555,7 @@ async function bus(rest, io, deps) { if (parsed.flags.has("--dev-local-owner") && parsed.flags.has("--pm")) throw usage("--dev-local-owner cannot be combined with --pm"); const instance = parsed.flags.has("--dev-local-owner") ? devOwnerInstance(io.env) : null; const businessId = parsed.positional[0]; - const system = deps.system ?? loadSystem({ env: io.env }); + const system = instance ? loadSystem({ env: io.env, instance }) : (deps.system ?? loadSystem({ env: io.env })); // Fail closed, and say so (vikunja:19/302): a refused load is recorded where the Console and // `bus status` can read it, then thrown as before. No retry. const file = businessFilePath(businessId, configDir(io.env)); diff --git a/packages/cli/src/config.mjs b/packages/cli/src/config.mjs index 95dc8274f..3c84e3c2d 100644 --- a/packages/cli/src/config.mjs +++ b/packages/cli/src/config.mjs @@ -21,8 +21,8 @@ export const REPO = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", // `/bus/writer.lock` (packages/bus/src/store.mjs). export const socketPath = (dataRoot) => join(dataRoot, "bus", "broker.sock"); -export function loadSystem({ env = process.env } = {}) { - const proc = spawnSync(process.execPath, [join(REPO, "scripts", "mosaic-config.mjs"), "validate"], { +export function loadSystem({ env = process.env, instance = null } = {}) { + const proc = spawnSync(process.execPath, [join(REPO, "scripts", "mosaic-config.mjs"), "validate", ...(instance === null ? [] : ["--instance", instance])], { encoding: "utf8", maxBuffer: 1024 * 1024, env, diff --git a/packages/webui/src/cli.mjs b/packages/webui/src/cli.mjs index a98a2c8a9..9ca3a5745 100644 --- a/packages/webui/src/cli.mjs +++ b/packages/webui/src/cli.mjs @@ -76,7 +76,7 @@ try { let bus = null, send = null, settingsWrite = null, projectFiles = null, projectFile = null, libraryFile = null, libraryStatus = null, librarySync = null, libraryRevert = null, librarySave = null, projectSave = null, chat = null, nameWrite = null, assistantStop = null, instancesWrite = null, routesWrite = null, agentWrite = null, proxyCall = null, decisionWrite = null, requestRead = null, requestWrite = null, busLine, system = null; let processing = null, ownerCall = null; try { - system = loadSystem(); + system = loadSystem({ instance }); const { dataRoot } = system; const call = ownerCall = busCaller({ dataRoot, socket: socketPath(dataRoot), business: options.business ?? null }); // FED R6 (#1800): the bus-backed options, shared with each granted user's session (console-bus.mjs). diff --git a/packages/webui/tests/dev-local-owner.test.mjs b/packages/webui/tests/dev-local-owner.test.mjs index 230744bd7..1ac80c916 100644 --- a/packages/webui/tests/dev-local-owner.test.mjs +++ b/packages/webui/tests/dev-local-owner.test.mjs @@ -31,6 +31,41 @@ test('dev owner refuses a named config symlink to the default config', async t = const r=run(['--dev-local-owner'],{HOME:home,MOSAIC_CONFIG:join(named,'config.json')}); assert.equal(r.status,2); assert.match(r.stderr,/--dev-local-owner requires a named instance/); }); + +for (const scenario of [ + { name: 'missing marker', owner: null, reason: /instance-root-unclaimed.*holds no instance\.json naming test/ }, + { name: 'default dev marker', owner: 'dev', reason: /instance-root-mismatch.*claimed by instance dev, not test/ }, + { name: 'different instance marker', owner: 'other', reason: /instance-root-mismatch.*claimed by instance other, not test/ }, + { name: 'named hard link to default config', owner: 'dev', hardLink: true, reason: /instance-root-mismatch.*claimed by instance dev, not test/ }, +]) { + test(`dev owner entry points refuse ${scenario.name} before startup`, async t => { + const { existsSync, linkSync, mkdirSync, mkdtempSync, renameSync, rmSync, writeFileSync } = await import('node:fs'); + const { tmpdir } = await import('node:os'); + const { join } = await import('node:path'); + const { fixture } = await import('../../cli/tests/helpers.mjs'); + const root = mkdtempSync(join(tmpdir(), 'dev-owner-claim-')); + t.after(() => rmSync(root, { recursive: true, force: true })); + const f = fixture(root), home = join(root, 'home'), base = join(home, '.config'); + mkdirSync(base, { recursive: true }); + if (scenario.hardLink) { + renameSync(join(root, 'config'), join(base, 'mosaic-dev')); + mkdirSync(join(base, 'mosaic-test')); + linkSync(join(base, 'mosaic-dev', 'config.json'), join(base, 'mosaic-test', 'config.json')); + } else renameSync(join(root, 'config'), join(base, 'mosaic-test')); + if (scenario.owner) writeFileSync(join(f.dataRoot, 'instance.json'), JSON.stringify({ instanceVersion: 1, name: scenario.owner })); + const env = { ...f.env, HOME: home, MOSAIC_CONFIG: join(base, 'mosaic-test', 'config.json') }; + for (const args of [ + ['packages/webui/src/cli.mjs', 'serve', '--port', '0', '--dev-local-owner'], + ['packages/cli/src/cli.mjs', 'bus', 'start', 'acme', '--dev-local-owner'], + ]) { + const r = spawnSync(process.execPath, args, { env, encoding: 'utf8', timeout: 3000 }); + assert.notEqual(r.status, 0, args.join(' ')); + assert.match(r.stderr, scenario.reason, args.join(' ')); + assert.doesNotMatch(r.stdout, /DEV LOCAL OWNER MODE|Mosaic Console:|bus host up:/); + assert.equal(existsSync(join(f.dataRoot, 'bus')), false, 'no bus startup state'); + } + }); +} test('dev identity is fixed and cannot be configured as a real SSO issuer', () => { const provider = createDevOwner(), a = provider.session(), b = provider.session(); assert.equal(a,b); assert.deepEqual({provider:a.provider,iss:a.iss,sub:a.sub}, DEV_OWNER); @@ -54,7 +89,7 @@ test('dev owner enforces exact Host and Origin and exposes mode', async t => { }); test('dev owner resolves a decision through the real Console wrapper and bus', {timeout:90000}, async t => { - const { mkdtempSync, mkdirSync, renameSync, openSync, closeSync, readFileSync, rmSync } = await import('node:fs'); + const { mkdtempSync, mkdirSync, renameSync, openSync, closeSync, readFileSync, rmSync, writeFileSync } = await import('node:fs'); const { tmpdir } = await import('node:os'); const { join } = await import('node:path'); const { spawn } = await import('node:child_process'); @@ -66,6 +101,7 @@ test('dev owner resolves a decision through the real Console wrapper and bus', { t.after(()=>rmSync(root,{recursive:true,force:true})); const f=fixture(root); notifyConfig(f.dataRoot, 'acme', null); const home=join(root,'home'), configDir=join(home,'.config','mosaic-test'); mkdirSync(join(home,'.config'),{recursive:true}); renameSync(join(root,'config'),configDir); + writeFileSync(join(f.dataRoot,'instance.json'), JSON.stringify({instanceVersion:1,name:'test'})); const env={...f.env,HOME:home,MOSAIC_CONFIG:join(configDir,'config.json')}; const system=loadSystem({env}), boot=bootConfig({system,businessId:'acme',env}); const store=new Store(f.dataRoot), broker=new Broker({store,businesses:boot.businesses});