Skip to content

bc-dgx7.77: B7e-role — A relay role's whole operating contract, in one call - #758

Open
mordam wants to merge 10 commits into
mainfrom
worktree-b7e-role-dgx777
Open

bc-dgx7.77: B7e-role — A relay role's whole operating contract, in one call#758
mordam wants to merge 10 commits into
mainfrom
worktree-b7e-role-dgx777

Conversation

@mordam

@mordam mordam commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Adds bin/b7e-role: a relay role's whole operating contract in one call, closing the gap
five deluvia sessions each paid for by hand-slicing docs/STUDIO_CHARTER.md (726 lines),
APPROVAL_PIPELINE.md and a role file differently every time a relay opened or changed
roles — one of them reading a rule off trunk that a later ruling had already superseded
because its hand-cut slice happened to stop just short of the correction.

b7e-role -w <workspace> <role> prints the role's own charter block, the studio's one
law, the role file in full, its declared output template, and the legal --next targets
(lib/relay.js's rolesOf) — each annotated with a source path and line range so a disputed
sentence can be checked against the file it came from. --next alone answers the
question that cost four of the five sessions a rejected beadcause-relay --next call,
and --all lists the roster with each role's department and gate. Every path is read off
that workspace's own config.relays[name] entry (lib/relay.js) — the same definition
beadcause-relay and the relay brief already use — so deluvia is only the first caller,
not a hardcoded assumption.

lib/rolecontract.js does the markdown slicing as pure functions over already-read text.
The one non-obvious piece: clio's real output template is a worked example wrapped in a
fenced code block that is itself written in markdown headings (## Clio's Continuity Report, ### 1. Timeline) — a naive heading scanner reads the example as more of the
document and cuts the template off after two lines, so section-finding runs against a
fence-blanked copy of the text (same length, same line breaks) while every slice returned
is still cut from the original.

Wired per bc-dgx7.2: both bin registrations, Bash(b7e-role:*) on DEFAULT_TOOL_LIST
classified read in lib/grants.js, a README section, and test/role.mjs. The CLI half of
the test suite builds its own fixture workspace on disk with an isolated
BEADCAUSE_CONFIG_DIR, so it needs no deluvia checkout to run; a final block checks the
shipped deluvia default's roster shape (19 roles, 18 legal next-roles for clio) using
only --all/--next, which read no files at all, so that block holds on a machine that
has never heard of deluvia — the same guarantee test/relay.mjs's own shipped-config check
relies on.

Unsure of one thing: main moved under me while I worked (another branch added
b7e-rebaseline between the same two package.json bin entries b7e-role lands
between), so the registration lines will very likely collide on merge — a routine
take-both, per this repo's own notes on b7e-registry conflicts, but flagging it since I
haven't seen the other branch's actual diff.

Tests: node test/role.mjs (55/55 standalone), then the full local gate: bin/b7e-gate --jobs 3 — 478/478 suites passed (including test/role.mjs and test/lockfile.mjs).

Files changed — 8 files · +907 −0 · against `main`
test/role.mjs        +369 −0
bin/b7e-role         +314 −0
lib/rolecontract.js  +148 −0
README.md            +65 −0
lib/toolbelt.js      +8 −0
lib/grants.js        +1 −0
package-lock.json    +1 −0
package.json         +1 −0

Opened by a beadcause worker session on bc-dgx7.77 — b7e-role — A relay role's whole operating contract, in one call, instead of slicing a 726-line charter. It merges itself once the checks report; merging is what closes the bead. If this is still open, something stopped that, and the reason is on bc-dgx7.77 and in Adam's inbox.

bead: bc-dgx7.77

…e call

Five deluvia sessions (dv-5eu.1.1, dv-gr6.43, dv-gr6.41, dv-b5d.4.3, dv-gr6.38) each
hand-sliced docs/STUDIO_CHARTER.md (726 lines), APPROVAL_PIPELINE.md and a role file
differently every time a relay opened or changed roles, and dv-gr6.43's hand-cut slice
of clio.md happened to stop short of a ruling that superseded the rule it read instead.
b7e-role -w <workspace> <role> prints the role's own charter block, the studio's one
law, the role file in full, its declared output template, and the legal --next targets
(lib/relay.js's rolesOf) — each with a source path and line range. --next alone answers
the question that cost four of the five sessions a rejected `beadcause-relay --next`.
--all lists the roster with department and gate.

lib/rolecontract.js does the markdown slicing as pure functions over already-read text,
fence-aware (a role's worked-example output template can itself be written in markdown
headings, which would otherwise fool the section scanner into cutting it short). The
command is workspace-general: every path comes off that workspace's own
config.relays[name] entry, the same definition beadcause-relay and the relay brief
already read, so deluvia is only the first caller.

Wired per bc-dgx7.2: both bin registrations (package.json, package-lock.json),
Bash(b7e-role:*) on DEFAULT_TOOL_LIST and classified `read` in lib/grants.js, a README
section, and test/role.mjs (55 checks) — the CLI half runs against a fixture workspace
built on disk with an isolated BEADCAUSE_CONFIG_DIR, so it needs no deluvia checkout;
one final block checks the shipped deluvia default's roster shape (19 roles, 18 legal
next-roles for clio) without reading any of its files, so it holds on a machine that
has never heard of deluvia.

Tests: node test/role.mjs (55/55) standalone, then the full gate — bin/b7e-gate --jobs 3
— 478/478 suites passed, including test/role.mjs and test/lockfile.mjs.
@mordam

mordam commented Aug 26, 2026

Copy link
Copy Markdown
Owner Author

A beadcause worker opened this and does not merge its own work. It is on the merge queue as bc-ovby9.

@mordam

mordam commented Aug 26, 2026

Copy link
Copy Markdown
Owner Author

The beadcause merge queue tried to merge this and could not: it has been tried 3 times and stopped at the same place each time. the branch still conflicts with main and no resolver is on it any more — the window that was opened on it ended without making it mergeable, so this one is yours to settle. Tried 3 times — that was the last. It is Adam's call now — see bc-ovby9.

beadcause-memory's a-checkout-dir-is-not-a-workspaces-dir note flags exactly this
command's shape: cfg.workspaces[name].dir is the bd tracker's directory
(~/beads/deluvia/.beads), never the code checkout, and a new b7e-* command that needs
"which checkout is this workspace" should use lib/session.js's resolveSessionDir — the
pair ~25 existing call sites (lib/advocate.js, lib/deploy.js, lib/jiraingest.js,
lib/mergesweep.js, lib/prboard.js) already share — rather than hand-roll a path match.

b7e-role previously defaulted an unset --dir to process.cwd(), which only worked by
accident when invoked from inside the workspace's own checkout (true for a relay session,
not for anything else). It now tries resolveSessionDir(cfg, ws) first, falling back to
cwd when the workspace has no cfg.workspaces entry or resolveSessionDir cannot place it —
so `b7e-role -w deluvia clio` now finds the real charter and role files from anywhere,
verified against the real deluvia checkout on this Mac from inside the beadcause worktree
itself. --dir still wins outright, and every previously-passing test (cwd-based) still
passes unchanged; one new test covers the no-dir/cwd-elsewhere path directly.

Tests: node test/role.mjs (57/57, up from 55). The full gate (bin/b7e-gate --jobs 3) ran
clean at 478/478 before this fix; a second full-gate run afterward showed 52 unrelated
timeouts (bdtemplate, call, commission, census, deploy, endorse, evidence, ...) under
heavy concurrent load on this Mac — test/role.mjs itself only "failed" there as a 939s
timeout, and passes cleanly standalone in ~19s, so this is the documented
gate-reds-on-a-loaded-mac pattern, not a regression from this change.
@mordam

mordam commented Aug 26, 2026

Copy link
Copy Markdown
Owner Author

Updated — 2 commits on worktree-b7e-role-dgx777 — 8 files, +981 −0 against main.

Follow-up to the same bead, same branch/PR: switches bin/b7e-role's directory default
from process.cwd() to lib/session.js's resolveSessionDir(cfg, ws), falling back to cwd.
Found via beadcause-memory notes a-checkout-dir-is-not-a-workspaces-dir, read right after
the first delivery — it warns that cfg.workspaces[name].dir is the bd tracker's directory,
never the code checkout, and that a new b7e-* command should use resolveSessionDir (the
pair ~25 existing call sites already share) rather than rely on an incidental cwd match.
Previously b7e-role -w deluvia clio only found the real files when run from inside the
deluvia checkout; now it finds them from anywhere, verified against the real checkout on
this Mac from inside the beadcause worktree itself. --dir still overrides outright, and
every previously-passing test is unchanged; one new test covers the no-dir/cwd-elsewhere
path.

Tests: node test/role.mjs (57/57 standalone, ~19s). Full gate (bin/b7e-gate --jobs 3) ran clean 478/478 before this follow-up commit; a second full-gate run afterward hit 52 unrelated timeouts under heavy concurrent Mac load (test/role.mjs included, as a 939s timeout) but passes cleanly standalone — the documented gate-reds-on-a-loaded-mac pattern, not a regression.

@mordam

mordam commented Aug 26, 2026

Copy link
Copy Markdown
Owner Author

A beadcause worker opened this and does not merge its own work. It is on the merge queue as bc-72dnr.

# Conflicts:
#	lib/grants.js
#	package-lock.json
#	package.json
@mordam

mordam commented Aug 26, 2026

Copy link
Copy Markdown
Owner Author

The beadcause merge queue tried to merge this and could not: it has been tried 3 times and stopped at the same place each time. the branch still conflicts with main and no resolver is on it any more — the window that was opened on it ended without making it mergeable, so this one is yours to settle. Tried 3 times — that was the last. It is Adam's call now — see bc-72dnr.

# Conflicts:
#	package-lock.json
#	package.json
bc-wbrhi (#791) turned lib/grants.js and lib/toolbelt.js into derived
registries — a tool declares '@grant read' in its own header and
lib/tooldecl.js builds both lists from bin/. Those two files were still
merge=union on this branch's .gitattributes, so the merge silently kept
both sides: main's derived version plus this branch's 35 hand-written
b7e entries restored into each. Resolved by taking origin/main's
lib/grants.js and lib/toolbelt.js whole and declaring '@grant read' in
bin/b7e-role's header, which is the post-bc-wbrhi way to say the same
thing. README's paragraph about where b7e-role is registered updated to
match.
@NeanderthalMan

Copy link
Copy Markdown
Contributor

beadcause-resolver: stood down — worktree-b7e-role-dgx777 is already locked by another resolver on this same PR (reason "resolver pid 64046 #758", pid live in ps). Left the tree untouched and unlocked nothing; that session owns the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants