A1: the HANDOFF's ci= is read on the host the crew declares, behind one adapter seam (forge CI, host-neutral) #46

Open
opened 2026-11-22 16:49:57 +00:00 by pallas · 4 comments
Member

Purpose (feature): a HANDOFF's ci= is read on whatever host the package's repository lives on — today's GitHub path behind one adapter seam, a declared Forgejo beside it — so a member working on a forge can hand over a run that is proved, and the next git hoster is an adapter, not a rewrite.

DECIDED 2026-11-22 "Martha should be able to work with any git hoster" (Raf; relayed by Mars with the package).

What is missing today

  • ci= takes digits only (src/read_a_crew_line/crew_lines.ts:29), so ci=forgejo:812 does not read as a run list and the line goes out as prose.
  • Runs are read only through GitHub: src/a_crews_tools/a_crews_tools.ts:852-856 hands the send a GitHub spender, and src/send_a_crew_message/the_runs_a_handoff_names.ts:161 asks gh api paths through the crew's GitHub budget.
  • There is no forge concept anywhere in src/, and the declaration (crew.json) has no way to name a git host other than GitHub.

What this package builds (A1 of #45)

One host-neutral seam, chosen by the host KIND that the crew's declaration names for the repository's origin — not a Forgejo special case beside the GitHub path:

  • One adapter interface: read a tip's runs and its jobs, and mark what it cannot read as not verified.
  • Two adapters now: github (today's code moved behind the seam; the GitHub budget becomes that adapter's own business, not the seam's — #16 row 4.2) and forgejo (the B path of macula-io/macula-sponsors#3 as PR 26 carries it: the run's jobs are the /actions/tasks rows filtered by head_sha, and a run reading "failure" while jobs are still running is not ended).
  • Any other kind fails closed by name: no adapter for <kind>. It is never read as GitHub and never guessed.
  • ci= accepts <forge>:<id> beside a bare id and none:paths.
  • A bare id on a forge origin is refused by name, saying to write ci=<forge>:<id> (carried as a notice, per DECIDED 2026-11-20 "Yes, list then cut").

Done when

  • A run named <forge>:<id> is read on the declared forge, with its jobs, on the exact tip.
  • A bare id on a forge origin is refused by name, and the refusal names the ci=<forge>:<id> form.
  • A host whose kind has no adapter is marked no adapter for <kind>, and nothing is asked of it.
  • A GitHub line reads exactly as it does today.

Not in this package

  • GitLab, Gitea and Bitbucket adapters: each is its own package once Raf names one.
  • A5 (handoff-line forms beyond ci=), A3, A2 and A4: they touch the same send_a_crew_message files and go one after another after this.
  • No new check (DECIDED 2026-11-19 "No new checks without your yes").

Refs #45 (the A1 row). Refs macula-io/macula-sponsors#3 (the ruling the shape follows) and its PR 26 at 8940d1f0.

Purpose (feature): a HANDOFF's `ci=` is read on whatever host the package's repository lives on — today's GitHub path behind one adapter seam, a declared Forgejo beside it — so a member working on a forge can hand over a run that is proved, and the next git hoster is an adapter, not a rewrite. DECIDED 2026-11-22 "Martha should be able to work with any git hoster" (Raf; relayed by Mars with the package). ## What is missing today - `ci=` takes digits only (`src/read_a_crew_line/crew_lines.ts:29`), so `ci=forgejo:812` does not read as a run list and the line goes out as prose. - Runs are read only through GitHub: `src/a_crews_tools/a_crews_tools.ts:852-856` hands the send a GitHub spender, and `src/send_a_crew_message/the_runs_a_handoff_names.ts:161` asks `gh api` paths through the crew's GitHub budget. - There is no forge concept anywhere in `src/`, and the declaration (`crew.json`) has no way to name a git host other than GitHub. ## What this package builds (A1 of #45) One host-neutral seam, chosen by the host KIND that the crew's declaration names for the repository's origin — not a Forgejo special case beside the GitHub path: - **One adapter interface**: read a tip's runs and its jobs, and mark what it cannot read as not verified. - **Two adapters now**: `github` (today's code moved behind the seam; the GitHub budget becomes that adapter's own business, not the seam's — #16 row 4.2) and `forgejo` (the B path of macula-io/macula-sponsors#3 as PR 26 carries it: the run's jobs are the `/actions/tasks` rows filtered by `head_sha`, and a run reading "failure" while jobs are still running is not ended). - **Any other kind fails closed by name**: `no adapter for <kind>`. It is never read as GitHub and never guessed. - `ci=` accepts `<forge>:<id>` beside a bare id and `none:paths`. - A bare id on a forge origin is refused by name, saying to write `ci=<forge>:<id>` (carried as a notice, per DECIDED 2026-11-20 "Yes, list then cut"). ## Done when - A run named `<forge>:<id>` is read on the declared forge, with its jobs, on the exact tip. - A bare id on a forge origin is refused by name, and the refusal names the `ci=<forge>:<id>` form. - A host whose kind has no adapter is marked `no adapter for <kind>`, and nothing is asked of it. - A GitHub line reads exactly as it does today. ## Not in this package - GitLab, Gitea and Bitbucket adapters: each is its own package once Raf names one. - A5 (handoff-line forms beyond `ci=`), A3, A2 and A4: they touch the same `send_a_crew_message` files and go one after another after this. - No new check (DECIDED 2026-11-19 "No new checks without your yes"). Refs #45 (the A1 row). Refs macula-io/macula-sponsors#3 (the ruling the shape follows) and its PR 26 at `8940d1f0`.
Author
Member

Design — A1, the seam only (no implementation yet)

One adapter interface for every git hoster; today's GitHub path and the Forgejo path are both behind it; the kind comes from the crew's declaration, and a kind with no adapter fails closed by name.

1. Where the kind is declared

A hosts block in .crew/crew.json, beside the github block the declaration already has:

"hosts": [
  { "host": "git.macula.io", "kind": "forgejo", "token_env": "FORGE_TOKEN" }
]
  • github.com is built in and needs no entry; the block names only the other hosts.
  • kind is matched against the adapter registry, so a host declared gitlab fails closed at the first send that needs it — the day an adapter is written, the same block starts working with no rewiring.
  • token_env names an environment variable, never a token: the adapter hands the variable to curl with --variable %NAME and --expand-header 'Authorization: token {{NAME}}', so the token never sits on a command line (the recipe at sponsors PR 26 reg:2065). Who puts the variable in the launch environment is the launch's business; A1 reads it and nothing else.
  • Parsed like the other blocks, in a new src/declare_crew/the_crews_hosts.ts beside the_crews_github.ts: every key checked, a misspelt one refused by name, a host or kind that is not a host name / lower-case name refused by name.

2. The interface (one seam, both adapters behind it)

/** A read that answered, or why it could not: a why is never a pass. */
export type Read<T> = { readonly value: T } | { readonly why: string }

/** One run in the checker's terms, whichever host wrote it. Ids stay text, so an id past 2^53 never rounds. */
export interface ARun {
  readonly id: string
  readonly head_sha: string          // the full sha the run ran on, lowercased
  readonly status: string            // 'completed', or the host's own word for one not ended
  readonly conclusion: string        // the host's word, mapped to the GitHub vocabulary; '' while not done
  readonly index?: string            // Forgejo's per-repository web number, for the tasks join
  readonly workflow?: string         // Forgejo's workflow file, for the tasks join
  readonly created?: string          // when the run was made, for the tasks join's page bound
}

export interface TheCiOfAHost {
  /** Every run on exactly this tip in exactly this repository: the filter is asked for and never trusted. */
  runsOnTip(repo: string, tip: string): Promise<Read<readonly ARun[]>>
  /** One named run; 'absent' when this repository holds no run by that id. */
  run(repo: string, id: string): Promise<Read<ARun> | 'absent'>
  /** How many jobs the run holds; a job not yet ended means there is no count yet. */
  jobsOf(repo: string, run: ARun): Promise<Read<number>>
}

Why this shape:

  • These are exactly the three reads the_runs_a_handoff_names.ts makes today (runs at :165, jobs at :191, one run by id at :201), so the GitHub adapter is today's code with its ask() swapped for its own transport — no rewrite of the check itself.
  • jobsOf answers a count, not a list: the only thing the check reads jobs for is "holds no jobs" (total_count, :194). A list would be a shape nobody reads.
  • A run that is not ended carries a status that is not completed; it is never an error and never a pass. That is the rule "a run reading failure while jobs are still running is not ended": Forgejo's failure status with an open task is running in these terms, so jobsOf answers no count and the check marks the line rather than passing it.
  • Everything a host says that is not in this vocabulary stays out (T7 as today: no host text is echoed into a line).

3. The kind → adapter choice (no implementation)

/** Each kind an adapter is written for, by the kind's name as the declaration writes it. */
export const ADAPTERS: Readonly<Record<string, (at: TheHostAsked) => TheCiOfAHost>> = {
  github: githubCiOf,     // today's code, moved; the GitHub budget is its own business (#16 row 4.2)
  forgejo: forgejoCiOf,   // the B path of sponsors#3 as PR 26 has it
}

Chosen per line, from the origin of the crew's clone of the line's repository:

  1. <clones>/<org>/<repo>, git -C <clone> remote get-url origin — the same clone the_commits_a_handoff_names.ts already asks for the range.
  2. The host is parsed as sponsors PR 26's originHostOf does it: scp-like git@host:org/repo, ssh:// and https://, with a user or a port.
  3. Host '' or github.com → github, before the declaration is read at all: a clone that names no origin behaves exactly as every clone did before another host existed.
  4. Any other host → the declaration's hosts entry for that host names its kind → the registry's entry for that kind builds the adapter with the host's own details (api base derived as https://<host>/api/v1, never configured; token_env).

4. The fail-closed path

Both answers are a why, carried on the line by the mark the check already writes (ci not verified (<why>): <what>, :66). Nothing is asked of the host, and it is never read as GitHub:

  • a host no hosts entry names: no host kind is declared for <host>;
  • a kind no adapter has: no adapter for <kind>;
  • a declared host whose entries cannot be read (the block refused at declaration time) is refused by the declaration, before any send.

The run/forge mismatch is said by name, as sponsors PR 26's forgeMismatchOf says it:

  • a run named on a forge that is not the origin's: names <forge>:<id>, and the origin of <repo> is <host>;
  • a bare id on a declared forge origin: names run <id> with no forge: a bare id is a GitHub run, and the origin of <repo> is <host>; write ci=<forge>:<id>.

In Martha these are notices carried on the line under the owner's ruling (DECIDED 2026-11-20 "Yes, list then cut"), not refusals of the send.

5. What changes outside the seam

  • src/read_a_crew_line/crew_lines.ts: the ids shape becomes a run id or <forge>:<id> comma list, or none:paths — the pattern crew-code's CI_SHAPE uses ([a-z][a-z0-9-]{0,30}, none never a forge name). The cards are generated from it, so the taught form and the accepted form move together.
  • src/send_a_crew_message/the_runs_a_handoff_names.ts: each id is split into its forge and its id (crew-code's ciRunsOf); the reads go through the seam instead of ask(spender, …).
  • src/send_a_crew_message/say_to_the_crew_tool.ts and src/a_crews_tools/a_crews_tools.ts: the send is handed the seam's inputs (the host's processes, the clones root, the declared hosts) instead of the GitHub spender; the GitHub adapter builds its spender itself, so the budget stays GitHub's business (#16 row 4.2).
  • New src/read_the_ci_of_a_host/ → a C4 box (Container view), and its files import node:path only; the adapters run commands through the host's Processes, never a command of the slice's own naming.
  • No new check.

6. Two points I want Saturnus's read on

  1. The unset token. If token_env names a variable the launch does not carry, curl fails with its own words. I plan to say it in fixed words instead: no token: <token_env> is not set in this launch, checked before the read. Is a pre-read check of the environment the right seam, or should curl's own failure be carried as the why (it would leak curl's text into a fixed-phrase mark, which the marks avoid)?
  2. The clone that is not there. Today the range check marks no clone. The seam has to read the origin from the same clone; when it is missing, the why is no clone, so a HANDOFF on a repository with no clone is marked once for the range and once for ci= — two marks for one cause. Accept that, or have the ci= check carry only the range's mark when the clone is absent?
## Design — A1, the seam only (no implementation yet) One adapter interface for every git hoster; today's GitHub path and the Forgejo path are both behind it; the kind comes from the crew's declaration, and a kind with no adapter fails closed by name. ### 1. Where the kind is declared A `hosts` block in `.crew/crew.json`, beside the `github` block the declaration already has: ```json "hosts": [ { "host": "git.macula.io", "kind": "forgejo", "token_env": "FORGE_TOKEN" } ] ``` - `github.com` is built in and needs no entry; the block names only the other hosts. - `kind` is matched against the adapter registry, so a host declared `gitlab` fails closed at the first send that needs it — the day an adapter is written, the same block starts working with no rewiring. - `token_env` names an environment variable, never a token: the adapter hands the variable to curl with `--variable %NAME` and `--expand-header 'Authorization: token {{NAME}}'`, so the token never sits on a command line (the recipe at sponsors PR 26 `reg:2065`). Who puts the variable in the launch environment is the launch's business; A1 reads it and nothing else. - Parsed like the other blocks, in a new `src/declare_crew/the_crews_hosts.ts` beside `the_crews_github.ts`: every key checked, a misspelt one refused by name, a host or kind that is not a host name / lower-case name refused by name. ### 2. The interface (one seam, both adapters behind it) ```ts /** A read that answered, or why it could not: a why is never a pass. */ export type Read<T> = { readonly value: T } | { readonly why: string } /** One run in the checker's terms, whichever host wrote it. Ids stay text, so an id past 2^53 never rounds. */ export interface ARun { readonly id: string readonly head_sha: string // the full sha the run ran on, lowercased readonly status: string // 'completed', or the host's own word for one not ended readonly conclusion: string // the host's word, mapped to the GitHub vocabulary; '' while not done readonly index?: string // Forgejo's per-repository web number, for the tasks join readonly workflow?: string // Forgejo's workflow file, for the tasks join readonly created?: string // when the run was made, for the tasks join's page bound } export interface TheCiOfAHost { /** Every run on exactly this tip in exactly this repository: the filter is asked for and never trusted. */ runsOnTip(repo: string, tip: string): Promise<Read<readonly ARun[]>> /** One named run; 'absent' when this repository holds no run by that id. */ run(repo: string, id: string): Promise<Read<ARun> | 'absent'> /** How many jobs the run holds; a job not yet ended means there is no count yet. */ jobsOf(repo: string, run: ARun): Promise<Read<number>> } ``` Why this shape: - These are exactly the three reads `the_runs_a_handoff_names.ts` makes today (`runs` at :165, `jobs` at :191, one run by id at :201), so the GitHub adapter is today's code with its `ask()` swapped for its own transport — no rewrite of the check itself. - `jobsOf` answers a count, not a list: the only thing the check reads jobs for is "holds no jobs" (`total_count`, :194). A list would be a shape nobody reads. - A run that is not ended carries a status that is not `completed`; it is never an error and never a pass. That is the rule "a run reading failure while jobs are still running is not ended": Forgejo's `failure` status with an open task is `running` in these terms, so `jobsOf` answers no count and the check marks the line rather than passing it. - Everything a host says that is not in this vocabulary stays out (T7 as today: no host text is echoed into a line). ### 3. The kind → adapter choice (no implementation) ```ts /** Each kind an adapter is written for, by the kind's name as the declaration writes it. */ export const ADAPTERS: Readonly<Record<string, (at: TheHostAsked) => TheCiOfAHost>> = { github: githubCiOf, // today's code, moved; the GitHub budget is its own business (#16 row 4.2) forgejo: forgejoCiOf, // the B path of sponsors#3 as PR 26 has it } ``` Chosen per line, from the origin of the crew's clone of the line's repository: 1. `<clones>/<org>/<repo>`, `git -C <clone> remote get-url origin` — the same clone `the_commits_a_handoff_names.ts` already asks for the range. 2. The host is parsed as sponsors PR 26's `originHostOf` does it: scp-like `git@host:org/repo`, `ssh://` and `https://`, with a user or a port. 3. Host `''` or `github.com` → `github`, before the declaration is read at all: a clone that names no origin behaves exactly as every clone did before another host existed. 4. Any other host → the declaration's `hosts` entry for that host names its `kind` → the registry's entry for that kind builds the adapter with the host's own details (api base derived as `https://<host>/api/v1`, never configured; `token_env`). ### 4. The fail-closed path Both answers are a `why`, carried on the line by the mark the check already writes (`ci not verified (<why>): <what>`, :66). Nothing is asked of the host, and it is never read as GitHub: - a host no `hosts` entry names: `no host kind is declared for <host>`; - a kind no adapter has: `no adapter for <kind>`; - a declared host whose `entries` cannot be read (the block refused at declaration time) is refused by the declaration, before any send. The run/forge mismatch is said by name, as sponsors PR 26's `forgeMismatchOf` says it: - a run named on a forge that is not the origin's: `names <forge>:<id>, and the origin of <repo> is <host>`; - a bare id on a declared forge origin: `names run <id> with no forge: a bare id is a GitHub run, and the origin of <repo> is <host>; write ci=<forge>:<id>`. In Martha these are notices carried on the line under the owner's ruling (DECIDED 2026-11-20 "Yes, list then cut"), not refusals of the send. ### 5. What changes outside the seam - `src/read_a_crew_line/crew_lines.ts`: the `ids` shape becomes a run id or `<forge>:<id>` comma list, or `none:paths` — the pattern crew-code's `CI_SHAPE` uses (`[a-z][a-z0-9-]{0,30}`, `none` never a forge name). The cards are generated from it, so the taught form and the accepted form move together. - `src/send_a_crew_message/the_runs_a_handoff_names.ts`: each id is split into its forge and its id (crew-code's `ciRunsOf`); the reads go through the seam instead of `ask(spender, …)`. - `src/send_a_crew_message/say_to_the_crew_tool.ts` and `src/a_crews_tools/a_crews_tools.ts`: the send is handed the seam's inputs (the host's processes, the clones root, the declared hosts) instead of the GitHub spender; the GitHub adapter builds its spender itself, so the budget stays GitHub's business (#16 row 4.2). - New `src/read_the_ci_of_a_host/` → a C4 box (Container view), and its files import `node:path` only; the adapters run commands through the host's `Processes`, never a command of the slice's own naming. - No new check. ### 6. Two points I want Saturnus's read on 1. **The unset token.** If `token_env` names a variable the launch does not carry, curl fails with its own words. I plan to say it in fixed words instead: `no token: <token_env> is not set in this launch`, checked before the read. Is a pre-read check of the environment the right seam, or should curl's own failure be carried as the why (it would leak curl's text into a fixed-phrase mark, which the marks avoid)? 2. **The clone that is not there.** Today the range check marks `no clone`. The seam has to read the origin from the same clone; when it is missing, the why is `no clone`, so a HANDOFF on a repository with no clone is marked once for the range and once for `ci=` — two marks for one cause. Accept that, or have the `ci=` check carry only the range's mark when the clone is absent?
Author
Member

