Commit Graph
141 Commits
Author SHA1 Message Date
davidandClaude Opus 5.5 a47990f9bf Phase 14, part 1: plans, each team's account, and their limits
The multi-tenant edition's plans (Free and Paid as decided, or a plans
file) and each team's billing account, with a 14-day trial of Paid. A
team's plan caps what its people and agents may change: modules outside it
stay readable, a lapsed team changes nothing, and agents, Market entries,
crawls and background jobs keep to it. Without a Stripe key, no billing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 13:15:00 -07:00
davidandClaude Opus 5.5 e47764a78e TEST.md: three passes (local, server with the Core, multi-tenant), and checks for Phases 11–13
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 13:07:21 -07:00
davidandClaude Opus 5.5 07233e8d85 gofmt coresignin.go
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 13:00:40 -07:00
davidandClaude Opus 5.5 962dbe3286 Phase 12: signing in with the Core's Authelia
Admins make the client's secret under Settings → Sign-in, which shows the
entry for the Core's idproviders.yml (the secret's PBKDF2-SHA512 hash, the
redirect address, PKCE). People sign in with their Core account: invited
ones are matched by verified email, then by subject; optionally anyone at
the Core's domain joins. Passwords can be turned off but for the owner's,
and signing out ends the Core's session where it can. On multi-tenant, the
team is found by its proved domain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 13:00:36 -07:00
davidandClaude Opus 5.5 637ef1cc25 PLAN.md: what the Core's idproviders.yml shows about adding a client
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:52:40 -07:00
davidandClaude Opus 5.5 0de5ab6698 PLAN.md: Phase 13 is built, and was run for real with Garage
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:47:14 -07:00
davidandClaude Opus 5.5 f4c31c9fa3 Phase 13, part 9: running at scale, and the proof
The multi-tenant edition starts. compose.multi.yaml runs several copies
behind Caddy, with the managed Postgres and Garage outside. A test walks
every page and fragment, with ids filled in, and every MCP tool, as one
team, and none shows another team's data or changes it; another has three
copies share six teams' work, each team's turn once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:46:01 -07:00
davidandClaude Opus 5.5 b8a64e258a Phase 13, part 8: a team's data is theirs
The owner exports everything from Settings → Your data (the keys only with
their password), and can delete the team: it closes at once, everyone in it
is told, it can be undone for 30 days, and then its schema, files, agents
and memberships go for good.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:40:28 -07:00
davidandClaude Opus 5.5 d35ed7cbb2 Phase 13, part 7: the platform's own admin
The people running the multi-tenant service (SUPERMARKET_PLATFORM_ADMINS,
with two-factor sign-in) see every team at /platform with its size, people
and what failed lately, and can suspend or restore a team, resend its
invitations and release its domain. They don't see a team's data unless
they view as it: with a reason, for at most an hour, read-only, recorded in
the team's own audit log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:35:53 -07:00
davidandClaude Opus 5.5 76407cdea8 gofmt pages.go
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:29:48 -07:00
davidandClaude Opus 5.5 1865140507 Phase 13, part 6: each team's Core
On the server and multi-tenant editions a team's admin enters its Core's
domain and account under Settings → Core & Hermes, instead of core.conf;
Hermes connects from the team's side with an agent's key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:29:44 -07:00
davidandClaude Opus 5.5 af6598271c Phase 13, part 5: each team's jobs, locks, files and sign-ins
Background jobs run for each active team on its own Server and under its
own locks, a few teams at a time and from a different team each round, so
the work is shared between copies of the app and no team holds up another.
Each team's files are under its own prefix, and an OAuth sign-in comes
back only to the team that started it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:26:33 -07:00
davidandClaude Opus 5.5 47cc8b2b10 Phase 13, part 4: proving a team's domain
Before Supermarket crawls a team's website, reads its Search Console data
or publishes to it, the team proves the domain is theirs: a DNS TXT
record, a file on the site, or owning its Search Console property. One
team holds a domain at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:21:42 -07:00
davidandClaude Opus 5.5 d5fb1898e8 Phase 13, part 3: signing up, and several teams per person
On the multi-tenant edition anyone can set up a team: their account, the
company and its website, whose registered domain the team works on (the
profile keeps to it). A person can belong to several teams and switch
between them from the sidebar, or set up another. Inviting someone who has
an account adds them to the team.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:17:15 -07:00
davidandClaude Opus 5.5 210b1e57fc Phase 13, part 2: each team's own database role
A team's connections take a Postgres role that owns its schema and may
use the shared tables, nothing else: even SQL naming another team's
schema is refused. The second guard behind the search_path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:11:57 -07:00
davidandClaude Opus 5.5 0e695ac810 Phase 13, part 1: a Postgres schema per team
On the multi-tenant edition each team's data is in its own schema; the
tables every team shares (people, sessions, memberships, keys, locks, and
a new teams table) stay in the main one. A team's connection pool searches
its own schema first, so the app's SQL runs unchanged and can't reach
another team's tables. Each request is served by a copy of the Server for
the viewer's team, with that team's database, secrets and caches; agents
work on their own team's. The local and server editions are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:08:47 -07:00
davidandClaude Opus 5.5 ff5eaa9784 PLAN.md: Phase 12 waits for the Core's idproviders.yml
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 11:47:52 -07:00
davidandClaude Opus 5.5 aa6c3ca390 Phase 11, part 5: the JSON API
/api/v1 offers the MCP tools as plain HTTP for scripts: GET /api/v1/tools
lists what a key may call, POST /api/v1/<tool> calls one with JSON. Each
call goes through /mcp internally, so keys, scopes, limits, logging and
approvals are the same. /api/v1/docs documents every tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 11:22:22 -07:00
davidandClaude Opus 5.5 6bf0517163 Phase 11, part 4: agents' limits, recent calls and a pause switch
Each agent has calls a minute and things it may ask to send out a day,
checked on every tool call and every request to send; every call is
recorded (tool, outcome, time) and the agent's page lists the last 50 and
what it's waiting on. Pause refuses all its calls at once. Also fixes each
agent's MCP server being shared with others that had the same scopes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 11:09:18 -07:00
davidandClaude Opus 5.5 311d2e815b Phase 11, part 3: approvals for what agents send out
Agents can now ask to publish or schedule a post, send an email, add
someone to a mailing list, or apply an SEO change. Each waits on the
Approvals page (with a count in the sidebar) for an admin or a member with
edit on its module, who can edit it first, approve or refuse it, and let
the agent take that class of action on its own with a cap per day. A
rotation after a leak revokes the old keys and withdraws everything
allowed. All of it is in the audit log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 10:54:53 -07:00
davidandClaude Opus 5.5 bfb74e7700 Phase 11, part 2: module tools over MCP
Agents get each module's tools by their scopes: reading tools with read,
the others with read and act. Content (drafts and items; writing, editing
and discarding drafts), Prospects (signals, review, outreach, suppression;
outreach drafts and edits), SEO (the morning check, What to write next,
links, changes; editing a proposal), Sites and Metrics (reading) and the
Market (list, get, save). They call what the pages call, and what an agent
changes is in the audit log as the agent. Nothing that leaves Supermarket
is offered yet: that waits for approvals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 10:31:43 -07:00
davidandClaude Opus 5.5 da2d56f8d2 Phase 11, part 1: agents and their keys
Agents are users of kind agent, each given modules to read, or to read
and act on, and the CRM scope. Admins make them under Settings → Agents,
on every edition; keys (sm_…) are shown once and kept as hashes, can
expire, be rotated (the old one works a day) or revoked, and record their
last use. /mcp takes agent keys and offers each agent only the tools its
scopes allow. On the local edition, mcp-token is the key of a built-in
Hermes agent with the CRM and the Market.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 10:26:31 -07:00
davidandClaude Opus 5.5 da16736fb4 Phase 10, part 9: the server package
compose.server.yaml runs Supermarket behind Caddy (HTTPS from Let's
Encrypt, Caddy's own CA or the team's), with Postgres on an internal
network and a nightly pg_dump kept two weeks. install-server.sh asks for
the domain, certificate and mail server, makes the secret key and database
password, starts it all and prints the setup link. Settings → Backups lists
the dumps on a server, and how the operator restores one. Checked end to
end in Docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:37:34 -07:00
davidandClaude Opus 5.5 c8964cec12 Phase 10, part 8: the audit log, and who made what
Sign-ins and failed ones, everything admins do to users, connections,
posting accounts, each post published and email sent, pull requests and
deletions go in an audit log (schema 36), kept two years; admins read it
under Settings → Activity. Drafts, published posts and outreach emails
show who made them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:31:33 -07:00
davidandClaude Opus 5.5 bb4772637c Phase 10, part 7: posting accounts, and who may post to which
Social accounts become posting accounts: several per network, the
company's and each person's own, with their tokens kept per account. The
old sign-ins are adopted as the company's. Admins say who may post to which
(Settings → Posting accounts); a draft can go out from one account or a
copy to several, each recording who posted it and as what. Signing an
account out, or removing its owner, holds the posts scheduled to it and
tells whoever scheduled them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:26:34 -07:00
davidandClaude Opus 5.5 a4dd36f5a4 Phase 10, part 6: Settings → Connections, with who connected each
Admins see every service Supermarket uses, whether it's connected,
failing or not set up, when it was last tested (every Test button now
records its result), and who connected or removed it and when. Keys and
sign-ins saved from the settings pages record the person; refreshed
tokens don't.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:15:43 -07:00
davidandClaude Opus 5.5 2b9d04297f Phase 10, part 5: access enforced on every page, form and fragment
One table maps every address to an area (a module, Settings, anything
signed in, or public); each route is checked against it, and the app won't
start with a route missing from it. Changing needs edit on the module. For
members who may only view, forms that would change something are shown
disabled and htmx buttons hidden. The menu, the Overview, Search and the
SEO emails follow each person's modules; Settings is for admins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:13:16 -07:00
davidandClaude Opus 5.5 47a504b7b2 Phase 10, part 4: inviting users, and what admins can change
Settings → Users lists everyone with their access and status. Admins
invite people by email (a link for 7 days), as admins or as members with
modules each to view or edit; the invitation's page sets the password,
profile and emails wanted. Admins can resend or withdraw invitations,
change access, turn accounts off and on, unlock, reset two-factor, sign
someone out, and remove them; never the owner, nor themselves. Your
account gets the emails wanted and a photo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:07:32 -07:00
davidandClaude Opus 5.5 8040512a18 Phase 10, part 3: signing in and out, resets, locks and two-factor
The server edition now starts. Sign-in by email and password, limited per
address and per IP; ten failures in a row lock the account and email its
owner, and a reset by email (or an admin) unlocks it. Settings → Your
account has the profile, the password, where you're signed in, and
two-factor sign-in with an authenticator app (TOTP, from a QR code) and
ten recovery codes. The app's own mail goes through SUPERMARKET_MAIL_URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:01:29 -07:00
davidandClaude Opus 5.5 72455438c9 Phase 10, part 2: the first owner, from a one-time setup link
A new server prints a link to create its owner (supermarket setup-link
makes another); until it's used, every page says the setup isn't
finished. One-time links (schema 33) are kept as hashes and used up in
one statement; resets and invitations will use them too. The server
edition opens Postgres.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 08:53:14 -07:00
davidandClaude Opus 5.5 96404a3580 Phase 10, part 1: users, sessions and form tokens
Schema 32 adds users, memberships and sessions, on both databases.
internal/users keeps accounts (Argon2id passwords), roles and modules,
and sessions whose rows hold only a hash of the cookie's value; they end
after a week unused or 30 days. On the server edition, every page but the
public ones needs a session and sends others to /signin. Every edition's
forms now carry a CSRF token (a cookie repeated in each form, added as
pages render; htmx sends it as a header), besides the same-origin check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 08:49:45 -07:00
davidandClaude Opus 5.5 d537fb367f PLAN.md: where things stand after Phase 9, and how to pick up again
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 08:37:45 -07:00
davidandClaude Opus 5.5 5f1b8d59ce Phase 9, part 7: export and import, between SQLite and Postgres
supermarket export [--with-secrets] writes a whole Supermarket as a
.tar.gz (a manifest, each table as JSON lines, secrets if asked for) to
the file storage. supermarket import loads one into an empty database at
the same schema, SQLite or Postgres, in one transaction, parents first,
checking row counts and moving Postgres' identity counters past the
imported ids.

Checked on Federated's 112,543 rows: imported into Postgres and SQLite,
every table and total matches, and TestPagesOnRealData renders all 57
pages the same from both. That found unsettled ordering (case-alike
campaigns, customers with the same name, metrics' float sums), now fixed
with ORDER BY and tie-breakers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 08:09:14 -07:00
davidandClaude Opus 5.5 c6c4c40600 Phase 9, part 6: background work shared safely between copies of the app
internal/jobs keeps named locks as leases in the database (schema 31:
locks, instances), taken with one conditional UPDATE on SQLite or Postgres,
renewed while the work runs and lapsing if its copy stops. Each background
loop's turn, sending an email, audits, discovery runs and imports run
under a lock; OAuth sign-ins under way are kept in the database. Copies
check in, and work marked running is recovered at start only when no
other copy is alive. Settings -> About lists the copies and work under
way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 07:56:47 -07:00
davidandClaude Opus 5.5 ba6114f367 go.mod: minio-go is a direct dependency
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 07:42:22 -07:00
davidandClaude Opus 5.5 d2f1658708 Phase 9, part 5: file storage, a folder or an S3 bucket
internal/storage keeps files that must outlast the app's disk (exports,
uploads) behind one interface: a folder (<data>/files) or an S3-compatible
bucket (minio-go, path-style, for Garage). Names that would reach outside
the store are refused. An S3 store is checked at start; supermarket config
checks the storage and Postgres for real. The same tests run on a folder
and on Garage (SUPERMARKET_TEST_S3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 07:42:11 -07:00
davidandClaude Opus 5.5 c76a7791ee Phase 9, part 4: secrets in the database, encrypted
The server and multi-tenant editions keep keys and tokens in a secrets
table (schema 30, the first migration for both databases), each sealed
with AES-256-GCM under a key derived from SUPERMARKET_SECRET_KEY and bound
to its name. A wrong key stops the start with a clear message;
SUPERMARKET_SECRET_KEY_OLD reseals everything under a new key. Values are
read when asked for, so several copies of the app agree on a refreshed
token. The local edition keeps secrets.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 07:31:41 -07:00
davidandClaude Opus 5.5 d827d507c1 Phase 9, part 3: schema migrations for both databases
Migrations from schema 30 on are one list (internal/db/migrations.go),
written in SQLite's SQL and translated for Postgres (db.PostgresSQL)
unless one gives its own. On Postgres the whole migration is one
transaction under an advisory lock, and each step is recorded in
schema_migrations. TestSchemasMatch compares the two schemas (tables,
columns, types, NOT NULL, nocase, indexes), with and without a new
migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 07:17:56 -07:00
davidandClaude Opus 5.5 1b2947de7c Phase 9, part 2: one database layer for SQLite and Postgres
db.DB wraps database/sql for either database. The SQL stays SQLite's: on
Postgres each statement's ? become $n and LIKE ignores case as SQLite's
does, and the Postgres schema (postgres.sql, schema 29 as a whole) adds
SQLite's instr, json_extract and two-argument max/min, and a nocase ICU
collation. Needs Postgres 18.

LastInsertId became db.Insert (RETURNING id), INSERT OR IGNORE became ON
CONFLICT DO NOTHING, upserts qualify their columns, and three queries
group by every column they use. SUPERMARKET_TEST_POSTGRES runs the test
suite on Postgres, a new schema per test; all tests pass on both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 07:10:44 -07:00
davidandClaude Opus 5.5 7a857c7346 Phase 9, part 1: editions and their settings
SUPERMARKET_MODE picks local (the default), server or multi. internal/config
reads and checks every setting the editions need (database, secret key,
storage, the app's own mail, an https address), reporting all problems at
once. supermarket config prints them without passwords; supermarket
secret-key makes a key. Settings -> About shows the edition. Server and
multi-tenant are checked but refuse to start until they're built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:55:30 -07:00
davidandClaude Opus 5.5 338eaa2c79 PLAN.md: decisions for Phases 9–14: teams and domains, agent approvals, Garage, Free and Paid tiers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:50:18 -07:00
davidandClaude Opus 5.5 734ecb0e0c PLAN.md: Phases 9–14, editions (local, server, multi-tenant), users, agents and billing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:30:31 -07:00
davidandClaude Opus 5.5 4405f7bef2 Sidebar and Overview: Sites before Metrics
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 13:43:36 -07:00
davidandClaude Opus 5.5 b6758417a3 Prospects: Listmonk mailing lists, and their opt-outs
Settings → Email → Mailing lists connects Listmonk (the Core's, by
default) with an API user and its token; Test reads the lists. A person
in Review can be added to a list, with their company, title and signal:
a double opt-in list asks them to confirm unless they already agreed; a
single opt-in list takes them only once they have; a suppressed address
is refused. Their card shows the lists they're on (a new list_members
table). Every hour, or on Sync now, everyone blocklisted in Listmonk or
unsubscribed from one of its lists goes on the suppression list, with
the reason; an address already there keeps its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 13:15:37 -07:00
davidandClaude Opus 5.5 a81ced3503 Inventory is now the Market
Everything the user sees says Market: the sidebar, titles, breadcrumbs,
help text, messages, suggestions and the agent tool's description; the
export downloads as supermarket-market.yaml. Its pages live under
/market, and the old /inventory addresses redirect there (308, so a
form's POST stays a POST). The YAML format (inventory:), the database
and the code's names are unchanged, so exported files still import. A
breadcrumb no longer repeats the page's own title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 12:38:50 -07:00
davidandClaude Opus 5.5 98f8788f18 PLAN and TEST: Phase 8 built, and its checks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 11:09:03 -07:00
davidandClaude Opus 5.5 c3246bdb67 Phase 8 part 4: where to win a link
Supermarket looks at each Inventory partner's pages that list providers,
hosts or partners (from their sitemap and home page) and keeps the ones
that list others but not the site; once a month by itself, or on
request. On request (up to 4 web searches), the AI finds lists of
alternatives to a competitor, and each page is read to keep the ones
that name others but not the company. Each opportunity can be marked
asked, won or dismissed; it's marked won when a link from its site shows
up. SEO → Links lists them; open ones join What to write next. Nothing
is sent: asking is the user's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 11:09:03 -07:00
davidandClaude Opus 5.5 2fd3e43293 PLAN: Phase 8 parts 2 and 3 built
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 08:43:30 -07:00
davidandClaude Opus 5.5 a1409d91ad Phase 8 part 3: lost links
Each known linking page (from Bing, Plausible or added by hand) is
opened once a week, at most 100 a day, to check it still links to the
site: kept, gone (the page no longer has the link), page gone (404, 410
or moved elsewhere) or pointing at a 404 (our page it links to is gone).
SEO → Links lists the lost ones with what happened, when last seen and
what the site brought; links can be added by hand (checked at once),
checked now, or forgotten. What to write next suggests a redirect for a
link to a 404, and asking for a lost link back when it brought visitors.
Links and What to write next now work for websites without Search
Console too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 08:43:30 -07:00
davidandClaude Opus 5.5 fc7dcf1f66 Phase 8 part 2: who links to you, from Bing
With a Bing Webmaster key, Supermarket reads once a week (or on Read
now) how many links Bing knows to each page of the site, and for the 25
most linked pages, the pages that link and their anchor text, into the
backlinks table. SEO → Links lists the linking sites, new ones first,
with the pages they link to and their link text; without a key it says
how to get one. A refused key keeps the last read, with the error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 08:31:27 -07:00