Skip to content

Lead build step 3: the hook's write list for leads (T181) #118

Closed

Description

@erickb336

Task: T181, step 3 of 4 (the lead build) · large · risk flag: auth · waits for step 2 (#117).

Where this fits

Design: #62 comments, section 8 ("Logbook writes") and its command table. Today the hook refuses every state tool write by an agent (PR #36). This step adds the lead's allow-list on top of that rule. Step 4 (#119) adds the agent file.

Goal

  1. A state tool command from an agent passes only when all of these are true:
    • the event's agent_type is sage:lead;
    • the agent holds a bound slot;
    • the command is on the lead list in T181 step 1: Lead build: the hook applies the spawn rules to nested agents #62 section 8: run add and run done for the five team roles, finding add, finding close and finding triage (dismiss only a low finding, with a reason), verdict, round, task <T> set for the states building to verified plus branch= and pr=, and the read commands.
  2. Each such command names the lead's own task only. For a run id or a finding key, the hook finds its task with the function from step 2.
  3. The hook refuses everything else from a lead, and every write from a child, with a sentence that says to report to the sage.
  4. If Lead build step 1 follow-ups: idle leads lose slots, spawn rules check the caller not the type, children outlive their lead's slots (before step 2) #102's L1 is still open: the main session starts a lead only with the name lead-T<n> of a task with a running lead run.

Acceptance

  • Tests sent as events to handle():
    • each allowed command passes for the lead's own task;
    • the same command on another task is refused, also through a run id or a finding key of another task;
    • each command not on the list is refused;
    • a child's write is refused.
  • The README's "Rules held in code" table gets one line.

Rules for every sage task

  • Edit the sources only (packages/, principles/, writing/, preferences/). Never edit build output. Run npm run build, npm run check and npm test.
  • Tests that touch processes use a fake ps, pgrep and kill first on PATH. No flaky tests. Never pass a test string to a real shell.
  • Use repo paths only in the PR: the repo is public. Commit with your no-reply identity.
  • Branch codex/t181-step3. The PR title ends with "(T181)", and the body has "Closes Lead build step 3: the hook's write list for leads (T181) #118".
  • Risk flag: auth. The sage runs 2 clean review cycles before it lands the PR.

Activity

  1. added
    codex
    on Oct 11, 2026
  2. erickb336 commented on Oct 12, 2026

    @erickb336
    OwnerAuthor

    Note from the sage (Claude), for Codex: the sage builds this step itself, after PR #121 (#102) merges, because each step needs a live check in Claude Code. Please do not start it.

  3. erickb336 commented on Oct 12, 2026

    @erickb336
    OwnerAuthor

    Input from the review of step 2 (PR #123): finding add --key accepts any text, so the task number inside a finding key does not prove which task owns it. The hook in this step must check the command's own task argument (for example finding triage ), not only taskFor(key), and must not let a lead pass --key.

  4. erickb336 commented on Oct 12, 2026

    @erickb336
    OwnerAuthor

    Input from the security review of step 2 (PR #123): taskFor returns undefined for no logbook, an unknown id, an id on two tasks, a malformed id, and an empty logbook. The hook in this step must refuse a lead's write when taskFor returns undefined, never allow it; otherwise a made-up run id or finding key lets the write through. taskFor throws on a damaged logbook; catch that and refuse too.

  5. erickb336 commented on Oct 12, 2026

    @erickb336
    OwnerAuthor

    More input from the security review of step 2 (PR #123, R880): (1) taskFor takes the project from its caller, but the state tool finds the project from --project, then SAGE_PROJECT, then cwd. The hook must find the project the same way as the state tool (one shared helper in core), or refuse --project and SAGE_PROJECT in a lead's commands; otherwise a lead checks ownership in one logbook and writes another. (2) taskFor reads every table with no size limit on each call. Give the hook's call a byte limit and refuse above it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    codex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions