Skip to content
Merged
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
5 changes: 5 additions & 0 deletions pmoves/docker-compose.agents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ services:
- CLAUDE_API_KEY=${CLAUDE_API_KEY:-}
- CLAUDE_CODE_OAUTH_TOKEN=${CLAUDE_CODE_OAUTH_TOKEN:-}
- CLAUDE_USE_GLOBAL_AUTH=${CLAUDE_USE_GLOBAL_AUTH:-false}
# CLAUDE_BIN_PATH: path to the Claude CLI binary inside the container.
# Default empty (uses $PATH). The upstream Archon Dockerfile installs
# Claude at /usr/local/bin/claude; set this only if the image builds
# Claude at a non-standard path or you want to pin a specific binary.
- CLAUDE_BIN_PATH=${CLAUDE_BIN_PATH:-}
# gh auth — non-fatal warning if absent.
- GH_TOKEN=${GH_TOKEN:-}
# Host environment leak guard (see x-host-leak-guard docs above)
Expand Down
5 changes: 5 additions & 0 deletions pmoves/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3100,6 +3100,11 @@ services:
- CLAUDE_API_KEY=${CLAUDE_API_KEY:-}
- CLAUDE_CODE_OAUTH_TOKEN=${CLAUDE_CODE_OAUTH_TOKEN:-}
- CLAUDE_USE_GLOBAL_AUTH=${CLAUDE_USE_GLOBAL_AUTH:-false}
# CLAUDE_BIN_PATH: path to the Claude CLI binary inside the container.
# Default empty (uses $PATH). The upstream Archon Dockerfile installs
# Claude at /usr/local/bin/claude; set this only if the image builds
# Claude at a non-standard path or you want to pin a specific binary.
- CLAUDE_BIN_PATH=${CLAUDE_BIN_PATH:-}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Let env.tier-agent supply the custom Claude binary path

When an operator follows the new template and sets CLAUDE_BIN_PATH only in env.tier-agent, the documented raw docker compose --profile agents ... invocation in pmoves/README.md:112 does not use that file for Compose interpolation. This expression therefore resolves to an empty string, and the explicit environment entry overrides the value that the service's env_file would otherwise inject. Custom Archon images consequently fall back to $PATH and cannot launch Claude; the repository already identifies this exact empty-default shadowing pattern in pmoves/docs/operations/CREDENTIAL_AND_DRIFT_SITREP.md:85. Omit the explicit entry or ensure every supported invocation supplies the tier file with --env-file.

Useful? React with 👍 / 👎.

# gh auth — non-fatal warning if absent.
- GH_TOKEN=${GH_TOKEN:-}
# Host environment leak guard (see x-host-leak-guard docs above)
Expand Down
7 changes: 7 additions & 0 deletions pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md
Original file line number Diff line number Diff line change
Expand Up @@ -1573,3 +1573,10 @@ edo for slice 6 (4th-commit pattern). (2) functional: pmoves/tools/creator-colla
- `2026-08-03T10:30:00Z` CLAIM `Mavis (orchestrator, mvs_09c9b116c675418b9d8b1a48b10867dc)` scope: **Lane 2228 yt-cookies refactor — moved the Google OAuth refresh_token out of the hand-rolled `pmoves_core.yt_oauth_cookies.encrypted_refresh_token` column and into Supabase Auth's `auth.identities` (managed by Supabase, not us).** Branch `refactor/yt-cookies-oauth-to-supabase-auth` off `main` @ `9c07b9a182`. 2 stacked commits ready for review: P1 `174fdfd98b` (new `oauth_client.py` + new `supabase_auth.py` + `supabase_client.py` cleanup + `main.py` refactor + delete `oauth_handler.py`, +266/-90, 5 files), functional `60bc62124c` (17-test smoke suite + `migrations/0001_drop_encrypted_refresh_token.sql`, +5 files, 0 deletions). Docs is this CLAIM + the 12.6KB spec doc at `pmoves/docs/specs/yt-cookies-supabase-auth-2026-08-03.md`. **Root cause:** the 3-PR env var fix dance this week (#2327, #2333, #2346) was patching a symptom. The real problem was that we were storing the Google OAuth refresh_token in a custom Supabase table and hand-rolling the OAuth refresh flow with a direct `httpx.post(TOKEN_URL, ...)`. When the legacy `SERVICE_ROLE_KEY` env var carried a stale key signed by a retired JWT secret, every Supabase upsert 401'd, and the only fix was to swap the env var preference. The architectural fix is to let Supabase Auth own the OAuth token storage and just do the actual refresh_token → access_token exchange server-side. **What shipped:** (1) P1 = new `oauth_client.py` (~50 lines) — focused direct OAuth2 client for refreshing the Google `provider_token` from the `provider_refresh_token`. The 30 lines of actual logic + the env var guard + the structured-error-preservation pattern from the deleted `oauth_handler.py`. This is the smallest possible hand-roll because Supabase does not auto-refresh Google provider_token server-side. (2) P1 = new `supabase_auth.py` (~110 lines) — reads the Google identity from `auth.identities` for the `darkxside@pmoves.ai` user via the Supabase Management API (admin endpoint with service_role key). Uses `params=` for proper URL encoding (the previous f-string interpolation would have broken for any email containing `+` or other reserved URL characters). (3) P1 = `supabase_client.py` cleanup — drops the `encrypted_refresh_token` column references; keeps the YouTube session cookie + PO token + operational status storage (genuinely custom, no Supabase equivalent). (4) P1 = `main.py` refactor — reads `provider_refresh_token` from Supabase Auth first; the Playwright cookie extraction + NATS publisher + cookie writer stay untouched (those are the genuinely-custom parts); `/status` endpoint now reports `has_google_identity: true/false` so the operator can verify the new flow without grep'ing logs. (5) P1 = `oauth_handler.py` DELETED — 50 lines of hand-rolled spaghetti removed. (6) Functional = 17 tests (5 for `oauth_client`, 7 for `supabase_auth`, 5 for smoke/regression net). The smoke test is the regression net for the next time someone tries to "fix" the auth flow. All 17 pass on a clean `python -m unittest discover -s pmoves/services/yt-cookie-refresher/tests`; ruff clean. (7) Functional = `migrations/0001_drop_encrypted_refresh_token.sql` — drops the unused column. Operator runs this AFTER the new code path is verified end-to-end. **Validation:** 17/17 tests pass; ruff clean; the import graph smoke test verifies main.py no longer references the deleted `oauth_handler.py` and that the new modules are present. **Out of scope (intentional):** the Makefile `yt-cookies-auth` target still opens a browser for the legacy OAuth flow via `tools/yt_oauth_flow.py`; a follow-up PR can update the Makefile + deprecate the tools script. The runtime code is now independent of this; the Makefile lag is just operator UX. The actual refresh `provider_token` is still done via direct OAuth2 client (~50 lines) because Supabase does not auto-refresh Google provider_token server-side — this is the smallest possible hand-roll. The 3-PR env var fix dance this week is no longer relevant going forward because the Supabase Admin API uses its own key path, not the same `SERVICE_ROLE_KEY` that's been bouncing around `env.shared`. **Operator's manual steps after this lands:** (1) create the `darkxside@pmoves.ai` Supabase user in the dashboard (Auth > Users > Add user > Create with Google); (2) sign in once via Google, granting `cataclysmstudios@gmail.com`'s Google identity (which has YouTube Premium access); (3) run `make yt-cookies-refresh` to verify the new flow works (the `/status` endpoint should report `has_google_identity: true`); (4) after verification, run the migration at `migrations/0001_drop_encrypted_refresh_token.sql` to drop the unused column. **Three-body:** delivery=Mavis (this), control=DARKXSIDE (operator creates the Supabase user + signs in via Google + runs the migration after verification), memory=this trail + 2 commits + spec doc + 17 new test cases + the migration SQL. **CHIT trail unsigned-local** (no `CHIT_PASSPHRASE` loaded in Mavis session). agent_signature: `ACK::Mavis::YT-COOKIES-SUPABASE-AUTH-REFACTOR-CLAIM-2026-08-03`.

<!-- GRAPHITI_MARK: Mavis::YT-COOKIES-SUPABASE-AUTH-REFACTOR-CLAIM-2026-08-03 -->


## Issue #2217 — Archon 0.6.0 env wiring (2026-08-03)

- `2026-08-03T11:45:00Z` CLAIM `Mavis (orchestrator, mvs_09c9b116c675418b9d8b1a48b10867dc)` scope: **Issue #2217 item #4 (Auth for live workflows) closed.** Archon 0.6.0's TS server already exits(1) at boot if no Claude auth is present, and the bulk of the live-workflow tokens were already wired in earlier PRs (`CLAUDE_API_KEY` from the upstream `ANTHROPIC_API_KEY`, `CLAUDE_CODE_OAUTH_TOKEN`, `CLAUDE_USE_GLOBAL_AUTH`, `GH_TOKEN` from the upstream `GITHUB_PAT_TOKEN`). The one remaining token from the issue was `CLAUDE_BIN_PATH` — the path to the Claude CLI binary inside the container, which the archon server uses when spawning Claude Code as a subprocess for the Agent Work Orders feature.** Branch `refactor/archon-env-wiring-2217` off `main` @ `bf317e46e9`. 1 stacked commit `f4f6cfe2ee` (3 files changed, +30 lines: `pmoves/docker-compose.yml` +5, regenerated `pmoves/docker-compose.agents.yml` +5, `pmoves/env.tier-agent.example` +20). Docs is this CLAIM + the cold-read spec at `pmoves/docs/specs/archon-env-wiring-2026-08-03.md`. **Root cause:** the lane was small because earlier PRs had already renamed and wired the upstream `PMOVES-Archon/.env.example` tokens to PMOVES conventions. This lane just closed the gap on the one token that was still missing for the live-workflow path. **What shipped:** (1) `pmoves/docker-compose.yml` — add `CLAUDE_BIN_PATH=${CLAUDE_BIN_PATH:-}` to the `archon` service env with a 4-line comment explaining the default (uses `$PATH`) and the upstream's standard install path (`/usr/local/bin/claude`). The default is empty so the standard upstream image just works; operators only need to set this if they're running a custom build. (2) `pmoves/docker-compose.agents.yml` — regenerated by `make -C pmoves compose-split` to reflect the new env var on the `agents`-profile split. All other split overlays (`core`, `media`, `ui`, `workers`, `apps`, `juicefs`) are unchanged because they don't include the archon service. (3) `pmoves/env.tier-agent.example` — new "Archon — Claude / gh live-workflow auth (Issue #2217)" section that documents the full set of live-workflow tokens (CLAUDE_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, CLAUDE_USE_GLOBAL_AUTH, CLAUDE_BIN_PATH, GH_TOKEN) with comments on each. This makes the operator's `env.shared` setup explicit; previously these were scattered between the compose file and the env template without a unified comment. **Validation:** `yaml.safe_load` parses the main compose cleanly; `make -C pmoves compose-split` reports 102/102 services across overlays, all YAML syntactically valid. **Out of scope (intentional):** the Makefile archon targets (`up-archon-submodule`, `up-archon-native`, `archon-smoke`, etc.) don't reference `CLAUDE_BIN_PATH` so no change needed. The `archon-data` / `archon-user-home` / `archon-pg-data` volumes are persistent state, not auth, so no change needed. The upstream `PMOVES-Archon/.env.example` has additional env vars (`ENABLE_AGENT_WORK_ORDERS`, `STATE_STORAGE_TYPE`, `SERVICE_DISCOVERY_MODE`, `ENABLE_DOCKER_SOCKET_MONITORING`, `MCP_HEALTH_CHECK_TIMEOUT`, `LOGFIRE_TOKEN`, `LOG_LEVEL`) that aren't relevant to PMOVES's single-service deployment; we can wire them in a follow-up lane if Agent Work Orders is ever added as a separate PMOVES service. **What this means for Issue #2217:** items #1 (first-class main-compose service), #2 (fabric wiring), #3 (DB decision), and #5 (retire the dead Python wrapper) were all already done in earlier PRs; item #4 is now complete with this commit. The issue is effectively closed at the wiring level. **Three-body:** delivery=Mavis (this), control=DARKXSIDE (operator sets `CLAUDE_BIN_PATH` in `env.shared` if needed; verifies the archon service still boots), memory=this trail + 1 commit + spec doc + 1 env var + 5 lines of comments in `env.tier-agent.example`. **CHIT trail unsigned-local** (no `CHIT_PASSPHRASE` loaded in Mavis session). agent_signature: `ACK::Mavis::ARCHON-ENV-WIRING-CLAIM-2026-08-03`.

<!-- GRAPHITI_MARK: Mavis::ARCHON-ENV-WIRING-CLAIM-2026-08-03 -->
132 changes: 132 additions & 0 deletions pmoves/docs/specs/archon-env-wiring-2026-08-03.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Archon env wiring (Issue #2217, 2026-08-03)

> Cold-read spec for the archon live-workflow env wiring. If you are a
> fresh local model picking this work up next session, this is the
> document that tells you what shipped, why, and what's left.

## TL;DR

The archon service in `pmoves/docker-compose.yml` already wires most
of the live-workflow auth (CLAUDE_API_KEY, CLAUDE_CODE_OAUTH_TOKEN,
CLAUDE_USE_GLOBAL_AUTH, GH_TOKEN) — all from the upstream
`PMOVES-Archon/.env.example`, just renamed to PMOVES conventions. The
one remaining token from Issue #2217's "Auth for live workflows"
section is `CLAUDE_BIN_PATH`, which the TS archon server uses when
spawning the Claude CLI as a subprocess. This lane adds that one
token + documents the full set in `env.tier-agent.example`.

## Why now

- Issue #2217's #4 ("Auth for live workflows") listed three things:
`CLAUDE_USE_GLOBAL_AUTH`, the `token` (ambiguous; either API key or
OAuth token), and `CLAUDE_BIN_PATH`. The first two are already
wired; `CLAUDE_BIN_PATH` is the only remaining piece.
- 4090-Claude is doing parallel work on the Agent Zero side
(checking latest upstream Archon and related docs). This lane
is the archon side of the same overall wiring.

## What shipped (1 stacked commit)

### `pmoves/docker-compose.yml`

Add `CLAUDE_BIN_PATH=${CLAUDE_BIN_PATH:-}` to the `archon` service
env, with a 4-line comment:

```yaml
# CLAUDE_BIN_PATH: path to the Claude CLI binary inside the container.
# Default empty (uses $PATH). The upstream Archon Dockerfile installs
# Claude at /usr/local/bin/claude; set this only if the image builds
# Claude at a non-standard path or you want to pin a specific binary.
- CLAUDE_BIN_PATH=${CLAUDE_BIN_PATH:-}
```

The default is empty (uses $PATH), which is correct for the standard
upstream Archon image. Operators only need to set this if they're
running a custom build.

### `pmoves/docker-compose.agents.yml`

Regenerated by `make -C pmoves compose-split` to reflect the new env
var on the `agents`-profile split. All other split overlays
(`core`, `media`, `ui`, `workers`, `apps`, `juicefs`) are unchanged
because they don't include the archon service.

### `pmoves/env.tier-agent.example`

New "Archon — Claude / gh live-workflow auth (Issue #2217)" section
that documents the full set of live-workflow tokens:

```bash
# ---------------------------------------------------------------------------
# Archon — Claude / gh live-workflow auth (Issue #2217)
# ---------------------------------------------------------------------------
# The TS server exits(1) at boot if no Claude auth is present. The compose
# file wires the following tokens to the `archon` service env. Set at least
# one of CLAUDE_API_KEY or CLAUDE_CODE_OAUTH_TOKEN; leave the others empty.
#
# CLAUDE_BIN_PATH: path to the Claude CLI binary inside the archon container.
# Default empty (uses $PATH). The upstream Archon Dockerfile installs Claude
# at /usr/local/bin/claude; set this only if your image builds Claude at a
# non-standard path or you want to pin a specific binary.
#
# GH_TOKEN: GitHub PAT for `gh auth` inside the container. Scopes: repo, workflow.
# Non-fatal warning if absent (workflows that need gh will fail at use-time).
CLAUDE_API_KEY=
CLAUDE_CODE_OAUTH_TOKEN=
CLAUDE_USE_GLOBAL_AUTH=false
CLAUDE_BIN_PATH=
GH_TOKEN=
```

This makes the operator's `env.shared` setup explicit. Previously
these were scattered between the compose file and the env template
without a unified comment.

## Validation

- `yaml.safe_load` parses the main compose cleanly
- `make -C pmoves compose-split` reports 102/102 services across
overlays, all YAML syntactically valid
- No new failure modes introduced (the new env var has a safe default)

## What does NOT change (intentionally)

- **The Makefile archon targets** (`up-archon-submodule`,
`up-archon-native`, `archon-smoke`, etc.) — they don't reference
`CLAUDE_BIN_PATH`. No change needed.
- **The `archon-data` / `archon-user-home` / `archon-pg-data`
volumes** — those are persistent state, not auth.
- **The upstream `PMOVES-Archon/.env.example` additional env vars:**
- `ENABLE_AGENT_WORK_ORDERS` (no work-orders service in PMOVES yet)
- `STATE_STORAGE_TYPE` / `FILE_STATE_DIRECTORY` (same)
- `SERVICE_DISCOVERY_MODE` (single-service deployment)
- `ENABLE_DOCKER_SOCKET_MONITORING` (security risk; HTTP mode is
the default; the archon service has no Docker socket mounted)
- `MCP_HEALTH_CHECK_TIMEOUT` (operational, low-priority)
- `LOGFIRE_TOKEN` / `LOG_LEVEL` (optional, low-priority)

We can wire these in a follow-up lane if Agent Work Orders is
ever added as a separate PMOVES service, or if the operator
wants the upstream's full env surface.

## What's left for Issue #2217 (out of scope for this lane)

- Issue #2217's items #1 (first-class main-compose service),
#2 (fabric wiring), #3 (DB decision), and #5 (retire the dead
Python wrapper) are all already done in earlier PRs. Item #4
(auth for live workflows) is now complete with this commit.

- This lane closes #2217. A follow-up AGNOTE closeout can mark it
SHIPPED.

## Three-body

- **delivery:** Mavis (this lane)
- **control:** DARKXSIDE (operator sets `CLAUDE_BIN_PATH` in
env.shared if needed; verifies the archon service still boots)
- **memory:** this spec + 1 commit + 1 env var + 5 lines of comments
in `env.tier-agent.example`

## CHIT trail

`unsigned-local` (no `CHIT_PASSPHRASE` in Mavis session).
20 changes: 20 additions & 0 deletions pmoves/env.tier-agent.example
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ ARCHON_SERVER_PORT=8091
ARCHON_MCP_PORT=8051
ARCHON_SUPABASE_BASE_URL=

# ---------------------------------------------------------------------------
# Archon — Claude / gh live-workflow auth (Issue #2217)
# ---------------------------------------------------------------------------
# The TS server exits(1) at boot if no Claude auth is present. The compose
# file wires the following tokens to the `archon` service env. Set at least
# one of CLAUDE_API_KEY or CLAUDE_CODE_OAUTH_TOKEN; leave the others empty.
Comment on lines +65 to +70

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

State the Archon exception to the TensorZero-only policy.

The file says agent-tier services must not receive direct external LLM API keys, but this section instructs operators to set CLAUDE_API_KEY. State that Archon live workflows are the exception and that these credentials must not be copied to other agent services.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pmoves/env.tier-agent.example` around lines 65 - 70, Update the Archon
authentication comment near the Claude/gh live-workflow section to explicitly
identify Archon live workflows as the exception to the TensorZero-only policy,
and state that CLAUDE_API_KEY and CLAUDE_CODE_OAUTH_TOKEN must not be copied or
provided to other agent-tier services.

#
# CLAUDE_BIN_PATH: path to the Claude CLI binary inside the archon container.
# Default empty (uses $PATH). The upstream Archon Dockerfile installs Claude
# at /usr/local/bin/claude; set this only if your image builds Claude at a
# non-standard path or you want to pin a specific binary.
#
# GH_TOKEN: GitHub PAT for `gh auth` inside the container. Scopes: repo, workflow.
# Non-fatal warning if absent (workflows that need gh will fail at use-time).
CLAUDE_API_KEY=
CLAUDE_CODE_OAUTH_TOKEN=
CLAUDE_USE_GLOBAL_AUTH=false
CLAUDE_BIN_PATH=
GH_TOKEN=

# ---------------------------------------------------------------------------
# DeepResearch Settings
# ---------------------------------------------------------------------------
Expand Down
Loading