Commit Graph
4748 Commits
Author SHA1 Message Date
jason.woltje 381039fe5f selector: --org and --business in stack-copy check
check takes --org as --business in one scope: each spelling once, both only
with the same value. A repeated, conflicting, missing, empty or flag-shaped
value exits 4 before any unit is read; an id outside check's own grammar
still exits 1. copy and wrapper refuse either spelling with usage, as
before. The sourced-library path used by stack-release.sh does not read
selector.sh; the command path refuses if it cannot.
2026-11-08 22:35:24 -06:00
jason.woltje 1105de280b selector: stack-release rehearsal fixture copies org-selector.mjs
The rehearsal builds fake copies from an explicit file list. f198cfd47 made
packages/cli/src/access.mjs import org-selector.mjs, which the list lacked,
so every rehearsal that ran the copied CLI failed with "Cannot find module"
(17 of 226 tests) from f198cfd47 until this commit. Real copies were not
affected: stack-copy.sh COPY_PATHS takes packages/cli/src whole.
2026-11-08 22:35:24 -06:00
jason.woltje af29832a05 Keep request selection and requirement state by identity across refreshes
Sol's re-check of c0b2f7d86 found two failures. A refresh that changed only an
unselected request kept the page and so kept the request selector's old closure;
selecting that request then drew its old PRD. Retained handlers now draw from the
newest accepted read for their container.

Requirement disclosures and focus were saved by position, so a requirement
inserted above the focused one handed its open state and focus to a neighbour.
Requirement and provenance details carry a restore key; open state and summary
focus are restored by that key and a key that no longer exists is dropped. The
outer chat capture uses the same helper.

org-live-fix-r3-browser.test.mjs holds Sol's two probes: 0/2 on c0b2f7d86, 2/0
here. Nineteen live-update, chat, project, request and s10-s15 files: 231/0.
2026-11-08 22:23:59 -06:00
jason.woltje 9e458878df selector: --org and --business in stack-upgrade's args-file scopes
read_args takes --org as --business in the unit flags before -- and in the
serve flags after it, with per-scope duplicate and conflict refusal, and
refuses a file whose serve flags name no selector or another business, as
case2-unit.sh would at the render after A2 stopped the units. The serve
flags are walked with case2-unit.sh's grammar so a value is never read as a
selector. The file is not rewritten; only --copy's value changes, as before.
A checkout without scripts/selector.sh refuses checkout-unreadable.
2026-11-08 22:05:44 -06:00
jason.woltje c0b2f7d86a Preserve live project views through overlapping refreshes 2026-11-08 21:57:48 -06:00
jason.woltje ac63a187e8 Merge walkthrough fixes and LAN dev bind (org-stage) into refactor
org-walkthrough-fix 60f3b3d78 (Sol APPROVE 0/0/0) and org-lan-bind 95a5f7072 (Sol APPROVE 0/0/1) via org-stage 265f1767c.
2026-11-08 21:56:43 -06:00
jason.woltje 226be2e935 selector: --org and --business in case1-accept's three scopes 2026-11-08 21:56:02 -06:00
jason.woltje dbb6909dcd selector: case2-precheck and case2-install refuse when selector.sh cannot be read
Neither script runs under set -e, so a failed source left selector_take
undefined and parsing carried on without the duplicate and conflict rules.
2026-11-08 21:56:02 -06:00
jason.woltje 4b7ddbcb43 selector: --org and --business in case2-unit's outer and serve scopes 2026-11-08 21:39:20 -06:00
jason.woltje 623388603b Merge organizations MVP (ui-org-r2) into refactor
BUILD-LOG.md: append-only union, refactor entries first, then the branch's.
docs/SESSIONS.md: append-only union, refactor entries first, then the branch's.
packages/bus/src/runtime.mjs: keep the organization usage timer and refactor's halted/invalid startup-recovery gate.
packages/harness/src/first-output.mjs: keep the branch's harness-neutral markers; refactor's empty-length rejection moves into the Pi monitor (packages/plugins/harness/pi/model-stream.mjs).
packages/harness/tests/runner.test.mjs: keep refactor's length-continuation cases and the branch's output-policy cases.
packages/plugins/harness/pi/index.mjs: keep the documented GLM limits and the branch's transport-based bundle.

Suites: 6356 pass, 32 fail; all 32 fail identically on both parents
(node_modules symlink EISDIR in pinned-copy and stack copy/release tests,
missing Python jsonschema in two conversation tests).
2026-11-08 21:38:42 -06:00
jason.woltje 7f882a905d selector: --org and --org-file in case2-install
Rename design r2, "Selector scopes and parser matrix", case2-install row. --org/--business
and --org-file/--business-file are two families, each its own scope: each spelling once, and
a second spelling must carry the same text (file paths compared as given). Missing values
are usage; a flag-shaped or invalid id keeps the business-id refusal; a flag-shaped file, a
repeated spelling and a conflict say why. All exit 4 before anything is read or written.
The persona-import call it spawns still passes --business.
2026-11-08 21:27:37 -06:00
jason.woltje 265f1767c0 Merge org-lan-bind into org-stage 2026-11-08 21:27:33 -06:00
jason.woltje 3baf6f2297 selector: --org and --business in case2 persona-import and precheck
Rename design r2, "Selector scopes and parser matrix". case2-persona-import.mjs takes --org
through selectorScope and case2-precheck.sh through scripts/selector.sh, one scope each. Both
keep their exit codes and their old business-id wording; a repeated or conflicting selector
says why. persona-import now checks the id while parsing, so stage refuses an invalid
selector before it reads anything.

The case2-install fake stack copy carries packages/business/src/selector.mjs, which the real
copy already does (COPY_PATHS takes packages/business/src).
2026-11-08 21:25:49 -06:00
jason.woltje 298081dbf3 Keep console views stable across refreshes 2026-11-08 21:24:12 -06:00
jason.woltje 259302a368 selector: --org and --business in the Console CLI and service parsers
cli.mjs serve and webui-service.sh each take --org as --business in their own
scope through the shared selector rules; the service unit still carries the
canonical --business. A flag-shaped or invalid value keeps each script's old
wording and exit code; a repeated or conflicting selector is a usage error.
2026-11-08 21:20:09 -06:00
jason.woltje f198cfd47b selector: --org and --business in each CLI parser's own scope
Rename design r2, "Selector scopes and parser matrix". packages/business/src/selector.mjs
and scripts/selector.sh carry one rule set: in a parser's scope each spelling appears once,
and a second spelling must carry exactly the same value; a repeated spelling, a missing or
flag-shaped value, an invalid id and unequal values refuse. The file family
(--business-file/--org-file) compares paths as given.

Every CLI parser that took --business now takes --org through orgSelector, and the old
global --org rewrite in main() is gone, so a value another option consumes is never read as
a selector. The id is checked while parsing (OrgError org-invalid, exit 3), so grants admin
set no longer reads the token and proxy init no longer prompts for the key before an
invalid id refuses. access gains the same local id check.
2026-11-08 21:14:11 -06:00
jason.woltje 95a5f7072d Document the console LAN flags and console status 2026-11-08 21:13:56 -06:00
jason.woltje 665a5148d4 Open the dev owner Console to allowed LAN names
mosaic console start --dev-local-owner --dev-insecure-bind ADDR
--dev-allow-host NAME[,NAME...] binds 0.0.0.0 or an IPv4 address and
answers only NAME:<bound port> plus the loopback names. Both flags are
refused without the dev owner, the bind without an allowed name, and a
specific ADDR that is not itself a name. Start and console status print
the no-sign-in warning; the state file records bind and allowHosts.

serve.mjs takes devAllowHosts only with the dev owner; SSO, preview and
tester listeners stay loopback. Writes need Origin http://<same Host>.
Chromium sends no Fetch Metadata from a LAN http origin, so for an
allowed name a write with that exact Origin and no Sec-Fetch-Site counts
as same-origin; an explicit header is still judged by the routes.
chat.js builds its operation keys without crypto.randomUUID, which an
insecure context lacks.
2026-11-08 21:13:53 -06:00
jason.woltje 60f3b3d78f Offer New organization in the header menu, picker and empty state
Once organizations existed, Quick Setup was reachable only through
Settings > Organizations > type an ID > New organization. This tree
has no header organization switcher, so the owner of a Console with
organization setup now gets "New organization" in the header avatar
menu, under the Organization picker on Settings > Organization, and
next to the Settings link in the no-organization empty state. Each
opens #/settings/organizations?new=1, which focuses the ID field and
then drops the flag. The form itself is unchanged.

The new browser test covers the menu at 1400 and 390px, the picker
and the empty state. It fails on 6ca7f3b65 and passes here.
2026-11-08 20:58:46 -06:00
jason.woltje 4b40c7f57b Keep project crumbs evenly spaced for short project names
"Projects / work /  / Conversations / init" had no missing label.
Every project crumb link had min-width:44px, so a short name such as
"work" was padded with blank space after its text, and the separators
around it read as an empty crumb. The 44px target width now comes
from an ::after overlay centred on the link, so the layout box fits
the text on every project route.

The new browser test measures text-to-separator gaps and hit width
on the overview, conversations and conversation routes at 1440 and
390px. It fails on 6ca7f3b65 and passes here.
2026-11-08 20:58:40 -06:00
jason.woltje a1491a0163 Give organization Consoles a request read so request status resolves
The organization options in cli.mjs carried no requestRead, so
/api/orgs/<id>/config never offered requests and the project and
conversation pages counted "requests not offered" as a failed read:
"Request status unavailable." on a conversation whose message went
through. The owner now reads request status over the organization's
own bus socket, as the root Console does. Request writes stay off,
per the README Console actions inventory.

The new browser test runs the real cli.mjs serve --dev-local-owner
against a real organization record with only the bus transports
shimmed. It fails on 6ca7f3b65 and passes here.
2026-11-08 20:58:35 -06:00
jason.woltje 500418e710 test: pin remaining v1 organization contracts 2026-11-08 20:53:16 -06:00
jason.woltje c2a6fad2a8 dev fixture: --ttl for the endpoint, and init replaces a stale record (P19 #882)
The endpoint ended after MOSAIC_FIXTURE_TTL_S, but init passed it only PATH, so
the lifetime was always the 14400 s default. Its record stayed after it ended,
and init refused fixture-exists until `dev fixture stop`.

init now takes --ttl SECONDS (0 = no expiry; otherwise 60 to 2147483, the
longest delay a Node timer holds; the default stays 14400), passes it to the
endpoint, and records ttlSeconds and expiresAt. /health and status report them.
A record whose pid is no longer the endpoint is stale: init removes it and says
which pid it replaced. A live endpoint still refuses fixture-exists.

A running bus keeps the endpoint it read at start, so after a replacement
the bus needs a restart; --ttl 0 avoids the expiry in the first place.
2026-11-08 20:53:03 -06:00
jason.woltje 7d1ab7cd96 test: pin v1 resolver and command contracts 2026-11-08 20:45:50 -06:00
jason.woltje 041e163d3c tester-cli: load the bus client only in the nonce child (P19 #876)
The tester-cli test makes about 20 Console reads and chat calls in a
row. Each one spawns TESTER_CLI, which re-executes itself so the nonce
is in its initial environment; both processes statically imported the
client and the broker module graph behind it, though the parent only
spawns the child. The child now imports Client and readProcess after
the re-exec branch, so the parent is a bare node start. Interleaved
over 20 calls at load 19: 258 ms per call before, 192 ms after. The
proof, nonce and argv are unchanged.

What remains is legitimate serial work: about 20 round trips of two
node processes each, about 3 s idle and 10 s at load 20 on 16 cores
(before this change). 30 s left under 3x room on a busy machine, so the
test's hang guard is now 60 s.
2026-11-08 20:45:23 -06:00
jason.woltje 588253e524 test: stop dev-local-owner buses before removing their root (P19 #875)
The Console-and-bus test in packages/webui/tests/dev-local-owner.test.mjs
registered rmSync(root) as its first t.after hook. Hooks run in
registration order, so root went first, both `bus stop` calls then failed,
and the SIGTERM fallback reached only the outer `bus start`. Each run left
the beta and acme --internal-host processes and their brokers running.

One hook now kills the Console, stops both buses while root exists, waits
for every recorded process (outer CLIs, hosts from their receipts, and the
hosts' children, each matched by start time) and fails if any survives,
SIGKILLing the survivors first so the failure does not leak. Root is
removed last. A mutant that skips the stops fails with six survivors.
packages/bus/tests/dev-local-owner.test.mjs already stopped its bus and
leaves nothing behind.
2026-11-08 20:39:31 -06:00
jason.woltje 93a73a7375 test: leave a linked node_modules out of the copy fixtures
On a deploy tree node_modules is a symlink. .gitignore's node_modules/
matches only a directory, so git ls-files -co --exclude-standard lists
the link as an untracked file and the fixtures' cpSync throws EISDIR
on it (8 failures in pinned-copy.test.mjs). stack-copy.sh never takes
node_modules from git (it archives COPY_PATHS and runs npm ci), so the
fixtures now exclude **/node_modules from the listing. The copy code is
unchanged.
2026-11-08 20:34:53 -06:00
jason.woltje 6ca7f3b656 Merge branch 'org-quick-project' into ui-org-r2 2026-11-08 15:53:52 -06:00
jason.woltje c47fcc750d Merge branch 'org-polish-2' into ui-org-r2 2026-11-08 15:53:52 -06:00
jason.woltje 86c1546a4f Merge branch 'org-testhang' into ui-org-r2 2026-11-08 15:53:52 -06:00
jason.woltje 1b175a0511 Merge branch 'org-recover-r2' into ui-org-r2 2026-11-08 15:53:52 -06:00
jason.woltje 6694b4b6d6 Fix polish review findings F1-F3 (P19 #868)
F1: the org list shows a broken org as invalid only when the failure
came after the owner check passed (ownerVerified). A broken root or
marker on someone else's org stays hidden.

F2: /api/orgs answers a registry read failure with a fixed message.
The parser text could quote private registry bytes.

F3: selected-org pages keep the list error, paint one replaceable
header banner, and Retry always re-reads the list. The Board shows the
registry message once.

New tests org-list-privacy and org-list-refresh-browser fail on
0e9b2c505 for F1, F2 and F3 and pass here. Serial batch over all 134
webui files plus business org-* and cli org: only failures were the
known pinned-copy EISDIR (8) and an org-switch assertion on the old
pass-through text, updated here.
2026-11-08 15:53:42 -06:00
jason.woltje 0e9b2c505d Org polish: lock-free reads, visible org errors, no-board label (P19 #867, #868, #869)
#867: organization reads no longer take the registry writer lock; they
retry while the lock exists or the registry changed during the read.
#868: a broken organization is listed as invalid with a path-masked
reason instead of disappearing; the Board, header and picker show it,
and /api/orgs 503 carries the reason. Orgs the principal may not see and
archived orgs still give an empty list.
#869: a Console with no board says "No board", not "Board: null".
#866 (save-path validation at bus admission) is left out: it refused
documents the bus accepted before and needs a migration story first.

Every bus, business, cli and webui file run serially; failures are only
the known EISDIR node_modules-link files.
2026-11-08 15:27:19 -06:00
jason.woltje fe042f072b fix(webui): create project during quick setup 2026-11-08 15:26:03 -06:00
jason.woltje f9f34bd249 Fix testhang review findings F1-F4 (P19 #865)
serve.mjs keeps the bound address as well as the port, so the settings,
queue and business routes answer a request that arrives after close().
browser.mjs keeps an exited leader's group tracked until it is killed at
exit, and close() signals the group only while the leader is alive. The
late-request test is event-based with one owned timeout. New test: the
chromium group dies when the main process dies and close() never runs.

Webui browser and server files (92, pinned-copy excluded): 741 pass, 0 fail.
2026-11-08 15:22:48 -06:00
jason.woltje 11f95842ef Answer requests that arrive after close starts; kill chromium by process group (P19 #865)
- serve.mjs read server.address().port in the Host checks. Once close() starts that is
  null, so a request on a kept-alive connection threw and was never answered, and the test
  file waited forever. The bound port is now stored on 'listening'.
- Killing only chromium's main process left its renderer and GPU children writing into the
  profile, so the profile rm failed with ENOTEMPTY. Chromium now runs in its own process
  group; close() and the exit hook kill the group, and the rm retries.
- teardown.test.mjs: a request sent after close() starts gets a 200.
2026-11-08 15:00:28 -06:00
jason.woltje d68e7b0976 Fix recovery review findings: live Console identity, crashed clear fence, atomic quarantine (P19 #857, #862)
- A Console is stale only when its pid is gone or its start time differs. A live Console
  started from another entry path is never quarantined; stop refuses to signal it and
  names the path it was started from.
- The lock-clear fence records the clearer's pid and start time. A fence left by a dead
  clearer is moved aside and recovery continues; a live or unreadable fence refuses.
  lock show reports a fence.
- Console state is moved aside with one atomic rename after an inode re-check.
2026-11-08 14:52:42 -06:00
jason.woltje 56a21e4e33 Bound test teardown so org browser runs cannot hang (P19 #865)
Combined node --test runs hung in the org browser files. Two causes:

- org-quick: a page's GET /api/config reached the server on a
  kept-alive connection after close(server) had stopped the listener.
  The handler threw on server.address().port, the request was never
  answered, and server.close() waited for it forever. close() in
  fixture.mjs now cuts every connection and fails the hook after 5 s
  with a message.
- org-delete: t.after hooks run in registration order, so the data
  directory was removed while the server still wrote there. The rm
  failed with ENOTEMPTY, node:test skipped the later hooks, and the
  open server and chromium kept the file running. The three org files
  and project-archive-style now register the removal last.

browser.mjs: close() kills a browser that does not answer
Browser.close within 5 s, a call to an exited browser fails at once,
and an unclosed chromium no longer holds the event loop and is killed
when the test process exits.

teardown.test.mjs reproduces each case: 0/4 pass on the old helpers,
4/4 on the new ones.
2026-11-08 14:38:58 -06:00
jason.woltje e9a7adab11 Recover stale Console state, dead org locks and wedged bus hosts
console start and stop move a console.json whose recorded process is gone
aside instead of refusing (P19 #857). mosaic org lock show|clear reports a
lifecycle lock holder and clears it only when the holder is dead.
mosaic bus recover marks a bus host stopped when its process is gone and its
socket does not answer, and writes a recovery receipt (P19 #862).
2026-11-08 14:11:13 -06:00
jason.woltje 606911834e Merge organization archive and fixes (quick-setup 57d5675ae)
# Conflicts:
#	packages/cli/src/cli.mjs
2026-11-07 23:06:53 -06:00
jason.woltje 57d5675ae3 Name the final delete button for what it does
The panel says the organization moves to the deleted folder, so the
final button no longer says it deletes permanently.
2026-11-07 23:06:32 -06:00
jason.woltje 312c62fd4f Fence organization archive against in-flight startup 2026-11-07 23:05:43 -06:00
jason.woltje ec143b2b9c Add organization archive and restore 2026-11-07 22:49:49 -06:00
jason.woltje 53e0f189a2 Merge quick setup review fixes (quick-setup-fix 653b3e2e7) 2026-11-07 22:37:13 -06:00
jason.woltje 009024ea45 Merge organization quick setup and delete (quick-setup 614559a94) 2026-11-07 22:37:13 -06:00
jason.woltje 614559a94c Fix organization deletion review findings 2026-11-07 22:36:33 -06:00
jason.woltje 047825460f Delete an organization after two confirmations
mosaic org delete ID --confirm ID --if-revision N, and POST /api/orgs/:id/delete,
mark the organization as deleting, stop its bus, move its files into
<dataRoot>/deleted/<ID>-<stamp>/ with a receipt, then drop it from the registry
and append deleted.log. A failure stops at its step and a rerun resumes. Bus
start refuses an organization that is being deleted. The settings page asks
twice: a panel that lists the effects, then typing the ID before Delete
permanently is enabled. Purge and remote revocation are follow-ups.
2026-11-07 22:22:05 -06:00
jason.woltje 3272fd9c6f Let the import scanner accept the plug-in loader's own module import
Quick Setup made organization code import the plug-in loader, which loads
packages/plugins/<kind>/<name>/index.mjs by a computed path. The scanner now
allows exactly that form in the loader file and still refuses it anywhere else.
2026-11-07 22:22:05 -06:00
jason.woltje 653b3e2e75 Stop quick setup on an unreadable reply and reset controls for a new draft
A 200 or 201 with a body that does not name the expected step as done now
stops at that step as an unknown outcome, with no further writes. Starting a
new draft re-enables the preset, thinking and run controls and clears the
risk checkbox. Browser regression covers both (Sol review P1, P2).
2026-11-07 22:03:45 -06:00
jason.woltje c09570d696 Add plugin-based organization quick setup 2026-11-07 21:43:03 -06:00