Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ed454f3
docs(roadmap): close P03-8 delivery after merge
cemililik Nov 19, 2026
24547d5
docs(decisions): propose P03-9 operator authority and recovery
cemililik Nov 19, 2026
a396f50
docs(decisions): accept P03-9 operator ADRs 0101-0104
cemililik Nov 19, 2026
bfba122
feat(platform): add operator authority gate and killswitch writer
cemililik Nov 19, 2026
5ebc567
fix(platform): harden operator auth, scope facade and killswitch writer
cemililik Nov 19, 2026
e18032c
fix(platform): close P03-9 step 1 review round 2 findings
cemililik Nov 19, 2026
5555d72
feat(platform): add operator onboarding acts (ADR-0102 step 2)
cemililik Nov 19, 2026
a2a6675
docs(runbooks): add the tenant onboarding runbook
cemililik Nov 19, 2026
101578c
fix(platform): close P03-9 step 2 review round 1 findings
cemililik Nov 19, 2026
4eb54f2
fix(platform): close P03-9 step 2 review round 2 findings
cemililik Nov 19, 2026
fd11198
docs(roadmap): record P03-9 step 2 delivery, reviews and proof
cemililik Nov 19, 2026
e23088b
feat(identity): add the issuer-rebind role, storage and freeze locks
cemililik Nov 19, 2026
897e686
feat(platform): add the offline issuer-rebind tool and shared validator
cemililik Nov 19, 2026
5bbba1d
test(identity): close the step 3 mutation gaps
cemililik Nov 19, 2026
cde9a4b
fix(identity): close P03-9 step 3 review round 1 findings
cemililik Nov 19, 2026
c89dd12
fix(identity): close P03-9 step 3 review round 2 findings
cemililik Nov 20, 2026
fc57429
feat(platform): operator recovery of dead-lettered work
cemililik Nov 20, 2026
708635a
fix(platform): close P03-9 step 4 review round 1 findings
cemililik Nov 20, 2026
da418cb
fix(platform): close P03-9 step 4 review round 2 findings
cemililik Nov 20, 2026
5392089
feat(platform): federation operator report, remove and disable
cemililik Nov 20, 2026
c991e16
fix(platform): close P03-9 step 5 review round 1 findings
cemililik Nov 20, 2026
b8d74c5
fix(platform): close P03-9 step 5 review round 2 findings
cemililik Nov 20, 2026
17c79db
docs(roadmap): close P03-9 step 5 gate wording and verification record
cemililik Nov 21, 2026
bf434eb
fix(platform): clear CA1068 and CA1822 that failed the hosted build
cemililik Nov 21, 2026
84914f9
fix(platform): make two unit theories serializable for hosted CI
cemililik Nov 21, 2026
82d18d8
fix(platform): wait on the realm request in the rebind signal test
cemililik Nov 21, 2026
f1e42f5
docs(roadmap): record the hosted layout-B result of P03-9 step 5
cemililik Nov 21, 2026
db7776b
test: make unserializable theory data a build error
cemililik Nov 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
60 changes: 29 additions & 31 deletions .claude/skills/add-feature-key/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ the socket; [ADR-0021](../../../docs/decisions/0021-feature-based-entitlement.md
`platform_entitlement_cache` itself.
- **Tenant-flag** keys read `tenant_feature_flags` (per-tenant rollout / opt-in).
- **Killswitches** read `platform_killswitches`, a platform-scoped table with no
tenant column and no foreign key, through the L1 cache. Packet 9 ships that table
**unwritten** — read path only, no toggle — and Phase 03 owns the command that flips a
switch (Step 6).
tenant column and no foreign key, through the L1 cache. Their single writer is
`KillswitchToggle`, reached by the operator route (P03-9 Step 1).

`IFeatureFlags` is the **only** module-facing read and it **composes** over the port
rather than querying a table; the catalogue's `Source` descriptor says which half a key
Expand Down Expand Up @@ -331,9 +330,11 @@ role and no `BYPASSRLS` moves it. Killswitches ship as **`platform_killswitches`
the Tenancy migration chain with role-qualified policies like
`platform_host_to_tenant`'s: `ENABLE` **and** `FORCE`,
`FOR SELECT TO learnstack_app USING (true)`, every write reserved to
`learnstack_platform` through the audited `EnterPlatformAdminScope(reason)` path — which
is what makes `tenancy.killswitch.toggle` a MUST-class audit row with a real actor
([ADR-0045 § 5](../../../docs/decisions/0045-entitlement-and-feature-flag-socket.md)).
`learnstack_platform` through the audited, admission-gated `IPlatformAdminScope` path —
which is what makes `tenancy.killswitch.toggle` a MUST-class audit row that names the
operator in `metadata.operator`
([ADR-0045 § 5](../../../docs/decisions/0045-entitlement-and-feature-flag-socket.md),
[ADR-0101](../../../docs/decisions/0101-platform-operator-authority.md)).

The overlay is read through the **L1 cache** and invalidated on toggle, under a second
allowed platform `CacheKey` family — `platform:tenancy:killswitch`. `EnsureValid` admits
Expand All @@ -343,31 +344,28 @@ the key's default (`true`, enabled) and logs at `Error`: a cache outage must not
every gated path platform-wide. A flip is eventually consistent across instances,
bounded by the TTL and the invalidation event.

**Packet 9 ships the table unwritten, and nothing in it flips a switch**
**The table has one writer: `KillswitchToggle`**
([ADR-0101 § 13](../../../docs/decisions/0101-platform-operator-authority.md)). Packet 9
shipped the table, the policies, the overlay, the cache family and the three
`KillswitchKeys` with no writer, because every write needs an authenticated operator
holding the Platform permission and none existed
([ADR-0045 Amendment 1 § 4](../../../docs/decisions/0045-entitlement-and-feature-flag-socket.md#amendment-1--what-the-other-repository-already-shipped-2026-09-08)).
The table, the policies, the overlay, the cache family and the three `KillswitchKeys`
ship; no writer does. The reason is reachability rather than scheduling: every killswitch
write runs inside `EnterPlatformAdminScope(reason)`, the registered `IPlatformAdminGate`
is `DenyAllPlatformAdminGate`, and nothing can enter that scope until the Platform-scope
permission arrives with the registry in
[Phase 03](../../../docs/roadmap/phase-03-identity-admin.md). A toggle command shipped
now would be unreachable code with a permission key nothing registers. **Phase 03 owns
the toggle command, its permission and its runbook**; until it lands,
`tenancy.killswitch.toggle` carries `(planned)` in the Tenancy matrix beside the
`(off-path)` marker it keeps permanently
P03-9 Step 1 added the operator scheme, the gate and the writer: the operator calls
`PUT /api/platform/v1/killswitches/{key}`, the gate checks `platform.killswitch.write`,
and the writer flips the row and records the MUST result row on one transaction. No
other file may write the table (an architecture rule pins it), and a new key needs no
new command: declaring it in `KillswitchKeys.All` makes it flippable through the same
route. `tenancy.killswitch.toggle` keeps `(off-path)` in the Tenancy matrix permanently
([Audit Coverage § The join](../../../docs/standards/18-audit-coverage.md),
[ADR-0044 Amendment 3](../../../docs/decisions/0044-audit-write-path.md#amendment-3--what-the-join-binds-to-and-the-types-the-ports-carry-2026-09-08)).
Every gated read honours a flipped switch the day one exists; what is absent is the
flipping.
Every gated read honours a flipped switch.

So a killswitch key added before Phase 03 is read-only, and its runbook lands with the
command that makes it flippable. The runbook entry — in `docs/runbooks/`, a directory
[Phase 11](../../../docs/roadmap/phase-11-production-hardening.md) owns — describes:
So a killswitch key added from now on is flippable the day it is declared, and its entry
in `docs/runbooks/killswitch.md` lands in the same change. The entry describes:

- When to use it (the incident shape).
- How to flip it — the operator action through `EnterPlatformAdminScope(reason)`, never
a hand-written `UPDATE` as `learnstack_app`, which holds no write privilege on the
table.
- How to flip it — the operator request, never a hand-written `UPDATE` as
`learnstack_app`, which holds no write privilege on the table.
- How to restore (revert + observability check).

A flippable killswitch without a runbook is incomplete.
Expand Down Expand Up @@ -482,11 +480,11 @@ public async Task RefreshAsync_AppliesAnEqualGenerationPush()
- **Omitting the failure posture.** ADR-0034 puts it in the registry; a key that leaves
it to the call site has no answer for the unresolved case, which is the one case the
member exists for.
- **A killswitch without a runbook, once one can be flipped.** The runbook belongs with
the command Phase 03 lands, not with the key Packet 9 registers. CI does not enforce
its presence; review must.
- **Writing a killswitch toggle in Packet 9.** The table ships unwritten and
`DenyAllPlatformAdminGate` is registered, so the command would be unreachable code
gated by a permission nothing registers.
- **A killswitch without a runbook entry.** The key is flippable the moment it is
declared, so its entry in `docs/runbooks/killswitch.md` belongs in the same change. CI
does not enforce its presence; review must.
- **A second writer of `platform_killswitches`.** `KillswitchToggle` is the only one; an
architecture rule fails any other file that inserts, updates, deletes or truncates the
table.
- **Removing a key without a deprecation cycle.** A rename / remove follows the
same one-release-deprecation-warning rule as permissions.
5 changes: 4 additions & 1 deletion .claude/skills/local-dev-setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ a fresh `postgres-data` volume
`learnstack_migration` owns every table, `learnstack_app` is what the API
connects as, and `learnstack_platform` / `learnstack_outbox_admin` hold audited
bypasses. The four roles/passwords and baseline connection strings are in
`.env.example`, and their privileges are not interchangeable. The accepted
`.env.example`, and their privileges are not interchangeable. Two confined roles join
them: `learnstack_identity_ingress` (provider intake) and `learnstack_identity_rebind`,
the offline issuer-rebind tool's role, whose connection string is never a stack or host
setting ([runbook](../../../docs/runbooks/identity-issuer-rebind.md)). The accepted
P03-2 application-role sources do not expand this role set. Running migrations as the
runtime role would make it the table owner, which is the arrangement
`FORCE ROW LEVEL SECURITY` exists to defeat.
Expand Down
10 changes: 7 additions & 3 deletions .claude/skills/seed-tenant/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ credential-free projection children receive process prerequisites without those
runtime values. Proxy and trust prerequisites remain available; migration,
platform, dispatcher and provider-admin credentials do not enter a Seeder child.

The direct tool reads its process environment; it does not load `.env`. Supply
`ConnectionStrings__Default`, `Identity__AuthorityId` and
`Authentication__Tenant__Issuer` from the selected private configuration. The
The direct tool reads its process environment; it does not load `.env`. It runs only
with `Deployment__Mode=Development` and exits 2 before reading any credential
otherwise: production tenants are onboarded through the operator surface
([runbook](../../../docs/runbooks/tenant-onboarding.md), ADR-0102 § 10). Supply
`Deployment__Mode=Development`, `ConnectionStrings__Default`,
`Identity__AuthorityId` and `Authentication__Tenant__Issuer` from the selected private
configuration. The
authority must already be installed: `make seed` passes the stable pair through
`make migrate`, whose deployment installer runs before content seeding. The
Seeder never installs, rewrites or infers that anchor. A schema-only migration
Expand Down
19 changes: 14 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,22 @@ POSTGRES_USER=learnstack
POSTGRES_PASSWORD=learnstack
POSTGRES_DB=learnstack

# ─── The four database roles (ADR-0003 Amendment 3) ──────────────────────
# ─── The database roles (ADR-0003 Amendment 3, 14) ───────────────────────
# Read by infra/compose/postgres-init/02-create-roles.sql through psql's
# \getenv on first boot. Four roles and four separate login credentials;
# the role model is closed and a fifth role requires an ADR. Additional
# application-role sources do not create roles (ADR-0076/0077).
# \getenv on first boot. Four baseline roles, the confined fifth and sixth
# below, and one login credential each; the role model is closed and a further
# role requires an ADR. Additional application-role sources do not create
# roles (ADR-0076/0077).
# An unset variable aborts initdb rather than creating a passwordless role.
LEARNSTACK_MIGRATION_PW=learnstack-migration-dev
LEARNSTACK_APP_PW=learnstack-app-dev
LEARNSTACK_PLATFORM_PW=learnstack-platform-dev
LEARNSTACK_OUTBOX_PW=learnstack-outbox-dev
# ADR-0097 confined machine intake; no business/Platform/outbox access.
LEARNSTACK_IDENTITY_INGRESS_PW=learnstack-identity-ingress-dev
# ADR-0104 offline issuer-rebind tool only; no API, worker, seeder or web host
# ever receives this credential or its connection string.
LEARNSTACK_IDENTITY_REBIND_PW=learnstack-identity-rebind-dev

# ─── Baseline connection strings ────────────────────────────────────────
# Double underscore is the .NET environment spelling of `ConnectionStrings:X`.
Expand All @@ -59,7 +63,8 @@ LEARNSTACK_IDENTITY_INGRESS_PW=learnstack-identity-ingress-dev
# FORCE ROW LEVEL SECURITY exists to defeat.
# Default — ordinary request/job business owners. NOBYPASSRLS.
# PlatformAdmin — resolvable only by PlatformAdminScope. BYPASSRLS.
# OutboxDispatcher — API-owned OutboxProcessor only. Never Seeder or web.
# OutboxDispatcher — the API's dispatcher stores only: the OutboxProcessor, the DeliveryProcessor and
# the operator recovery lane behind them. Never Seeder or web.
ConnectionStrings__Migration='Host=localhost;Port=5432;Database=learnstack;Username=learnstack_migration;Password=learnstack-migration-dev'
ConnectionStrings__Default='Host=localhost;Port=5432;Database=learnstack;Username=learnstack_app;Password=learnstack-app-dev'
ConnectionStrings__PlatformAdmin='Host=localhost;Port=5432;Database=learnstack;Username=learnstack_platform;Password=learnstack-platform-dev'
Expand Down Expand Up @@ -103,6 +108,10 @@ Federation__ClientSecret=learnstack-federation-admin-dev-secret
# Federation__Egress__AllowedHosts__0=idp.corp.internal:8443
# IdentityEvents__RealmId=<actual retained realm id>
# ConnectionStrings__IdentityIngress=Host=localhost;Port=5432;Database=learnstack;Username=learnstack_identity_ingress;Password=<private fifth-role password>
# The sixth role's connection string exists ONLY in the environment of the offline
# rebind tool for the minutes it runs (docs/runbooks/identity-issuer-rebind.md).
# Never place it in this file, a compose service block or a host configuration:
# ConnectionStrings__IdentityRebind=Host=<host>;Port=5432;Database=learnstack;Username=learnstack_identity_rebind;Password=<sixth-role password>
# Optional native tenant BFF (ADR-0070). Explicit false keeps the anonymous demo
# independent of Keycloak. For local watch mode, opt in with true and the issuer
# below; production launch requires an HTTPS issuer and a trusting private CA.
Expand Down
22 changes: 12 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ rules:
`BYPASSRLS` moves. Killswitches live in the platform-scoped
`platform_killswitches`
([ADR-0045](docs/decisions/0045-entitlement-and-feature-flag-socket.md)).
Packet 9 ships that table, its policies, the overlay and its cache family —
and **no writer**: every toggle runs inside `EnterPlatformAdminScope(reason)`,
whose registered gate is `DenyAllPlatformAdminGate`, so nothing can enter that
scope until the Platform-scope permission arrives, and
[Phase 03](docs/roadmap/phase-03-identity-admin.md) owns the toggle command,
its permission and its runbook
([ADR-0045 Amendment 1](docs/decisions/0045-entitlement-and-feature-flag-socket.md)).
Packet 9 shipped that table, its policies, the overlay and its cache family;
the single writer is `KillswitchToggle`, which enters the platform scope only
with a `PlatformAdmission` the operator gate minted for an authenticated
operator holding `platform.killswitch.write`
([ADR-0101](docs/decisions/0101-platform-operator-authority.md),
[runbook](docs/runbooks/killswitch.md)), and the architecture rules pin that no
other file writes the table.
- **Read `platform_entitlement_cache` from a module, `IFeatureFlags` included.**
The only sanctioned reader *and* writer is an `IEntitlementProvider`
implementation; `IFeatureFlags` composes over the port, which is what makes
Expand All @@ -347,9 +347,11 @@ rules:
branches once, modules never.
- Write `audit_log`, `platform_entitlement_cache`, or producer `outbox_messages`
rows directly — use `IAuditStore`, `IEntitlementProvider.RefreshAsync`, `IOutbox`.
Only ADR-0046's confined dispatcher writes outbox status through fenced
parameterized SQL; its terminal UPDATE and narrow witness-bound audit INSERT
share one transaction.
Only ADR-0046's confined dispatcher and
[ADR-0103](docs/decisions/0103-operator-recovery-of-asynchronous-work.md)'s confined
operator recovery owner write outbox status through fenced parameterized SQL; each
terminal or recovery UPDATE and its narrow witness-bound audit INSERT share one
transaction.
- Write `inbox_messages` or `event_deliveries` from a module or Seeder. ADR-0046's
transport-owned acceptance, inbox/business owner and confined scheduler alone
write their granted columns.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ for identity, membership and authorization work; the
| Area | Delivered now | Next milestone |
|---|---|---|
| **Tenancy** | Tenant provisioning, organizations, locales, typed settings/branding reads, host resolution and database isolation, plus bounded organization, default, locale and setting administration | Full organization and settings editors in [Phase 06](docs/roadmap/phase-06-renderer-admin-studio.md) |
| **Identity** | Global User binding, contextual Membership/Profile/Role foundations, live scoped authorization, bounded member directory and trusted denial evidence, protected Studio membership and Role administration, native new-user entry and scope switching, verified invitations with automatic email, and revision-pinned Membership custom values with personal consent | Provider event ingress, back-channel revocation, federation, platform authority and DSAR in [Phase 03](docs/roadmap/phase-03-identity-admin.md) |
| **Identity** | Global User binding, contextual Membership/Profile/Role foundations, live scoped authorization, bounded member directory and trusted denial evidence, protected Studio membership and Role administration, native new-user entry and scope switching, verified invitations with automatic email, revision-pinned Membership custom values with personal consent, authenticated provider-event ingress with a deduplicated tenant Audit mirror, back-channel session revocation, and confined tenant SAML/OIDC federation | Platform authority, operational recovery and DSAR in [Phase 03](docs/roadmap/phase-03-identity-admin.md) |
| **Customization** | Content types, level taxonomies, exact-definition and generation-cached batched display readers, text-card metadata validation, finite Membership field definition authoring, create-only provisioning defaults and semantic built-in seed verification | Remaining authoring capabilities across [Phases 04–08a](docs/roadmap/README.md) |
| **Audit** | Classified write path and transactional durability for business changes | Operational hardening in [Phase 11](docs/roadmap/phase-11-production-hardening.md) |
| **Education** | Course and Lesson aggregates, translations, protected-content policy, scoped authoring commands, complete demo seeds and isolated public GET/HEAD reads | Full versioned curriculum in [Phase 05](docs/roadmap/phase-05-education-learning-content.md) |
Expand Down Expand Up @@ -127,7 +127,9 @@ Continue with the manual HTTPS prerequisites below, then run `make demo`. It
creates missing private configuration and restores dependencies without changing
Git hooks. `make seed` converges application data and the development identity
realm and its application-owned identity foundation without starting the API or
web. The argument-free direct .NET Seeder remains data-only.
web. The argument-free direct .NET Seeder remains data-only and runs only with
`Deployment__Mode=Development`; production tenants are onboarded through the operator
surface ([runbook](docs/runbooks/tenant-onboarding.md)).

The seed provisions `demo-english` and `demo-yoga`, their organizations and host
mappings, enabled locales, distinct branding, built-in and tenant-authored definitions,
Expand Down
7 changes: 7 additions & 0 deletions backend/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
2.12.0 or later. -->
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.12" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.12" />
<!-- The operator token validator lives in Infrastructure so the API scheme and the offline rebind tool share one
definition (ADR-0101 § 7, ADR-0104 § 3). The versions are the ones JwtBearer already resolves.
JwtBearer requires Protocols.OpenIdConnect at its own floor: raising JwtBearer past 10.0.12
can raise that floor above these pins, and restore then fails with NU1605 in every project
that references Infrastructure. Raise the two pins with it. -->
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.19.2" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.19.2" />

<!-- EF Core (per-module Infrastructure projects). One servicing release for the
whole EF set, and every project that references the Npgsql provider references
Expand Down
1 change: 1 addition & 0 deletions backend/LearnStack.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<Project Path="src/LearnStack.Api/LearnStack.Api.csproj" />
<Project Path="src/LearnStack.Tools.Seeder/LearnStack.Tools.Seeder.csproj" />
<Project Path="src/LearnStack.Tools.IdentityAuthorityInstaller/LearnStack.Tools.IdentityAuthorityInstaller.csproj" />
<Project Path="src/LearnStack.Tools.IdentityAuthorityRebind/LearnStack.Tools.IdentityAuthorityRebind.csproj" />
</Folder>
<Folder Name="/analyzers/">
<Project Path="analyzers/LearnStack.Analyzers/LearnStack.Analyzers.csproj" />
Expand Down
1 change: 1 addition & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ backend/
LearnStack.Infrastructure.Audit/ # ADR-0033 audit pipeline plumbing
LearnStack.Api/ # ASP.NET host
LearnStack.Tools.IdentityAuthorityInstaller/ # deployment-only identity anchor
LearnStack.Tools.IdentityAuthorityRebind/ # offline controlled issuer rebind (ADR-0104)
LearnStack.Tools.Seeder/ # finite development data/adoption

Modules/
Expand Down
Loading
Loading