agent RELEASE.md
60 kB · 999 lines
Markdown

RELEASE — v1 #

Target: a few days from 2026-08-03. This is the checklist, not a plan. Every box is either done, or it is work someone has to do before the thing is on the internet with another person's account behind it.

What v1 is #

An agent that reads Bluesky and publishes conversations to atproto, running on Johan's home PC, reachable from anywhere, usable by a small number of invited people who each publish as themselves.

Three things make that sentence different from what runs today, and they are the whole release:

  1. Other people, logging in as themselves. Today there is one identity in one .env, held as an app password. v1 has atproto OAuth and no app passwords at all — johan.aligned.click included.
  2. Off localhost. Today everything binds 127.0.0.1 and trusts whatever reaches it.
  3. On a phone. Today both frontends are desktop-only in a way that is not a matter of taste — see §F.

What runs where #

  phone / laptop
        │  https
        ▼
  aligned.click ──────► auth proxy ──┬─► opencode server (one, shared)
  (Cloudflare Tunnel,    OAuth login  │      │    users' agent cannot write
   no open ports)        session→user │      │       password-locked too
                         session→DID  │      │       rate limit per user
                                      │      └─► greenpt proxy ─► GreenPT
                                      │           (tees `impact`)   ▲ one key,
                                      │                             │ yours
                                      └─► the chat UI (served by the proxy)
                                            + publish endpoint, as the session's DID

  read.aligned.click ──► GitHub Pages ──► reads atproto directly, no backend
                                          never calls aligned.click

Two properties hold this together and both are checked below: the agent users get cannot write anything, which is what makes one shared workspace safe, and the proxy is the only thing that knows who anyone is, which is what makes a publish land in the right repo.

"the agent users get" is doing real work in that sentence as of 2026-08-05. There is one that can write — builder, bash and edit, for Johan alone — and it is reachable only by naming it in the prompt and being listed for it in users.json. It is not sandboxed. See §B, "One shared workspace".

The reader is already live and has no backend, so it is not in the risk surface of this release. Everything below concerns the other half.


A. Split the repo — decide what ships publicly #

The code goes public on tangled.org at release. The strategizer, the scraping machinery and the creator data are not part of the thing being released, and some of it must not be in a public repo at all.

History is dropped — decided #

Re-init for the first release. The public repo starts at commit one with the cleaned tree; this repository stays private on GitHub as the reference copy of how it got here.

That is the right call and it is not paranoia. Measured here, 2026-08-03:

STRATEGIST.md              13 commits, real creator name in 5 of them
public/products/strategist  4 commits
sync/                       6 commits
47 commits total.  private/ has never been tracked — that part is clean.

Deleting a file, gitignoring it, or moving it to a branch does nothing to any of that; only new history does.

Decided: this repo becomes read-only reference. Development moves to the new one at git init; nothing is cherry-picked back. That removes the divergence question rather than answering it, which is the only reliable way to handle two trees.

  • Published to both forges from one remote with two push URLs: fetch from
    `tangled.org` (canonical), push to tangled and to
    `github.com/circularmachines/aligned.click` (the mirror, which exists so
    GitHub Actions can deploy the reader to Pages). Note that this
    arrangement lives in `.git/config` — it is a property of that working
    copy and does not travel to a clone.
    
    The tangled remote is a **repo DID**, not `handle/repo`:
    `git@tangled.org:did:plc:4ubwcjik6lc44ef5hiqknm7r`. The DID resolves to
    no handle at all, which is why guessing the path was never going to work.
    Pushing needs an ssh key published to the atproto account that owns the
    repo — the knot identifies pushes by key, not by password.
    

Clean the tree — done 2026-08-03 #

Five commits on main here, 2ea0bfa..902a49a. The seed tree is what gets committed at git init, so this had to be right first.

Two things this surfaced that the doc had wrong:

  • GREENPT_API_KEY was briefly read by nothing here — vision.py was its only reader and is parked — and then became required again, because the provider block moved into this repo's agent/opencode.json so a checkout knows its own models. server/models.py reads it too. It is the one secret in .env.example.

  • analyze-image was listed as "stays, unverified". It could not stay: creator_index was leaving, and analyze-image imports it. "Unverified" was too generous — it was already broken.

B. Users — atproto OAuth, no app passwords #

Decided: users log in, they do not hand over a password. johan.aligned.click enrols through the same door as everybody else, and there is no privileged account with a shortcut. That is the right call for a reason worth stating: an app password is a bearer credential with full write access to someone's repo, it cannot be scoped, and a service that collects them is asking people to trust it in a way it has not earned.

This is the largest item in the release and the most likely to slip the date.

What it deletes. The BSKY_* identity — the one account every tool currently reads as. tools/auth.py's app-password machinery survives, but only to hold the admin fallback below.

Reads go as the user, with an admin fallback. An earlier draft of this doc claimed the reading tools need no token because every app.bsky.* call is a public read. That is false, and it is false for exactly the tools that matter most. Measured unauthenticated against public.api.bsky.app, 2026-08-03:

searchActors    200      getPostThread   200      getFollows     200
getProfile      200      getPosts        200      getFollowers   200
getAuthorFeed   200      getLikes        200      getRepostedBy  200

searchPosts     403  — an HTML Cloudflare block page, not even a JSON error.
                       401 against bsky.social. `search-posts` is the tool
                       the agent reaches for most.
getActorLikes   400  — "Profile not found" for every actor, handle or DID.
                       An actor's likes are not a public view. This is
                       `liked-posts`.

So: reads authenticate as the requesting user, through their PDS with their OAuth token (the PDS proxies app.bsky.* to the appview — the same path publishing already takes). The admin app-password session stays as the fallback, so ADMIN_HANDLE / ADMIN_APP_PASSWORD remain in .env and tools/auth.py keeps its app-password path for that one account. Only BSKY_* goes away.

  • Verified with real tools: `search-posts`, `search-actors` and `profile`
    all return results as `johan.aligned.click`. And all four failure paths
    say something actionable — no `ACTING_DID`, a handle where a DID belongs,
    a DID that never logged in, and the sidecar being down.
    
  • The link already existed. opencode hands each wrapper a `sessionID`; the
    13 wrappers now pass it down as `ACTING_SESSION`, and `acting_did()` looks
    up the owner the proxy recorded at login. **`start.sh` exports no identity
    at all** — verified by reading the running opencode process's environment
    — and a live `search-posts` over the tunnel still worked, which it could
    only do through the session.
    
    Checked: a session nobody owns fails loudly rather than falling back, and
    a session **overrides** a conflicting `ACTING_DID`. `ACTING_DID` survives
    only for running a tool by hand from a shell, where there is no session to
    belong to.
    

OAuth runs in a Node sidecar — decided 2026-08-03 #

The earlier instruction here was "do not hand-roll the DPoP proofs, use an existing atproto OAuth library". In Python there is no such library. Checked, not assumed:

  • The official atproto SDK (0.0.69) has zero OAuth or DPoP code across 546 modules. It does app-password createSession and nothing else.
  • dpop on PyPI is a GIF generator.
  • @atproto/oauth-client-node 0.5.1 is the official implementation, published 2026-07-31 and actively maintained.

So Node goes on the mini-PC and owns the OAuth half. Installed to ~/.local/lib/node (v24.18.1, checksum verified, no sudo) so it is one directory to delete.

The sidecar is the authenticated request path, not a login helper. This is the part worth understanding before building anything, and it was got wrong in the first sketch of this decision. OAuthSession exposes fetchHandler(pathname, init) and no way to obtain a usable bearer token — getTokenInfo() returns expiry, scope and subject only. That is inherent to DPoP: every request carries a proof signed by the key the token is bound to, so whoever holds the key must be the one making the request. Handing Python "the token" is not a thing that can happen.

Which settles the layering, and settles it in a nicer place than planned:

Python proxy — the only thing on the tunnel
  ├── /client-metadata.json, /oauth/*  → sidecar
  ├── /session/*                       → opencode, session→user enforced
  └── the chat UI

Node sidecar — 127.0.0.1 only, never exposed
  ├── GET  /client-metadata.json
  ├── GET  /oauth/login?handle=…       PAR + PKCE
  ├── GET  /oauth/callback             code → stored session
  └── POST /xrpc/<nsid>  {did, …}      DPoP-signed, as that user

tools/bsky.py calls that last route. No Python code ever sees a token, which is a smaller and more auditable surface than threading one through would have been.

Two things this left standing that are not done:

  • One correction on the way: `alg` was added to the published JWK, since a
    server that infers it *should* work but an authorization server that
    declines reports a bad assertion rather than a missing field. A `use:
    "sig"` went in with it and came straight back out — the library already
    emits `key_ops`, and RFC 7517 requires the two to agree if both appear,
    which "sig" and a `key_ops` listing "encrypt" do not.
    
  • **So there is no app password anywhere in this project.** Not the
    operator's, not a user's. `BSKY_HANDLE`, `BSKY_APP_PASSWORD`,
    `ADMIN_HANDLE` and `ADMIN_APP_PASSWORD` can all come out of `.env` —
    left in place rather than deleted, since that file is yours and those
    credentials may be used elsewhere.
    

One shared workspace — decided #

All users share one agent/ directory and one opencode server. That is only safe because the agent users get cannot write. The condition and the decision have to ship together:

C. The edge — home PC, reachable, token-gated #

  • The scheme is **HTTP Basic with the username literally `opencode`** —
    measured, not guessed: an empty username, `admin` and a random one all
    return 401 with the correct password. Worth writing down, because nothing
    documents it and a `Bearer` token or a custom header both fail the same
    silent way.
    

It runs on the mini-PC — done 2026-08-05 #

atproto-server@192.168.86.250, four systemd services, all enabled so they come back after a reboot. Reached by cloning the public repo from tangled, writing .env by hand and running sudo deploy/install.sh once — which was also the test of whether anybody else could stand this up, and it passed on the real path rather than a rehearsal.

Moving DNS off Namecheap — required, and the riskiest step in the release #

Cloudflare Tunnel can only attach a hostname to a zone Cloudflare hosts: *.cfargotunnel.com targets do not resolve otherwise. aligned.click is on dns1/dns2.registrar-servers.com, so the nameservers move.

Two TXT records in this zone are identities. If _atproto.johan.aligned.click does not come back up, the handle stops resolving to the DID — which breaks the Bluesky account, the OAuth login built above, and the authorship of everything already published. This is not a "recreate it later" record.

Full inventory, read from the authoritative servers 2026-08-03:

aligned.click                 TXT    v=spf1 include:spf.efwd.registrar-servers.com ~all
aligned.click                 MX     10 eforward1 / 10 eforward2 / 10 eforward3
                                     15 eforward4 / 20 eforward5 .registrar-servers.com
read.aligned.click            CNAME  circularmachines.github.io
_atproto.aligned.click        TXT    did=did:plc:kdnkzvtg6nugup477ev22xfa
_atproto.johan.aligned.click  TXT    did=did:plc:evocjxmi5cps2thb4ya5jcji
_lexicon.chat.aligned.click   TXT    did=did:plc:kdnkzvtg6nugup477ev22xfa

D. The GreenPT proxy — energy per call #

Not cosmetic: the argument for this project is that it is measured rather than asserted, and this is the measurement. From PLAN.md §7, all verified.

One key, yours. Every user's turns bill to GREENPT_API_KEY. Two things follow and both are release items, not later:

  • The rate limit in §C is what stands between an invited friend and your card. A trusted user does not protect you from a loop, and a loop is the normal failure mode of an agent.

  • Per-user attribution stops being a nice readout and becomes the thing that tells you whose session did it.

E. Publishing to atproto #

Mostly done. What remains is one DNS record and one path from the UI.

  • **Who may choose what is per user**, as optional `models`, `tools` and
    `agents` lists in `private/users.json`; absent means everything, so
    nobody's access changed when this arrived. Read through the file the proxy
    already re-reads when it moves, so narrowing somebody takes effect on
    their next request rather than at the next restart.
    
    One asymmetry worth keeping in mind, because it is the half that would
    fail silently: **a model can be refused, but tools have to be imposed.**
    Naming a model is how you get it, so refusing the name is enough. A tool
    the prompt never mentions falls through to `opencode.json`, which switches
    it *on* — so every tool a caller may not use is written in as `false`
    whatever the page sent. The page can narrow; it cannot widen, and it
    cannot widen by staying silent.
    
  • Two things it is deliberately not:
    
    - **Not editing.** The page sends the words to remove, never the text to
      publish, and the server checks them against what the model actually
      said. A page that could send replacement text could put sentences in
      the model's mouth under its label, which is the one thing a record of a
      conversation must not allow.
    - **Not a filter on reading.** The words stay in `private/` only because
      every future write of that turn has to remove them again. Nothing
      publishes them, and a stored span that stops matching its turn
      withholds the turn rather than letting the words through.
    
  • **Within a published conversation nothing changes**: every turn still gets
    a record, withheld ones included, because that is where the holes are the
    point. The two rules meet at zero — unticking the last published turn takes
    the whole conversation down rather than leaving the placeholders standing,
    since a hole is only honest when it is in something. The button says
    "Take this conversation down" when that is what pressing it will do.
    
    **Records written under the old rule stay on the network until somebody
    removes them.** A live conversation cleans itself up the next time it
    syncs — the page sends what is live, which is nothing, and that is now a
    take-down — but an abandoned one never takes another turn, so nothing
    would ever reach it. **Done 2026-08-06**: 11 conversations, 32 withheld
    turns and 11 session records, removed with a throwaway script over
    `publish.take_down` run on the mini-PC. Deliberately not committed — it
    runs once and is a trap afterwards, since it reads rkeys out of
    `published.json`, and that file has to be the one the live server keeps.
    Both machines' copies were byte-identical before and were resynced after.
    
    Confirmed from the PDS rather than from the script's own count: 6 sessions
    and 127 message records left, and **no session with zero published turns**.
    The 21 withheld records that remain all sit inside conversations published
    in part, which is where they belong. Two of those sessions (9 records, all
    published) predate the UI publish path and are in no `published.json` —
    written by `publish/chat.py`. Nothing here can take those down; they are
    fully published, so nothing should.
    
    Two follow-ups, neither breaking: **the published schema still describes
    the old rule** — `withheld`'s description says every turn gets a record
    when it happens — so `publish/lexicons.py --publish` wants re-running,
    which needs the `ADMIN_DID` account logged into the sidecar. No field
    changed type, was added or became required, so nothing already written
    stops validating. And §1's "default private" is now true of the storage
    and not only of the gesture.
    
    **Cleared again 2026-08-09, deliberately and completely** — a fresh start
    before drawing attention to the site. 194 records: 133 for
    `johan.aligned.click` (6 sessions, 127 messages) and 61 for
    `testing2345.eurosky.social` (8 sessions, 53 messages). Both repos verified
    empty afterwards by listing their PDS directly, which is the only answer
    worth having.
    
    **The take-down could not go through `publish.take_down` this time, and
    that is the lesson worth keeping.** It works from `published.json`, and
    that map had drifted: 15 session entries against 4 session rkeys, while
    2 session and 9 message records were live on the network that it did not
    list — the same class as the two `publish/chat.py` sessions above. Driving
    a take-down from the map would have left 11 records published with nothing
    locally remembering they exist. So the throwaway script enumerated
    `com.atproto.repo.listRecords` instead, which is the only authoritative
    answer to what is published, and refused to run unless the handle it was
    given resolved to the DID it was pointed at — two accounts share that map
    and a misaimed delete is not recoverable. `published.json` is now `{}`,
    with a timestamped backup beside it.
    
    Worth stating because it recurs: the map is a cache of what this server
    did, not a description of what is published. Anything that must be
    complete has to ask the PDS.
    
  • The consequences below still hold word for word. Two new ones:
    
    - **`reader/` is the whole of what Pages can publish**, so anything both
      sites use has to live inside it — hence `reader/shared/`, which the
      proxy serves at the same `/shared/…` URLs for the chat side.
    - **Pages must be turned off on the old `read.aligned.click` repo before
      this one takes the CNAME.** Two repositories cannot serve one custom
      domain, and the failure mode is the live reader going down.
    
  • Two consequences to hold on to:
    
    - **Nothing in the reader may call this server.** Not for energy figures,
      not for counts, not for a "live" badge. The moment it does, it inherits
      this machine's uptime.
    - **`lexicons/` now exists in both repos.** Here it is the source
      `publish/lexicons.py` publishes from; there it is documentation. The
      published `com.atproto.lexicon.schema` records are the authority over
      both, so a mismatch is a bug in whichever copy disagrees with the
      network — not a merge conflict.
    

F. Mobile #

Verified, not guessed: there is not one width-based @media query in either frontend. The only queries present are prefers-color-scheme and prefers-reduced-motion. Both pages were built at desktop width and have never had a breakpoint.

Chat (public/index.html, this repo) and reader (public/chat.html in the aligned.click repo — one copy now, not two):

G. Other people's data — out of scope, and here is why #

Empty by construction, not by omission. sync/, private/external.db and everything the strategizer collected stay off the mini-PC entirely. The service holds no data about anyone who did not log into it, so the retention work in PLAN.md (purge.py, the subjects table, the scrape allowlist) is not a v1 blocker — it is a blocker for the strategizer, on a different machine, on a different day.

Two things do carry over, and they are small:


Ship sequence #

  1. §A — clean the tree, then git init. First, because it is the only step that cannot be undone, and because everything after it is easier in a tree with the strategizer gone.
  2. §C's hostname — decided: aligned.click. The tunnel itself can come later; the name could not, because §B's OAuth client_id is a URL on it.
  3. §B — OAuth, still on localhost. This is the long pole; if the date is at risk, this is what is at risk. Do the bsky.py token-threading as part of it, not before — there is no useful intermediate state now that reads need an identity.
  4. §F — mobile. Self-contained and testable from a phone on the LAN, so it can run in parallel with §B rather than behind it.
  5. §C — proxy, verified rejecting an unauthenticated request and a cross-user session id, then the tunnel.
  6. §E — the DNS TXT, then the publish endpoint.
  7. §D — the energy proxy. It can follow the release; the rate limit in §C cannot.
  8. Cellular test as a second user. Then invite one person who isn't you.

The remotes, at step 1 — tangled canonical, GitHub a mirror #

Set after git init, not before: this tree still points at at_opencode, which is the repository being left behind. One git push should reach both, so the mirror cannot quietly fall behind the thing it mirrors.

git init && git add -A && git commit -m "aligned.click v1"
git remote add origin <tangled-url>          # fetch and push
git remote set-url --add --push origin <tangled-url>
git remote set-url --add --push origin git@github.com:circularmachines/aligned.click.git
git push -u origin main

git remote -v should then show one fetch URL (tangled) and two push URLs. Fetching from GitHub is never right: it is a copy, and a divergence there is a mistake to overwrite rather than merge.

GitHub is a mirror for one reason — Pages. reader/ is deployed by .github/workflows/pages.yml, which only runs on GitHub, so the mirror is what keeps read.aligned.click alive. Two things have to be done there by hand:

Explicitly not in v1 #

Say these in the README so nobody discovers them:

  • No agent writes to Bluesky. Every action button in a card is inert; the only path from the UI to the agent is the composer. Publishing a conversation is a separate, human-approved act.
  • The agent cannot write files or run commands. That is what makes one shared workspace acceptable, so it is a guarantee, not a default.
  • No app passwords from users. The service never asks a user for one and never stores one. The operator's own credential exists as a read fallback and can write to exactly one repo: the operator's.
  • No background workers, no notes, no delegation.
  • No strategizer, no scraping, no imports, no /media/.
  • No appview: the member list is a curated list, because listRecords names one repo and cross-author listing needs an index. Since 2026-08-09 that list is itself on atproto — one click.aligned.chat.member record per member in the collective's repo, replacing reader/authors.json, so admitting somebody takes effect without a commit and the reader still calls nothing here.
  • No account recovery, no self-signup. Invite only, and identity is atproto's problem rather than ours — which is most of the point.
  • The left pane, the matcher, the confirm loop, analyze-video — all in PLAN.md, none in this release.

Open — deliberately undecided #

Two questions that are not blockers but will be answered by shipping something, so record the options rather than defaulting into one by accident.

1. Private vs. public chats #

Right now every conversation is private (it lives in opencode's local storage) and publishing is a separate, explicit act. The question is whether that stays true, and what the gesture for publishing is.

The proposal on the table: the send button is the publish button — sending publishes the user's message and the preceding assistant message to atproto. Held open. What recommends it, and what makes it uncomfortable:

  • It makes publishing continuous rather than a decision, which matches how a conversation actually reads — you approve the exchange you just had, while you remember it, instead of reviewing a transcript later.
  • It makes the transcript authored: a user who knows the last exchange goes public writes differently. Whether that is a feature or a chilling effect depends entirely on whether they can opt out mid-conversation, cheaply.
  • The asymmetry is the problem. You approve the assistant's last message before you have seen what your own message causes. So the model's reply to the message you are sending now is published by your next send — which means the last exchange of every conversation is never published, and a conversation you walk away from ends mid-sentence in public.
  • It removes the "publish a session" concept entirely, and with it any way to publish something that already happened.

Alternatives worth costing before choosing: a per-conversation public/private toggle set at the start; a per-message "publish this exchange" affordance that is not the send button; publish-at-the-end with a review screen (what publish/chat.py does today, moved into the UI).

Whatever wins, two things hold: default private, and a user sees exactly what goes out before it goes, because a record on the firehose cannot be recalled.

2. Showing energy in the UI #

§D captures the number. Where it surfaces is unanswered, and the answer determines whether it is an honest measurement or decoration.

The options run from a per-turn figure (accurate, and noise at 0.016 Wh for a short reply), through a session total (readable, and the natural unit since it matches what a published conversation is), to a running account total (the credible number for the project's argument, and the one nobody looks at).

Two things to get right whenever it lands: units people can hold — 0.57 Wh means nothing to most readers, and a comparison invites the accusation of spin, so pick carefully — and the number must be the measurement, not a model of it. Carry GreenPT's methodology version, and say there is no water figure rather than estimating one.

Worth noting the interaction with §1: if a published record carried its energy cost, that would be the first version of this anyone else could verify. That is a lexicon change, so it is a v2 conversation, but it is the reason not to paint this into a corner now.

Known-imperfect at ship #

Write these down here rather than discovering them in an issue:

  • An edit in a card is invisible to the agent and does not survive a reload. Cards are rebuilt from tool output in the message history.
  • Publishing is silent. A click.aligned.chat.* record lands in the user's repo, goes out on the firehose and is readable by anyone — but no Bluesky notification fires, it appears in nobody's feed, and no follower learns it exists. Custom records are invisible to the appview, which only indexes app.bsky.*. So a user who publishes a conversation and expects a response gets silence, and will reasonably conclude the feature is broken. The answer is the discussion field: post about it on Bluesky, where attention already is, and link the two. Make sure the UI says this at the moment someone publishes, not in a README they won't read.
  • A referenced post that its author later deletes stops appearing in the conversation. That is correct behaviour, and it does make old logs read worse.
  • read.aligned.click/ (bare root) may still serve a stale 404 from GitHub's edge; /chat.html and /index.html are fine and are what links use.