Repository navigation
feat(regulations): add the regulations.* router with permissions, procedure and deleghe - #114
Draft
lorenzocorallo wants to merge 2 commits into
Draft
lorenzocorallo wants to merge 2 commits into
lorenzocorallo wants to merge 2 commits into
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…cedure and deleghe Every procedure of the contract shared with the admin dashboard. Access combines the IdP permissions (regulations:read|write|manage|rectify), per-draft assignments (viewer, commenter, editor) and the Segretario's deleghe; drafts a caller can't see don't exist for them, and drafts.get returns the caller's role and capabilities so the dashboard doesn't repeat the rules. The procedure is configuration per document type (states, transitions, who takes them, deadlines). Sending to approval freezes the live text through the collab service (one draft in approval per document), the approval records the delibera, and the 3-day emanation and 10-day opposition deadlines are computed in Italian time. Merges use the last merge or the shared version as base, restores keep the current text as a snapshot, comments are threaded and resolvable, and documents and their first version are imported from legal.json. Also keeps the Yjs compaction marker from moving back when the log is empty.
…st line of output
lorenzocorallo
force-pushed
the
feat/regulations-collab
branch
from
November 2, 2026 23:02
1995770 to
b3cefe5
Compare
lorenzocorallo
force-pushed
the
feat/regulations-router
branch
from
November 2, 2026 23:02
4ece422 to
e549a9c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #113. The
regulations.*router (src/regulations/router.ts, mounted atregulations) and its service.It implements every procedure of the contract in #110. The one rename is
merge.apply→merge.execute, becauseapplyis a reserved tRPC name; the admin thread knows.Access
{ user: { scope: backend:admin } }on every procedure. People who only have an assignment use thedashboard too, so the service checks the rest.
regulations:write→ editor. Otherwise the assignment.regulations:read→ at least viewer.Nothing else → the draft is
NOT_FOUND.regulations:read: documents and versions;regulations:write: create, assign, merge, send to approval, delete;regulations:manage: approve, (next PRs) emanate and regenerate the diff,documents.sync;regulations:rectifyor an active delega covering the document: start and emanate a rettifica.drafts.getreturnsmyRoleandcan(edit, comment, assign, merge, transitions withblockedBy, approve,emanate, rectify, regenerateDiff, delete, rename, snapshot, restore), plus
deadlines,procedure,delibera,diffStatusandemanationStatus.me.get(no permission): assigned drafts, active deleghe, permissions, andrectifiabledocuments with theirlatest version.
Procedure (
procedure.ts)Configuration per document type. RRI:
bozza → in_approvazione(write): requires the text to parse. The collab service inserts ids and freezes allconnections, and the text is stored in
frozen_files. One per document (checked, and backed by the partialunique index). Hook for the LLM diff (next PR).
in_approvazione → bozza(write): reopen.in_approvazione → approvata(manage): the delibera{ body, date (not in the future), verbaleUrl? }.approvata → emanataandbozza → emanata(rettifica): emanation only (next PRs).overdue), and the 10-day opposition window fromnotification (info). Both are calendar days, ending 23:59:59 Europe/Rome.
Rest
editor assignment. Soft delete.
published version.
preview→ conflicts and applied changes.executeneeds every conflict resolved and aresult that parses, then replaces the live text through the collab service, with snapshots before and after.
compile.status/pdf.email (next PRs).
documents.sync(manage) importslegal.jsonand, for a document without versions, its sources and assetbundle as the first published version. The source is
REGULATIONS_LEGAL_DIRfor now, the GitHub App later.versions.pdfserves the official PDF, or compiles the version through the worker once and keeps it.compacted_throughback to 0 when the log was empty.Verified
tests/regulations-service.fixture.ts(real Postgres, faked collab over the stored Yjs state). It checks:tests/regulations-router.test.ts: the policy on every procedure, refusing tokenless, service and wrong-scopecallers, and the exact list of procedure names.