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
23 changes: 23 additions & 0 deletions .dev-brain/STATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# State — HPH
Updated: 2026-10-25 · Branch: main

## Goal
Provider-neutral authentication and sessions — acceptance: server functions resolve the actor from a verified session through `MembershipRepository::resolve_actor`, never from the demo actor; tenant-scoped SQL uses only session UUIDs.

## Done (latest first, max 5)
- English UI, errors and docs + README recruiter note — merged as `f54564b` (PR #8) — evidence: CI run 38468961276 `checks` and `database` PASS
- Persisted membership lookup `resolve_actor` under RLS (PR #7) — evidence: CI run 38466596064 PASS
- SQLx company module repository, admin-only atomic writes, tested as non-owner role — evidence: CI run 38465298093 PASS
- PostgreSQL schema + RLS tenant isolation — evidence: CI run 38456551456 `database` PASS

## In progress / blockers
- Authentication/sessions — status: not started
- Browser QA (desktop/mobile, hydration, visual) — status: NOT RUN; no browser environment so far

## Known pre-existing failures
- none recorded

## Next (max 3)
1. Design the session model (provider-neutral identity → `UserIdentity` + selected tenant) and agree it before coding.
2. Connect `resolve_actor` and the module repository to server functions behind the session.
3. Run browser QA on desktop and mobile when a build environment is available.
41 changes: 41 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# HPH

Reusable foundation for modular business management software (time tracking first), Rust end to end; currently a local demo, not for real company data.

## Stack
- Rust stable (edition 2024), `rust-toolchain.toml` adds `wasm32-unknown-unknown`, rustfmt, clippy
- Leptos 0.8 (SSR + WASM hydration), Axum 0.8 + Tokio, cargo-leptos 0.3.11
- PostgreSQL 18 with SQLx 0.9 and Row-Level Security; `Cargo.lock` is committed, use `--locked`
- Cargo workspace: root crate `hph` + `crates/hph-core` (pure domain rules)

## Commands (repository root)
- Run: `HPH_DEMO=true cargo leptos watch` → http://127.0.0.1:3000 (refuses to start without `HPH_DEMO=true` or on a non-loopback address)
- Format: `cargo fmt --all --check`
- Test: `cargo test --workspace --features ssr --locked` (compiles the workspace; slow on a cold `target/`)
- WASM check: `cargo check --target wasm32-unknown-unknown --features hydrate --lib --locked`
- Build: `cargo leptos build`
- PostgreSQL tests run only in CI (`.github/workflows/ci.yml`, job `database`); locally they need `HPH_TEST_DATABASE_URL` and `HPH_TEST_ADMIN_DATABASE_URL`

## Structure
- `crates/hph-core/src/lib.rs` — module catalog and dependencies, roles, memberships, attendance state machine; no Leptos/HTTP/DB code
- `src/api.rs` — server functions; the acting identity always comes from server context, never from the client
- `src/app.rs` — Leptos screens and components; `style/main.css` — tokens, sage/indigo themes
- `src/server.rs` — demo config/state, Axum router, HTTP and SSR tests
- `src/database.rs`, `src/module_repository.rs`, `src/membership_repository.rs` — SQLx pool, migrations, tenant-scoped repositories
- `migrations/` — schema and RLS policies; `migrations/tests/tenant_isolation.sql` checks isolation
- `hph.toml` — organization, theme, preset or explicit `modules` list, validated at startup
- `docs/MODULES.md` — module extension contract; `docs/DATABASE.md` — tenant boundary rules

## Conventions and gotchas
- Interface text, errors, accessibility labels, comments and docs are English.
- Module rules live only in `hph-core` (`ModuleId`, `catalog()`, `ModuleSet`), shared by server and browser; no second catalog in the UI.
- Disabling a module hides and blocks its operations but never deletes its data; open work sessions block disabling Attendance.
- Every company-data DB operation runs in `Database::begin_tenant_transaction(user_id, tenant_id)` with transaction-local settings; the runtime role must not own tables or have `BYPASSRLS`.
- Screens still use in-memory demo state with a synthetic actor; its IDs are not DB UUIDs. Never adapt it into a tenant-scoped SQL identity.
- Deeply nested SSR components overflowed the stack; component boundaries use `AnyView`.
- Timestamps are UTC, server-generated, displayed as `YYYY-MM-DD`.
- The deployment model (dedicated instance or multi-company service) is undecided: keep the tenant boundary explicit everywhere.

## Do not
- Expose the demo through a proxy, tunnel or public network, or load real company data before authentication and persistence are integrated.
- Change the GitHub "Template repository" setting or deploy without an explicit request.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Domain tests cover dependencies, permissions, foreign companies, duplicate clock
- `src/module_repository.rs` and `src/membership_repository.rs`: company module configuration and active membership lookup.
- `style/main.css`: layout, tokens, themes and mobile styles.
- `docs/MODULES.md`: the module extension contract.
- `harness/PROJECT_MAP.md` and `harness/PROJECT_STATE.md`: architecture and project checkpoint.
- `AGENTS.md` and `.dev-brain/STATE.md`: project facts for coding agents and the current checkpoint (goal, evidence, next actions).

The next functional increment is **authentication and sessions**. The SQLx repository can already resolve an active membership for a selected company, but the screens do not use it yet. Until authentication, authorization and application persistence are integrated, HPH remains a local demo and must not host real company data.

Expand Down
72 changes: 0 additions & 72 deletions harness/PROJECT_MAP.md

This file was deleted.

Loading
Loading