Files
visa/AGENTS.md
T
grabowski 2e009700a9
CI / secret scan (push) Successful in 4s
CI / fmt, clippy, tests (push) Successful in 42s
Phase 1: app, Kanidm login, people, passports, addresses, audit log
visa.buildfor.life keeps the immigration records of the foreigners B4L
looks after. This first phase is the base the deadlines and extension
packs build on (docs/PLAN.md, phases 2 to 7).

- One Rust binary (axum 0.8, minijinja, sqlx on PostgreSQL) with its
  templates, static files and migrations compiled in.
- Login through Kanidm (OpenID Connect with PKCE and a nonce, ES256),
  client visa-web, group visa; sessions in PostgreSQL keyed by the
  SHA-256 of the cookie. VISA_INSECURE_NO_LOGIN=1 for loopback
  development only.
- Same-site check and form token on every POST; a CSP without inline
  script or style; security headers.
- People: list with filter, page, create, edit, archive, restore.
- Passports from the machine-readable zone with check digits (ICAO
  9303 TD3); expiry warnings at 12 and 6 months.
- Addresses in Thailand in the order Thai forms use, with the house
  master and the TM.30 receipt.
- Append-only audit log of every view and change, with the names of the
  changed fields but never their values (PDPA); the Activity page.
- Invented demo people (visa seed-demo, refused when login is on).
- 40 tests: unit tests, pages with demo data, the forms, the audit log
  and the whole login against a fake OpenID provider.
- CI: gitleaks over the history, fmt, clippy and the tests against
  PostgreSQL 18; the pre-commit secret scan.
2026-11-17 16:58:48 +07:00

3.3 KiB

Working on this repository (for agents and people)

visa.buildfor.life holds passport data of real people. Read this file and docs/PLAN.md before changing anything.

Rules

  • No real personal data in the repo, in tests, in demo data or in screenshots. Demo people are invented (src/seed.rs) and carry the note "Demo record, invented for development." Test passports use invented numbers such as C01X00T47.
  • No secrets in the repo. Secrets reach the app as files or systemd credentials (src/config.rs); the pre-commit hook and CI run gitleaks.
  • The audit log stays complete. Every handler that shows a person's record writes a view row, and every change writes a row with the names of the changed fields (changed_fields! in src/people.rs), never their values. The table refuses UPDATE and DELETE (migrations/0001_init.sql).
  • Every POST goes through the same-site check and the form token (src/web/mod.rs); forms carry <input type="hidden" name="csrf">.
  • No inline script or style. The Content Security Policy refuses them; tests/pages.rs checks the templates.
  • Migrations are never edited once they are on main; add a new file.
  • Dates are shown as "Nov 17, 2026" in Chiang Mai time (src/dates.rs); countries are ISO 3166-1 alpha-3 codes as in the passport's zone (src/countries.rs, generated by scripts/gen_countries.py).
  • Writing for people (pages, docs) follows the house style: plain American English in whole sentences, no em dashes, "Nov 17, 2026" in tables.

Checks before a push

eval "$(bash scripts/dev-db.sh)"
cargo fmt --all --check
cargo clippy --all-targets -- -D warnings
cargo test

CI (.gitea/workflows/ci.yml) runs the same against PostgreSQL 18, plus the secret scan over the whole history. For a page change, look at it in light and dark, at desktop and phone width, with scripts/dev.sh running.

Layout

Path What
src/main.rs the commands serve, migrate, seed-demo
src/config.rs settings from the environment and credentials
src/oidc.rs OpenID Connect against Kanidm (PKCE, nonce, ES256), from the fleet overview
src/session.rs sessions in PostgreSQL, keyed by the SHA-256 of the cookie
src/audit.rs the activity log
src/people.rs people, passports, addresses: validation and SQL
src/mrz.rs reading the passport's machine-readable zone (ICAO 9303, TD3)
src/web/ routes, the login gate, pages
templates/ minijinja templates, compiled in by build.rs
static/ CSS and JavaScript, compiled in; the URL carries a content hash
migrations/ SQL migrations, compiled in
tests/ integration tests, one binary (tests/main.rs declares each file)