docs(legal): amend tenant legal documents & consent versioning spec - #100
Open
patrykbojczuk wants to merge 7 commits into
Open
docs(legal): amend tenant legal documents & consent versioning spec#100patrykbojczuk wants to merge 7 commits into
patrykbojczuk wants to merge 7 commits into
Conversation
Add the spec for a new upstream `legal` core module: a versioned, append-only legal-documents ledger plus an append-only consent ledger. Versions are effective-date-aware dotted-decimal; per-language content lives in append-only translation rows (a new language is an insert, not an edit); documents reference each other via stable legal:<type>[:<version>] tokens resolved client-side. Recording consent captures the accepted document and its reference closure under one action id. No backend deeplink config; append-only, audit-logged, not-undoable commands.
Make the consent `metadata` field explicit: an open, caller-supplied JSON object stored verbatim on every row of an acceptance, for provenance and linking a consent to the business event that required it (notably a payment authorization carrying the payment id). The core module neither enumerates a closed source set nor interprets metadata.
Extend the reference token grammar to legal:<type>[:<version>][?lang=<code>]
so a reference can pin the referenced document's display language (for
"governed by the English version" clauses), overriding the reader's
locale with default-locale fallback. References become
{ type, version?, language? }; <type> now also forbids '?'; a pinned
lang need not exist at publish. Updates discrepancy checks, consent
closure resolution, and tests accordingly.
…ling notes Enrich the spec with generalizable design details: - assertConsentCurrent / POST /api/legal/consents/verify: validate a consent map is complete and effective without recording, so an irreversible flow (e.g. a payment) rejects a stale consent up front. - Data protection & retention: append-only consent is retained under right-to-erasure; metadata/placeholder_values are the only free-form fields; no encryption map (justified N/A); a future subscriber to the platform privacy.subject.erased event can pseudonymize + scrub while keeping the evidence skeleton. - renderedContent substitution semantics (unknown token left literal, no re-substitution); effectiveFrom clock-skew grace; and the cross-module coupling pattern (record/verify via command bus, react to legal.consent.recorded).
The on-session gate is the consent recorded when the payment intent is minted; a separate pre-check there is redundant. Reframe assertConsentCurrent / POST /api/legal/consents/verify as a standing-consent check (does the user already hold a current consent for a type + its active closure) for off-session/recurring charges and re-consent prompts, where money moves with no user present to consent.
…ts design Upstream PR open-mercato#5364 merged a full design that spreads legal documents (content), controller identity (directory), and the consent ledger (auth) across existing modules with host-based public-page resolution, integrity seals, and pseudonym-salt GDPR erasure. Rework our spec as an amendment on that base: keep its placement and GDPR/host/seal/identity design wholesale, and add four deltas - per-language append-translation content rows, legal:<kind>[:<version>][?lang=<code>] reference tokens + closure consent, open consent metadata + off-session standing-consent check, and any-language (ISO 639-1) input. Supersede the earlier standalone-legal-module draft.
Add the rationale for appending a locale to a live version instead of cutting a new one: a version bump is the re-consent signal, so a new version to add a language would force everyone who accepted the prior version to re-consent to text that is byte-identical in the locale they actually saw - a false re-consent. Appending a write-once content row leaves existing rows and the consents that pin them untouched.
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.
Summary
Reframes this spec as an amendment on the merged upstream design
(
.ai/specs/2026-08-18-tenant-legal-documents-and-consent-versioning.md, PR open-mercato#5364), which placeslegal documents in
content, controller identity indirectory, and the append-only consent ledgerin
auth(withonboarding/checkoutconsumers, host-based public-page resolution, integrity seals,and pseudonym-salt GDPR erasure). We keep that placement and infrastructure wholesale and add four
capabilities on top. Spec only; no code.
Changes
.ai/specs/2026-08-20-legal-documents-consent-ledger.mdinto a delta on the base spec, adding:content(a locale can be added to a liveversion without a new version; each row write-once and separately hashed).
legal:<kind>[:<version>][?lang=<code>]tokenincorporates another legal document; accepting the primary records consent for its whole closure
under one action, in
auth.metadata(unsealed, e.g.{ source:'payment', paymentId }, cleared on erasure)and an off-session standing-consent check for charges taken with no user present.
legal-module draft (single module, dotted-decimal versions, ownconsent command/tables, client-only deeplink tokens, lighter erasure note) - all replaced by the base
spec's placement, integer versioning, DI
consentLogService, host resolution, and salt erasure.Specification
Does a spec exist for this feature/module?
2026-08-18-tenant-legal-documents-and-consent-versioning.md)Spec file path:
.ai/specs/2026-08-20-legal-documents-consent-ledger.mdTesting
Documentation/spec only - no code changed, so no build or tests were run.
Checklist
develop.docs/cla.md)..ai/qa/tests/..ai/specs/with a changelog entry.priority-low.risk-low(a design amendment document; no code, schema, or API surface).skip-qa(documentation only).Design System Compliance
Linked issues
None.