diff --git a/BUILD-LOG.md b/BUILD-LOG.md index 5aea71591..1ac0d1d15 100644 --- a/BUILD-LOG.md +++ b/BUILD-LOG.md @@ -5971,3 +5971,4 @@ Owner directed static-only fallback after actual nativepriority drift: no new pr 2026-11-03T03:41:28Z | Claude Opus 5.5 implementation sub-agent (lead T3 c5c1e8ba) | Vikunja #774 R2 for row 332 (GPT review P2 on round 1) on t3/proxy-launch-774-r2-fix, product commit b8f01a189 on a605e44d1 | Correction to the round 1 entry: its first proxy check refused only when the primary and the fallback both refused, so a healthy primary at capacity zero passed it and was refused only after modelPreflight. Both checks now pick the route through one helper, pickRoute in check(): the primary when its harness preflight passes, else the fallback through its own preflight. The first check calls it with a stand-in session proxy (PENDING_ADMISSION_KEY "pending-admission", a fixed non-secret marker, on the configured proxy port) that reaches only the preflights, then gates the picked route only, gate() still given null; no union and no retry. The final check calls it with proxyFor; its body is the round 1 code moved into the helper (proxyFor renamed proxyOf, two spaces less indent). Nothing reads the first check's route: startLocked takes model and account from the final check. Fixture options extra, real and hostEnv load the real claude-code harness with a pi fallback. Tests: 7 new in proxy-launch-order.test.mjs (healthy primary at capacity zero, fallback launch, failed primary at capacity zero, fallback at capacity zero, both preflights fail, no fallback, stand-in key absent from the launch log, bus events, session.json and the data root); on a605e44d1 the four refusal tests fail on modelPreflight 1 !== 0 and the three live tests pass. Runs: cli 1120/1121 with 1 skip (FED R7), 768 s; bus 1397/1397, 52 s; launch-limit-checks 5/5; neither known flake appeared. Mutants M4 (fall back on any primary gate refusal, test 1), M5 (first check never falls back, tests 2, 3, 4a, 4b, 6), M6 (no predicted preflight, tests 3, 4a, 4b, 5), the reviewer's unconditional throw at the helper's fallback decision (tests 2, 3, 4a, 4b, 6) and M7 (stand-in key written to the launch log, test 6) each killed. No push, queue, Vikunja, Gitea or PR action. 2026-11-03T04:07:40Z | Claude Opus 5.5 implementation sub-agent (lead T3 c5c1e8ba) | editor-browser.test.mjs:154 under Chromium 156 (Vikunja #784) on t3/editor-chromium-156, test commit 0c6aa1a1e on 1ff45c4ad | Case 2, no product defect: Chromium 156 checks script-src-attr when an inline handler attribute is created, also in a document with no window (WPT PR 62762; PR 64290 later skips such documents and 156 lacks it). All four reports come from prosemirror-view readHTML's innerHTML parse into a new createHTMLDocument (editor.js:8212:19, target the page document, one per pasted handler: img onerror, a onclick, a onmouseover, svg onload); no on* attribute reaches the live page and injected stays null; Chromium 153, 151 and Brave 154 report none for the same paste. Fix is test-only: the page's CSP record sets aside a script-src-attr report whose sourceFile is /editor.js, whose line is readHTML's parse (computed from the bundle, with a guard pinning those lines and detachedDoc) and whose target is the document; quiet(), inert(), injected, errors, rejections and the Console CSP are unchanged. New test: after a hostile paste, a handler set on a live editor paragraph, one parsed into a page-owned element never attached, and one set through prosemirror-view's attributes prop each still fail quiet(). editor-browser 17/17, editor plus editor-provenance 11/11, no skips; 4 mutants killed (all script-src-attr, target only, target only without the paragraph case, editor.js at any line). Residual: an element from that parse attached to the page after its report was sent would not be caught by the CSP record; on 156 its listener is never set. Full webui suite not run (bundle not rebuilt); Chromium 152 not on the host. No push, queue or PR action. +2026-11-03T04:12:57Z | Claude Opus 5.5 implementation sub-agent (lead T3 c5c1e8ba) | Vikunja #415 and #416, .53 and .54 Console writes, on t3/console-writes-53-54, fix commit bd79daffd on 1ff45c4ad | Factory: scripts/case2-unit.sh takes the paired bare --sso --send (the lane b00019548 serve_flags rule), refuses either alone, still refuses the preview set and the proof pair, and before any unit write a bounded query run as the stack user, through the existing config-query supervisor, checks for console.sso. Library: unchanged and still read-only. Library --send with forward-auth and proof is not done: since #385 the tip's Console refuses --send without --sso (packages/webui/src/cli.mjs:63, serve.mjs:681), and reverting that is more than about 40 lines across the webui, service, release and upgrade scripts and reopens a reviewed security boundary, so it goes back to the lead. docs/guides/case1-business.mosaic-stack.json launches claude-opus-5-5 with provider proxy, route anthropic, under account factory with credential proxy. Tests: 5 new in case2-unit.test.mjs (4 RED on base) and 1 updated; case1-business-file.test.mjs 1 updated (RED on the base document) and 1 new. Runs: cli case2-unit 88/88, stack-upgrade 25/25, case1-accept 53/53; business case1-business-file 8/8, case1-project-key 3/3, chief-library-credentials 3/3; no skips. Mutants: factory --send without --sso and library without --proof-header required, each killed. Not done: scripts/case1-accept.sh still refuses --sso and --send in the args file (out of scope). No push, queue or PR action. diff --git a/docs/SESSIONS.md b/docs/SESSIONS.md index ee6a77421..2467c21c7 100644 --- a/docs/SESSIONS.md +++ b/docs/SESSIONS.md @@ -1977,3 +1977,4 @@ are never rewritten or removed; corrections are new entries. 2026-11-03 | Claude (sub-agent of Mosaic Stack lead c5c1e8ba) | Vikunja #774 F1/F4 for row 332 | 85ecdfbde on t3/proxy-launch-774 (base 1ff45c4ad): proxy first check runs every key-independent refusal before authorizeLaunch, checkouts and modelPreflight; testProxy test option refused with system.proxy; 7 new tests; cli 1113 + 1 skip, bus 1397, launch-limit-checks 5; mutants M1-M3 killed 2026-11-03 | Claude (sub-agent of Mosaic Stack lead c5c1e8ba) | Vikunja #774 R2 for row 332 | b8f01a189 on t3/proxy-launch-774-r2-fix (base a605e44d1): one pickRoute helper picks the route in both checks; the first check predicts it on a stand-in key and gates only that route; 7 new tests; cli 1120 + 1 skip, bus 1397, launch-limit-checks 5; mutants M4-M7 and the reviewer's throw killed; no push, queue or PR action 2026-11-03 | Claude (sub-agent of Mosaic Stack lead c5c1e8ba) | editor-browser :154 under Chromium 156 (Vikunja #784) | 0c6aa1a1e on t3/editor-chromium-156 (base 1ff45c4ad): test-only; the page's CSP record sets aside the paste's inert-parse script-src-attr reports, keyed on editor.js readHTML's parse line and target document; a new test shows live inline handlers still fail quiet(); editor-browser 17/17, editor plus editor-provenance 11/11, no skips; 4 mutants killed; no push, queue or PR action. +2026-11-03 | Claude (sub-agent of Mosaic Stack lead c5c1e8ba) | Vikunja #415 and #416, .53 and .54 Console writes | bd79daffd on t3/console-writes-53-54 (base 1ff45c4ad): factory takes the paired --sso --send with a console.sso check before any unit write; .53 business document on provider proxy, route anthropic, account factory/proxy; library --send not done (needs the #385 refusal reverted, returned to the lead); cli case2-unit 88, stack-upgrade 25, case1-accept 53, business 8, 3 and 3, no skips; 2 mutants killed; no push, queue or PR action. diff --git a/docs/guides/case1-business.mosaic-stack.json b/docs/guides/case1-business.mosaic-stack.json index ff155dc10..fa8dc7b71 100644 --- a/docs/guides/case1-business.mosaic-stack.json +++ b/docs/guides/case1-business.mosaic-stack.json @@ -38,10 +38,15 @@ "launch": { "by": "chief", "instances": ["assistant"], + "account": { + "name": "factory", + "credential": "proxy" + }, "models": { "claude-opus-5-5": { - "provider": "anthropic", - "model": "claude-opus-5-5" + "provider": "proxy", + "model": "claude-opus-5-5", + "route": "anthropic" } } } diff --git a/packages/business/tests/case1-business-file.test.mjs b/packages/business/tests/case1-business-file.test.mjs index 7226178a0..0d5853236 100644 --- a/packages/business/tests/case1-business-file.test.mjs +++ b/packages/business/tests/case1-business-file.test.mjs @@ -73,7 +73,9 @@ test("row 323: committed Case 1 document loads unchanged through the business lo assert.equal(b.launch.by, "chief"); assert.deepEqual(b.launch.instances, ["assistant"]); assert.deepEqual(b.arbiters, { delivery: "chief", technical: "chief" }); - assert.deepEqual(b.launch.models["claude-opus-5-5"], { provider: "anthropic", model: "claude-opus-5-5" }); + // #416: the .53 factory reaches Anthropic through the proxy, under the factory account. + assert.deepEqual(b.launch.models["claude-opus-5-5"], { provider: "proxy", model: "claude-opus-5-5", route: "anthropic" }); + assert.deepEqual(b.launch.account, { name: "factory", credential: "proxy" }); for (const role of Object.values(b.roles)) { assert.equal(role.vars.harness, "claude-code"); assert.equal(role.vars.model, "claude-opus-5-5"); @@ -83,6 +85,17 @@ test("row 323: committed Case 1 document loads unchanged through the business lo } }); +// #416 changed the shipped route; the direct-provider input it replaced still loads. +test("row 323: a direct Anthropic launch without an account still loads", (t) => { + const x = world(t); + x.doc.launch.models["claude-opus-5-5"] = { provider: "anthropic", model: "claude-opus-5-5" }; + delete x.doc.launch.account; + writeJson(x.business, x.doc); + const b = loadBusiness("mosaic-stack", { dir: x.configDir, rolesDir: REPO_ROLES }); + assert.deepEqual(b.launch.models["claude-opus-5-5"], { provider: "anthropic", model: "claude-opus-5-5" }); + assert.equal(b.launch.account, undefined); +}); + test("row 323: real business validate accepts the Case 1 fixture without tracker credentials", (t) => { const x = world(t); configure(x); diff --git a/packages/cli/tests/case2-unit.test.mjs b/packages/cli/tests/case2-unit.test.mjs index fb65a3af8..6849e347f 100644 --- a/packages/cli/tests/case2-unit.test.mjs +++ b/packages/cli/tests/case2-unit.test.mjs @@ -568,14 +568,86 @@ test("factory refuses duplicate socket, a missing --port or --business, and each refuses(unit(h, { profile: "factory", flags: [...factoryFlags(), '--port', '443'] }), /given twice/); refuses(unit(h, { profile: "factory", flags: ["--business", "acme"] }), /serve flag --port is required/); refuses(unit(h, { profile: "factory", flags: ["--port", "443"] }), /serve flag --business is required/); - for (const [flag, value] of [["--public-host", "x.example"], ["--auth-header", "X-A"], ["--allow-user", "u"], ["--proof-header", "X-P"], ["--proof-file", h.proof], ["--send", null]]) { + for (const [flag, value] of [["--public-host", "x.example"], ["--auth-header", "X-A"], ["--allow-user", "u"], ["--proof-header", "X-P"], ["--proof-file", h.proof]]) { refuses(unit(h, { profile: "factory", flags: [...factoryFlags(), flag, ...(value === null ? [] : [value])] }), new RegExp(`the factory profile refuses ${flag}`)); } - for (const [flag, value, pattern] of [["--checkout", "/srv/x", /refusing --checkout/], ["--board", "http://127.0.0.1:7331", /refusing --board/], ["--sso", null, /refusing --sso/], ["--nonsense", "1", /unknown serve flag/]]) { + for (const [flag, value, pattern] of [["--checkout", "/srv/x", /refusing --checkout/], ["--board", "http://127.0.0.1:7331", /refusing --board/], ["--nonsense", "1", /unknown serve flag/]]) { refuses(unit(h, { profile: "factory", flags: [...factoryFlags(), flag, ...(value === null ? [] : [value])] }), pattern); } }); +// #415/#416: the factory Console signs its owner in itself (console.sso) and takes writes only as the +// paired --sso --send. The pair never unlocks the proxy preview set or the proof pair. +const ssoConfig = (h) => writeJson(h.query, { dataRoot: h.dataRoot, console: { sso: { providers: [] } } }); +const noUnits = (h) => { + assert.equal(existsSync(busFile(h)), false); + assert.equal(existsSync(webuiFile(h)), false); + assert.equal(existsSync(h.log), false); +}; + +test("#415 factory with --sso --send renders and the Console unit carries both flags", (t) => { + const h = hub(t); + ssoConfig(h); + const r = unit(h, { profile: "factory", flags: [...factoryFlags(), "--sso", "--send"] }); + assert.equal(r.code, 0, r.out + r.err); + const webui = read(webuiFile(h)); + assert.deepEqual(lines(webui, "ExecStart"), [`${USR_NODE} ${copyDir(h)}/packages/webui/src/cli.mjs serve --port 443 --business acme --tester-socket --sso --send`]); + assert.deepEqual(lines(webui, "EnvironmentFile"), []); + assert.deepEqual(webui.split("\n").filter((l) => /^(ProtectSystem|ReadWritePaths|ProtectHome|PrivateTmp)=/.test(l)), HARDENING(h)); + // The console.sso check ran as the stack user, through the same sudo as the tester query. + const sudo = read(h.sudoLog); + assert.match(sudo, new RegExp(`^-u mosaic -H env -i HOME=${h.home} PATH=`, "m")); + assert.match(sudo, /s\.console&&s\.console\.sso/); + // Without the tester marker the pair renders too, in the order given. + const g = hub(t); + ssoConfig(g); + assert.equal(unit(g, { profile: "factory", flags: ["--port", "443", "--send", "--business", "acme", "--sso"] }).code, 0); + assert.deepEqual(lines(read(webuiFile(g)), "ExecStart"), [`${USR_NODE} ${copyDir(g)}/packages/webui/src/cli.mjs serve --port 443 --send --business acme --sso`]); +}); + +test("#415 factory refuses --sso alone and --send alone before writing a unit", (t) => { + const h = hub(t); + ssoConfig(h); + refuses(unit(h, { profile: "factory", flags: [...factoryFlags(), "--sso"] }), /refusing --sso without --send in the factory profile/); + refuses(unit(h, { profile: "factory", flags: [...factoryFlags(), "--send"] }), /the factory profile refuses --send without --sso/); + refuses(unit(h, { profile: "factory", flags: [...factoryFlags(), "--sso", "--sso", "--send"] }), /serve flag --sso given twice/); + refuses(unit(h, { profile: "factory", flags: [...factoryFlags(), "--sso", "--send", "--send"] }), /serve flag --send given twice/); + noUnits(h); +}); + +test("#415 factory with --sso --send still refuses each proxy preview flag and the proof flags", (t) => { + const h = hub(t); + ssoConfig(h); + for (const [flag, value] of [["--public-host", "x.example"], ["--auth-header", "X-A"], ["--allow-user", "u"], ["--proof-header", "X-P"], ["--proof-file", h.proof]]) { + refuses(unit(h, { profile: "factory", flags: [...factoryFlags(), "--sso", "--send", flag, value] }), new RegExp(`the factory profile refuses ${flag}: its host has no proxy`)); + } + noUnits(h); +}); + +test("#415 factory --sso refuses before any unit write when the stack user's config has no console.sso", (t) => { + const h = hub(t); + const pair = ["--port", "443", "--business", "acme", "--sso", "--send"]; + refuses(unit(h, { profile: "factory", flags: pair }), /--sso needs console\.sso in mosaic's system config/); + writeJson(h.query, { dataRoot: h.dataRoot, console: {} }); + refuses(unit(h, { profile: "factory", flags: pair }), /--sso needs console\.sso in mosaic's system config/); + noUnits(h); + // Only the exact one-line answer counts; anything else refuses, and so does a failed query. + for (const [output, status, pattern] of [['{"sso":true}\nforged', "0", /sso config query has invalid facts/], ['{"sso":"true"}', "0", /sso config query has invalid facts/], ['{"sso":true}', "1", /sso config query inner-command/]]) { + writeFileSync(join(h.root, "query-output"), output); + writeFileSync(join(h.root, "query-status"), status); + refuses(unit(h, { profile: "factory", flags: pair }), pattern); + } + noUnits(h); +}); + +test("#416 library still refuses --sso, alone and with --send, before writing a unit", (t) => { + const h = hub(t); + ssoConfig(h); + refuses(unit(h, { flags: [...libraryFlags(h), "--sso"] }), /refusing --sso: the Console signs people in through the proxy/); + refuses(unit(h, { flags: [...libraryFlags(h), "--sso", "--send"] }), /refusing --sso: the Console signs people in through the proxy/); + noUnits(h); +}); + test("row253 factory refuses retired TCP and a value after the socket marker", (t) => { const h = hub(t); refuses(unit(h, { profile: "factory", flags: ['--port','443','--business','acme','--tester-port','7333'] }), /case2-unit.sh retires tester TCP; use --tester-socket/); diff --git a/scripts/case2-unit.sh b/scripts/case2-unit.sh index 477a6bd2c..85371cacc 100755 --- a/scripts/case2-unit.sh +++ b/scripts/case2-unit.sh @@ -20,7 +20,7 @@ # never imports copy code. This adds sudo and GNU timeout to the installer # dependencies. The inner query supervisor runs after the uid drop: 5 s inside, # 7 s on root's wait. Fixed system Bash, setsid, sleep, timeout and head are -# resolved and root-validated. Only the config query uses this supervisor. +# resolved and root-validated. Only the config queries use this supervisor. # It renders the default instance only. # # The library profile takes exactly these serve flags, each once: @@ -29,10 +29,13 @@ # --auth-header HEADER --allow-user ID # --proof-header NAME --proof-file PATH # It is proxy-preview read-only until Case 2 supports --sso (#412); --send -# is explicitly refused. The proof still protects proxy preview reads. +# and --sso are explicitly refused. The proof still protects proxy preview reads. # The factory profile takes --port N (1..1023) and --business ID, and an -# optional bare --tester-socket marker. Retired tester TCP refuses. Only factory takes -# --pm and --claude. +# optional bare --tester-socket marker. It also takes the paired bare +# --sso --send (#415): the Console signs its owner in from console.sso, which +# the stack user's config must have; either one alone refuses, and the +# preview and proof flags still refuse. Retired tester TCP refuses. Only +# factory takes --pm and --claude. # # On a re-install the installed units must equal the render in everything # but the copy id, and all selected units must name one copy, so a re-pin or rollback @@ -298,6 +301,7 @@ tester_capture() ( cat -- "$file" ) +SSO_QUERY='import {pathToFileURL} from "node:url";const m=await import(pathToFileURL(process.argv[1]).href);const s=m.loadSystem();console.log(JSON.stringify({sso:Boolean(s.console&&s.console.sso)}));' TESTER_QUERY='import {readFileSync} from "node:fs";import {pathToFileURL} from "node:url";const m=await import(pathToFileURL(process.argv[1]).href);const s=m.loadSystem();console.log(JSON.stringify({dataRoot:s.dataRoot,socket:readFileSync(process.argv[2],"utf8").includes("MOSAIC_TESTER_SOCKET_V1")}));' tester_facts() { local LC_ALL=C pattern='^\{"dataRoot":"([A-Za-z0-9/._@+-]+)","socket":(true|false)\}$' @@ -342,7 +346,7 @@ tester_location() { serve_flags() { local -A seen=() local flags='' name value - local port='' public_host='' auth_header='' allow_user='' proof_header='' proof_file='' tester_socket=0 + local port='' public_host='' auth_header='' allow_user='' proof_header='' proof_file='' tester_socket=0 sso=0 local i=0 n=${#SERVE[@]} while [ "$i" -lt "$n" ]; do name="${SERVE[$i]}" @@ -351,10 +355,8 @@ serve_flags() { --tester-socket) [ "$PROFILE" = factory ] || die "the library profile refuses --tester-socket" ;; --checkout) die "refusing --checkout: Case 2 has no queue panel" ;; --board) die "refusing --board: Case 2 runs no control board" ;; - --sso) die "refusing --sso: the Console signs people in through the proxy, with the preview set and the proof pair (Q175 phase 2 is a follow-up)" ;; - --send) - [ "$PROFILE" = library ] || die "the factory profile refuses --send: its host has no proxy" - die "the library profile is read-only; refusing --send until Case 2 supports --sso (#412)" ;; + --sso) [ "$PROFILE" = factory ] || die "refusing --sso: the Console signs people in through the proxy, with the preview set and the proof pair (Q175 phase 2 is a follow-up)" ;; + --send) [ "$PROFILE" = factory ] || die "the library profile is read-only; refusing --send until Case 2 supports --sso (#412)" ;; --port|--business) ;; --public-host|--auth-header|--allow-user|--proof-header|--proof-file) [ "$PROFILE" = library ] || die "the factory profile refuses $name: its host has no proxy" ;; @@ -363,6 +365,8 @@ serve_flags() { [ -z "${seen[$name]:-}" ] || die "serve flag $name given twice" seen[$name]=1 if [ "$name" = --tester-socket ]; then tester_socket=1; flags="$flags --tester-socket"; i=$((i + 1)); continue; fi + if [ "$name" = --sso ]; then sso=1; flags="$flags --sso"; i=$((i + 1)); continue; fi + if [ "$name" = --send ]; then flags="$flags --send"; i=$((i + 1)); continue; fi [ $((i + 1)) -lt "$n" ] || die "serve flag $name needs a value" value="${SERVE[$((i + 1))]}" case "$name" in @@ -391,6 +395,17 @@ serve_flags() { [ -n "${seen[$name]:-}" ] || die "serve flag $name is required" done if [ "$PROFILE" = factory ]; then + # #415: only the paired owner sign-in and writes. No preview header or + # proof file is inferred. The Console refuses --sso without console.sso + # at start; this asks the stack user's config first, before any write. + [ "$sso" = 0 ] || [ -n "${seen[--send]:-}" ] || die "refusing --sso without --send in the factory profile" + [ -z "${seen[--send]:-}" ] || [ "$sso" = 1 ] || die "the factory profile refuses --send without --sso" + if [ "$sso" = 1 ]; then + local answer + answer="$(tester_capture 5 7 4096 "$USER_NAME" "$HOME_DIR" "$UNIT_PATH" "$NODE" --input-type=module -e "$SSO_QUERY" "$COPY/packages/cli/src/config.mjs")" || die "sso config query $(tester_capture_reason "$?")" + [ "$answer" != '{"sso":false}' ] || die "--sso needs console.sso in $USER_NAME's system config" + [ "$answer" = '{"sso":true}' ] || die "sso config query has invalid facts" + fi if [ "$tester_socket" = 1 ]; then local query query="$(tester_capture 5 7 4096 "$USER_NAME" "$HOME_DIR" "$UNIT_PATH" "$NODE" --input-type=module -e "$TESTER_QUERY" "$COPY/packages/cli/src/config.mjs" "$COPY/packages/webui/src/cli.mjs")" || die "tester config query $(tester_capture_reason "$?")"