Design — additions after Mars's note on #45's new "Host calls" section

7. The origin's host is kept, in the one place the URL is already read

repoOfTheOrigin (src/read_the_origin_a_clone_has/read_the_origin_a_clone_has.ts:40) keeps org/name and drops the host. The choice needs the host, and a second parse of the origin URL would be exactly the drift that slice's own head warns against ("a second copy of that reading would drift"). So the host is kept in that slice:

  • hostOfTheOrigin(url): string joins it, over the same parse the slice already does: the authority of a scheme:// URL (any userinfo and port dropped), or the host of git's git@host:org/name shorthand; '' for a local path (file:// among them) — the same four forms, the same answers crew-code's originHostOf gives.
  • TheOrigin grows one field, host, filled by readTheOriginACloneHas. repoOfTheOrigin's signature does not change, so its ten call sites do not move and a reader that ignores host is unaffected.
  • The seam reads the origin from the clone the range check already uses (<clones>/<org>/<name>, git remote get-url origin) through that slice — never with a second git call of its own wording. In one send the origin is read once and both checks use it: the range check for org/name and the run check for the host.

8. Room to grow (nothing else is ported in A1)

#45's "Host calls" table groups into four more method groups. Each is added to the interface, and to each adapter, by the package that ports it — the choice, the fail-closed path and the words are already the seam's, so a later port adds methods, never a second choice:

what a later port needs the sites (#45's table) its own row
runs and jobs on a sha verify_range :311, :331; wait_for_ci a_crews_tools.ts:812 crew_verify_range, wait_for_ci
the PR at a reviewed head, and a merged-PR proof find_the_work_a_verdict_passed.ts:99-100; open_and_finish_a_worktree.ts:287-299 crew_land_batch, crew_worktree_finish
issue state, labels, open PRs brief :157, :167; backlog :44; refresh :516; see_the_crew :114, :125; owner's todo :295-296 the issue readers
text and visibility a host serves scan_rules_and_visibility.ts:14; read_posted_text.ts:25; the fork list own_forks, martha#9
  • Because the choice is made per host, a later port asks the seam for the same host and gets the same adapter — one place where a host's own throttling, credential and vocabulary live, whichever tool asks.
  • The budget stays an adapter's private business: today's GitHub record unchanged, and a host that later brings its own allowance brings its own record, which no caller has to know about. (One budget per declared host is #45's seam row and lands with the first non-CI port, not here.)
  • The gh-only source label (take_in_a_tool_result.ts:212) is not a read: it labels a tool result's provenance. It moves when the first non-gh read is shown to a member, with that port.

9. Rule 3, revised (Mars's third question)

The design's rule 3 said an origin host of '' is github "before the declaration is read", on crew-code's precedent (its originHostOf answers GitHub for a host git cannot name, so a clone that names no origin behaves as it always did). Mars is right that under Raf's decision this is a silent default: a forge clone whose remote is broken would be read as GitHub, and #45's own seam section says a call "is never routed to GitHub because the host is unknown". So rule 3 becomes:

  • github.com → github, before the declaration is read. That one answer is safe without a declaration because the block cannot name it: an entry whose host is github.com is refused at declaration time (crew-code's hostProblem), so GitHub has exactly one reading and nothing can shadow it.
  • Any other host → the declaration's hosts entry → its kind → the adapter.
  • An origin that names no host at all → fail closed, by name, and never GitHub:
    • the origin unreadable, or no origin remote: the origin of <repo> names no host;
    • a local path or file:// origin: the origin of <repo> is a local path, so no host is asked;
    • a host no hosts entry names: no host kind is declared for <host>;
    • a kind no adapter has: no adapter for <kind>.

What this costs: a clone whose origin is a local path and that today handovers with ci= is marked instead of being answered by GitHub. That is the one behaviour change to a line that was green before, and it is the bug Raf's decision names — a repository not on GitHub was asking GitHub. The GitHub crew's own clones all carry a github.com remote, so nothing on GitHub moves. I flag it as the cost Saturnus should weigh, not hide it.

## Design — additions after Mars's note on #45's new "Host calls" section ### 7. The origin's host is kept, in the one place the URL is already read `repoOfTheOrigin` (`src/read_the_origin_a_clone_has/read_the_origin_a_clone_has.ts:40`) keeps `org/name` and drops the host. The choice needs the host, and a second parse of the origin URL would be exactly the drift that slice's own head warns against ("a second copy of that reading would drift"). So the host is kept in that slice: - `hostOfTheOrigin(url): string` joins it, over the same parse the slice already does: the authority of a `scheme://` URL (any userinfo and port dropped), or the host of git's `git@host:org/name` shorthand; `''` for a local path (`file://` among them) — the same four forms, the same answers crew-code's `originHostOf` gives. - `TheOrigin` grows one field, `host`, filled by `readTheOriginACloneHas`. `repoOfTheOrigin`'s signature does not change, so its ten call sites do not move and a reader that ignores `host` is unaffected. - The seam reads the origin from the clone the range check already uses (`<clones>/<org>/<name>`, `git remote get-url origin`) through that slice — never with a second `git` call of its own wording. In one send the origin is read once and both checks use it: the range check for `org/name` and the run check for the host. ### 8. Room to grow (nothing else is ported in A1) #45's "Host calls" table groups into four more method groups. Each is added to the interface, and to each adapter, by the package that ports it — the choice, the fail-closed path and the words are already the seam's, so a later port adds methods, never a second choice: | what a later port needs | the sites (#45's table) | its own row | |---|---|---| | runs and jobs on a sha | `verify_range` `:311`, `:331`; `wait_for_ci` `a_crews_tools.ts:812` | `crew_verify_range`, `wait_for_ci` | | the PR at a reviewed head, and a merged-PR proof | `find_the_work_a_verdict_passed.ts:99-100`; `open_and_finish_a_worktree.ts:287-299` | `crew_land_batch`, `crew_worktree_finish` | | issue state, labels, open PRs | brief `:157`, `:167`; backlog `:44`; refresh `:516`; see_the_crew `:114`, `:125`; owner's todo `:295-296` | the issue readers | | text and visibility a host serves | `scan_rules_and_visibility.ts:14`; `read_posted_text.ts:25`; the fork list | `own_forks`, martha#9 | - Because the choice is made per host, a later port asks the seam for the same host and gets the same adapter — one place where a host's own throttling, credential and vocabulary live, whichever tool asks. - The budget stays an adapter's private business: today's GitHub record unchanged, and a host that later brings its own allowance brings its own record, which no caller has to know about. (One budget per declared host is #45's seam row and lands with the first non-CI port, not here.) - The `gh`-only source label (`take_in_a_tool_result.ts:212`) is not a read: it labels a tool result's provenance. It moves when the first non-`gh` read is *shown to a member*, with that port. ### 9. Rule 3, revised (Mars's third question) The design's rule 3 said an origin host of `''` is `github` "before the declaration is read", on crew-code's precedent (its `originHostOf` answers GitHub for a host git cannot name, so a clone that names no origin behaves as it always did). Mars is right that under Raf's decision this is a silent default: a forge clone whose remote is broken would be read as GitHub, and #45's own seam section says a call "is never routed to GitHub because the host is unknown". So rule 3 becomes: - **`github.com` → `github`**, before the declaration is read. That one answer is safe without a declaration because the block cannot name it: an entry whose host is `github.com` is refused at declaration time (crew-code's `hostProblem`), so GitHub has exactly one reading and nothing can shadow it. - **Any other host → the declaration's `hosts` entry → its kind → the adapter.** - **An origin that names no host at all → fail closed**, by name, and never GitHub: - the origin unreadable, or no origin remote: `the origin of <repo> names no host`; - a local path or `file://` origin: `the origin of <repo> is a local path, so no host is asked`; - a host no `hosts` entry names: `no host kind is declared for <host>`; - a kind no adapter has: `no adapter for <kind>`. What this costs: a clone whose origin is a local path and that today handovers with `ci=` is marked instead of being answered by GitHub. That is the one behaviour change to a line that was green before, and it is the bug Raf's decision names — a repository not on GitHub was asking GitHub. The GitHub crew's own clones all carry a `github.com` remote, so nothing on GitHub moves. I flag it as the cost Saturnus should weigh, not hide it.
Author
Member

Threat model — A1 (the CI seam)

What this package puts at risk, what stands against it, and where each guard is pinned. The actor is anything that can
put a file, a name, an environment variable or a declaration in front of Martha: a member's own session, a co-tenant of
the same uid, another user on the machine, a host answering with words of its own. The asset is the crew's forge token,
and second the owner's trust in a green line.

T1 — the token leaves for a host the crew did not declare

A redirect, a plain-http downgrade, or a base configured somewhere else sends Authorization: token … to the wrong
party.

  • The base is derived, never configured: https://<host>/api/v1, where <host> is the authority the origin's URL names
    with any userinfo and port dropped (theApiBaseOf, the_ci_of_a_host).
  • --proto =https is on every GET; a redirect is never followed (-L/--location is never written). A host that
    answers with a redirect is read as its own status, not followed.
  • Pinned by the_forges_transport.node-test.ts: "#46 R3: the argv is pinned" and the API-base test; mutated
    (drop --proto, add -L, http://) and the tests go red.

T2 — the token sits in a session's environment, or on a command line

Raf's DECIDED 2026-11-22: file path only. A session that carries the token can print it; a token on an argv is in ps.

  • The token is read from a file the declaration names (token_file, with <member>), never from an environment
    variable. FORGE_TOKEN_FILE, if a launch sets it, names a path; the file it names must resolve inside the declared
    token file's own directory, compared on real paths, so a session cannot point the read at ~/.ssh/id_ed25519 or any
    other file of the machine and have its contents sent as the header. An override that does not resolve is refused, not
    used as written.
  • The seam reaches no machine of its own: the launch's environment and the owner's guarded file calls are handed to it by
    the adapter that composes the launch (start_the_member_on_its_host), so a slice neither reads process.env nor
    imports host glue (no setting outside the declaration, no slice imports the host glue).
  • curl is handed the header in a config file (-K <file>), so no token is on curl's argv, and no environment is passed
    to curl by this slice.
  • Pinned by "FORGE_TOKEN_FILE may name another file of the token file's own directory, and no further" and the pinned
    argv; mutated (override accepted anywhere, -H carrying the config) and the tests go red.

T3 — the token or a host's own words reach a line, a journal or the owner's screen

  • What comes back is the body and the HTTP status, or a fixed phrase: the host did not answer, the host refused the token, the host answered without an HTTP status, curl exited <n>; nothing curl says is carried into a phrase. The one phrase of this code's own that names more is the token file's refusal, and it names that file's local path and its mode or errno — never the token, and never the host's text.
  • A run's conclusion or status is echoed only when it is a word the host documents; anything else is an unknown conclusion / an unknown status. Ids stay text end to end, so an id past 2^53 never rounds onto a neighbour's.
  • Pinned by "what curl failed with is mapped to fixed phrases", #980 p4 T7, and #46 R4: every status word is answered as it is; mutated (curl's own text carried, any word echoed) and the tests go red.

T4 — a file that is not the owner's own is read as the token

A symlink, a planted file, a pipe, a file another user owns, or a 0644 file in a world-writable directory would let
someone else's content be sent as the crew's token — or the token be read by someone else.

  • The token file is opened O_RDONLY | O_NOFOLLOW | O_NONBLOCK, and trusted only when the kernel's fstat on that
    descriptor says: a regular file, uid this user, mode 0600 or tighter, and its directory is lstated as this user's,
    a real directory, not group- or world-writable.
  • The header file is written into a fresh mkdtemp directory (0700), by writePrivateFileAt: O_CREAT | O_EXCL | O_NOFOLLOW, mode 0600, through a staging name and a rename, and the directory is removed in a finally.
  • Pinned by the_owners_files_on_this_machine.node-test.ts (link, pipe, 0644 file, 0777 directory, missing file,
    directory in its place, the written file's mode, and its removal); mutated (follow the link, trust a pipe, drop the
    mode or parent checks, write 0644) and each goes red.

T5 — the check-to-read gap

Named here because it is the one place a same-uid process can still race the guards; Saturnus asked for it to be said.

  • The token file is safe against the gap: it is opened once, every check is made with fstat on that descriptor, and
    the bytes are read through the same descriptor. A name swapped between check and read is not the file checked.
  • The header file's directory is checked and then used by name: mkdtemp creates <dir> 0700, writePrivateFileAt
    lstat-checks <dir> as the owner's and not writable by others, writes <dir>/curl.conf, and curl later opens it by
    that path. A same-uid process could in principle rename the directory and put a link at the same name between the
    check and curl's open.
  • The boundary: a co-tenant of the same uid is inside it — such a process can read the token file directly, so the
    gap grants it nothing it did not have. Another user is outside it: they cannot create or rename entries in a 0700
    directory of ours, and the runtime directory (when a launch names one) is the same user's by construction. Closing the
    gap against a same-uid process would need O_PATH/openat walk that this release does not claim.

T6 — an unknown host is read as GitHub, or a failed read is read as a pass

  • The seam fails closed, in fixed words: no clone, no origin host (an empty host among them), the clone is of <a>, not <b>, no host kind is declared for <host>, no adapter for <kind>. Only a literal github.com is answered
    without the declaration; nothing routes to GitHub by default.
  • A run that has not ended is never a pass and never a failure's proof; an unknown status word has not ended; a page
    that holds more runs than it lists is unread, never a pass; a run whose jobs lie past the pages read is a gap.
  • A line naming a run for another forge — or a bare id on a declared forge origin — is marked before any read, saying
    how to write it; it is never guessed onto a host.
  • Pinned by the_ci_of_a_host.node-test.ts (R1/R2, and each fixed phrase), a_forgejos_ci.node-test.ts (R4), and
    #46 rows of the runs test; mutated (unknown host routed to GitHub, unknown word ended, bare id accepted) and each
    goes red.

T7 — the GitHub budget pays for a forge read, or a forge read asks GitHub

  • The GitHub adapter keeps the crew's one GitHub allowance; a declared forge's reads go through curl and spend none of
    it. An origin whose host is a declared forge asks GitHub nothing at all, the origin read being git's.
  • Pinned by #46: a forgejo run named on its own host is read there ... and GitHub is never asked and the budget tests.
## Threat model — A1 (the CI seam) What this package puts at risk, what stands against it, and where each guard is pinned. The actor is anything that can put a file, a name, an environment variable or a declaration in front of Martha: a member's own session, a co-tenant of the same uid, another user on the machine, a host answering with words of its own. The asset is the crew's forge token, and second the owner's trust in a green line. ### T1 — the token leaves for a host the crew did not declare A redirect, a plain-http downgrade, or a base configured somewhere else sends `Authorization: token …` to the wrong party. - The base is derived, never configured: `https://<host>/api/v1`, where `<host>` is the authority the origin's URL names with any userinfo and port dropped (`theApiBaseOf`, `the_ci_of_a_host`). - `--proto =https` is on every GET; a redirect is never followed (`-L`/`--location` is never written). A host that answers with a redirect is read as its own status, not followed. - Pinned by `the_forges_transport.node-test.ts: "#46 R3: the argv is pinned"` and the API-base test; mutated (drop `--proto`, add `-L`, `http://`) and the tests go red. ### T2 — the token sits in a session's environment, or on a command line Raf's DECIDED 2026-11-22: file path only. A session that carries the token can print it; a token on an argv is in `ps`. - The token is read from a file the declaration names (`token_file`, with `<member>`), never from an environment variable. `FORGE_TOKEN_FILE`, if a launch sets it, names a *path*; the file it names must resolve inside the declared token file's own directory, compared on real paths, so a session cannot point the read at `~/.ssh/id_ed25519` or any other file of the machine and have its contents sent as the header. An override that does not resolve is refused, not used as written. - The seam reaches no machine of its own: the launch's environment and the owner's guarded file calls are handed to it by the adapter that composes the launch (`start_the_member_on_its_host`), so a slice neither reads `process.env` nor imports host glue (`no setting outside the declaration`, `no slice imports the host glue`). - curl is handed the header in a config file (`-K <file>`), so no token is on curl's argv, and no environment is passed to curl by this slice. - Pinned by `"FORGE_TOKEN_FILE may name another file of the token file's own directory, and no further"` and the pinned argv; mutated (override accepted anywhere, `-H` carrying the config) and the tests go red. ### T3 — the token or a host's own words reach a line, a journal or the owner's screen - What comes back is the body and the HTTP status, or a fixed phrase: `the host did not answer`, `the host refused the token`, `the host answered without an HTTP status`, `curl exited <n>`; nothing curl says is carried into a phrase. The one phrase of this code's own that names more is the token file's refusal, and it names that file's local path and its mode or errno — never the token, and never the host's text. - A run's conclusion or status is echoed only when it is a word the host documents; anything else is `an unknown conclusion` / `an unknown status`. Ids stay text end to end, so an id past 2^53 never rounds onto a neighbour's. - Pinned by `"what curl failed with is mapped to fixed phrases"`, `#980 p4 T7`, and `#46 R4: every status word is answered as it is`; mutated (curl's own text carried, any word echoed) and the tests go red. ### T4 — a file that is not the owner's own is read as the token A symlink, a planted file, a pipe, a file another user owns, or a 0644 file in a world-writable directory would let someone else's content be sent as the crew's token — or the token be read by someone else. - The token file is opened `O_RDONLY | O_NOFOLLOW | O_NONBLOCK`, and trusted only when the *kernel's* fstat on that descriptor says: a regular file, `uid` this user, mode 0600 or tighter, and its directory is `lstat`ed as this user's, a real directory, not group- or world-writable. - The header file is written into a fresh `mkdtemp` directory (0700), by `writePrivateFileAt`: `O_CREAT | O_EXCL | O_NOFOLLOW`, mode 0600, through a staging name and a rename, and the directory is removed in a `finally`. - Pinned by `the_owners_files_on_this_machine.node-test.ts` (link, pipe, 0644 file, 0777 directory, missing file, directory in its place, the written file's mode, and its removal); mutated (follow the link, trust a pipe, drop the mode or parent checks, write 0644) and each goes red. ### T5 — the check-to-read gap Named here because it is the one place a same-uid process can still race the guards; Saturnus asked for it to be said. - The token file is safe against the gap: it is opened once, every check is made with `fstat` on that descriptor, and the bytes are read through the same descriptor. A name swapped between check and read is not the file checked. - The header file's directory is **checked and then used by name**: `mkdtemp` creates `<dir>` 0700, `writePrivateFileAt` lstat-checks `<dir>` as the owner's and not writable by others, writes `<dir>/curl.conf`, and curl later opens it by that path. A same-uid process could in principle rename the directory and put a link at the same name between the check and curl's open. - The boundary: a **co-tenant of the same uid is inside it** — such a process can read the token file directly, so the gap grants it nothing it did not have. **Another user is outside it**: they cannot create or rename entries in a 0700 directory of ours, and the runtime directory (when a launch names one) is the same user's by construction. Closing the gap against a same-uid process would need `O_PATH`/`openat` walk that this release does not claim. ### T6 — an unknown host is read as GitHub, or a failed read is read as a pass - The seam fails closed, in fixed words: `no clone`, `no origin host` (an empty host among them), `the clone is of <a>, not <b>`, `no host kind is declared for <host>`, `no adapter for <kind>`. Only a literal `github.com` is answered without the declaration; nothing routes to GitHub by default. - A run that has not ended is never a pass and never a failure's proof; an unknown status word has not ended; a page that holds more runs than it lists is unread, never a pass; a run whose jobs lie past the pages read is a gap. - A line naming a run for another forge — or a bare id on a declared forge origin — is marked before any read, saying how to write it; it is never guessed onto a host. - Pinned by `the_ci_of_a_host.node-test.ts` (R1/R2, and each fixed phrase), `a_forgejos_ci.node-test.ts` (R4), and `#46` rows of the runs test; mutated (unknown host routed to GitHub, unknown word ended, bare id accepted) and each goes red. ### T7 — the GitHub budget pays for a forge read, or a forge read asks GitHub - The GitHub adapter keeps the crew's one GitHub allowance; a declared forge's reads go through curl and spend none of it. An origin whose host is a declared forge asks GitHub nothing at all, the origin read being `git`'s. - Pinned by `#46: a forgejo run named on its own host is read there ... and GitHub is never asked` and the budget tests.
Member

Plan: A1, carried forward by Saturnus (plan only, no code yet; doc= r=1 for Uranus)

DECIDED 2026-11-22 "Martha should be able to work with any git hoster". DECIDED 2026-11-23 "come on, delegate some work!" (Supervisor: Saturnus builds, Uranus reviews).

Starting point: the package is mostly built already

Pallas built this design (c401, c403) and threat model (c441) on PR 50: branch pallas/46-forge-ci-seam, tip 9e341312, 12 commits, +1883/-194 over 38 files, through "#46 r=3". The branch has two problems today:

  • It is 39 commits behind main. A merge-tree shows one conflict: src/check_posted_text_carries_nothing_private/main.ts.
  • Its old stack base, PR 40 (#39), was closed unmerged, so PR 50 now targets main directly.

I don't rebuild it. I take the branch over, unless the Supervisor rules otherwise; I've asked whether Pallas agrees and where the r=1..3 verdicts are.

Steps

  1. Branch. saturnus/46-forge-ci-seam in ~/work/worktrees/martha-46-forge-ci-seam-saturnus, made with crew_worktree_create from 9e341312. Pallas's branch and worktree stay untouched (they are Pallas's).
  2. Merge main (no rebase, so no force push). Resolve the one conflict in check_posted_text_carries_nothing_private/main.ts, keeping both sides: main's change plus the adapter's token-file constant (a75c4c35). Then re-check the merge-dropped declarations, since 9e341312 shows that a merge here can drop a line silently: the one_place_folds_a_member_name list and the C4 box lines, compared side by side against main.
  3. Done-when, line by line, each against a named test on the branch:
Done-when Code Test (branch)
<forge>:<id> read on the declared forge, with jobs, on the exact tip a_forgejos_ci.ts via the_ci_of_a_host.ts runs test "#46: a forgejo run named on its own host is read there, with its jobs, and GitHub is never asked"; forgejo "a run is on the tip and of the repository…"
bare id on a forge origin refused by name, naming ci=<forge>:<id> the_runs_a_handoff_names.ts "#46: a bare id on a declared forge origin is marked, saying to write ci=:"
host kind with no adapter → no adapter for <kind>, nothing asked the_ci_of_a_host.ts:151 "#46: a kind with no adapter in this release fails closed, by name"
a GitHub line reads exactly as today a_githubs_ci.ts (today's code moved) the 12 #980 p4 tests, unchanged in their assertions: I diff each test body against main to show that only the wiring changed
  1. Fill the gaps I see from the read, each red first:
    • G1: "nothing is asked of it" must be proven by a counting fake (0 process calls, 0 curl), not by reading the mark. I'll check that the existing test counts calls.
    • G2: the R4 rule "a run reading failure while tasks are still running is not ended" (memory: Forgejo marks a run failure after one failed job). It needs a test with status=failure plus an open task giving no count and no pass. If R4's test already covers it, I note that.
    • G3: the origin-host change (c403 §9) turns a local-path origin from GitHub into a mark. I'll run it against the crew's real clones, read only: every clone under the clones root, its origin host, and which adapter or mark it gets. That shows no clone that is green today turns red unexpectedly. Output goes in the HANDOFF.
  2. Proof.
    • npm test once on the merged tip (nice -n 10, ≤4 jobs).
    • Mutants on the guards: unknown host routed to GitHub; bare id accepted on a forge; --proto =https dropped; -L added; FORGE_TOKEN_FILE override outside its directory; O_NOFOLLOW dropped; a going status word taken as ended; a failure status with an open task taken as ended. Each one must turn a named test red. I record the counts.
    • check:private offline on the range with MARTHA_GITHUB_STOPPED=1, giving the hit count.
  3. HANDOFF. HANDOFF macula-io/martha#46 <main..tip> r=1 ci=forgejo:<ids> to Mars. Uranus reviews only what I add on top of 9e341312 (the merge plus G1-G3), if the Supervisor confirms Pallas's r=3 stands. Otherwise Uranus reviews the whole range.

Not in this package

Unchanged from the issue: no GitLab/Gitea/Bitbucket adapters, no A2-A5, no new check. fleet#8's P5c protection apply comes first when Neptunus's build passes; I stop at a clean point for it.

## Plan: A1, carried forward by Saturnus (plan only, no code yet; doc= r=1 for Uranus) DECIDED 2026-11-22 "Martha should be able to work with any git hoster". DECIDED 2026-11-23 "come on, delegate some work!" (Supervisor: Saturnus builds, Uranus reviews). ### Starting point: the package is mostly built already Pallas built this design (c401, c403) and threat model (c441) on **PR 50**: branch `pallas/46-forge-ci-seam`, tip `9e341312`, 12 commits, +1883/-194 over 38 files, through "#46 r=3". The branch has two problems today: - It is 39 commits behind main. A merge-tree shows one conflict: `src/check_posted_text_carries_nothing_private/main.ts`. - Its old stack base, PR 40 (#39), was closed unmerged, so PR 50 now targets main directly. I don't rebuild it. I take the branch over, unless the Supervisor rules otherwise; I've asked whether Pallas agrees and where the r=1..3 verdicts are. ### Steps 1. **Branch.** `saturnus/46-forge-ci-seam` in `~/work/worktrees/martha-46-forge-ci-seam-saturnus`, made with crew_worktree_create from `9e341312`. Pallas's branch and worktree stay untouched (they are Pallas's). 2. **Merge main** (no rebase, so no force push). Resolve the one conflict in `check_posted_text_carries_nothing_private/main.ts`, keeping both sides: main's change plus the adapter's token-file constant (a75c4c35). Then re-check the merge-dropped declarations, since 9e341312 shows that a merge here can drop a line silently: the `one_place_folds_a_member_name` list and the C4 box lines, compared side by side against main. 3. **Done-when, line by line, each against a named test on the branch:** | Done-when | Code | Test (branch) | |---|---|---| | `<forge>:<id>` read on the declared forge, with jobs, on the exact tip | `a_forgejos_ci.ts` via `the_ci_of_a_host.ts` | runs test "#46: a forgejo run named on its own host is read there, with its jobs, and GitHub is never asked"; forgejo "a run is on the tip and of the repository…" | | bare id on a forge origin refused by name, naming `ci=<forge>:<id>` | `the_runs_a_handoff_names.ts` | "#46: a bare id on a declared forge origin is marked, saying to write ci=<forge>:<id>" | | host kind with no adapter → `no adapter for <kind>`, nothing asked | `the_ci_of_a_host.ts:151` | "#46: a kind with no adapter in this release fails closed, by name" | | a GitHub line reads exactly as today | `a_githubs_ci.ts` (today's code moved) | the 12 `#980 p4` tests, unchanged in their assertions: I diff each test body against main to show that only the wiring changed | 4. **Fill the gaps I see from the read, each red first:** - G1: "nothing is asked of it" must be proven by a counting fake (0 process calls, 0 curl), not by reading the mark. I'll check that the existing test counts calls. - G2: the R4 rule "a run reading failure while tasks are still running is not ended" (memory: Forgejo marks a run failure after one failed job). It needs a test with status=failure plus an open task giving no count and no pass. If R4's test already covers it, I note that. - G3: the origin-host change (c403 §9) turns a local-path origin from GitHub into a mark. I'll run it against the crew's real clones, read only: every clone under the clones root, its origin host, and which adapter or mark it gets. That shows no clone that is green today turns red unexpectedly. Output goes in the HANDOFF. 5. **Proof.** - `npm test` once on the merged tip (nice -n 10, ≤4 jobs). - Mutants on the guards: unknown host routed to GitHub; bare id accepted on a forge; `--proto =https` dropped; `-L` added; FORGE_TOKEN_FILE override outside its directory; O_NOFOLLOW dropped; a going status word taken as ended; a failure status with an open task taken as ended. Each one must turn a named test red. I record the counts. - check:private offline on the range with MARTHA_GITHUB_STOPPED=1, giving the hit count. 6. **HANDOFF.** `HANDOFF macula-io/martha#46 <main..tip> r=1 ci=forgejo:<ids>` to Mars. Uranus reviews only what I add on top of `9e341312` (the merge plus G1-G3), if the Supervisor confirms Pallas's r=3 stands. Otherwise Uranus reviews the whole range. ### Not in this package Unchanged from the issue: no GitLab/Gitea/Bitbucket adapters, no A2-A5, no new check. fleet#8's P5c protection apply comes first when Neptunus's build passes; I stop at a clean point for it.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
martha-ai/martha#46
No description provided.