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
100 changes: 100 additions & 0 deletions .github/workflows/e2e-models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# The model flows (ADR-081, amended 2026-11-22): `just e2e-models` on a fresh runner. The same private
# stack as the core flows (e2e.yml), but the worker holds a provider key and Playwright runs only its
# `models` project: real tasks, a follow-up, a fork, a document and its verification, questions, a
# bot's chat, evals and drafter, a routine's run, each on a real model. The verification needs a
# frame, so the job also starts the compose egress proxy and builds the base frame image, as the
# nightly frame tests do. A run spends about twenty cents, so it never runs on a schedule or a PR:
# by hand only (Actions -> E2E model flows -> Run workflow).
# It needs the repository secret E2E_ANTHROPIC_API_KEY, and stops at its first step without one.
name: E2E model flows

on:
workflow_dispatch:

concurrency:
group: e2e-models-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
flows:
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
# The key rides only the steps that need it, never the dependency installs.
steps:
- name: Check the provider key
env:
PRISMOID_WORKER_ANTHROPIC_API_KEY: ${{ secrets.E2E_ANTHROPIC_API_KEY }}
run: |
if [ -z "$PRISMOID_WORKER_ANTHROPIC_API_KEY" ]; then
echo "::error::Set the repository secret E2E_ANTHROPIC_API_KEY to run the model flows."
exit 1
fi

- uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.12"

- name: Install backend deps
working-directory: backend
run: uv sync --frozen

# No version: the action reads the root package.json's packageManager pin (pnpm 12, ADR-071).
- name: Install pnpm
uses: pnpm/action-setup@v6

- name: Install node
uses: actions/setup-node@v7
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Install the JS workspace
run: pnpm install --frozen-lockfile

- name: Install Chromium for Playwright
working-directory: web
run: pnpm exec playwright install --with-deps --only-shell chromium

# A document's verification runs in a throwaway frame: frames join the compose frame network,
# which the egress proxy creates (its control port, 3129, is the worker setting's default), and
# boot the base frame image, built here so the first receipt does not wait on a build.
- name: The frame network, its egress proxy and the base frame image
working-directory: backend
run: |
docker compose -f deploy/compose.yaml up -d --wait egress-proxy
uv run python -c "from prismoid.ai.frames.docker_driver import ensure_image; print(ensure_image('base'))"

# The runner sets CI, which turns on a retry, forbids test.only and writes the HTML report.
- name: The model flows
env:
PRISMOID_WORKER_ANTHROPIC_API_KEY: ${{ secrets.E2E_ANTHROPIC_API_KEY }}
run: uvx --from rust-just just e2e-models

# The upload is not masked the way the log is: a file that carries the key never leaves the
# runner. No file should (the key never reaches the browser, and the logs print no headers).
- name: Drop any file that carries the key
if: failure()
env:
PRISMOID_WORKER_ANTHROPIC_API_KEY: ${{ secrets.E2E_ANTHROPIC_API_KEY }}
run: |
grep -rlF -- "$PRISMOID_WORKER_ANTHROPIC_API_KEY" \
web/playwright-report web/test-results web/e2e/.state/logs 2>/dev/null \
| while read -r leaked; do echo "::warning::dropped $leaked: it carries the key"; rm -f "$leaked"; done

- name: Keep the report, traces and stack logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: e2e-models-report
path: |
web/playwright-report/
web/test-results/
web/e2e/.state/logs/
retention-days: 14
11 changes: 6 additions & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# The browser smoke flows (ADR-081): `just e2e` on a fresh runner. It starts its own Postgres and
# Silo (S3) containers, the worker and the API, builds and serves the web app, and drives sign-in, a
# project, settings, the design-system page and a task record in Chromium. No flow calls a model,
# so the job needs no secret and runs the same on a fork. Not on every PR: nightly, or by hand
# (Actions -> E2E smoke flows -> Run workflow).
# The browser flows (ADR-081): `just e2e` on a fresh runner. It starts its own Postgres and Silo
# (S3) containers, the worker and the API, builds and serves the web app and the operator console,
# and drives every surface a person reaches without a model run in Chromium. Every provider key is
# blanked and no flow calls a model, so the job needs no secret and runs the same on a fork. Not on
# every PR: nightly, or by hand (Actions -> E2E smoke flows -> Run workflow). The flows that call a
# real model run separately, by hand only: e2e-models.yml.
name: E2E smoke flows

on:
Expand Down
2 changes: 1 addition & 1 deletion HANDOFF.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Metric: **IPT — Interventions Per Task** (unplanned human touches; designed ga
| `@testing-library/user-event` (14.6.10, web + blocks dev, exact) | Drive a component with real event sequences: typing, Tab, Enter, Space, arrow keys (ADR-079) | the same DOM test files | Fires the keydown, input and keyup chain a browser does, so keyboard paths are tested as they run. `fireEvent` alone rejected: one synthetic event per call misses focus moves and default actions |
| `@vitest/coverage-v8` (4.1.12, web + blocks dev, exact, matches `vitest`) | `pnpm test:coverage` in `web/` and `packages/blocks/` (ADR-079) | `web/vitest.config.ts` · `packages/blocks/vitest.config.ts` | V8 coverage needs no instrumenting build step. istanbul rejected: a transform per file for the same numbers |
| `pytest-cov` (dev; brings `coverage`) + CI-only tools, never installed into the project: `pip-audit` and `pip-licenses` (uvx, exact pins), `gitleaks` (pinned release binary, checksum-verified), `staticcheck` and `govulncheck` (`go run`, exact pins) | Coverage of the unit and integration suites with a no-regression floor in the job summary; the `security` job's vulnerability, secret and license gates; sandbar's static analysis (ADR-080) | `backend/pyproject.toml` (`[tool.coverage]`) · `.github/workflows/ci.yml` · `backend/tools/license_gate.py` | pytest-cov is the standard pytest driver for coverage.py and combines xdist workers' data itself; coverage.py's `greenlet` concurrency sees the ORM's async lines. The scanners are the ecosystems' own (PyPA, the Go team) or the de facto standard (gitleaks), run at a pinned version so a gate does not move under a PR. Rejected: a hosted coverage service (a third party for one number) and the gitleaks Action (needs a license key for organisations) |
| `@playwright/test` (1.65.1, web dev, exact; Apache-2.0) + Chromium's headless shell (downloaded by `playwright install`, never by `pnpm install`) | The browser smoke flows: sign-in, a project, settings, `/ds` and a held task record against a real API and worker, no model (ADR-081) | `web/playwright.config.ts` · `web/e2e/**` · `just e2e` · `.github/workflows/e2e.yml` (nightly) | Microsoft's runner, with role locators that read like the Testing Library queries the DOM tests use; one runner for the flows and their traces. Cypress rejected (runs inside the page, a second way of writing tests). Not in the frame image: the frame's browser stays the sidecar's CDP pipe (ADR-066) |
| `@playwright/test` (1.65.1, web dev, exact; Apache-2.0) + Chromium's headless shell (downloaded by `playwright install`, never by `pnpm install`) | The browser flows: every surface a person reaches without a model run, the operator console included, against a real API and worker with no model; and, opt-in, the model flows on a real provider key (ADR-081, amended 2026-11-22) | `web/playwright.config.ts` · `web/e2e/**` · `just e2e` · `just e2e-models` · `.github/workflows/e2e.yml` (nightly) · `.github/workflows/e2e-models.yml` (by hand) | Microsoft's runner, with role locators that read like the Testing Library queries the DOM tests use; one runner for the flows and their traces. Cypress rejected (runs inside the page, a second way of writing tests). Not in the frame image: the frame's browser stays the sidecar's CDP pipe (ADR-066) |
| `googleapis/release-please-action` (v5, CI only, Apache-2.0; never installed into the project) | Release PRs, on a manual run only: reads the conventional commits on main, bumps `version.txt`, `backend/pyproject.toml`, `backend/uv.lock` and `prismoid.__version__`, writes the CHANGELOG section; tags (a draft GitHub release) only on a manual run with `tag` checked, publishes nothing (ADR-082) | `.github/workflows/release.yml` · `release-please-config.json` · `.release-please-manifest.json` | Google's maintained tool for exactly this, driven by the commit convention the repo already follows, and the version stays readable in the tree with no build or runtime dependency. git-cliff rejected (a changelog generator only: the bump, the PR and the tag would be ours to script); hatch-vcs rejected (a new build dependency, and a build outside a git checkout needs the version passed in) |
| `pgsty/silo` (container image, `RELEASE.2026-10-26T00-00-00Z` pinned by digest; AGPL-3.0-or-later; never a Python or JS package) | The self-hosted S3 store: the dev stack, CI, the nightly frame tests, `just e2e` and the single-host `minio` profile; its bundled `mcli` makes the buckets (ADR-083) | `backend/deploy/compose.yaml` · `deploy/compose.prod.yaml` · `web/e2e/stack.sh` | A maintained fork of the MinIO server, whose own images are gone: the same S3 API, `MINIO_*` settings, health routes and on-disk format, so existing volumes open as they are. The frozen `bitnamilegacy/minio` archive, SeaweedFS and Garage (different systems, different layouts), RustFS (early) and Chainguard's MinIO (unpinnable free tier) rejected. Production may point `S3_*` at any S3 instead |
| `searxng/searxng` (container image, pinned by digest; AGPL-3.0; never a Python or JS package) | The self-hosted search engine behind `web.search`: `just searxng` in dev and the opt-in `search` profile of the single-host stack (ADR-047) | `deploy/compose.prod.yaml` (`searxng`) · `deploy/searxng/settings.yml` · `justfile` | Prismoid speaks its HTTP JSON API at arm's length and ships none of it (ADR-047 names it the self-host engine). It publishes no port; the worker reaches it on the compose network. A keyed engine (Brave, Tavily) needs no container and stays the other way to turn search on |
Expand Down
2 changes: 1 addition & 1 deletion STATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ cannot pass a dry run with Caddy's `local_certs`.
| Before a workstream merges | `just test`: the whole backend suite, integration tests included (needs `just up`; refuses while `just dev` runs) |
| A sandbar change | `just sandbar-check` |
| A user-visible change | One real run: `just smoke` or the CLI flow. An agent, prompt or skill change adds `just evals` |
| The drills | Nightly in CI: evals, `just perf`, `just e2e`, the frame integration tests. Weekly: `just chaos`. On demand: `just load`, `just endurance`, `just backup-restore`, `just fresh-clone`, `just range` |
| The drills | Nightly in CI: evals, `just perf`, `just e2e` (the browser flows over every surface reachable without a model run, the operator console included; a flow marked `knownBug` names a bug still open, ADR-081), the frame integration tests. Weekly: `just chaos`. On demand: `just e2e-models` (the browser flows on a real model; needs a provider key, also Actions -> E2E model flows), `just load`, `just endurance`, `just backup-restore`, `just fresh-clone`, `just range` |

Red means stop and fix it before new work.

Expand Down
12 changes: 10 additions & 2 deletions backend/prismoid/operations/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def update(
row.text = body
if kind is not None:
row.kind = kind.value
await session.commit()
await _commit_redated(session, row)
return row


Expand All @@ -183,11 +183,19 @@ async def retire(session: AsyncSession, actor: Actor, memory_id: uuid.UUID) -> M
await _authorise(session, actor, row, write=True)

row.status = MemoryStatus.RETIRED.value
await session.commit()
await _commit_redated(session, row)
logfire.info("memory {id} retired", id=str(memory_id))
return row


async def _commit_redated(session: AsyncSession, row: Memory) -> None:
"""Commit an edit and read back the `updated_at` Postgres re-dated it to. The ORM fetches a
server default after an INSERT but not after an UPDATE, so the column is left expired, and the
serializer's read of it would lazy-load outside the async greenlet (a 500 on a saved edit)."""
await session.commit()
await session.refresh(row, ["updated_at"])


async def _authorise(session: AsyncSession, actor: Actor, row: Memory, *, write: bool) -> None:
"""The lane's gate, given a fetched row. User rows 404 for anyone else (existence is
privileged); project rows defer to `Project.get_for` (which 404s strangers, 403s viewers on
Expand Down
4 changes: 4 additions & 0 deletions backend/tests/integration/memory/test_memories_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import pytest

from prismoid.api.serializers.memories import memory_out
from prismoid.db.models.memory import Memory, MemoryKind, MemoryScope, MemoryStatus
from prismoid.db.models.project_member import ProjectMember
from prismoid.db.session import session_scope
Expand Down Expand Up @@ -57,9 +58,12 @@ async def test_user_scope_is_private_and_retire_keeps_the_row() -> None:

edited = await ops.update(session, alice, row.id, text="Prefers one-page memos.")
assert edited.text == "Prefers one-page memos."
# The API serializes the row it gets back: its re-dated updated_at must already be loaded.
assert memory_out(edited).updated_at >= row.created_at

retired = await ops.retire(session, alice, row.id)
assert retired.status == MemoryStatus.RETIRED.value
assert memory_out(retired).status == MemoryStatus.RETIRED.value
assert await ops.list_memories(session, alice, scope=MemoryScope.USER) == [], "active list hides it"
lineage = await ops.list_memories(session, alice, scope=MemoryScope.USER, status=None)
assert [m.id for m in lineage] == [row.id], "retire keeps the row - nothing is deleted"
Expand Down
Loading