Files
tandClaude Opus 5.5 62b0f80b33
ci / test-guard (pull_request) Successful in 3s
ci / go (pull_request) Successful in 3m34s
ci / package (pull_request) Successful in 3m39s
ci / install-test (debian:13) (pull_request) Successful in 1m16s
ci / install-test (debian:12) (pull_request) Successful in 1m24s
ci / smb (pull_request) Successful in 1m15s
ci / e2e (pull_request) Successful in 3m6s
Remove passkey login
Owner's decision 2026-11-30 after a cost/value review. WebAuthn only works
when the UI is opened by host name with a trusted certificate; most homes and
small offices use an IP address and the self-signed certificate, where
passkeys don't work at all. For that it cost ~800 lines of security-relevant
code and 9 of the 11 Go dependencies (go-webauthn and what it pulls in: cbor,
go-tpm, jwt, uuid, mapstructure, msgp, …), each a source of update churn.

Removed: internal/app/passkeys, the /api/v1/auth/passkey/* and
/api/v1/me/passkeys* routes and their API description, auth.LoginVerified /
Failed / Blocked (only passkey login used them), the passkey button on the
login page, the Passkeys card on "My account", lib/webauthn.ts, the
dependencies (go mod tidy: go.mod now needs only pam and x/sys). F-AUT-6 is
marked dropped in 02-requirements with the reason. Password login, its
backoff and locked-account checks are unchanged.

Existing installations keep /var/lib/sharestead/passkeys.json; nothing reads
it any more (public keys only, no secret).

Effect: .deb 5.4 → 4.1 MB. Checked on CT 151: the passkey routes answer 404;
login, wrong password, self-service, own account, CSP and axe e2e tests pass
on desktop and phone.

Test changed because: these tests covered the removed passkey feature
(F-AUT-6, dropped by the owner) and are deleted with it:
internal/app/passkeys/passkeys_test.go; TestPasskeysNeedAHostName,
TestDeletingAUserForgetsTheirPasskeys, TestMyPasskeys,
TestPasskeyLoginIsBlockedDuringBackoff (internal/server);
TestPasskeyLoginOfLockedAccountIsRefused and the passkey half of
TestLockedAccountCantLogIn (internal/auth; its password half stays);
web/src/lib/webauthn.test.ts; the e2e test "passkeys: add one, log in with
it, remove it". The requirements they covered for passwords (backoff, locked
accounts, own account) keep their own tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 18:38:43 +01:00

6.7 KiB

AGENTS.md — working on Sharestead

For AI coding agents (and humans). Project layout and dev commands: README.md. Product and design decisions: docs/planning/; the MVP list is in 02-requirements, the binding design system in 04-ux-and-mockups §4b.

Rules

  • Standards first. WCAG 2.2 AA (checked with axe-core), WAI-ARIA patterns, OpenAPI 3.1 (linted with Redocly), errors as RFC 9457 problem details. Reuse the components in web/src/components/ instead of building new variants.
  • Say when something isn't possible or would break a standard, and offer an alternative with its trade-off. Don't silently build a weaker version.
  • Facts, not guesses. Reproduce before naming a cause; run it before saying a fix works; label anything you could not verify.
  • The config files stay the source of truth (smb.conf, /etc/exports, …): edits are lossless and touch only their lines; hand edits keep working.
  • No CDN, strict CSP (default-src 'self'). Everything ships inside the binary.
  • Dependencies pinned exactly (--save-exact). Licence GPL-3.0-only: third-party code must be compatible, keep its licence notice.
  • Code comments say what the code does, never what it doesn't do or what was removed. Reasons go into the commit message or docs/.
  • Never commit secrets.

Before every commit

Same checks as CI (.gitea/workflows/ci.yml):

# on CT 140, in the repo
export PATH="$HOME/.local/go/bin:$HOME/.local/node/bin:$PATH"
gofmt -l cmd internal          # must print nothing
go vet ./... && go test ./...
(cd web && npm run check && npm test && npm run build)
go run ./cmd/sharestead -openapi > dist/openapi.json && (cd web && npm run lint:api)   # after API changes

Writing tests

  • From the spec, not the code: take the expected result from docs/planning/02-requirements.md, 07-security-and-testing.md or the API description first. If a test fails, decide from the spec whether the code or the test is wrong; never just change the expectation to what the code does.
  • API tests use the harness in internal/server/harness_test.go (newWorld): real store, journal and files in a temp dir, recorded system commands. It also checks every answer against the API description. Check Samba access with checkAccess (independent smb.conf(5) model).
  • Fakes behave like the real system (see fakeSystem); a fake that is too friendly hides bugs.
  • Tests that need root (chown) skip as a normal user; run them with unshare -r env PATH=$PATH HOME=$HOME go test ./internal/adapters/osfs.
  • Coverage may not fall below .coverage-min (CI). When it rises, raise the number.
  • Behaviour that depends on the filesystem (ACLs, limits, free space, mounts): add it to internal/fsmatrix and run the matrix on VM 152 (commands at the top of scripts/fs-matrix.sh).
  • UI states (greyed out, warnings): add a scenario to web/e2e/fixtures/scenarios.json and its expected UI to web/e2e/ui-states.spec.ts; fixtures_test.go checks the fixture against the API.

When a test fails

  1. Read the requirement the test refers to (02-requirements, 07, the API description).
  2. Reproduce it — on the real system where possible (CT 151, VM 152, smbclient), not only in the fake. A fake that is too friendly or too strict is a bug in the test.
  3. Decide from the spec, not from the code: code wrong → fix the code (the test stays); test wrong → fix the test and say why in the commit message: Test changed because: <requirement / what was broken in the test, and why the code is right>. A test that passes only on its retry is a failure too (CI fails on flaky tests).
  4. CI enforces this: the test guard fails a pull request that changes or deletes existing test lines, deletes a test file or lowers .coverage-min / .mutation-min without that block (adding tests is free). The guard script comes from the target branch, so a PR can't switch it off for itself. Lowering a minimum is weakening a test.

UI changes: check them in a real browser first

Test instance: CT 151 (https://192.168.0.157:8443), test admin ssttest. It's yours to use: install, restart, create test users. Nothing else in the homelab without the owner's OK. Storage folders: /mnt/test (POSIX ACLs on) and /mnt/test-noacl (ACLs off). Features that depend on ACLs must be checked on both.

Second test instance: VM 152 (https://192.168.0.164:8443, ssh debian@192.168.0.164 with the CT 140 key, test admin ssttest). It covers what a container can't: /srv/xfs and /srv/ext4 belong to the VM (XFS/ext4 with project quota: hard limits possible), /mnt/host is a host folder via virtiofs (soft limits only, no ACLs). Deploy: scp the .deb, then ssh debian@192.168.0.164 'sudo apt-get install -y /tmp/sharestead.deb'. Features that depend on the filesystem owner (limits, ACLs) must be checked on both instances.

  1. Deploy to CT 151:
    # on CT 140, in the repo
    ARCHS=amd64 ./scripts/build-packages.sh
    ssh pve "pct push 151 /dev/stdin /root/sharestead.deb" < "$(ls -t dist/*amd64.deb | head -1)"
    ssh pve "pct exec 151 -- apt-get install -y /root/sharestead.deb"
    
    ✅ Check: the version printed by the build shows up on the System page.
  2. Run only the e2e tests you touched, on desktop and phone:
    # on CT 140, in web/ (set a fresh password first: ssh pve "pct exec 151 -- chpasswd")
    SST_URL=https://192.168.0.157:8443 SST_USER=ssttest SST_PASS='…' \
      npx playwright test --trace off --project=chromium --project=mobile -g "users and groups|accessibility"
    
    ⚠️ Never run the full suite there: it expects the CI fixtures (scripts/e2e-setup.sh, /srv/sst-test) and rewrites CT 151's config. Tests that need those fixtures (e.g. "personal folders", "storage limit") fail on CT 151 by design.
  3. Take screenshots (desktop, phone, light and dark) and look at them critically.

ignoreHTTPSErrors hides certificate errors, so it proves nothing about untrusted certificates.

Git

  • Early phase: the AI may commit and push to main directly; CI must stay green.
  • Ask the owner before tagging a release (first one: 0.1.0).
  • Commit messages explain what changed and why; one topic per commit.
  • CI runs per push only the fast set (e2e in Chromium + phone); Firefox, WebKit and the wide screen run nightly and on demand (Run workflow). A newer push cancels the older run. Several small commits are fine, but don't push them one by one while CI is busy: push them together.
  • Several agents may work at once: put larger changes that touch shared files on a branch (or a separate worktree) and open a pull request.