diff --git a/CLAUDE.md b/CLAUDE.md index 1b54a7b..27e53eb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,11 @@ Guidance for Claude Code when working in this repository. ## What this is -**Agora** — A self-hosted management console. Built on **dredd-core**, the shared substrate of this app family: +**Agora** — the family's **contract negotiations** (Negocjacje), split out of Compass (work package +M3 of the Compass split plan, 2026-11-06): a negotiation **room** on one document (`negotiation_room`), +the **rounds** of the exchange (`negotiation_round`, Compass's `contract_version`), the team's +internal **thread** (`negotiation_comment`, Compass's `contract_comment`), the comparison of two +.docx rounds, and the room's **participants**. A counterparty guest is a later work package. Built on **dredd-core**, the shared substrate of this app family: identity, sessions, auth, the access-control resolver, the org tree, audit and the security primitives are an installed dependency, not source in this repo. Stack: **FastAPI + SQLAlchemy 2 + Alembic + PostgreSQL 16 / 17**, Argon2id auth + server-side cookie sessions, a @@ -79,12 +83,13 @@ backend/app/ observability.py logging_config.py (db/errors/security/enums are shims) models/ __init__ (shim: re-exports core's AppUser/Session/ModulePermission/AppSetting/AuditLog [+ Node/PermissionGrant/Favorite in nodes tenancy]) - example (the demo entity — this app's own model) + negotiation (room · participant · round · comment — this app's own) services/ auth · audit · moderation (shims over dredd_core) authz (nodes tenancy: shim over dredd_core.authz · simple: local moderator/owner rules) - changes · settings · nodes · audit_log · example (this app's logic) + changes · settings · nodes · audit_log (this app's logic) + rooms · negotiation · uploads · compare (the negotiation room, M3) (nodes: nodes tenancy only · audit_log: the read-only audit query) - routers/ health auth users admin nodes example dashboard (nodes: nodes tenancy only) + routers/ health auth users admin nodes rooms dashboard (nodes: nodes tenancy only) backend/tests/ unit (DB-free, always run) + integration (opt-in) backend/alembic/ env + 0001_initial (pgcrypto, create_enum_types, create_all) + 0002_runtime_grants (runtime_grants_sql for DB_APP_ROLE; evidence tables in models/__init__) @@ -94,6 +99,9 @@ backend/alembic/ env + 0001_initial (pgcrypto, create_enum_types, create_all) + 0004_module_permission (dredd-core v0.11.0 renamed `module_moderator`; a database whose 0001 ran before that still has the old table, and 0001 never runs again — rename it, add `role`, or build it from the metadata, decided by the catalog) + + 0005_negotiation (rooms, participants, rounds, comments; the event log: + standalone `module_event` + its RLS policies, on the platform a local copy + dropped while empty; idempotent, decided by the catalog of current_schema()) backend/scripts/ license_gate · deploy_check frontend/ index.html · app.css · app.js (no build step) Tabler icon path data vendored into app.js's ICN map (CREDITS.md) @@ -298,7 +306,42 @@ node --check frontend/app.js # ALWAYS after editing the console when frames are throttled. `transform` transitions; `visibility` flips instantly. - Name model modules so they cannot shadow a stdlib module (`timelog.py`, not `time.py`). + +## The negotiation room (M3) + +- **`negotiation_room` is the subject** (`dredd_core.document_ref.SubjectRefMixin`, like Arbiter's + `analysis_subject` and Lexicon's `library_source`): exactly one Galena `DocumentRef` or one + `plain_files` `FileRef`, no foreign key across modules. Its reference is **round 1** and never + changes. +- **A round is an event carrying a file, not a document history** (the plan, "Agora a nikt poza + Galeną nie wersjonuje"). On a Galena room the round's bytes are a **new commit on the room's + document**: `POST {GALENA_BASE_URL}/api/v1/projects/{document_id}/upload` with `dest` = the + document's path, the person's own token (`dredd_core.module_client`, never a service account), so + Galena's chokepoint applies (role `editor`, review policy — the commit may land on the person's + working version —, encryption, audit). The round pins the commit Galena answers and reads it back + once to prove the hash. A round must keep the document's format (`format_differs`). On a plain + room the round is one new `plain_files` file, never overwritten. No merging, authorship or + redaction in Agora. `GALENA_BASE_URL` empty = Galena off: a document room answers 409 + `galena_disabled` (D9). +- **Access (plan P5): participants + this module's moderators**, no copy of `node`. The owner is + always a participant; the owner or a moderator manages the room and its participants; anyone else + gets a 404. With Galena, Galena still decides on the bytes. +- **Comparison stays server-side** (`services/compare.py`, standard library only, ported verbatim): + paragraph then word diff of two .docx rounds, tracked changes read as accepted, footnotes last, + hardened against XXE / zip bombs. Not yet replaced by ReaderJS's `compare` — see the [T] note in + the README. +- **Event**: a round from the other side (`druga_strona`) writes `negotiation.round_received` + (`dredd_core.events.emit`, payload identifiers only: room, round, side, and on a Galena room the + document and commit) in the round's own transaction. Compass's G8 (`szkic → negocjacje`) is the + register's, i.e. Galena's, to act on. Standalone the log is `agora.module_event` (RLS); on the + platform it is the hub's `dredd.module_event`, and **the hub must list `agora_app` among its + emitter roles before Agora goes live there**, or every round from the other side fails. +- Rooms, rounds and comments are on `NO_DELETE`; a comment is deleted by `deleted_at`, a room is + closed, never removed. `module_event` and `module_event_receipt` are on `APPEND_ONLY`. + ## Status -Scaffolded skeleton on dredd-core v0.22.0. The `example` entity (`Record`) is a worked seam — -model → migration → service → router → console screen — to copy for the real domain, then delete. +Scaffolded on dredd-core v0.22.0 (2026-11-12), then the negotiation room ported from Compass +(M3). Verified: DB-free suite, integration suite standalone on PG16, the platform shape (cutover, +the hub's `dredd.module_event`, `managed check --identity-tier reader --events`), license gate, +deploy check, `provision.sql` (platform rendering). diff --git a/README.md b/README.md index fe49cf2..3b88b11 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,24 @@ # Agora -A self-hosted management console. +Negocjacje umów — contract negotiations. + +Agora is the family's **contract negotiations** module (Negocjacje), split out of Compass: a +negotiation room on one document, the rounds each side sends, a word-level comparison of two Word +rounds, and the team's internal comment thread. With Galena a room sits on a Galena document and +every round is saved there as a new version of it, with the person's own account; without Galena the +room and its rounds are plain files. A room is seen by its participants and the module's moderators. + +**Open questions for review [T]:** + +- **Comparison.** The plan (`Podgląd i porównanie`) prefers ReaderJS's `compare` and drops + `compare.py` "if ReaderJS covers its rules". It is kept for now: ReaderJS diffs extracted text + word by word, while `compare.py` pairs reworded paragraphs, reads tracked changes as accepted, + puts footnotes last and is hardened against XXE and zip bombs on the server. Agora also has no + ReaderJS viewer yet. To decide: are those rules needed, or does ReaderJS suffice? +- **Access without Galena** (P5): participants + moderators, as recommended. On a Galena room + Galena's tree still decides on the bytes; the room list does not mirror it. +- **Event semantics**: `negotiation.round_received` is written only for a round from the other side + (the old G8 trigger), not for our own rounds. Self-hosted and single-tenant, built on **dredd-core** — the shared substrate this app family installs as a dependency rather than copies.