Skip to content

feat(addie): secretariat console — human-approved action queue, executor, and admin page - #6064

Open
bokelley wants to merge 1 commit into
mainfrom
secretariat-console
Open

feat(addie): secretariat console — human-approved action queue, executor, and admin page#6064
bokelley wants to merge 1 commit into
mainfrom
secretariat-console

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Stage A of the Secretariat console (specs/spec-guardian.md): the operating surface where humans watch and approve everything the AAO Secretariat wants to do. Every intended action becomes a proposed row — nothing executes until an admin approves it at /admin/secretariat; approved actions are executed by a worker job as aao-secretariat[bot].

What's in it

  • Migration 528secretariat_actions: kind, title, rationale (with evidence links), JSONB payload, dedupe key, edited flag, result/error, decided_by/at. State machine proposed → approved → executing → done (plus rejected, and failed → proposed via retry), every transition an atomic UPDATE … WHERE status = '<from>' so nothing double-executes. (Builder originally picked 524; renumbered after verifying main had advanced to 527.)
  • Executor job (2-minute tick) — single kind-allowlist (open_pr, post_issue_comment, file_issue, post_slack_message); unknown kinds fail closed; hard rule enforced in code and comments: never calls PR-merge or PR-review endpoints. Executes through the existing Secretariat seams (resolveGitHubToken() → App token).
  • PR shepherd job (hourly) — the first proposer: finds open PRs stuck >7 days on a pending IPR signature and proposes a friendly nudge comment, dedupe-keyed to one per PR. Proposes only; a human approves before anything posts.
  • github-pr.ts refactored into shared internals with a multi-file upsertFilesPr (single-file API preserved — the digest job keeps working; multi-file PUT stops at first failure with no orphan PR). postIssueComment added on the filer's auth/timeout/secret-redaction pattern.
  • Admin API — all routes requireAuth + requireAdmin: list/get, approve, reject (reason required), edit-payload (proposed only, sets edited for the autonomy stats), retry, manual enqueue (kind-validated), /watching (open PRs + needs-wg-review queue snapshot, 5-min cache), /stats (per-kind approved-without-edit rate — the evidence feed for future autonomy toggles).
  • Admin page/admin/secretariat: Watching / Proposed inbox (full draft previews) / In-flight / Done+Failed. All dynamic DOM built via textContent helpers; the 13 innerHTML uses are container-clears only. Design-system variables, sentence case. Sidebar link added.

Safety posture

Nothing self-executes: rows are born proposed and only a human admin can move them to approved. The executor's allowlist is the single source (ALLOWED_KINDS), reused by the enqueue route's validation. Merge/review/approve of PRs is structurally outside the action vocabulary. Failed actions surface with errors and require explicit human retry.

Test plan

  • 55 tests across 5 suites: state-machine gates (approve only from proposed, atomic claim, dedupe conflict returns existing, edit sets flag), executor dispatch per kind + fail-closed unknown kind, shepherd propose/dedupe/resilience, multi-file PR helper (one branch, one PR, stop-on-first-failure), plus the pre-existing digest-job suite unaffected.
  • tsc --noEmit clean; full precommit suite passed on commit; branch rebased onto current main.
  • Post-deploy: /admin/secretariat loads; seed the two Docket Welcome to adcp Discussions! #1 docs-PR actions via the enqueue endpoint; approve; verify both PRs open as aao-secretariat[bot].

Implementation by a Sonnet subagent; reviewed by the session orchestrator (migration numbering, state-machine atomicity, executor allowlist, route auth, XSS posture). No changeset — Addie server work.

🤖 Generated with Claude Code

…tor, PR shepherd, admin page

Stage A of the Secretariat console (specs/spec-guardian.md): every action
the Secretariat wants to take becomes a proposed row a human approves in
/admin/secretariat before a worker job executes it as aao-secretariat[bot].

- Migration 528: secretariat_actions with an application-enforced state
  machine (proposed -> approved -> executing -> done | rejected | failed
  -> proposed via retry), every transition an atomic
  UPDATE ... WHERE status = '<from>'.
- Executor (2-min tick): kind allowlist (open_pr, post_issue_comment,
  file_issue, post_slack_message); unknown kinds fail closed; never
  calls PR-merge or PR-review endpoints.
- PR shepherd (hourly): proposes friendly IPR-signature nudges for PRs
  pending >7 days, dedupe-keyed to one nudge per PR; proposes only.
- github-pr.ts refactored into shared internals with multi-file
  upsertFilesPr (single-file API preserved); postIssueComment added on
  the filer's auth/timeout/redaction pattern.
- Admin routes (all requireAuth+requireAdmin): list/get/approve/reject/
  edit/retry/enqueue + watching snapshot + per-kind approved-without-edit
  stats. Admin page builds all dynamic DOM via textContent helpers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Argus review could not complete

The automated review encountered an issue (possibly reached max turns, timed out, or failed to post the final gh pr review). A human reviewer should take this PR.

View workflow run

This is an automated message from the Argus AI review workflow.

@bokelley bokelley added the addie Issues related to Addie (via any channel) label Jul 28, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Argus review could not complete

The automated review encountered an issue (possibly reached max turns, timed out, or failed to post the final gh pr review). A human reviewer should take this PR.

View workflow run

This is an automated message from the Argus AI review workflow.

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

Labels

addie Issues related to Addie (via any channel)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant