Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,32 @@ with `--confirm-bypass`, which a program can pass, so the flag records a choice,
`permissions allow`. `--by` records who the caller says asked; it is not authentication
(PC-125).

## What `anchor install` touches

`passioncode anchor install` (not in the help yet; a step of a guided install) checks a service package as the person
who runs it and then hands it to macOS's own Installer: Gatekeeper assessments must be on (`spctl --status`), the
package's SHA-256 must equal its line in the release's `SHA256SUMS` (and a deployment manifest's pin when one is given),
its GitHub build attestation must verify (`gh attestation verify`) as made by the anchor workflow on a pushed
`brain-anchor-v` tag (a build from any other ref is refused), and `pkgutil --check-signature` must read a
notarised Developer ID Installer signature of team `KJ35UYYL22` that chains to the Apple Root CA by its fingerprint.
`spctl -a -t install` is a further check only: it accepted a signed package with one byte changed, which `pkgutil`
refused (2026-11-25). The launcher refuses to run as root, never runs `sudo` and never reads or passes a password:
the password goes only into Installer's own prompt. It writes `~/.passioncode/brain-anchor.json` (the role, the
organisation for an organisation space, and the roster row the install step enrols; nothing else) and opens Installer
with `open -a Installer`. A failed check writes nothing and opens nothing. The limit of a check made as the person:
the package and the request sit where that user (and so any agent session of that user) can write, between the checks
and the moment Installer reads them. Gatekeeper's notarisation check applies to a package that carries the
download quarantine (a browser download does; a package taken with `gh run download` or copied by hand does not), and the package's own first elevated step compares its payload with the pin shipped inside the same package before
anything changes, which catches a modified payload of a genuine package but checks no signature and no team. So a
same-user swap, between the checks and Installer's read, of the package (for another team's notarised package, or a
package that Installer opens without a notarisation check) or of the request is not caught by the launcher; what still
holds is that the store paths come from the package, never from the request. This is a known limit (PC-250).
`spctl`, `pkgutil` and `open` run by their absolute paths under `/usr` (System Integrity Protection keeps them), never
through the person's `PATH`, so a shim a process of the same user puts on the `PATH` cannot report a check as passed;
`gh` is not a system tool and is found on the `PATH`, so a shimmed `gh` could fake the attestation check alone, while
the signature check still runs through `/usr/sbin/pkgutil`. The role is never defaulted: `--role` is required, and
without it nothing is checked or written.

## What anonymous counts send

Each command sends, when it ends, the events listed in [docs/analytics-events.md](docs/analytics-events.md) to
Expand Down
24 changes: 23 additions & 1 deletion bin/passioncode.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function analyticsCommand(rest) {
async function main(argv) {
const [cmd = 'help', ...rest] = argv;
if (cmd === 'permissions') return await permissionsCommand(rest);
if (cmd === 'analytics') return analyticsCommand(rest);
if (cmd === 'analytics') return analyticsCommand(rest); if (cmd === 'anchor') return await anchorCommand(rest); // W7 T28a: anchorCommand at the end
if (cmd === 'setup' || cmd === 'onboard' || cmd === 'doctor') {
try { return await setupOrDoctor(cmd === 'onboard' ? 'setup' : cmd, rest); } catch (error) {
threw = true;
Expand Down Expand Up @@ -359,3 +359,25 @@ main(argv).then(async (code) => {
const errorCode = cmd === 'doctor' && !argv.includes('--fix') && !threw ? 'check-failed' : 'other';
await require('../lib/analytics').after({ command: cmd, code, errorCode, json: argv.includes('--json'), quiet: argv.includes('--quiet'), existing, startedAt, version: VERSION, state: L.paths().state });
});

// W7 T28a: `anchor install`, the service package hand-off (lib/anchor.js). Checks as the person, then macOS Installer asks
// for the password in its own prompt. Not in the help yet: it is a step of the owner's sitting, run with its runbook.
async function anchorCommand(rest) {
const A = require('../lib/anchor');
const json = rest.includes('--json');
const [verb, ...args] = rest.filter((a) => a !== '--json');
const o = { dryRun: false };
const names = { '--pkg': 'pkg', '--url': 'url', '--sums': 'sumsFile', '--deploy': 'deployFile', '--role': 'role', '--org': 'org', '--row': 'row' };
for (let i = 0; i < args.length; i++) {
if (args[i] === '--dry-run') { o.dryRun = true; continue; }
const key = names[args[i]];
if (!key || args[i + 1] === undefined || o[key] !== undefined) return usage('anchor install takes --pkg PATH --sums PATH | --url URL, [--deploy FILE] --role person|owner|org-space [--org ORG] [--row ROW] [--dry-run] [--json]');
o[key] = args[++i];
}
if (verb !== 'install') return usage('anchor takes install');
let r;
try { r = await A.anchor(o); } catch (error) { process.stderr.write(`passioncode: ${error.message}\n`); return 1; }
const lines = (r.checks || []).map((c) => `${c.ok ? 'ok ' : 'FAILED'} ${c.check.padEnd(16)} ${c.detail}`);
process.stdout.write(json ? JSON.stringify(r, null, 2) + '\n' : [...lines, r.message].join('\n') + '\n');
return r.code;
}
2 changes: 1 addition & 1 deletion docs/analytics-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ for any other (`-rc.N`, `-beta.N`, a build tag).
| `app_installed` | live | lib/analytics.js:164 | the first command on this machine that tries to send (a send that fails is not repeated, so an offline first run never reports it) | `existing`: `"true"` when the launcher was installed here before the counts existed (its `~/.passioncode/state.json` was there when the first run of a counting version started, whatever its flags; that answer is kept in `analytics.json`; so a machine an agent sets up with `setup --json` counts as a new install), `"false"` for a new install (a string, as every property: growth filters only string properties) | 2026-11-04 |
| `app_updated` | live | lib/analytics.js:165 | the first command after the launcher's version changed (an update the SessionStart hook ran is counted at the next command, so it can arrive a session late) | `from`: the previous version | 2026-11-04 |
| `app_active` | live | lib/analytics.js:168 | the first command of a UTC day on this machine (counts daily active machines; two commands that end at the same moment on a new day may both send it) | none | 2026-11-04 |
| `command_run` | live | lib/analytics.js:171 | every command, when it ends | `command`: `setup`, `doctor`, `update`, `status`, `restore`, `config`, `uninstall`, `permissions`, `analytics` or `help` (any other word is sent as `other`, never as typed; a new command gets a new value here in the same change, a removed one is marked retired and its value is never reused); `outcome`: `ok` (exit 0), `failed` (exit 1: a check or a step failed) or `usage` (exit 2: the words given were not a command the launcher takes); `duration`: `under-1s`, `1-10s`, `10-60s` or `over-60s` (the bounds are part of the series: other bounds would be a new property, never new meanings of these); `json`: `"true"` or `"false"` (strings) | 2026-11-04 |
| `command_run` | live | lib/analytics.js:171 | every command, when it ends | `command`: `setup`, `doctor`, `update`, `status`, `restore`, `config`, `uninstall`, `permissions`, `analytics`, `help` or `anchor` (`anchor` added 2026-11-25 with `anchor install`, W7 T28a; any other word is sent as `other`, never as typed; a new command gets a new value here in the same change, a removed one is marked retired and its value is never reused); `outcome`: `ok` (exit 0), `failed` (exit 1: a check or a step failed) or `usage` (exit 2: the words given were not a command the launcher takes); `duration`: `under-1s`, `1-10s`, `10-60s` or `over-60s` (the bounds are part of the series: other bounds would be a new property, never new meanings of these); `json`: `"true"` or `"false"` (strings) | 2026-11-04 |
| `app_error` | live | lib/analytics.js:172 | a command that ends with exit 1 | `where`: the command, as above; `code`: `check-failed` for a plain `doctor` whose checks found a problem on the machine (not a fault in the launcher; not `doctor --fix`, whose exit 1 can be a failed repair, and not a run that ended on a thrown error; added 2026-11-04 before the first release) or `other` (fixed codes per failure come later, each added here first) | 2026-11-04 |

Never sent: a path, a file or folder name, a user name, a rule, an argument, an app id the person typed, a token, an
Expand Down
2 changes: 2 additions & 0 deletions docs/backlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,5 @@ derives its common backlog from [backlog-sources.json](backlog-sources.json).
| PC-246 | `PC-163: the server end of this account's own connection reads \`own\` from the real socket table` (`test/listener.test.js`) fails on a build machine whose `netstat` prints no row for the server end of the test's own loopback connection (`table-restricted … netstat printed no table`); it fails the same on unchanged `origin/main` `df80ead` there, 2026-11-24. Make the test skip with its reason where the table is restricted, or read the table the way that machine allows | open 2026-11-24: P3 | W2 session 06, full `npm test` on `agent/w2-s06-base1-owner-mac` (681 of 687 pass, 2 fail: this one and a strings.md drift fixed in the same branch) |
| PC-247 | Pin Fabric Agent Adapter `v0.103.3` (`f9b87061`, npm `latest` 0.103.3 with the same `gitHead`, release run 45555348309 green) and release the launcher: check `git diff --name-status v0.102.0 v0.103.3 -- plugins/fabric-agent-adapter`, vendor with `--release`, run the full gate, release 0.2.84 | done 2026-11-25: released in 0.2.84: PR #367 merged as `9b408de` (merge commit), annotated tag `v0.2.84` on it, release run 45566649147 success (validate gate, node, macos, windows; release; publish), npm `latest` 0.2.84 published 2026-11-25T07:36:45Z, `gitHead` `9b408de`, SLSA provenance; the published tarball carries adapter plugin 0.103.3. Gate on `5cc0fd0`: full `npm test` 689 tests, 685 pass, 0 fail, 4 skipped (Windows only); `vendor:release` exit 0; `claude plugin validate ./payload --strict` passed; check-docs 0 errors. The diff `v0.102.0..v0.103.3` adds three scripts, modifies 28 files, removes none. Open: this Mac's install waits on free disk (the disk sentry refuses installs below 14 GB; 12 GB on 2026-11-25). The Fabric Base 1 line stays on 0.2.83 until fabric-workspace moves the base manifest. Handoff `docs/handoffs/2026-11-25-release-0.2.84.md` | board request `645b9e02` from fabric-agent-adapter (thread `2b08b15f`), deadline 2026-11-28 |
| PC-248 | R5 of the harness-loss audit (H-06): the session-start course line (`plugin/passioncode/hooks/repo-rules.js`), `working-in-passioncode` §0 and `AGENTS.md` named the unified plan of 2026-11-11 after the system design of 2026-11-21 became the plan of record (fabric-workspace `AGENTS.md:10`, `knowledge/rules.md:32`). Read the plan from the knowledge base, not as a string: point at rules §0, which names it | done 2026-11-25: released in 0.2.84: PR #367 merged as `9b408de` (merge commit), annotated tag `v0.2.84` on it, release run 45566649147 success (validate gate, node, macos, windows; release; publish), npm `latest` 0.2.84 published 2026-11-25T07:36:45Z, `gitHead` `9b408de`, SLSA provenance; the published tarball carries the new course line (no `2026-11-11-unified` in `hooks/repo-rules.js`). Test `PC-248: …` in `test/repo-rules.test.js` failed before the fix and passes with it. R8 (H-10, Codex plugin versions and hooks) belongs to the adapter and Switchboard | board request `ca9354fa` from fabric-workspace (thread `5552be73`), deadline 2026-11-26 |
| PC-249 | W7 T28a, the service package hand-off: `passioncode anchor install` (`lib/anchor.js`, `test/anchor.test.js`, SECURITY.md "What `anchor install` touches") checks a package as the person (Gatekeeper on, SHA256SUMS and a manifest pin, the build attestation, `pkgutil` signature of team `KJ35UYYL22` to the Apple Root CA, `spctl`, the embedded pin) and hands it to macOS Installer; never sudo. Left: a help line and strings.md rows when it ships, and a launcher release after the owner's sitting (T28d) proves it on the live package | open 2026-11-25: built on branch `w7-anchor-launcher-2026-11-25`, not merged, not released | Studio session 45 (W7 trust-anchor lane, thread `bb204715`); fabric-workspace `w7-anchor-2026-11-25` `tools/brain/anchor/` |
| PC-250 | The anchor hand-off's same-user window (W7 T28a, review round 1 of Studio session 59): `passioncode anchor install` checks the package and writes `~/.passioncode/brain-anchor.json` as the person, so any process of that user (an agent session included) can swap the package (for another team's notarised package, or a self-built package Installer opens without a notarisation check, whose own pin matches its own payload) or rewrite the request, between the checks and the moment macOS Installer reads them; the package's first step compares only its payload with its own pin, and Installer checks no team. SECURITY.md "What `anchor install` touches" names the limit. The same user can also shim `gh` on the `PATH` (it is found there; `spctl`, `pkgutil` and `open` run by absolute path since review round 8), which fakes the attestation check alone. A fix needs a hand-off the user cannot write between check and read (for example the package's own first elevated step checking the team of its own signature, or Installer reading a copy the user cannot change) | open 2026-11-25 | Studio session 59, review finding 9 of round 1 (W7 trust-anchor lane, thread `bb204715`); nothing in T28a's done line depends on it (the payload still aborts off its pin) |
56 changes: 56 additions & 0 deletions docs/handoffs/2026-11-25-w7-anchor-launcher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Handoff: the service package hand-off on the launcher (W7 trust-anchor lane, Studio session 45), 2026-11-25

Objective: task T28a's launcher part: fetch the trust anchor's installer package, check it as the person and hand it
to macOS Installer, which alone asks for the administrator password. Program thread `bb204715`. Backlog row: PC-249 in
[docs/backlog.md](../backlog.md) (with PC-250, the same-user window; numbered PC-247 and PC-248 on this branch
until `main` took those ids for release 0.2.84). The package, its workflow and its machine proof live in fabric-workspace, branch
`w7-anchor-2026-11-25`, `tools/brain/anchor/` (handoff `docs/handoffs/2026-11-25-w7-anchor-lane.md` there).

## Done

- `lib/anchor.js` and `passioncode anchor install --pkg PATH --sums PATH | --url URL [--deploy FILE] --role
person|owner|org-space [--org ORG] [--row ROW] [--dry-run] [--json]` (dispatched from `bin/passioncode.js`, the function at the
file's end so no line a strings.md row cites moves). Checks in order: Gatekeeper on, SHA-256 against SHA256SUMS and
a deployment manifest's pin, `gh attestation verify` for `passioncode-ai/fabric-workspace`'s `brain-anchor.yml`, made on a pushed `brain-anchor-v` tag (any other source ref refused),
`pkgutil --check-signature` (notarised, Developer ID Installer of `KJ35UYYL22`, Developer ID CA, Apple Root CA by
fingerprint, the manifest's certificate pin), `spctl -a -t install`, the embedded pin (shown with its commit; equal to the manifest's
tool tree hash when given; a manifest that pins no package sha256 is refused). Then it writes
`~/.passioncode/brain-anchor.json` (role, organisation, roster row) and runs `open -a Installer`.
- SECURITY.md: "What `anchor install` touches", with the same-user window between the checks and Installer's read,
and the system tools run by absolute path (`TOOL` in `lib/anchor.js`; `gh` from the `PATH`), the role required
(review round 8 of Studio session 59)
(PC-250).
- Studio session 59 (integration and blind review rounds): the attestation's source ref, `--row`, the manifest's
package pin, PC-250; `origin/main` merged in.

## Checks actually run

- Session 59, after merging `origin/main` `7421947` (0.2.84) at `6340353`: `node --test test/anchor.test.js` 22 of 22;
full `npm test` 711 tests, 706 pass, 4 skipped, 1 fail (the known PC-246: the PC-163 socket-table test fails the same
on unchanged `origin/main` `7421947` on this machine, run again 2026-11-25); IP gate (public) on the merge's changes
and the PR text: pass.
- Session 59: `node --test test/anchor.test.js` 22 of 22 (at `cb27ada`, review round 8: the role required, the system
tools by absolute path); full `npm test` (on `8270c92`) 703 tests, 698 pass, 4 skipped, 1 fail (the
known PC-246); IP gate (`public:npm-passioncode`) on the changed `lib/anchor.js`, `bin/passioncode.js`, SECURITY.md,
the PC-250 row and the commit messages: pass.

- Session 45: `node scripts/test.mjs test/anchor.test.js`: 15 of 15 (fixtures are real `pkgutil` outputs, `test/fixtures/anchor`;
one test builds an unsigned package with the real `pkgbuild` and sees the real `pkgutil` refuse it).
- Full `npm test` on this machine: 678 tests, 672 pass, 4 skipped, 1 fail: PC-163's socket-table test, the known PC-246
failure of this build machine (fails the same on unchanged `origin/main`). `test/setup.test.js` was cut by the run's
time cap and ran again on its own with help, strings, no-em-dash, repo-rules and docs: 195 of 195, exit 0.
- IP gate (`ip_gate.py scan --destination public:npm-passioncode`) on `lib/anchor.js`, the CLI lines and the SECURITY
section: pass.
- The same refusals by the Python twin of this check on a real machine (fabric-workspace `assert_identity.py`, the same
`pkgutil` reading; the VM never ran `lib/anchor.js`): `tools/brain/anchor/evidence/` there (the unsigned, tampered,
flipped-byte and other-team packages refused by the agents' user before any elevation).

## Open

- Not merged and not released (W7 runs on branches; a launcher release follows the owner's sitting, T28d).
- A help line and strings.md rows when the command ships to people.

## The next task

After T28d's first signed package exists: download the workflow's artifact (`gh run download <run> -R passioncode-ai/fabric-workspace -n brain-anchor-signed`: nothing is published as a release) and run `passioncode anchor install --pkg <its package> --sums <its SHA256SUMS> --role owner --dry-run` on the
MacBook as the owner, then merge this branch through a PR and release the launcher.
2 changes: 1 addition & 1 deletion lib/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const APP_KEY = /^A-[A-Z]{2,4}-\d{10}$/;
const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; // an app may write it upper case: sent as written
const SEND_MS = 2000;
// The words a property may carry; anything else is dropped (a free string could hold a name or a path).
const COMMANDS = new Set(['setup', 'doctor', 'update', 'status', 'restore', 'config', 'uninstall', 'permissions', 'analytics', 'help']);
const COMMANDS = new Set(['setup', 'doctor', 'update', 'status', 'restore', 'config', 'uninstall', 'permissions', 'analytics', 'help', 'anchor']);
const OUTCOMES = new Set(['ok', 'failed', 'usage']);
// check-failed: a plain doctor whose checks found a problem on the machine (not --fix, not a thrown error); other: the rest.
const ERROR_CODES = new Set(['check-failed', 'other']);
Expand Down
Loading
Loading