What does the example domain protect, and which scenarios prove it? For someone reading or extending the example.

The domain

A code host holds repositories. An enterprise owns projects and teams, a project holds repositories, and one team of the enterprise owns each repository. A repository carries a visibility: the labels that say what the code is, and the restrictions that say who cannot read it. A membership in the project, or a role in the owning team, is an account's access path to the repository. An admin of the owning team can change the visibility, and a different reviewer approves the change. The example models four restrictions, one per shape of subject test.

RestrictionShown asTest on the subject
employees_onlyEMPLOYEE ONLYemployment is employee
export_controlledEXPORTcountry matches the owning enterprise's
invite_onlyINVITE ONLYthe subject is on the visibility's invited list, a per-object grant
releasable_toREGIONScountry is in the visibility's country list

EXPORT and REGIONS both read a country, and they ask two questions. EXPORT bars every subject whose country differs from the enterprise's. REGIONS requires the subject's country to be in a list the visibility carries. A subject passes both or the repository denies the read.

A directory is one part of a repository with a visibility of its own, and a repository's visibility is its rollup, the visibility under which a subject can read every directory. A checkout returns the repository without the directories the subject cannot read. Directory declares its own object type and is not a carried relation of Repository, so the checkout is one repository decision, one directory scope, and a preload under the directory decision. Scope fidelity then holds at directory level. Example and the moduledocs under it have the schemas and the contexts.

The rules

RuleStatement
C1 Access pathread on a Repository requires a Membership in its Project or a TeamRole in its owning Team.
C2 Restrictions, all ofEvery Restriction on the effective visibility is a test on the subject, and all must pass.
C3 Sensitive labelsA sensitive Label adds its implied Restrictions. The effective restrictions are the union of the declared and the implied. The domain copies nothing.
C4 RollupA Repository's rollup admits no subject that a Directory of it denies. Its Labels and Restrictions are the union of the Directories' own. Its REGIONS country list is the intersection of the lists of the Directories that carry that restriction. So no rollup releases a country one Directory withholds. A change to a Directory's visibility recomputes the rollup in one transaction, and the domain refuses a rollup that admits a subject a Directory denies. A scenario tests this at write time.
C5 EmbargoAfter the embargo lifts, C2 to C4 no longer apply. C1 still applies. The current time is an environment fact the port supplies.
C6 Invite is a direct grantinvite_only membership is per Repository per User and combines with nothing. It never overrides C1.
C7 Visibility gatesTo change a visibility, to set an embargo, or to lift one, a subject must hold an admin role in the owning Team.
C8 Re-authenticationA C7 operation also requires a session that re-authenticated within the configured window.
C9 Separation of dutiesA different reviewer must approve a visibility change that one admin proposes.
C10 Audited overrideA privileged user that holds the override permission can read a Repository outside C1 with a justification. The read succeeds, always emits its own event, and reports to the owning Team. The override is never unconditional.
C11 Continuous evaluationEvery check evaluates Memberships, invited lists, employment, and country. A change deletes nothing.
C12 Revocation clockThe system enforces a revoked fact within the configured maximum delay. The test records the measured latency beside the configured maximum, and no test asserts it.
C13 Scope fidelityscope returns exactly the rows for which check is true, for Repositories and for Directories.

Each thin application's README says which mechanism enforces each rule under its binding.

The scenarios

Example.Scenarios.Table holds this table as data, and the freeze test in example holds the module to this document row for row. Every row is a test in Example.Scenarios, its name is the sentence, and each of the four thin applications runs it. The Tests column names the rule, or review for the scenario that shows the port's review verb. An asterisk marks a citation outside the baseline.

IdSentenceGroupControls citedTests
enf-01A User with a Membership in a Repository's Project reads itenforcementAC-3C1
enf-02The Repository denies a User with neither a Membership nor a TeamRoleenforcementAC-3C1
enf-03A User with a TeamRole in the owning Team reads a Repository of that Team's Project without a MembershipenforcementAC-3C1
enf-04An EMPLOYEE ONLY Repository denies a contractor with a Membership in its ProjectenforcementAC-3, AC-16*C2
enf-05An EXPORT Repository denies a User whose country is not the owning Enterprise'senforcementAC-3C2
enf-06A REGIONS Repository denies a User whose country is outside its listenforcementAC-3C2
enf-07An INVITE ONLY Repository admits a User on its invited list and denies a User not on itenforcementAC-3C2, C6
enf-08A Repository with two restrictions denies a User who passes only one of themenforcementAC-3C2
enf-09A sensitive Label's implied restriction denies a User that the declared restrictions allowenforcementAC-3C3
enf-10Any User with an access path reads a Repository with no restrictionsenforcementAC-3C2
enf-11A User outside the Enterprise's country gets a checkout that omits an EXPORT Directory and returns the rest of the RepositoryenforcementAC-3C4, C13
enf-12The domain refuses at write time a Repository visibility that drops a Directory's restrictionenforcementAC-3, AC-16*C4
enf-13After the embargo lifts a contractor with a Membership reads an EMPLOYEE ONLY RepositoryenforcementAC-3C5
enf-14Before the embargo lifts, by the port's clock, the same Repository denies the contractorenforcementAC-3C5
enf-15A Repository whose embargo lifted still denies a User with no access pathenforcementAC-3C5, C1
enf-16A place on the invited list without a Membership does not grant the readenforcementAC-3C6
enf-17scope does not return a Repository of another Enterprise, and check does not allow itenforcementAC-3C1, C13
enf-18The whole Repository denies a User that one Directory releases to and another does notenforcementAC-3, AC-16*C4, C2
lp-01A Project member without a TeamRole cannot change a Repository's visibilityleast privilegeAC-6, AC-6(1)C7
lp-02An admin of another Team cannot change the visibilityleast privilegeAC-6(1)C7
lp-03An admin of the owning Team changes the visibilityleast privilegeAC-6(1)C7
lp-04Only an admin sets an embargo date or lifts an embargoleast privilegeAC-6(1)C7
lp-05A Directory's visibility change needs an admin of the Repository's owning Teamleast privilegeAC-6(1)C7, C4
lp-06An ordinary account cannot invoke the overrideleast privilegeAC-6(10)C10
lp-07A privileged account is a separate account, and the same person's ordinary account cannot overrideleast privilegeAC-6(2)C10
lp-08The access review lists every privileged account and every permission a role holdsleast privilegeAC-6(5), AC-2(7)C7, C10
sod-01A different reviewer approves the visibility change an admin proposesseparation of dutiesAC-5C9
sod-02The proposer, who is also a reviewer, cannot approve their own proposalseparation of dutiesAC-5C9
sod-03A proposal without approval does not change the visibilityseparation of dutiesAC-5, CM-5C9
rev-01A revoked Membership denies the next check, and the test records the latency and its components and never asserts themrevocation and expiryAC-2, PS-4, AC-3(8)*C11, C12
rev-02Removal from an INVITE ONLY list denies the next readrevocation and expiryAC-2, AC-2(1)C11
rev-03A change of employment from employee to contractor denies an EMPLOYEE ONLY read at the next checkrevocation and expiryAC-2, PS-5C11
rev-04A corrected country applies at the next checkrevocation and expiryAC-2, AC-16*C11
rev-05An archived Project revokes every Membership's access path at the next checkrevocation and expiryAC-2, AC-2(3)C11
rev-06A revocation deletes only the fact, the Repository and the Project remain, and the grant and the revoke each emit a change eventrevocation and expiryAC-2(4)C11
rvw-01The access review lists who can read what today, per Enterpriseaccess reviewAC-2, AC-6(7)review
ia-01An admin whose session re-authenticated within the window changes a visibilityre-authenticationIA-11C8
ia-02An admin whose session is older than the window cannot change a visibility until re-authenticationre-authenticationIA-11C8
ia-03The port refuses a visibility change that has no re-authentication factre-authenticationIA-11C8
ovr-01A privileged user with the override permission reads outside C1 with a justification, and the read emits an event and reports to the owning Teamemergency overrideAC-6(9), AU-6C10
ovr-02The override refuses a call without a justificationemergency overrideAC-6(9)C10
ovr-03The override never reaches C7, and a privileged user cannot change a visibility through itemergency overrideAC-6(9), AC-6(1)C10, C7

What the example decided

  • The directory is its own object type. A carried relation of the repository was the alternative. Then the repository's decision would cover every directory, and a checkout could not filter them.
  • The rollup is kept at write time. Computing it at read time was the alternative. A stored rollup is one row the read policy of every adapter tests, and a write that would widen it fails in the transaction that tried.
  • The override is a declared exemption with permission, justification, event, and report in the example's code. A rule in the adapter was the alternative. No adapter should carry a path around its own rule, and the exemption records who took it.
  • Re-authentication is an environment fact. A session table the adapters read was the alternative. The identity layer owns the session, and the port stamps the fact on the call.