Type the domain in protocol/domain, add the 17 refusals the core loop gives, and let a caller be a Person or Anonymous
Before adoption: this commit came in with the history the project adopted, so no landing records it.
- packages/protocol/src/domain/*.ts (new, one file per noun): territory, run, check, kind, ask, claim, outcome, answer, credit, landing, proposal, decision, front-page, record, visibility, env, event and policy, per spec 2.3 and 2.5 (minus VisibilityPolicy, 601's). Wire rules hold throughout: Int, optionalKey, DateTimeUtcFromString, ...Ms. Tagged unions are Schema.TaggedUnion, so cases, match and guards exist. Exported as "./domain/*"; "./envelope" exported too. - Decision: the env shape's schema is EnvSchemaView, not EnvShape. The anti-slop no-shape-in-symbol-names rule refuses "shape" in any symbol; the name follows ADR 0009 (the env shape is the .env.schema). Strings keep the word (envShape tag, "env shape" command). Later issues that name the symbol are listed in 201's Comments. - Decision: ProjectEvent members carry seq beside at, so watch can resume with since (W2 index departure 6). - Decision: PolicyInput is Policy minus at, asks, vouches, modules and judge, plus AskInput[]; run is RunBlock | FromCI and deciders may be "owners" (D20), which 203 writes and 204 resolves. The spec's defaults (5/14, 3/2, 2 h/24 h, 30/365, trailer, forCode + vouched.td from Brand.configDir) use withDecodingDefaultKey, since withDecodingDefault wraps Schema.optional, which the Effect traps ban. - Decision: ProjectListing.landedAt is optional (no landing yet), and ClaimRule.record.area is a NonEmptyString like CreditSummary.area. - ids.ts: ProjectName and AskId tightened to single-dash words; AskId refuses me and layer through an annotated filter (gen needs toCode; its JSON Schema is not/enum). New branded ids: LandedSha, TreeSha, BlobSha, PatchId, RequestId, ClaimToken, ProposalId, DecisionId, LandingId, KindName, LayerName, AreaName, LaneName, RatchetName, EnvKey, SuiteRoot, CheckVersion and RepoName (202 has artifacts re-export it). - refusal.ts: DirectPush, AskBlocked and Denounced join Push and claim; ReachedInternals joins Shape; StaleLayer joins Merge; UnstatedRequirement joins Maintainers only; NotDecider and DecisionClosed join Decision; new groups Lookup (UnknownProject, UnknownAsk, UnknownCommit, UnknownDecision), Setup (ProjectExists, ImportFailed) and Env (UnknownEnvItem, NotSensitive, ValueTooShort). retryable and next as spec 2.4 says; AskBlocked.of and ValueTooShort.of (next names the key; the reason names the minimum only, never the value or its length). At moved to domain/common.ts and is re-exported. render.ts has a reason for each; scripts/lib/gen.ts an example for each; docs/reference regenerated. - principal.ts: Principal = Person | Anonymous, tagged, with toTaggedUnion so handlers use Principal.match. asPerson provides a Person. Platform: Sessions.verify returns Option<Person>, and MemorySessions.layer takes a token-to-handle table (D9's shape for SESSION_TOKENS), so platform.ts passes the operator's handle. The 401 gate and verifyCredential behave as before. - envelope.ts: Envelope(data) as spec 4.2, plus type Envelope<A>. - contracts.ts: imports AskListing from domain/ask.ts; nothing else. AskListing gained kind, reserve and blockedBy, so the mcp and cli test fixtures gained them too. - Fence (a tightening): tsconfig.base.json gives packages/protocol/src/domain/** no unstable APIs, so effect/rpc, ai, cli or http there fails typecheck (planted Rpc.make: refused). - Tests, each seen red by assertion first (stubs as Schema.Never): domain.test.ts round-trips 66 hand-written encoded examples from test/fixtures/domain.json (JSON, since anti-slop refuses a literal _tag object in code), refuses five bad values, checks the defaults, the name and id patterns, Principal, Envelope, and that the JSON Schema of Policy, Verdict, Outcome and ProjectEvent has no Infinity, NaN or null. refusal.test.ts pins all 40 tags in union order with their groups and retryable; render.test.ts checks no reason prints undefined, DirectPush's and ValueTooShort's exact text. testing.test.ts (W1 109's ask): asPerson runs calls as its handle, asTester as tester (red with a planted bug). - ASSUMPTION: Reserve "people" is kept as the spec spells it; its meaning is not defined in the sources read, so its doc comment does not guess.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
45 files+5292 added−57 removed
- tests:+2293 added−9 removed
- other:+2999 added−48 removed
Provenance
- Commit
1ae3bb4- Tree
a4b3ebc- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
7486c72
45 files changed+5292 added−57 removed
modified:apps/platform/src/sessions/memory.ts+9 added-4 removed
11234566788910111213141515161718192021222324import type { Principal } from "@repo/protocol/principal";import type { Handle } from "@repo/protocol/ids";import { Person } from "@repo/protocol/principal";import { Effect, Layer, Option } from "effect";
import { Sessions } from "../sessions.ts";
/** Sessions from a fixed table of tokens, for tests and local runs. *//** Sessions from a fixed table of tokens to handles, for tests and local runs. */export const MemorySessions = { layer: (tokens: Readonly<Record<string, Principal>>) => { layer: (tokens: Readonly<Record<string, Handle>>) => { const byToken = new Map(Object.entries(tokens));
return Layer.succeed( Sessions, Sessions.of({ verify: (token) => Effect.succeed(Option.fromNullishOr(byToken.get(token))), Effect.succeed( Option.map(Option.fromNullishOr(byToken.get(token)), (handle) => Person.make({ handle }) ) ), }) ); },};modified:apps/platform/src/platform.ts+1 added-1 removed
34 unmodified lines353637383939404142434434 unmodified lines Effect.map(({ OPERATOR_HANDLE, OPERATOR_TOKEN }) => Layer.mergeAll( Vacant, MemorySessions.layer({ [Redacted.value(OPERATOR_TOKEN)]: { handle: OPERATOR_HANDLE }, [Redacted.value(OPERATOR_TOKEN)]: OPERATOR_HANDLE, }) ) ) ) );modified:apps/platform/src/sessions.ts+2 added-2 removed
112345678991011import type { Principal } from "@repo/protocol/principal";import type { Person } from "@repo/protocol/principal";import { Context } from "effect";import type { Effect, Option } from "effect";
/** Turns a bearer credential into the person it names, if it names anyone. */export class Sessions extends Context.Service< Sessions, { readonly verify: (token: string) => Effect.Effect<Option.Option<Principal>>; readonly verify: (token: string) => Effect.Effect<Option.Option<Person>>; }>()("platform/Sessions") {}modified:apps/platform/test/surfaces.test.ts+8 added-5 removed
1 import { describe, expect, it } from "@effect/vitest";2 import { Contracts } from "@repo/protocol/contracts";3 import { AskId, CommitSha, Handle } from "@repo/protocol/ids";4-import { CurrentPrincipal } from "@repo/protocol/principal";4+import { CurrentPrincipal, Principal } from "@repo/protocol/principal";5 import { NotClaimed } from "@repo/protocol/refusal";6 import { Effect, Layer, Ref } from "effect";7 8 import { MemorySessions } from "../src/sessions/memory.ts";7 unmodified lines16 17 const head = CommitSha.make("3333333333333333333333333333333333333333");18 19 const sessions = MemorySessions.layer({20- "alice-token": { handle: Handle.make("alice") },21- "bob-token": { handle: Handle.make("bob") },20+ "alice-token": Handle.make("alice"),21+ "bob-token": Handle.make("bob"),22 });23 24 /** Contracts where only `holder` holds the ask's claim. */25 const claimHeldBy = (holder: string) =>26 Contracts.toLayer({27 listAsks: () => Effect.succeed({ asks: [] }),28 submitAnswer: (payload) =>29 Effect.gen(function* () {30- const { handle } = yield* CurrentPrincipal;30+ const holds = Principal.match(yield* CurrentPrincipal, {31+ Anonymous: () => false,32+ Person: ({ handle }) => handle === holder,33+ });34 32- if (handle !== holder) {35+ if (!holds) {36 return yield* NotClaimed.of(payload.ask);37 }38 39 return { main };88 unmodified linesmodified:docs/reference/commands.json+12 added-2 removed
12 unmodified lines1314151617171819202124 unmodified lines464748495051525354555657585950606162636427 unmodified lines12 unmodified lines "payloadSchema": { "additionalProperties": true, "properties": { "project": { "pattern": "^[a-z0-9][a-z0-9-]*$", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$", "type": "string" } }, "required": [24 unmodified lines "payloadSchema": { "additionalProperties": true, "properties": { "ask": { "allOf": [ { "not": { "enum": [ "me", "layer" ] } } ], "pattern": "^[a-z0-9][a-z0-9-]*$", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$", "type": "string" }, "base": { "pattern": "^[0-9a-f]{40}$",27 unmodified linesmodified:docs/reference/mcp-tools.md+53 added-3 removed
22 unmodified lines23 {24 "additionalProperties": true,25 "properties": {26 "project": {27- "pattern": "^[a-z0-9][a-z0-9-]*$",27+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",28 "type": "string"29 }30 },31 "required": [13 unmodified lines45 "items": {46 "additionalProperties": true,47 "properties": {48 "ask": {49+ "allOf": [50+ {51+ "not": {52+ "enum": [53+ "me",54+ "layer"55+ ]56+ }57+ }58+ ],49- "pattern": "^[a-z0-9][a-z0-9-]*$",59+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",60 "type": "string"61 },62+ "blockedBy": {63+ "items": {64+ "allOf": [65+ {66+ "not": {67+ "enum": [68+ "me",69+ "layer"70+ ]71+ }72+ }73+ ],74+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",75+ "type": "string"76+ },77+ "type": "array"78+ },79 "claimed": {80 "type": "boolean"81 },82+ "kind": {83+ "pattern": "^[a-z][a-zA-Z0-9-]*$",84+ "type": "string"85+ },86+ "reserve": {87+ "enum": [88+ "newcomers",89+ "people"90+ ],91+ "type": "string"92+ },93 "territory": {94 "minLength": 1,95 "type": "string"96 },3 unmodified lines100 }101 },102 "required": [103 "ask",104+ "blockedBy",105 "claimed",106+ "kind",107 "territory",108 "want"109 ],110 "type": "object"25 unmodified lines136 {137 "additionalProperties": true,138 "properties": {139 "ask": {140+ "allOf": [141+ {142+ "not": {143+ "enum": [144+ "me",145+ "layer"146+ ]147+ }148+ }149+ ],100- "pattern": "^[a-z0-9][a-z0-9-]*$",150+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",151 "type": "string"152 },153 "base": {154 "pattern": "^[0-9a-f]{40}$",33 unmodified linesmodified:docs/reference/protocol.schema.json+1041 added-6 removed
1 {2 "$comment": "Generated by `bun run gen` from packages/protocol. Edit the contracts, not this file.",3 "$defs": {4+ "AskBlockedEncoded": {5+ "additionalProperties": true,6+ "properties": {7+ "_tag": {8+ "enum": [9+ "AskBlocked"10+ ],11+ "type": "string"12+ },13+ "ask": {14+ "allOf": [15+ {16+ "not": {17+ "enum": [18+ "me",19+ "layer"20+ ]21+ }22+ }23+ ],24+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",25+ "type": "string"26+ },27+ "at": {28+ "additionalProperties": true,29+ "properties": {30+ "line": {31+ "minimum": 1,32+ "type": "integer"33+ },34+ "path": {35+ "minLength": 1,36+ "type": "string"37+ }38+ },39+ "required": [40+ "line",41+ "path"42+ ],43+ "type": "object"44+ },45+ "blockedBy": {46+ "items": {47+ "allOf": [48+ {49+ "not": {50+ "enum": [51+ "me",52+ "layer"53+ ]54+ }55+ }56+ ],57+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",58+ "type": "string"59+ },60+ "minItems": 1,61+ "prefixItems": [62+ {63+ "allOf": [64+ {65+ "not": {66+ "enum": [67+ "me",68+ "layer"69+ ]70+ }71+ }72+ ],73+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",74+ "type": "string"75+ }76+ ],77+ "type": "array"78+ },79+ "next": {80+ "minLength": 1,81+ "type": "string"82+ },83+ "retryable": {84+ "enum": [85+ true86+ ],87+ "type": "boolean"88+ }89+ },90+ "required": [91+ "_tag",92+ "next",93+ "retryable",94+ "ask",95+ "blockedBy"96+ ],97+ "type": "object"98+ },99 "AskFullEncoded": {100 "additionalProperties": true,101 "properties": {102 "_tag": {2 unmodified lines105 ],106 "type": "string"107 },108 "ask": {109+ "allOf": [110+ {111+ "not": {112+ "enum": [113+ "me",114+ "layer"115+ ]116+ }117+ }118+ ],14- "pattern": "^[a-z0-9][a-z0-9-]*$",119+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",120 "type": "string"121 },122 "at": {123 "additionalProperties": true,199 unmodified lines323 ],324 "type": "string"325 },326 "ask": {327+ "allOf": [328+ {329+ "not": {330+ "enum": [331+ "me",332+ "layer"333+ ]334+ }335+ }336+ ],222- "pattern": "^[a-z0-9][a-z0-9-]*$",337+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",338 "type": "string"339 },340 "at": {341 "additionalProperties": true,31 unmodified lines373 "ask"374 ],375 "type": "object"376 },377+ "DecisionClosedEncoded": {378+ "additionalProperties": true,379+ "properties": {380+ "_tag": {381+ "enum": [382+ "DecisionClosed"383+ ],384+ "type": "string"385+ },386+ "at": {387+ "additionalProperties": true,388+ "properties": {389+ "line": {390+ "minimum": 1,391+ "type": "integer"392+ },393+ "path": {394+ "minLength": 1,395+ "type": "string"396+ }397+ },398+ "required": [399+ "line",400+ "path"401+ ],402+ "type": "object"403+ },404+ "decision": {405+ "pattern": "^[a-z]+-[0-9a-z]{6,26}$",406+ "type": "string"407+ },408+ "next": {409+ "minLength": 1,410+ "type": "string"411+ },412+ "retryable": {413+ "enum": [414+ false415+ ],416+ "type": "boolean"417+ }418+ },419+ "required": [420+ "_tag",421+ "next",422+ "retryable",423+ "decision"424+ ],425+ "type": "object"426+ },427+ "DenouncedEncoded": {428+ "additionalProperties": true,429+ "properties": {430+ "_tag": {431+ "enum": [432+ "Denounced"433+ ],434+ "type": "string"435+ },436+ "at": {437+ "additionalProperties": true,438+ "properties": {439+ "line": {440+ "minimum": 1,441+ "type": "integer"442+ },443+ "path": {444+ "minLength": 1,445+ "type": "string"446+ }447+ },448+ "required": [449+ "line",450+ "path"451+ ],452+ "type": "object"453+ },454+ "next": {455+ "minLength": 1,456+ "type": "string"457+ },458+ "retryable": {459+ "enum": [460+ false461+ ],462+ "type": "boolean"463+ }464+ },465+ "required": [466+ "_tag",467+ "next",468+ "retryable"469+ ],470+ "type": "object"471+ },472+ "DirectPushEncoded": {473+ "additionalProperties": true,474+ "properties": {475+ "_tag": {476+ "enum": [477+ "DirectPush"478+ ],479+ "type": "string"480+ },481+ "at": {482+ "additionalProperties": true,483+ "properties": {484+ "line": {485+ "minimum": 1,486+ "type": "integer"487+ },488+ "path": {489+ "minLength": 1,490+ "type": "string"491+ }492+ },493+ "required": [494+ "line",495+ "path"496+ ],497+ "type": "object"498+ },499+ "next": {500+ "minLength": 1,501+ "type": "string"502+ },503+ "ref": {504+ "minLength": 1,505+ "type": "string"506+ },507+ "retryable": {508+ "enum": [509+ false510+ ],511+ "type": "boolean"512+ }513+ },514+ "required": [515+ "_tag",516+ "next",517+ "retryable",518+ "ref"519+ ],520+ "type": "object"521+ },522 "FlakeEncoded": {523 "additionalProperties": true,524 "properties": {525 "_tag": {97 unmodified lines623 "suite"624 ],625 "type": "object"626 },627+ "ImportFailedEncoded": {628+ "additionalProperties": true,629+ "properties": {630+ "_tag": {631+ "enum": [632+ "ImportFailed"633+ ],634+ "type": "string"635+ },636+ "at": {637+ "additionalProperties": true,638+ "properties": {639+ "line": {640+ "minimum": 1,641+ "type": "integer"642+ },643+ "path": {644+ "minLength": 1,645+ "type": "string"646+ }647+ },648+ "required": [649+ "line",650+ "path"651+ ],652+ "type": "object"653+ },654+ "next": {655+ "minLength": 1,656+ "type": "string"657+ },658+ "reason": {659+ "minLength": 1,660+ "type": "string"661+ },662+ "retryable": {663+ "enum": [664+ true665+ ],666+ "type": "boolean"667+ }668+ },669+ "required": [670+ "_tag",671+ "next",672+ "retryable",673+ "reason"674+ ],675+ "type": "object"676+ },677 "IncompleteBriefEncoded": {678 "additionalProperties": true,679 "properties": {680 "_tag": {167 unmodified lines848 ],849 "type": "string"850 },851 "ask": {852+ "allOf": [853+ {854+ "not": {855+ "enum": [856+ "me",857+ "layer"858+ ]859+ }860+ }861+ ],542- "pattern": "^[a-z0-9][a-z0-9-]*$",862+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",863 "type": "string"864 },865 "at": {866 "additionalProperties": true,31 unmodified lines898 "ask"899 ],900 "type": "object"901 },902+ "NotDeciderEncoded": {903+ "additionalProperties": true,904+ "properties": {905+ "_tag": {906+ "enum": [907+ "NotDecider"908+ ],909+ "type": "string"910+ },911+ "at": {912+ "additionalProperties": true,913+ "properties": {914+ "line": {915+ "minimum": 1,916+ "type": "integer"917+ },918+ "path": {919+ "minLength": 1,920+ "type": "string"921+ }922+ },923+ "required": [924+ "line",925+ "path"926+ ],927+ "type": "object"928+ },929+ "next": {930+ "minLength": 1,931+ "type": "string"932+ },933+ "retryable": {934+ "enum": [935+ false936+ ],937+ "type": "boolean"938+ }939+ },940+ "required": [941+ "_tag",942+ "next",943+ "retryable"944+ ],945+ "type": "object"946+ },947 "NotRedFirstEncoded": {948 "additionalProperties": true,949 "properties": {950 "_tag": {37 unmodified lines988 "retryable"989 ],990 "type": "object"991 },992+ "NotSensitiveEncoded": {993+ "additionalProperties": true,994+ "properties": {995+ "_tag": {996+ "enum": [997+ "NotSensitive"998+ ],999+ "type": "string"1000+ },1001+ "at": {1002+ "additionalProperties": true,1003+ "properties": {1004+ "line": {1005+ "minimum": 1,1006+ "type": "integer"1007+ },1008+ "path": {1009+ "minLength": 1,1010+ "type": "string"1011+ }1012+ },1013+ "required": [1014+ "line",1015+ "path"1016+ ],1017+ "type": "object"1018+ },1019+ "key": {1020+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",1021+ "type": "string"1022+ },1023+ "next": {1024+ "minLength": 1,1025+ "type": "string"1026+ },1027+ "retryable": {1028+ "enum": [1029+ false1030+ ],1031+ "type": "boolean"1032+ }1033+ },1034+ "required": [1035+ "_tag",1036+ "next",1037+ "retryable",1038+ "key"1039+ ],1040+ "type": "object"1041+ },1042 "NotVouchedEncoded": {1043 "additionalProperties": true,1044 "properties": {1045 "_tag": {224 unmodified lines1270 "paths"1271 ],1272 "type": "object"1273 },1274+ "ProjectExistsEncoded": {1275+ "additionalProperties": true,1276+ "properties": {1277+ "_tag": {1278+ "enum": [1279+ "ProjectExists"1280+ ],1281+ "type": "string"1282+ },1283+ "at": {1284+ "additionalProperties": true,1285+ "properties": {1286+ "line": {1287+ "minimum": 1,1288+ "type": "integer"1289+ },1290+ "path": {1291+ "minLength": 1,1292+ "type": "string"1293+ }1294+ },1295+ "required": [1296+ "line",1297+ "path"1298+ ],1299+ "type": "object"1300+ },1301+ "next": {1302+ "minLength": 1,1303+ "type": "string"1304+ },1305+ "project": {1306+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",1307+ "type": "string"1308+ },1309+ "retryable": {1310+ "enum": [1311+ false1312+ ],1313+ "type": "boolean"1314+ }1315+ },1316+ "required": [1317+ "_tag",1318+ "next",1319+ "retryable",1320+ "project"1321+ ],1322+ "type": "object"1323+ },1324+ "ReachedInternalsEncoded": {1325+ "additionalProperties": true,1326+ "properties": {1327+ "_tag": {1328+ "enum": [1329+ "ReachedInternals"1330+ ],1331+ "type": "string"1332+ },1333+ "at": {1334+ "additionalProperties": true,1335+ "properties": {1336+ "line": {1337+ "minimum": 1,1338+ "type": "integer"1339+ },1340+ "path": {1341+ "minLength": 1,1342+ "type": "string"1343+ }1344+ },1345+ "required": [1346+ "line",1347+ "path"1348+ ],1349+ "type": "object"1350+ },1351+ "from": {1352+ "minLength": 1,1353+ "type": "string"1354+ },1355+ "next": {1356+ "minLength": 1,1357+ "type": "string"1358+ },1359+ "retryable": {1360+ "enum": [1361+ false1362+ ],1363+ "type": "boolean"1364+ },1365+ "to": {1366+ "minLength": 1,1367+ "type": "string"1368+ }1369+ },1370+ "required": [1371+ "_tag",1372+ "next",1373+ "retryable",1374+ "from",1375+ "to"1376+ ],1377+ "type": "object"1378+ },1379 "Refusal": {1380 "anyOf": [1381 {1382 "$ref": "#/$defs/NotClaimedEncoded"16 unmodified lines1399 {1400 "$ref": "#/$defs/RepoBusyEncoded"1401 },1402 {1403+ "$ref": "#/$defs/DirectPushEncoded"1404+ },1405+ {1406+ "$ref": "#/$defs/AskBlockedEncoded"1407+ },1408+ {1409+ "$ref": "#/$defs/DenouncedEncoded"1410+ },1411+ {1412 "$ref": "#/$defs/OutOfScopeEncoded"1413 },1414 {1415 "$ref": "#/$defs/TouchedJudgeEncoded"4 unmodified lines1420 {1421 "$ref": "#/$defs/PrivatePathInPublicTreeEncoded"1422 },1423 {1424+ "$ref": "#/$defs/ReachedInternalsEncoded"1425+ },1426+ {1427 "$ref": "#/$defs/StaleBaseEncoded"1428 },1429 {1430+ "$ref": "#/$defs/StaleLayerEncoded"1431+ },1432+ {1433 "$ref": "#/$defs/ChecksFailedEncoded"1434 },1435 {1436 "$ref": "#/$defs/HeldBackFailedEncoded"22 unmodified lines1459 {1460 "$ref": "#/$defs/SecretInOutputEncoded"1461 },1462 {1463+ "$ref": "#/$defs/UnstatedRequirementEncoded"1464+ },1465+ {1466 "$ref": "#/$defs/PostureChangeEncoded"1467+ },1468+ {1469+ "$ref": "#/$defs/NotDeciderEncoded"1470+ },1471+ {1472+ "$ref": "#/$defs/DecisionClosedEncoded"1473+ },1474+ {1475+ "$ref": "#/$defs/UnknownProjectEncoded"1476+ },1477+ {1478+ "$ref": "#/$defs/UnknownAskEncoded"1479+ },1480+ {1481+ "$ref": "#/$defs/UnknownCommitEncoded"1482+ },1483+ {1484+ "$ref": "#/$defs/UnknownDecisionEncoded"1485+ },1486+ {1487+ "$ref": "#/$defs/ProjectExistsEncoded"1488+ },1489+ {1490+ "$ref": "#/$defs/ImportFailedEncoded"1491+ },1492+ {1493+ "$ref": "#/$defs/UnknownEnvItemEncoded"1494+ },1495+ {1496+ "$ref": "#/$defs/NotSensitiveEncoded"1497+ },1498+ {1499+ "$ref": "#/$defs/ValueTooShortEncoded"1500 }1501 ]1502 },1503 "RepoBusyEncoded": {161 unmodified lines1665 "main"1666 ],1667 "type": "object"1668 },1669+ "StaleLayerEncoded": {1670+ "additionalProperties": true,1671+ "properties": {1672+ "_tag": {1673+ "enum": [1674+ "StaleLayer"1675+ ],1676+ "type": "string"1677+ },1678+ "at": {1679+ "additionalProperties": true,1680+ "properties": {1681+ "line": {1682+ "minimum": 1,1683+ "type": "integer"1684+ },1685+ "path": {1686+ "minLength": 1,1687+ "type": "string"1688+ }1689+ },1690+ "required": [1691+ "line",1692+ "path"1693+ ],1694+ "type": "object"1695+ },1696+ "layer": {1697+ "minLength": 1,1698+ "type": "string"1699+ },1700+ "next": {1701+ "minLength": 1,1702+ "type": "string"1703+ },1704+ "retryable": {1705+ "enum": [1706+ true1707+ ],1708+ "type": "boolean"1709+ }1710+ },1711+ "required": [1712+ "_tag",1713+ "next",1714+ "retryable",1715+ "layer"1716+ ],1717+ "type": "object"1718+ },1719 "TouchedJudgeEncoded": {1720 "additionalProperties": true,1721 "properties": {1722 "_tag": {52 unmodified lines1775 "paths"1776 ],1777 "type": "object"1778 },1779+ "UnknownAskEncoded": {1780+ "additionalProperties": true,1781+ "properties": {1782+ "_tag": {1783+ "enum": [1784+ "UnknownAsk"1785+ ],1786+ "type": "string"1787+ },1788+ "ask": {1789+ "allOf": [1790+ {1791+ "not": {1792+ "enum": [1793+ "me",1794+ "layer"1795+ ]1796+ }1797+ }1798+ ],1799+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",1800+ "type": "string"1801+ },1802+ "at": {1803+ "additionalProperties": true,1804+ "properties": {1805+ "line": {1806+ "minimum": 1,1807+ "type": "integer"1808+ },1809+ "path": {1810+ "minLength": 1,1811+ "type": "string"1812+ }1813+ },1814+ "required": [1815+ "line",1816+ "path"1817+ ],1818+ "type": "object"1819+ },1820+ "next": {1821+ "minLength": 1,1822+ "type": "string"1823+ },1824+ "retryable": {1825+ "enum": [1826+ false1827+ ],1828+ "type": "boolean"1829+ }1830+ },1831+ "required": [1832+ "_tag",1833+ "next",1834+ "retryable",1835+ "ask"1836+ ],1837+ "type": "object"1838+ },1839+ "UnknownCommitEncoded": {1840+ "additionalProperties": true,1841+ "properties": {1842+ "_tag": {1843+ "enum": [1844+ "UnknownCommit"1845+ ],1846+ "type": "string"1847+ },1848+ "at": {1849+ "additionalProperties": true,1850+ "properties": {1851+ "line": {1852+ "minimum": 1,1853+ "type": "integer"1854+ },1855+ "path": {1856+ "minLength": 1,1857+ "type": "string"1858+ }1859+ },1860+ "required": [1861+ "line",1862+ "path"1863+ ],1864+ "type": "object"1865+ },1866+ "next": {1867+ "minLength": 1,1868+ "type": "string"1869+ },1870+ "retryable": {1871+ "enum": [1872+ false1873+ ],1874+ "type": "boolean"1875+ },1876+ "sha": {1877+ "pattern": "^[0-9a-f]{40}$",1878+ "type": "string"1879+ }1880+ },1881+ "required": [1882+ "_tag",1883+ "next",1884+ "retryable",1885+ "sha"1886+ ],1887+ "type": "object"1888+ },1889+ "UnknownDecisionEncoded": {1890+ "additionalProperties": true,1891+ "properties": {1892+ "_tag": {1893+ "enum": [1894+ "UnknownDecision"1895+ ],1896+ "type": "string"1897+ },1898+ "at": {1899+ "additionalProperties": true,1900+ "properties": {1901+ "line": {1902+ "minimum": 1,1903+ "type": "integer"1904+ },1905+ "path": {1906+ "minLength": 1,1907+ "type": "string"1908+ }1909+ },1910+ "required": [1911+ "line",1912+ "path"1913+ ],1914+ "type": "object"1915+ },1916+ "decision": {1917+ "pattern": "^[a-z]+-[0-9a-z]{6,26}$",1918+ "type": "string"1919+ },1920+ "next": {1921+ "minLength": 1,1922+ "type": "string"1923+ },1924+ "retryable": {1925+ "enum": [1926+ false1927+ ],1928+ "type": "boolean"1929+ }1930+ },1931+ "required": [1932+ "_tag",1933+ "next",1934+ "retryable",1935+ "decision"1936+ ],1937+ "type": "object"1938+ },1939+ "UnknownEnvItemEncoded": {1940+ "additionalProperties": true,1941+ "properties": {1942+ "_tag": {1943+ "enum": [1944+ "UnknownEnvItem"1945+ ],1946+ "type": "string"1947+ },1948+ "at": {1949+ "additionalProperties": true,1950+ "properties": {1951+ "line": {1952+ "minimum": 1,1953+ "type": "integer"1954+ },1955+ "path": {1956+ "minLength": 1,1957+ "type": "string"1958+ }1959+ },1960+ "required": [1961+ "line",1962+ "path"1963+ ],1964+ "type": "object"1965+ },1966+ "key": {1967+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",1968+ "type": "string"1969+ },1970+ "next": {1971+ "minLength": 1,1972+ "type": "string"1973+ },1974+ "retryable": {1975+ "enum": [1976+ false1977+ ],1978+ "type": "boolean"1979+ }1980+ },1981+ "required": [1982+ "_tag",1983+ "next",1984+ "retryable",1985+ "key"1986+ ],1987+ "type": "object"1988+ },1989+ "UnknownProjectEncoded": {1990+ "additionalProperties": true,1991+ "properties": {1992+ "_tag": {1993+ "enum": [1994+ "UnknownProject"1995+ ],1996+ "type": "string"1997+ },1998+ "at": {1999+ "additionalProperties": true,2000+ "properties": {2001+ "line": {2002+ "minimum": 1,2003+ "type": "integer"2004+ },2005+ "path": {2006+ "minLength": 1,2007+ "type": "string"2008+ }2009+ },2010+ "required": [2011+ "line",2012+ "path"2013+ ],2014+ "type": "object"2015+ },2016+ "next": {2017+ "minLength": 1,2018+ "type": "string"2019+ },2020+ "project": {2021+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",2022+ "type": "string"2023+ },2024+ "retryable": {2025+ "enum": [2026+ false2027+ ],2028+ "type": "boolean"2029+ }2030+ },2031+ "required": [2032+ "_tag",2033+ "next",2034+ "retryable",2035+ "project"2036+ ],2037+ "type": "object"2038+ },2039+ "UnstatedRequirementEncoded": {2040+ "additionalProperties": true,2041+ "properties": {2042+ "_tag": {2043+ "enum": [2044+ "UnstatedRequirement"2045+ ],2046+ "type": "string"2047+ },2048+ "area": {2049+ "minLength": 1,2050+ "type": "string"2051+ },2052+ "at": {2053+ "additionalProperties": true,2054+ "properties": {2055+ "line": {2056+ "minimum": 1,2057+ "type": "integer"2058+ },2059+ "path": {2060+ "minLength": 1,2061+ "type": "string"2062+ }2063+ },2064+ "required": [2065+ "line",2066+ "path"2067+ ],2068+ "type": "object"2069+ },2070+ "next": {2071+ "minLength": 1,2072+ "type": "string"2073+ },2074+ "retryable": {2075+ "enum": [2076+ false2077+ ],2078+ "type": "boolean"2079+ }2080+ },2081+ "required": [2082+ "_tag",2083+ "next",2084+ "retryable",2085+ "area"2086+ ],2087+ "type": "object"2088+ },2089+ "ValueTooShortEncoded": {2090+ "additionalProperties": true,2091+ "properties": {2092+ "_tag": {2093+ "enum": [2094+ "ValueTooShort"2095+ ],2096+ "type": "string"2097+ },2098+ "at": {2099+ "additionalProperties": true,2100+ "properties": {2101+ "line": {2102+ "minimum": 1,2103+ "type": "integer"2104+ },2105+ "path": {2106+ "minLength": 1,2107+ "type": "string"2108+ }2109+ },2110+ "required": [2111+ "line",2112+ "path"2113+ ],2114+ "type": "object"2115+ },2116+ "key": {2117+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",2118+ "type": "string"2119+ },2120+ "minimum": {2121+ "type": "integer"2122+ },2123+ "next": {2124+ "minLength": 1,2125+ "type": "string"2126+ },2127+ "retryable": {2128+ "enum": [2129+ false2130+ ],2131+ "type": "boolean"2132+ }2133+ },2134+ "required": [2135+ "_tag",2136+ "next",2137+ "retryable",2138+ "key",2139+ "minimum"2140+ ],2141+ "type": "object"2142+ },2143 "VerifierBlockedEncoded": {2144 "additionalProperties": true,2145 "properties": {2146 "_tag": {187 unmodified lines2334 "listAsks.payload": {2335 "additionalProperties": true,2336 "properties": {2337 "project": {1353- "pattern": "^[a-z0-9][a-z0-9-]*$",2338+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",2339 "type": "string"2340 }2341 },2342 "required": [8 unmodified lines2351 "items": {2352 "additionalProperties": true,2353 "properties": {2354 "ask": {2355+ "allOf": [2356+ {2357+ "not": {2358+ "enum": [2359+ "me",2360+ "layer"2361+ ]2362+ }2363+ }2364+ ],1370- "pattern": "^[a-z0-9][a-z0-9-]*$",2365+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",2366 "type": "string"2367 },2368+ "blockedBy": {2369+ "items": {2370+ "allOf": [2371+ {2372+ "not": {2373+ "enum": [2374+ "me",2375+ "layer"2376+ ]2377+ }2378+ }2379+ ],2380+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",2381+ "type": "string"2382+ },2383+ "type": "array"2384+ },2385 "claimed": {2386 "type": "boolean"2387 },2388+ "kind": {2389+ "pattern": "^[a-z][a-zA-Z0-9-]*$",2390+ "type": "string"2391+ },2392+ "reserve": {2393+ "enum": [2394+ "newcomers",2395+ "people"2396+ ],2397+ "type": "string"2398+ },2399 "territory": {2400 "minLength": 1,2401 "type": "string"2402 },3 unmodified lines2406 }2407 },2408 "required": [2409 "ask",2410+ "blockedBy",2411 "claimed",2412+ "kind",2413 "territory",2414 "want"2415 ],2416 "type": "object"25 unmodified lines2442 "submitAnswer.payload": {2443 "additionalProperties": true,2444 "properties": {2445 "ask": {2446+ "allOf": [2447+ {2448+ "not": {2449+ "enum": [2450+ "me",2451+ "layer"2452+ ]2453+ }2454+ }2455+ ],1421- "pattern": "^[a-z0-9][a-z0-9-]*$",2456+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",2457 "type": "string"2458 },2459 "base": {2460 "pattern": "^[0-9a-f]{40}$",31 unmodified linesmodified:docs/reference/refusals.md+143 added
64 unmodified lines65 - Next: `git push`66 - Fields: none67 - Reason, for example: the repo was busy with another push68 69+### DirectPush70+71+- Retryable: no72+- Next: `myr asks`73+- Fields:74+ - `ref`: `string`75+- Reason, for example: main moves only by a landing, so refs/heads/main takes no direct push; push your answer to your claim's fork76+77+### AskBlocked78+79+- Retryable: yes80+- Next: `myr asks`81+- Fields:82+ - `ask`: `string`83+ - `blockedBy`: `readonly [string, ...Array<string>]`84+- Reason, for example: fix-parser waits on drop-moment to land first85+86+### Denounced87+88+- Retryable: no89+- Next: `myr status`90+- Fields: none91+- Reason, for example: this project's vouch file denounces you, so it takes no claims or proposals from you92+93 ## Shape94 95 ### OutOfScope96 26 unmodified lines123 - Fields:124 - `paths`: `readonly [string, ...Array<string>]`125 - Reason, for example: would put held-back paths in a public tree: src/a.ts126 127+### ReachedInternals128+129+- Retryable: no130+- Next: `myr check`131+- Fields:132+ - `from`: `string`133+ - `to`: `string`134+- Reason, for example: src/a.ts reaches into @datekit/format/src/internal.ts, which its module does not export135+136 ## Merge137 138 ### StaleBase139 4 unmodified lines144 - `conflicts`: `ReadonlyArray<string>`145 - `main`: `string`146 - Reason, for example: main moved to 2222222, past your base 1111111; conflicts in src/a.ts147 148+### StaleLayer149+150+- Retryable: yes151+- Next: `myr status`152+- Fields:153+ - `layer`: `string`154+- Reason, for example: the maintainers layer moved since this answer was checked; it will be checked again155+156 ## Checks157 158 ### ChecksFailed159 82 unmodified lines242 - `item`: `string`243 - `where`: `"output" | "tree"`244 - Reason, for example: the write-only value PAYMENTS_KEY appeared in the output245 246+### UnstatedRequirement247+248+- Retryable: no249+- Next: `myr check`250+- Fields:251+ - `area`: `string`252+- Reason, for example: a held-back check in parser enforces something no public clause states253+254 ## Decision255 256 ### PostureChange257 2 unmodified lines260 - Fields:261 - `from`: `"open" | "openWithSealedEvidence" | "openOnSchedule" | "openCore" | "sourceAvailable"`262 - `to`: `"open" | "openWithSealedEvidence" | "openOnSchedule" | "openCore" | "sourceAvailable"`263 - Reason, for example: landing would change the posture from open to openCore, which takes a decider264+265+### NotDecider266+267+- Retryable: no268+- Next: `myr status`269+- Fields: none270+- Reason, for example: only one of this project's deciders may do this271+272+### DecisionClosed273+274+- Retryable: no275+- Next: `myr today`276+- Fields:277+ - `decision`: `string`278+- Reason, for example: dec-000001 was already decided, or expired to its default279+280+## Lookup281+282+### UnknownProject283+284+- Retryable: no285+- Next: `myr asks`286+- Fields:287+ - `project`: `string`288+- Reason, for example: no project is named datekit289+290+### UnknownAsk291+292+- Retryable: no293+- Next: `myr asks`294+- Fields:295+ - `ask`: `string`296+- Reason, for example: this project has no ask named fix-parser297+298+### UnknownCommit299+300+- Retryable: no301+- Next: `git fetch`302+- Fields:303+ - `sha`: `string`304+- Reason, for example: this project has no commit 2222222222222222222222222222222222222222305+306+### UnknownDecision307+308+- Retryable: no309+- Next: `myr today`310+- Fields:311+ - `decision`: `string`312+- Reason, for example: this project has no decision dec-000001313+314+## Setup315+316+### ProjectExists317+318+- Retryable: no319+- Next: `myr asks`320+- Fields:321+ - `project`: `string`322+- Reason, for example: a project named datekit already exists323+324+### ImportFailed325+326+- Retryable: yes327+- Next: `myr init`328+- Fields:329+ - `reason`: `string`330+- Reason, for example: the import failed: the repo needs a sign-in to read331+332+## Env333+334+### UnknownEnvItem335+336+- Retryable: no337+- Next: `myr env shape`338+- Fields:339+ - `key`: `string`340+- Reason, for example: the env shape has no item PAYMENTS_KEY341+342+### NotSensitive343+344+- Retryable: no345+- Next: `myr env shape`346+- Fields:347+ - `key`: `string`348+- Reason, for example: PAYMENTS_KEY is not @sensitive, so it holds no write-only value349+350+### ValueTooShort351+352+- Retryable: no353+- Next: set when it is raised354+- Fields:355+ - `key`: `string`356+ - `minimum`: `number`357+- Reason, for example: the value for PAYMENTS_KEY is shorter than the 32 characters it needsadded:packages/protocol/src/domain/answer.ts+102 added
1+import { Schema } from "effect";2+3+import {4+ AreaName,5+ AskId,6+ CheckVersion,7+ CommitSha,8+ LaneName,9+ PatchId,10+ ProjectName,11+ RequestId,12+ SuiteRoot,13+ TreeSha,14+} from "../ids.ts";15+import { Outcome, StageName } from "./outcome.ts";16+17+/** How one lane's run ended. A load error is not a failure by an assertion. */18+export const LaneOutcome = Schema.Literals([19+ "passed",20+ "failed",21+ "loadError",22+ "flaked",23+ "blocked",24+]);25+26+export type LaneOutcome = typeof LaneOutcome.Type;27+28+/** One lane of the project's checks, run on an answer's merged tree. */29+export const LaneResult = Schema.Struct({30+ command: Schema.NonEmptyString,31+ durationMs: Schema.Int,32+ lane: LaneName,33+ /** Where the platform keeps the log; an answerer reads it through the platform, never raw. */34+ logRef: Schema.optionalKey(Schema.NonEmptyString),35+ result: LaneOutcome,36+});37+38+export type LaneResult = typeof LaneResult.Type;39+40+/**41+ * Held-back checks in one area: how many passed, of how many, under which42+ * commitment. Nothing else about them is disclosed.43+ */44+export const HeldBackResult = Schema.Struct({45+ area: AreaName,46+ passed: Schema.Int,47+ suite: SuiteRoot,48+ total: Schema.Int,49+});50+51+export type HeldBackResult = typeof HeldBackResult.Type;52+53+/**54+ * The record of one check run on an answer: base, head, the merged tree, the55+ * patch id, the check version and the platform as verifier, with each lane56+ * and the outcome. It is kept with the landing.57+ */58+export const Verdict = Schema.Struct({59+ ask: AskId,60+ at: Schema.DateTimeUtcFromString,61+ base: CommitSha,62+ checkVersion: CheckVersion,63+ head: CommitSha,64+ heldBack: Schema.Array(HeldBackResult),65+ lanes: Schema.Array(LaneResult),66+ outcome: Outcome,67+ patchId: PatchId,68+ project: ProjectName,69+ /** The furthest stage the answer reached. */70+ stage: StageName,71+ /** The merged tree the checks ran on. */72+ tree: TreeSha,73+ verifier: Schema.Literal("platform"),74+});75+76+export type Verdict = typeof Verdict.Type;77+78+/**79+ * What an answerer gets back on offering an answer: the request, and where80+ * the answer stands, usually still being checked.81+ */82+export const AnswerReceipt = Schema.Struct({83+ ask: AskId,84+ base: CommitSha,85+ head: CommitSha,86+ outcome: Outcome,87+ project: ProjectName,88+ requestId: RequestId,89+});90+91+export type AnswerReceipt = typeof AnswerReceipt.Type;92+93+/** One of a person's answers, as their status shows it. */94+export const AnswerView = Schema.Struct({95+ ask: AskId,96+ at: Schema.DateTimeUtcFromString,97+ head: CommitSha,98+ outcome: Outcome,99+ requestId: RequestId,100+});101+102+export type AnswerView = typeof AnswerView.Type;added:packages/protocol/src/domain/ask.ts+85 added
1+import { Schema } from "effect";2+3+import {4+ AskId,5+ Handle,6+ KindName,7+ LandedSha,8+ ProjectName,9+ RepoPath,10+} from "../ids.ts";11+import { CheckSpec } from "./check.ts";12+import { Territory } from "./territory.ts";13+14+/**15+ * An ask's brief: what an answerer reads first. The want is behavioural; it16+ * names no file and no line.17+ */18+export const Brief = Schema.Struct({19+ context: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),20+ /** What happens on main today. */21+ current: Schema.optionalKey(Schema.NonEmptyString),22+ outOfScope: Schema.optionalKey(Schema.NonEmptyArray(Schema.NonEmptyString)),23+ /** Words the ask uses in its project's sense. */24+ terms: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),25+ want: Schema.NonEmptyString,26+});27+28+export type Brief = typeof Brief.Type;29+30+/** Where an ask stands: open, claimed, waiting on its parent, or closed. */31+export const AskState = Schema.Literals([32+ "open",33+ "claimed",34+ "waitingOnParent",35+ "closed",36+]);37+38+export type AskState = typeof AskState.Type;39+40+/** Who an ask is held for, when it is held for someone: `newcomers` (with a mentor) or `people`. */41+export const Reserve = Schema.Literals(["newcomers", "people"]);42+43+export type Reserve = typeof Reserve.Type;44+45+/**46+ * An ask: a file on main in which a project states one change it wants, with47+ * a behavioural want, a territory, and a check that fails on main.48+ */49+export const Ask = Schema.Struct({50+ askedBy: Handle,51+ /** Asks that must land first, as a migrate's last step waits on its siblings. */52+ blockedBy: Schema.Array(AskId),53+ brief: Brief,54+ check: CheckSpec,55+ /** The ask's file on main, in the config folder's `asks/`. */56+ file: RepoPath,57+ id: AskId,58+ kind: KindName,59+ mentor: Schema.optionalKey(Handle),60+ openedAt: Schema.DateTimeUtcFromString,61+ /** The landing that opened it. */62+ openedIn: LandedSha,63+ /** The migrate ask this one is a step of. */64+ parent: Schema.optionalKey(AskId),65+ project: ProjectName,66+ reserve: Schema.optionalKey(Reserve),67+ state: AskState,68+ territory: Territory,69+});70+71+export type Ask = typeof Ask.Type;72+73+/** One open ask, as a list of asks shows it. */74+export const AskListing = Schema.Struct({75+ ask: AskId,76+ blockedBy: Schema.Array(AskId),77+ claimed: Schema.Boolean,78+ kind: KindName,79+ reserve: Schema.optionalKey(Reserve),80+ /** The territory's module. */81+ territory: Schema.NonEmptyString,82+ want: Schema.NonEmptyString,83+});84+85+export type AskListing = typeof AskListing.Type;added:packages/protocol/src/domain/check.ts+62 added
1+import { Schema } from "effect";2+3+import { RatchetName, RepoPath } from "../ids.ts";4+import { Command, JsonPath, SymbolName } from "./common.ts";5+6+/**7+ * An ask's check: what judges an answer to it, by check kind. `RedThenGreen`8+ * runs the run block's `test` on one file; the others count something with a9+ * command of the project's own.10+ */11+export const CheckSpec = Schema.TaggedUnion({12+ /** A lint rule's count goes to zero in the territory. */13+ LintToZero: {14+ command: Command,15+ rule: Schema.NonEmptyString,16+ territory: Schema.optionalKey(Schema.NonEmptyString),17+ },18+ /** Every use of `from` moves to `to`; `count` prints `{"total": n, "byModule": {...}}`. */19+ Migrate: {20+ count: Command,21+ from: SymbolName,22+ to: Schema.optionalKey(SymbolName),23+ },24+ /** A named ratchet goes down. */25+ Ratchet: { ratchet: RatchetName },26+ /** One check file fails on main by an assertion, and passes on the answer. */27+ RedThenGreen: { path: RepoPath },28+ /** The last step of a migrate: `symbol` is gone. */29+ SymbolAbsent: { count: Command, symbol: SymbolName },30+});31+32+export type CheckSpec = typeof CheckSpec.Type;33+34+/**35+ * How strong an ask's check must be: failing on main by an assertion, or36+ * also failing a null answer.37+ */38+export const Strength = Schema.Literals(["assertion", "nullAnswer"]);39+40+export type Strength = typeof Strength.Type;41+42+/** How a ratchet measures its number: a lint count, or a number in a command's JSON. */43+export const RatchetMeasure = Schema.TaggedUnion({44+ /** Counts lint findings from oxlint or ESLint JSON, for one rule or all. */45+ Count: { command: Command, rule: Schema.optionalKey(Schema.NonEmptyString) },46+ /** Reads one number at `path` in the command's JSON output. */47+ Metric: { command: Command, path: JsonPath },48+});49+50+export type RatchetMeasure = typeof RatchetMeasure.Type;51+52+/**53+ * A ratchet: a counted budget per territory that answers may lower and never54+ * raise; only a decider raises it.55+ */56+export const RatchetSpec = Schema.Struct({57+ measure: RatchetMeasure,58+ name: RatchetName,59+ territory: Schema.optionalKey(Schema.NonEmptyString),60+});61+62+export type RatchetSpec = typeof RatchetSpec.Type;added:packages/protocol/src/domain/claim.ts+51 added
1+import { Schema } from "effect";2+3+import {4+ AskId,5+ CommitSha,6+ Handle,7+ ProjectName,8+ RepoName,9+ SuiteRoot,10+} from "../ids.ts";11+12+/**13+ * Where a claim stands. A live claim is warned after a quiet spell and14+ * lapses after a longer one; only a push keeps it alive.15+ */16+export const ClaimState = Schema.Literals([17+ "live",18+ "warned",19+ "lapsed",20+ "released",21+ "answered",22+]);23+24+export type ClaimState = typeof ClaimState.Type;25+26+/**27+ * A claim, as its claimant sees it: one person's exclusive, expiring right to28+ * answer an ask, with the fork to push to and when it lapses.29+ */30+export const ClaimView = Schema.Struct({31+ ask: AskId,32+ /** Main's landed commit when the claim was made. */33+ base: CommitSha,34+ /** What `<cli> check` runs locally for this ask. */35+ checkCommand: Schema.NonEmptyString,36+ claimant: Handle,37+ /** The claim's fork: `<project>--<ask>--<handle in lowercase>`. */38+ fork: RepoName,39+ lapsesAt: Schema.DateTimeUtcFromString,40+ lastPushAt: Schema.optionalKey(Schema.DateTimeUtcFromString),41+ openedAt: Schema.DateTimeUtcFromString,42+ project: ProjectName,43+ /** The fork's URL at the gateway; never a storage URL. */44+ remote: Schema.NonEmptyString,45+ state: ClaimState,46+ /** The held-back suite pinned when the claim was made. */47+ suite: Schema.optionalKey(SuiteRoot),48+ warnsAt: Schema.DateTimeUtcFromString,49+});50+51+export type ClaimView = typeof ClaimView.Type;added:packages/protocol/src/domain/common.ts+78 added
1+/**2+ * Small schemas the domain's nouns share. Like every file in `domain/`, this3+ * one imports only `effect` and sibling protocol files, never the RPC stack,4+ * so the SDK and the rules sandbox can load it.5+ */6+import { Schema } from "effect";7+8+import { RepoPath } from "../ids.ts";9+10+/** A path pattern in a repo, as the config folder writes one: `packages/parse/**`. */11+export const Glob = Schema.NonEmptyString.pipe(Schema.brand("Glob"));12+13+export type Glob = typeof Glob.Type;14+15+/**16+ * One of the project's own commands, as its maintainers write it in the run17+ * block: `bun test {path}`. The platform runs it; it never rewrites it.18+ */19+export const Command = Schema.NonEmptyString.pipe(Schema.brand("Command"));20+21+export type Command = typeof Command.Type;22+23+/** A host a check's setup may reach, or an env item's proxy may serve: `registry.npmjs.org`. */24+export const Hostname = Schema.String.pipe(25+ Schema.check(26+ Schema.isPattern(27+ /^(?:\*\.)?[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*$/u28+ )29+ ),30+ Schema.brand("Hostname")31+);32+33+export type Hostname = typeof Hostname.Type;34+35+/** Where a ratchet reads its number in a command's JSON output: `/total/lines`. */36+export const JsonPath = Schema.NonEmptyString.pipe(Schema.brand("JsonPath"));37+38+export type JsonPath = typeof JsonPath.Type;39+40+/**41+ * A name in the project's code that a migrate ask moves from or to: an42+ * exported function, type or module. (`Symbol` would shadow the global.)43+ */44+export const SymbolName = Schema.NonEmptyString.pipe(45+ Schema.brand("SymbolName")46+);47+48+export type SymbolName = typeof SymbolName.Type;49+50+/** A full git ref name, as text: `refs/heads/main`. */51+export const RefNameText = Schema.String.pipe(52+ Schema.check(53+ Schema.isPattern(/^refs\/(?!.*\.\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+$/u)54+ ),55+ Schema.brand("RefNameText")56+);57+58+export type RefNameText = typeof RefNameText.Type;59+60+/**61+ * One fact a decider weighs on Today, as a label and a value, with a link to62+ * more when there is one. Never a diff, unless the ask's kind allows a finish.63+ */64+export const Evidence = Schema.Struct({65+ href: Schema.optionalKey(Schema.NonEmptyString),66+ label: Schema.NonEmptyString,67+ value: Schema.String,68+});69+70+export type Evidence = typeof Evidence.Type;71+72+/** Where in the tree something points, when it points at one line. */73+export const At = Schema.Struct({74+ line: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),75+ path: RepoPath,76+});77+78+export type At = typeof At.Type;added:packages/protocol/src/domain/credit.ts+34 added
1+import { Schema } from "effect";2+3+import { Handle } from "../ids.ts";4+5+/** The human roles a landing credits, each one a trailer. */6+export const CreditRole = Schema.Literals([7+ "Asked-by",8+ "Signed-off-by",9+ "Decided-by",10+ "Mentored-by",11+ "Finished-by",12+ "Advised-by",13+ "Released-by",14+]);15+16+export type CreditRole = typeof CreditRole.Type;17+18+/** One trailer on a landing, naming a person in one role. */19+export const Credit = Schema.Struct({ handle: Handle, role: CreditRole });20+21+export type Credit = typeof Credit.Type;22+23+/**24+ * The agent a person worked through, as an `Assisted-by:` trailer. It is a25+ * disclosure, never credit: credit goes only to people.26+ */27+export const AgentTrailer = Schema.Struct({28+ harness: Schema.NonEmptyString,29+ model: Schema.optionalKey(Schema.NonEmptyString),30+ /** Whether the platform confirmed it, or only read it from the answer's commits. */31+ verified: Schema.Boolean,32+});33+34+export type AgentTrailer = typeof AgentTrailer.Type;added:packages/protocol/src/domain/decision.ts+105 added
1+import { Schema } from "effect";2+3+import {4+ AskId,5+ CommitSha,6+ DecisionId,7+ EnvKey,8+ Handle,9+ ProjectName,10+ ProposalId,11+ RatchetName,12+} from "../ids.ts";13+import { Posture } from "../posture.ts";14+import { At, Evidence, Hostname, RefNameText } from "./common.ts";15+import { LandingView } from "./landing.ts";16+17+/** What a decision is about. */18+export const DecisionSubject = Schema.TaggedUnion({19+ /** A passing answer a decider may finish before it lands. */20+ Finish: { ask: AskId, head: CommitSha },21+ /** Open the ask a proposal asks for. */22+ OpenProposal: { proposal: ProposalId },23+ /** Change the project's posture. */24+ PostureChange: { from: Posture, to: Posture },25+ /** Let an env item's placeholder be swapped on requests to more hosts. */26+ ProxyWidened: { hosts: Schema.Array(Hostname), item: EnvKey },27+ /** Raise a ratchet, which only a decider may do. */28+ RaiseRatchet: {29+ after: Schema.Int,30+ ask: AskId,31+ before: Schema.Int,32+ ratchet: RatchetName,33+ territory: Schema.NonEmptyString,34+ },35+ /** A write-only value showed up in an answer's tree; the answer is held aside. */36+ SecretInTree: { ask: AskId, item: EnvKey },37+ /** A canonical ref moved without a landing: adopt it or revert it. */38+ StrayPush: { after: CommitSha, before: CommitSha, ref: RefNameText },39+ /** Admit a person by a line in the vouch file. */40+ Vouch: { handle: Handle },41+ /** Allow one weakening marker, with its reason. */42+ Waiver: {43+ ask: AskId,44+ at: At,45+ marker: Schema.NonEmptyString,46+ reason: Schema.NonEmptyString,47+ },48+});49+50+export type DecisionSubject = typeof DecisionSubject.Type;51+52+/** What a decider chooses. */53+export const Choice = Schema.Literals(["accept", "decline", "adopt", "revert"]);54+55+export type Choice = typeof Choice.Type;56+57+/**58+ * A decision: one choice for a project's deciders, with its evidence and a59+ * safe default that is taken when it expires.60+ */61+export const Decision = Schema.Struct({62+ decided: Schema.optionalKey(63+ Schema.Struct({64+ at: Schema.DateTimeUtcFromString,65+ by: Handle,66+ choice: Choice,67+ note: Schema.optionalKey(Schema.String),68+ })69+ ),70+ deciders: Schema.NonEmptyArray(Handle),71+ /** What happens when it expires undecided. */72+ default: Choice,73+ evidence: Schema.Array(Evidence),74+ expiresAt: Schema.DateTimeUtcFromString,75+ id: DecisionId,76+ openedAt: Schema.DateTimeUtcFromString,77+ project: ProjectName,78+ subject: DecisionSubject,79+});80+81+export type Decision = typeof Decision.Type;82+83+/**84+ * Today: a decider's daily page of decisions with evidence and safe defaults,85+ * held to their budget. What doesn't fit waits, and may expire.86+ */87+export const Today = Schema.Struct({88+ budget: Schema.Struct({89+ finishes: Schema.Int,90+ total: Schema.Int,91+ used: Schema.Int,92+ }),93+ decider: Handle,94+ /** In order of expiry, as many as the budget allows. */95+ decisions: Schema.Array(Decision),96+ expiringSoon: Schema.Array(DecisionId),97+ /** People who made their first claim this week, to welcome. */98+ newcomers: Schema.Array(Handle),99+ /** How many decisions wait beyond the budget. */100+ overflow: Schema.Int,101+ /** A sample of landings that needed no decision. */102+ unattended: Schema.Array(LandingView),103+});104+105+export type Today = typeof Today.Type;added:packages/protocol/src/domain/env.ts+53 added
1+import { Schema } from "effect";2+3+import { EnvKey, Handle, LandedSha, ProjectName, RepoPath } from "../ids.ts";4+5+/**6+ * One item of a project's env shape, as its `.env.schema` declares it. A7+ * write-only value's item says who set it and when, never the value.8+ */9+export const EnvItem = Schema.Struct({10+ deprecated: Schema.optionalKey(Schema.Boolean),11+ description: Schema.optionalKey(Schema.String),12+ docs: Schema.optionalKey(Schema.String),13+ key: EnvKey,14+ /** What unlanded code sees in place of a write-only value. */15+ placeholder: Schema.optionalKey(Schema.String),16+ /** The outbound requests on which the platform swaps the placeholder for the value. */17+ proxy: Schema.optionalKey(18+ Schema.Struct({19+ block: Schema.optionalKey(Schema.Boolean),20+ domains: Schema.NonEmptyArray(Schema.NonEmptyString),21+ method: Schema.optionalKey(Schema.String),22+ path: Schema.optionalKey(Schema.String),23+ })24+ ),25+ /** `depends` when the schema decides it with a function. */26+ required: Schema.Union([Schema.Boolean, Schema.Literal("depends")]),27+ /** A flag set by a function counts as sensitive. */28+ sensitive: Schema.Boolean,29+ tags: Schema.Array(Schema.NonEmptyString),30+ /** The `@type` text, shown and never run. */31+ type: Schema.optionalKey(Schema.NonEmptyString),32+ value: Schema.optionalKey(33+ Schema.Struct({ setAt: Schema.DateTimeUtcFromString, setBy: Handle })34+ ),35+});36+37+export type EnvItem = typeof EnvItem.Type;38+39+/**40+ * A project's env shape: the public schema of its environment variables,41+ * parsed from its committed `.env.schema` at a landed commit and never42+ * resolved. (Named for the file: lint keeps "shape" out of code names.)43+ */44+export const EnvSchemaView = Schema.Struct({45+ at: LandedSha,46+ currentEnvKey: Schema.optionalKey(EnvKey),47+ file: RepoPath,48+ imports: Schema.Array(Schema.String),49+ items: Schema.Array(EnvItem),50+ project: ProjectName,51+});52+53+export type EnvSchemaView = typeof EnvSchemaView.Type;added:packages/protocol/src/domain/event.ts+41 added
1+import { Schema } from "effect";2+3+import {4+ AskId,5+ CommitSha,6+ DecisionId,7+ Handle,8+ LandedSha,9+ ProposalId,10+} from "../ids.ts";11+import { AskListing } from "./ask.ts";12+import { Choice } from "./decision.ts";13+import { LandingView } from "./landing.ts";14+import { Outcome } from "./outcome.ts";15+import { LedgerEntry } from "./visibility.ts";16+17+// Every event carries its time and its place in the project's sequence, so a18+// watcher can resume after the last one it saw.19+const stamp = { at: Schema.DateTimeUtcFromString, seq: Schema.Int };20+21+/** One thing that happened in a project, as a watcher of it hears. */22+export const ProjectEvent = Schema.TaggedUnion({23+ AskClosed: { ...stamp, ask: AskId, landing: LandedSha },24+ AskOpened: { ...stamp, ask: AskListing },25+ Claimed: { ...stamp, ask: AskId, claimant: Handle },26+ Decided: { ...stamp, choice: Choice, decision: DecisionId },27+ /** An answer was checked. */28+ Judged: { ...stamp, ask: AskId, head: CommitSha, outcome: Outcome },29+ Landed: { ...stamp, landing: LandingView },30+ /** A claim lapsed: no push for too long. */31+ Lapsed: { ...stamp, ask: AskId },32+ LedgerAppended: { ...stamp, entry: LedgerEntry },33+ ProposalOpened: { ...stamp, proposal: ProposalId },34+ Pushed: { ...stamp, ask: AskId, head: CommitSha },35+ /** A claim was released. */36+ Released: { ...stamp, ask: AskId },37+ /** A claim was warned that it lapses without a push. */38+ Warned: { ...stamp, ask: AskId },39+});40+41+export type ProjectEvent = typeof ProjectEvent.Type;added:packages/protocol/src/domain/front-page.ts+27 added
1+import { Schema } from "effect";2+3+import { ProjectName } from "../ids.ts";4+import { Posture } from "../posture.ts";5+import { AskListing } from "./ask.ts";6+7+/** One open ask on the front page: the cross-project list of asks a viewer may take. */8+export const FrontPageEntry = Schema.Struct({9+ ask: AskListing,10+ posture: Posture,11+ project: ProjectName,12+ /** Whether this viewer may claim it: its reserve, their vouch and their record. */13+ takeable: Schema.Boolean,14+});15+16+export type FrontPageEntry = typeof FrontPageEntry.Type;17+18+/** One project, as the list of projects shows it. */19+export const ProjectListing = Schema.Struct({20+ /** When the platform last landed on its main; absent before the first landing. */21+ landedAt: Schema.optionalKey(Schema.DateTimeUtcFromString),22+ openAsks: Schema.Int,23+ posture: Posture,24+ project: ProjectName,25+});26+27+export type ProjectListing = typeof ProjectListing.Type;added:packages/protocol/src/domain/kind.ts+64 added
1+import { Schema } from "effect";2+3+import { Handle, KindName } from "../ids.ts";4+import { Strength } from "./check.ts";5+6+/** A field of an ask's brief that its kind can require. */7+export const BriefField = Schema.Literals([8+ "want",9+ "current",10+ "check",11+ "territory",12+ "outOfScope",13+ "terms",14+ "context",15+]);16+17+export type BriefField = typeof BriefField.Type;18+19+/** The check kind an ask kind's asks are judged by. */20+export const CheckKind = Schema.Literals([21+ "redThenGreen",22+ "lintToZero",23+ "ratchet",24+ "migrate",25+ "symbolAbsent",26+]);27+28+export type CheckKind = typeof CheckKind.Type;29+30+/**31+ * Who may claim an ask of a kind: anyone vouched for, anyone, a person whose32+ * record in an area reaches a count, or a newcomer with a mentor.33+ */34+export const ClaimRule = Schema.Union([35+ Schema.Literals(["vouched", "anyone"]),36+ Schema.Struct({37+ record: Schema.Struct({ area: Schema.NonEmptyString, atLeast: Schema.Int }),38+ }),39+ Schema.Struct({ newcomer: Schema.Struct({ mentor: Handle }) }),40+]);41+42+export type ClaimRule = typeof ClaimRule.Type;43+44+/**45+ * An ask kind: the typed template a project's asks are made from. It fixes46+ * the brief's fields, the check kind, who may claim, and whether a finish is47+ * required.48+ */49+export const AskKind = Schema.Struct({50+ checkKind: CheckKind,51+ claimers: ClaimRule,52+ /** Whether a decider's finish is never offered, optional, or required before landing. */53+ finish: Schema.Literals(["never", "optional", "required"]),54+ name: KindName,55+ /** Answers can't be undone by a later answer: judge changes and dependency changes. */56+ oneWay: Schema.Boolean,57+ /** How many claims an ask takes at once; 1 is exclusive (ADR 0008). */58+ race: Schema.Int,59+ /** The brief's fields an ask of this kind must have. */60+ requires: Schema.Array(BriefField),61+ strength: Strength,62+});63+64+export type AskKind = typeof AskKind.Type;added:packages/protocol/src/domain/landing.ts+28 added
1+import { Schema } from "effect";2+3+import { AskId, Handle, LandedSha, ProjectName, RequestId } from "../ids.ts";4+import { Verdict } from "./answer.ts";5+import { AgentTrailer, Credit } from "./credit.ts";6+7+/**8+ * A landing: the platform's commit of a checked tree to main, with the credit9+ * trailers that name every person in it.10+ */11+export const LandingView = Schema.Struct({12+ /** The ask it answers; absent for a decider's own landing and the first adoption. */13+ ask: Schema.optionalKey(AskId),14+ assisted: Schema.Array(AgentTrailer),15+ /** The accountable person. */16+ author: Handle,17+ credits: Schema.Array(Credit),18+ /** `Held-back: <area> <passed>/<total> @ <suite>`, when held-back checks judged it. */19+ heldBackTrailer: Schema.optionalKey(Schema.NonEmptyString),20+ landedAt: Schema.DateTimeUtcFromString,21+ parent: LandedSha,22+ project: ProjectName,23+ requestId: Schema.optionalKey(RequestId),24+ sha: LandedSha,25+ verdict: Schema.optionalKey(Verdict),26+});27+28+export type LandingView = typeof LandingView.Type;added:packages/protocol/src/domain/outcome.ts+37 added
1+import { Schema } from "effect";2+3+import { AskId, DecisionId, Handle, LandedSha } from "../ids.ts";4+import { Refusal } from "../refusal.ts";5+6+/** A stage of the gate, in the order of its cost. */7+export const StageName = Schema.Literals([8+ "parse",9+ "shape",10+ "merge",11+ "cheap",12+ "checks",13+ "heldBack",14+ "human",15+]);16+17+export type StageName = typeof StageName.Type;18+19+/**20+ * Where an answer stands: still being checked, landed, waiting (on its21+ * parent ask, a finish or a decision), or refused. Waiting is not a refusal.22+ */23+export const Outcome = Schema.TaggedUnion({24+ /** Waits on a decision, such as a posture change. */25+ AwaitingDecision: { decision: DecisionId },26+ /** Passed, and waits for a decider's finish. */27+ AwaitingFinish: { decider: Schema.optionalKey(Handle) },28+ /** The gate is at this stage. */29+ Checking: { stage: StageName },30+ Landed: { sha: LandedSha },31+ /** Every refusal from the cheapest failing stage. */32+ Refused: { refusals: Schema.NonEmptyArray(Refusal) },33+ /** Passed, and waits for its parent ask to land. */34+ WaitingOnParent: { ask: AskId },35+});36+37+export type Outcome = typeof Outcome.Type;added:packages/protocol/src/domain/policy.ts+179 added
1+import { Brand } from "@repo/brand";2+import { Effect, Schema, Struct } from "effect";3+4+import { Handle, LandedSha, RepoPath } from "../ids.ts";5+import { Ask } from "./ask.ts";6+import { RatchetSpec } from "./check.ts";7+import { Glob } from "./common.ts";8+import { AskKind } from "./kind.ts";9+import { RunBlock } from "./run.ts";10+import { Territory } from "./territory.ts";11+12+/** Where a policy came from: the config folder, or the defaults when there is none. */13+const Source = Schema.Literals(["config", "defaults"]);14+15+/** How many decisions a decider takes a day, and how long one waits before its default. */16+const Budget = Schema.Struct({17+ decisionsPerDay: Schema.Int,18+ expireDays: Schema.Int,19+});20+21+/** How many proposals and claims one person may hold open at once. */22+const Caps = Schema.Struct({23+ claimsPerPerson: Schema.Int,24+ proposalsPerPerson: Schema.Int,25+});26+27+/** How long a claim may go without a push before it is warned, and before it lapses. */28+const Claims = Schema.Struct({29+ lapseAfterMs: Schema.Int,30+ warnAfterMs: Schema.Int,31+});32+33+/** When a landing starts to count on a person's record, and how long it counts. */34+const RecordWindow = Schema.Struct({35+ countsAfterDays: Schema.Int,36+ windowDays: Schema.Int,37+});38+39+/**40+ * What a vouch gates: claims and sealed answers (`forCode`), everything41+ * (`all`), or nothing but denouncements (`bansOnly`); and the vouch file.42+ */43+const Vouch = Schema.Struct({44+ file: RepoPath,45+ mode: Schema.Literals(["forCode", "all", "bansOnly"]),46+});47+48+/** Whether landings carry `Assisted-by:` trailers for the agents people worked through. */49+const Agents = Schema.Literals(["trailer", "none"]);50+51+/** Which rules are functions, called on demand, rather than data. */52+const Functions = Schema.Struct({53+ admit: Schema.Boolean,54+ opensAlone: Schema.Boolean,55+});56+57+/** The markers that count as weakening a check when an answer adds them. */58+const Weakening = Schema.Struct({59+ markers: Schema.Array(Schema.NonEmptyString),60+});61+62+/**63+ * A project's evaluated config folder at one landed commit: the data its64+ * rules come to. Function-valued rules are not in it; `functions` says which65+ * exist, and they are called on demand.66+ */67+export const Policy = Schema.Struct({68+ agents: Agents,69+ /** Every ask file in the config folder at this commit. */70+ asks: Schema.Array(Ask),71+ at: LandedSha,72+ budget: Budget,73+ caps: Caps,74+ claims: Claims,75+ /** Who decides for which paths. */76+ deciders: Schema.Array(77+ Schema.Struct({ handles: Schema.NonEmptyArray(Handle), paths: Glob })78+ ),79+ functions: Functions,80+ /** The judge closure: every file that decides what the checks do. */81+ judge: Schema.Struct({82+ paths: Schema.Array(Glob),83+ /** Parts of files, as `<file>#<JSON pointer>`: `package.json#/scripts`. */84+ pointers: Schema.Array(Schema.NonEmptyString),85+ }),86+ kinds: Schema.Array(AskKind),87+ /** The territories answers may change, one per workspace package. */88+ modules: Schema.Array(Territory),89+ ratchets: Schema.Array(RatchetSpec),90+ record: RecordWindow,91+ run: RunBlock,92+ source: Source,93+ vouch: Vouch,94+ /** The vouch file's lines, parsed. */95+ vouches: Schema.Array(96+ Schema.Struct({97+ denounced: Schema.Boolean,98+ handle: Handle,99+ note: Schema.optionalKey(Schema.String),100+ })101+ ),102+ weakening: Weakening,103+});104+105+export type Policy = typeof Policy.Type;106+107+/**108+ * An ask as its file in the config folder states it: the platform adds its109+ * project, when and in which landing it opened, and its state.110+ */111+export const AskInput = Ask.mapFields(112+ Struct.omit(["openedAt", "openedIn", "project", "state"])113+);114+115+export type AskInput = typeof AskInput.Type;116+117+/**118+ * The marker for a run block the platform finds in the project's own scripts119+ * and CI files, instead of one the config folder writes out.120+ */121+export const FromCI = Schema.TaggedStruct("FromCI", {});122+123+export type FromCI = typeof FromCI.Type;124+125+/**126+ * What the config folder evaluates to, before the platform fills in what it127+ * knows: the landed commit, each ask's opening, the modules, the judge128+ * closure and the vouch file's lines. Deciders may be `owners`, the person129+ * who made the project. A key the folder leaves out takes its default.130+ */131+export const PolicyInput = Schema.Struct({132+ agents: Agents.pipe(Schema.withDecodingDefaultKey(Effect.succeed("trailer"))),133+ asks: Schema.Array(AskInput),134+ budget: Budget.pipe(135+ Schema.withDecodingDefaultKey(136+ Effect.succeed({ decisionsPerDay: 5, expireDays: 14 })137+ )138+ ),139+ caps: Caps.pipe(140+ Schema.withDecodingDefaultKey(141+ Effect.succeed({ claimsPerPerson: 3, proposalsPerPerson: 2 })142+ )143+ ),144+ claims: Claims.pipe(145+ Schema.withDecodingDefaultKey(146+ Effect.succeed({ lapseAfterMs: 86_400_000, warnAfterMs: 7_200_000 })147+ )148+ ),149+ deciders: Schema.Array(150+ Schema.Struct({151+ handles: Schema.Union([152+ Schema.NonEmptyArray(Handle),153+ Schema.Literal("owners"),154+ ]),155+ paths: Glob,156+ })157+ ),158+ functions: Functions,159+ kinds: Schema.Array(AskKind),160+ ratchets: Schema.Array(RatchetSpec),161+ record: RecordWindow.pipe(162+ Schema.withDecodingDefaultKey(163+ Effect.succeed({ countsAfterDays: 30, windowDays: 365 })164+ )165+ ),166+ run: Schema.Union([RunBlock, FromCI]),167+ source: Source,168+ vouch: Vouch.pipe(169+ Schema.withDecodingDefaultKey(170+ Effect.succeed({171+ file: `${Brand.configDir}/vouched.td`,172+ mode: "forCode" as const,173+ })174+ )175+ ),176+ weakening: Weakening,177+});178+179+export type PolicyInput = typeof PolicyInput.Type;added:packages/protocol/src/domain/proposal.ts+46 added
1+import { Schema } from "effect";2+3+import {4+ AskId,5+ CommitSha,6+ Handle,7+ ProjectName,8+ ProposalId,9+ RepoName,10+ RepoPath,11+} from "../ids.ts";12+13+/** Where a proposal stands; an open one expires unless a decider accepts it. */14+export const ProposalState = Schema.Literals([15+ "open",16+ "accepted",17+ "declined",18+ "expired",19+]);20+21+export type ProposalState = typeof ProposalState.Type;22+23+/**24+ * A proposal: a request to open an ask, from anyone not denounced, that25+ * expires unless a decider accepts it. It may carry a sealed answer, judged26+ * after the ask opens without the decider reading its diff.27+ */28+export const Proposal = Schema.Struct({29+ expiresAt: Schema.DateTimeUtcFromString,30+ /** The proposed ask file and its check, held until the proposal is accepted. */31+ files: Schema.Array(RepoPath),32+ /** The existing ask this proposal flags, instead of a new one. */33+ flags: Schema.optionalKey(AskId),34+ id: ProposalId,35+ openedAt: Schema.DateTimeUtcFromString,36+ project: ProjectName,37+ proposer: Handle,38+ sealed: Schema.optionalKey(39+ Schema.Struct({ fork: RepoName, head: CommitSha })40+ ),41+ state: ProposalState,42+ territory: Schema.optionalKey(Schema.NonEmptyString),43+ want: Schema.NonEmptyString,44+});45+46+export type Proposal = typeof Proposal.Type;added:packages/protocol/src/domain/record.ts+17 added
1+import { Schema } from "effect";2+3+import { ProjectName } from "../ids.ts";4+import { CreditRole } from "./credit.ts";5+6+/**7+ * How many landings credit a person in one role, in one area of one project.8+ * A count by role and area, never a score.9+ */10+export const CreditSummary = Schema.Struct({11+ area: Schema.NonEmptyString,12+ count: Schema.Int,13+ project: ProjectName,14+ role: CreditRole,15+});16+17+export type CreditSummary = typeof CreditSummary.Type;added:packages/protocol/src/domain/run.ts+24 added
1+import { Schema } from "effect";2+3+import { LaneName } from "../ids.ts";4+import { Command, Hostname } from "./common.ts";5+6+/**7+ * The run block: the project's own commands, which the platform runs to8+ * check an answer exactly as a contributor runs them at home.9+ */10+export const RunBlock = Schema.Struct({11+ /** Each lane's command, by lane: `{ lint: "bun run lint", unit: "bun run test" }`. */12+ checks: Schema.Record(LaneName, Command),13+ doctor: Schema.optionalKey(Command),14+ /** The checker image to run in; `checker:default` when absent. */15+ image: Schema.optionalKey(Schema.NonEmptyString),16+ /** Installs what the checks need, once, before the network closes. */17+ setup: Schema.optionalKey(Command),18+ /** Hosts setup may reach beyond the defaults; setup only, never the checks. */19+ setupEgress: Schema.optionalKey(Schema.Array(Hostname)),20+ /** Runs one check file, named by its `{path}` placeholder. */21+ test: Command,22+});23+24+export type RunBlock = typeof RunBlock.Type;added:packages/protocol/src/domain/territory.ts+18 added
1+import { Schema } from "effect";2+3+import { RepoPath } from "../ids.ts";4+import { Glob } from "./common.ts";5+6+/**7+ * The module an answer may change: by default one workspace package, its8+ * paths derived from the package's folder. Globs are the escape hatch.9+ */10+export const Territory = Schema.Struct({11+ /** The workspace package's name, or `.` for a single-package repo. */12+ module: Schema.NonEmptyString,13+ paths: Schema.NonEmptyArray(Glob),14+ /** The files the module exports, so an import of anything else reaches its internals. */15+ publicFiles: Schema.optionalKey(Schema.Array(RepoPath)),16+});17+18+export type Territory = typeof Territory.Type;added:packages/protocol/src/domain/visibility.ts+157 added
1+import { Schema } from "effect";2+3+import {4+ AreaName,5+ DecisionId,6+ EnvKey,7+ Handle,8+ LandedSha,9+ LayerName,10+ ProjectName,11+ RepoName,12+ SuiteRoot,13+} from "../ids.ts";14+import { Posture } from "../posture.ts";15+16+/** Who may read a layer. */17+export const Audience = Schema.Literals([18+ "public",19+ "contributors",20+ "claimants",21+ "maintainers",22+ "team",23+ "security",24+ "sponsors",25+ "personal",26+ "platform",27+]);28+29+export type Audience = typeof Audience.Type;30+31+/** What people outside a layer's audience learn about what it holds. */32+export const Disclosure = Schema.Literals([33+ "public",34+ "sealed",35+ "counted",36+ "declared",37+ "hidden",38+ "writeOnly",39+]);40+41+export type Disclosure = typeof Disclosure.Type;42+43+/** What a layer holds. */44+export const LayerKind = Schema.Literals([45+ "checks",46+ "agent-config",47+ "env",48+ "experiment",49+ "notes",50+ "fix",51+ "session",52+ "personal",53+ "attachment",54+ "source",55+]);56+57+export type LayerKind = typeof LayerKind.Type;58+59+/**60+ * A layer: a separate repo holding one audience's files for a project,61+ * overlaid on main's paths only where that audience may read.62+ */63+export const Layer = Schema.Struct({64+ audience: Audience,65+ disclose: Disclosure,66+ holds: Schema.NonEmptyArray(LayerKind),67+ /** The longest its content may stay unreleased. */68+ maxDays: Schema.optionalKey(Schema.Int),69+ name: LayerName,70+ reason: Schema.NonEmptyString,71+ /** Its repo, `<project>--<layer>`; absent for a layer that is config only. */72+ repo: Schema.optionalKey(RepoName),73+ /** When its content is due for release. */74+ sunsetDays: Schema.optionalKey(Schema.Int),75+});76+77+export type Layer = typeof Layer.Type;78+79+/**80+ * One entry of a project's ledger, numbered in order. A value set is recorded81+ * by who and when, never by the value.82+ */83+export const LedgerEntry = Schema.TaggedUnion({84+ /** A held-back suite passed main enough times and caught a known-bad tree. */85+ Admitted: {86+ area: AreaName,87+ at: Schema.DateTimeUtcFromString,88+ knownBadCaught: Schema.Int,89+ mainRuns: Schema.Int,90+ seq: Schema.Int,91+ suite: SuiteRoot,92+ },93+ /** A held-back suite's commitment, printed on every landing it judges. */94+ CommitmentPublished: {95+ area: AreaName,96+ at: Schema.DateTimeUtcFromString,97+ authors: Schema.Int,98+ checks: Schema.Int,99+ seq: Schema.Int,100+ suite: SuiteRoot,101+ },102+ /** How many items a layer holds in an area. */103+ CountChanged: {104+ area: AreaName,105+ at: Schema.DateTimeUtcFromString,106+ count: Schema.Int,107+ layer: LayerName,108+ seq: Schema.Int,109+ },110+ LayerDeclared: {111+ at: Schema.DateTimeUtcFromString,112+ disclose: Disclosure,113+ kinds: Schema.NonEmptyArray(LayerKind),114+ layer: LayerName,115+ seq: Schema.Int,116+ },117+ PostureChanged: {118+ at: Schema.DateTimeUtcFromString,119+ decision: DecisionId,120+ from: Posture,121+ seq: Schema.Int,122+ to: Posture,123+ },124+ /** A release: paths moved from a layer to main by a credited landing. */125+ Released: {126+ at: Schema.DateTimeUtcFromString,127+ by: Handle,128+ landing: LandedSha,129+ layer: LayerName,130+ paths: Schema.Int,131+ seq: Schema.Int,132+ },133+ /** A decider set a write-only value. */134+ ValueSet: {135+ at: Schema.DateTimeUtcFromString,136+ by: Handle,137+ key: EnvKey,138+ seq: Schema.Int,139+ },140+});141+142+export type LedgerEntry = typeof LedgerEntry.Type;143+144+/**145+ * The ledger: the public, append-only record of a project's layers, counts,146+ * commitments, releases and posture changes.147+ */148+export const Ledger = Schema.Struct({149+ entries: Schema.Array(LedgerEntry),150+ layers: Schema.Array(Layer),151+ posture: Posture,152+ /** The posture in words: `Open with sealed evidence`. */153+ postureLabel: Schema.NonEmptyString,154+ project: ProjectName,155+});156+157+export type Ledger = typeof Ledger.Type;modified:packages/protocol/src/contracts.ts+1 added-8 removed
8 unmodified lines9 Destructive,10 Idempotent,11 ReadOnly,12 } from "./annotations.ts";13+import { AskListing } from "./domain/ask.ts";14 import { AskId, CommitSha, ProjectName } from "./ids.ts";15 import { Authenticated } from "./principal.ts";16 import { ClaimLapsed, NotClaimed, RepoBusy, StaleBase } from "./refusal.ts";17 10 unmodified lines28 Surfaces,29 Visibility,30 } from "./annotations.ts";31 31-/** One open ask, as a list of asks shows it. */32-export const AskListing = Schema.Struct({33- ask: AskId,34- claimed: Schema.Boolean,35- territory: Schema.NonEmptyString,36- want: Schema.NonEmptyString,37-});38-32 export class ListAsks extends Rpc.make("listAsks", {33 payload: { project: ProjectName },34 success: Schema.Struct({ asks: Schema.Array(AskListing) }),35 })34 unmodified linesadded:packages/protocol/src/envelope.ts+39 added
1+import { Schema } from "effect";2+import type { Array } from "effect";3+4+import { Refusal } from "./refusal.ts";5+6+/**7+ * The one shape of every CLI command's `--json` output: the command's result,8+ * or the refusals it met instead, under a version a script can check.9+ */10+export const Envelope = <A extends Schema.Top>(data: A) =>11+ Schema.Union([12+ Schema.Struct({13+ command: Schema.NonEmptyString,14+ data,15+ ok: Schema.Literal(true),16+ v: Schema.Literal(1),17+ }),18+ Schema.Struct({19+ command: Schema.NonEmptyString,20+ ok: Schema.Literal(false),21+ refusals: Schema.NonEmptyArray(Refusal),22+ v: Schema.Literal(1),23+ }),24+ ]);25+26+/** A command's `--json` output whose result is an `A`. */27+export type Envelope<A> =28+ | {29+ readonly command: string;30+ readonly data: A;31+ readonly ok: true;32+ readonly v: 1;33+ }34+ | {35+ readonly command: string;36+ readonly ok: false;37+ readonly refusals: Array.NonEmptyReadonlyArray<Refusal>;38+ readonly v: 1;39+ };modified:packages/protocol/src/ids.ts+204 added-7 removed
1 import { Schema } from "effect";2 3+// Lowercase words joined by single dashes: no `--`, which separates a fork's4+// parts (`<project>--<ask>--<handle>`), and no leading or trailing dash.5+const Words = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;6+7+// A name in the config folder: a kind, a layer, an area, a lane, a ratchet.8+const ConfigName = /^[a-z][a-zA-Z0-9-]*$/u;9+10+// A git object id in SHA-1 format: 40 lowercase hex digits.11+const GitId = /^[0-9a-f]{40}$/u;12+13+// What the platform mints from a project's sequence: `prop-000001`, `dec-0a1b2c`.14+const Minted = /^[a-z]+-[0-9a-z]{6,26}$/u;15+16 /**4- * An ask's name. Lowercase letters, digits and dashes, so a command that names5- * it (`<cli> claim <ask>`) is safe to paste into a shell.17+ * Words an ask may not be named: `me` names a person's working fork18+ * (`<project>--me--<handle>`) and `layer` names a layer's repo.19 */20+const reservedAskIds = ["me", "layer"] as const;21+22+const isReserved = (name: string) =>23+ reservedAskIds.some((reserved) => reserved === name);24+25+/**26+ * An ask's name. Lowercase words joined by single dashes, so a command that27+ * names it (`<cli> claim <ask>`) is safe to paste into a shell and a fork's28+ * name splits back into its parts. `me` and `layer` are taken.29+ */30 export const AskId = Schema.String.pipe(8- Schema.check(Schema.isPattern(/^[a-z0-9][a-z0-9-]*$/u)),31+ Schema.check(32+ Schema.isPattern(Words),33+ Schema.makeFilter(34+ (name: string) =>35+ isReserved(name)36+ ? `${name} is reserved for working forks and layers, so no ask takes it`37+ : true,38+ {39+ expected: `an ask name other than ${reservedAskIds.join(" or ")}`,40+ toCode: () => ({41+ runtime: `Schema.makeFilter((name: string) => !${JSON.stringify(reservedAskIds)}.includes(name))`,42+ }),43+ toJsonSchema: () => ({ not: { enum: [...reservedAskIds] } }),44+ }45+ )46+ ),47 Schema.brand("AskId")48 );49 50 export type AskId = typeof AskId.Type;51 52 /** A git commit id: 40 lowercase hex digits, git's SHA-1 object format. */53 export const CommitSha = Schema.String.pipe(16- Schema.check(Schema.isPattern(/^[0-9a-f]{40}$/u)),54+ Schema.check(Schema.isPattern(GitId)),55 Schema.brand("CommitSha")56 );57 58 export type CommitSha = typeof CommitSha.Type;59 60+/**61+ * A commit the platform itself landed on main. Rules are read only from one62+ * of these (ADR 0005), never from a commit someone pushed.63+ */64+export const LandedSha = CommitSha.pipe(Schema.brand("LandedSha"));65+66+export type LandedSha = typeof LandedSha.Type;67+68+/** A git tree id: the exact tree a check ran on. */69+export const TreeSha = Schema.String.pipe(70+ Schema.check(Schema.isPattern(GitId)),71+ Schema.brand("TreeSha")72+);73+74+export type TreeSha = typeof TreeSha.Type;75+76+/** A git blob id: one file's content at one moment. */77+export const BlobSha = Schema.String.pipe(78+ Schema.check(Schema.isPattern(GitId)),79+ Schema.brand("BlobSha")80+);81+82+export type BlobSha = typeof BlobSha.Type;83+84+/**85+ * An answer's change set, as the platform identifies it: SHA-256 over the86+ * sorted (path, blob before, blob after) triples it changes. It moves exactly87+ * when a file the answer touches moved underneath it.88+ */89+export const PatchId = Schema.String.pipe(90+ Schema.check(Schema.isPattern(/^[0-9a-f]{64}$/u)),91+ Schema.brand("PatchId")92+);93+94+export type PatchId = typeof PatchId.Type;95+96+/**97+ * The key that makes an answer, a finish or a landing request safe to send98+ * twice: the second one with the same key converges on the first.99+ */100+export const RequestId = Schema.String.pipe(101+ Schema.check(Schema.isPattern(/^[A-Za-z0-9_-]{8,64}$/u)),102+ Schema.brand("RequestId")103+);104+105+export type RequestId = typeof RequestId.Type;106+107+/**108+ * A per-claim credential, reserved: today the person's platform token is the109+ * credential. It is redacted wherever it is printed, so it is never logged.110+ */111+export const ClaimToken = Schema.RedactedFromValue(Schema.String);112+113+export type ClaimToken = typeof ClaimToken.Type;114+115+/** A proposal's id, minted from its project's sequence: `prop-000001`. */116+export const ProposalId = Schema.String.pipe(117+ Schema.check(Schema.isPattern(Minted)),118+ Schema.brand("ProposalId")119+);120+121+export type ProposalId = typeof ProposalId.Type;122+123+/** A decision's id, minted from its project's sequence: `dec-000001`. */124+export const DecisionId = Schema.String.pipe(125+ Schema.check(Schema.isPattern(Minted)),126+ Schema.brand("DecisionId")127+);128+129+export type DecisionId = typeof DecisionId.Type;130+131+/** A landing's id, minted from its project's sequence: `land-000001`. */132+export const LandingId = Schema.String.pipe(133+ Schema.check(Schema.isPattern(Minted)),134+ Schema.brand("LandingId")135+);136+137+export type LandingId = typeof LandingId.Type;138+139+/** An ask kind's name, as the config folder declares it: `fix`, `lintToZero`. */140+export const KindName = Schema.String.pipe(141+ Schema.check(Schema.isPattern(ConfigName)),142+ Schema.brand("KindName")143+);144+145+export type KindName = typeof KindName.Type;146+147+/** A layer's name, as the config folder declares it: `maintainers`. */148+export const LayerName = Schema.String.pipe(149+ Schema.check(Schema.isPattern(ConfigName)),150+ Schema.brand("LayerName")151+);152+153+export type LayerName = typeof LayerName.Type;154+155+/** An area held-back checks are counted and reported by: `parse`. */156+export const AreaName = Schema.String.pipe(157+ Schema.check(Schema.isPattern(ConfigName)),158+ Schema.brand("AreaName")159+);160+161+export type AreaName = typeof AreaName.Type;162+163+/** One of the project's own check commands, by name: `lint`, `types`, `unit`. */164+export const LaneName = Schema.String.pipe(165+ Schema.check(Schema.isPattern(ConfigName)),166+ Schema.brand("LaneName")167+);168+169+export type LaneName = typeof LaneName.Type;170+171+/** A ratchet's name, as the config folder declares it: `anyCount`. */172+export const RatchetName = Schema.String.pipe(173+ Schema.check(Schema.isPattern(ConfigName)),174+ Schema.brand("RatchetName")175+);176+177+export type RatchetName = typeof RatchetName.Type;178+179+/** An item's key in a project's env shape: `PAYMENTS_KEY`. */180+export const EnvKey = Schema.String.pipe(181+ Schema.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_]*$/u)),182+ Schema.brand("EnvKey")183+);184+185+export type EnvKey = typeof EnvKey.Type;186+187+/** A commitment: the salted SHA-256 root of a held-back suite. */188+export const SuiteRoot = Schema.String.pipe(189+ Schema.check(Schema.isPattern(/^sha256:[0-9a-f]{64}$/u)),190+ Schema.brand("SuiteRoot")191+);192+193+export type SuiteRoot = typeof SuiteRoot.Type;194+195+/**196+ * What a check run's result depends on besides the tree: the check kind, the197+ * version of the rules it was declared with, and its commands198+ * (`redThenGreen@0.0.0+<hash>`). A verdict is reused only for the same tree199+ * and the same version.200+ */201+export const CheckVersion = Schema.NonEmptyString.pipe(202+ Schema.brand("CheckVersion")203+);204+205+export type CheckVersion = typeof CheckVersion.Type;206+207+/**208+ * A repo's name in its namespace: letters, digits, dots, dashes, underscores.209+ * A claim's fork is `<project>--<ask>--<handle>`, a layer's repo210+ * `<project>--<layer>`.211+ */212+export const RepoName = Schema.String.pipe(213+ Schema.check(Schema.isPattern(/^[A-Za-z0-9._-]+$/u)),214+ Schema.brand("RepoName")215+);216+217+export type RepoName = typeof RepoName.Type;218+219 /** A path inside a repo, as git prints it. */220 export const RepoPath = Schema.NonEmptyString.pipe(Schema.brand("RepoPath"));221 222 export type RepoPath = typeof RepoPath.Type;223 224 /**28- * A project's name. Lowercase letters, digits and dashes, like an ask's, so a29- * command that names it is safe to paste into a shell.225+ * A project's name. Lowercase words joined by single dashes, like an ask's,226+ * so a command that names it is safe to paste into a shell.227 */228 export const ProjectName = Schema.String.pipe(32- Schema.check(Schema.isPattern(/^[a-z0-9][a-z0-9-]*$/u)),229+ Schema.check(Schema.isPattern(Words)),230 Schema.brand("ProjectName")231 );232 233 export type ProjectName = typeof ProjectName.Type;8 unmodified linesmodified:packages/protocol/src/principal.ts+17 added-2 removed
1 unmodified line2 import { RpcMiddleware } from "effect/rpc";3 4 import { Handle } from "./ids.ts";5 6-/** Who is calling: the person a verified credential names. */7-export const Principal = Schema.Struct({ handle: Handle });6+/** A caller a verified credential names. */7+export const Person = Schema.TaggedStruct("Person", { handle: Handle });8 9+export type Person = typeof Person.Type;10+11+/**12+ * A caller with no credential. Only contracts anyone may call serve one: a13+ * public read, such as the front page.14+ */15+export const Anonymous = Schema.TaggedStruct("Anonymous", {});16+17+export type Anonymous = typeof Anonymous.Type;18+19+/** Who is calling: a person, or anyone at all. Branch on it with `Principal.match`. */20+export const Principal = Schema.Union([Person, Anonymous]).pipe(21+ Schema.toTaggedUnion("_tag")22+);23+24 export type Principal = typeof Principal.Type;25 26 /** The caller of the contract being handled. */27 export class CurrentPrincipal extends Context.Service<18 unmodified linesmodified:packages/protocol/src/refusal.ts+180 added-10 removed
1 import { Brand } from "@repo/brand";2 import { Effect, Schema } from "effect";3 4-import { AskId, CommitSha, RepoPath } from "./ids.ts";4+import { At } from "./domain/common.ts";5+import {6+ AskId,7+ CommitSha,8+ DecisionId,9+ EnvKey,10+ ProjectName,11+ RepoPath,12+} from "./ids.ts";13 import { Posture } from "./posture.ts";14 15+/** Where in the tree a refusal points, when it points at one line. */16+export { At } from "./domain/common.ts";17+18 const cli = (...args: readonly string[]) => [Brand.cli, ...args].join(" ");19 20 const Label = Schema.NonEmptyString;21 22 const Paths = Schema.NonEmptyArray(RepoPath);23 13-/** Where in the tree a refusal points, when it points at one line. */14-const At = Schema.Struct({15- line: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),16- path: RepoPath,17-});18-24 // Every refusal carries `retryable`, fixed per tag, and `next`, the command to25 // run next. Both are fields, not statics: Effect's MCP server sends only what26 // the failure schema encodes. No refusal has a `message`, so MCP sends JSON.27 const Retryable = {65 unmodified lines93 ...Retryable,94 ...nextIs("git push"),95 }) {}96 97+/**98+ * The push tried to move a canonical ref directly. Main moves only by a99+ * landing; an answer goes to the claim's fork.100+ */101+export class DirectPush extends Schema.TaggedError<DirectPush>()("DirectPush", {102+ ...Final,103+ ...nextIs(cli("asks")),104+ ref: Label,105+}) {}106+107+/** The ask waits on other asks to land first, as the delete step of a migrate does. */108+export class AskBlocked extends Schema.TaggedError<AskBlocked>()("AskBlocked", {109+ ...Retryable,110+ ...nextIs(cli("asks")),111+ ask: AskId,112+ blockedBy: Schema.NonEmptyArray(AskId),113+}) {114+ static readonly of = (115+ ask: AskId,116+ blockedBy: readonly [AskId, ...(readonly AskId[])]117+ ) => new AskBlocked({ ask, blockedBy });118+}119+120+/** The project's vouch file denounces the caller, so it takes no claims or proposals from them. */121+export class Denounced extends Schema.TaggedError<Denounced>()("Denounced", {122+ ...Final,123+ ...nextIs(cli("status")),124+}) {}125+126 // Shape: these accumulate, so one push hears about every one at once127 128 /** The answer changes paths outside the ask's territory. */129 export class OutOfScope extends Schema.TaggedError<OutOfScope>()("OutOfScope", {32 unmodified lines162 "PrivatePathInPublicTree",163 { ...Final, ...nextIs(cli("check")), paths: Paths }164 ) {}165 166+/**167+ * The answer imports another module's internals: a file that module does not168+ * export. `to` is what the import names.169+ */170+export class ReachedInternals extends Schema.TaggedError<ReachedInternals>()(171+ "ReachedInternals",172+ { ...Final, ...nextIs(cli("check")), from: RepoPath, to: Label }173+) {}174+175 // Merge176 177 /** Main moved past the answer's base; git's `fetch first` and `stale ref` land here too. */178 export class StaleBase extends Schema.TaggedError<StaleBase>()("StaleBase", {3 unmodified lines182 conflicts: Schema.Array(RepoPath),183 main: CommitSha,184 }) {}185 186+/**187+ * A layer the answer was checked with moved since; the answer is checked188+ * again against it, as a moved main is.189+ */190+export class StaleLayer extends Schema.TaggedError<StaleLayer>()("StaleLayer", {191+ ...Retryable,192+ ...nextIs(cli("status")),193+ layer: Label,194+}) {}195+196 // Checks197 198 /** A check failed; `next` is the command that reproduces it. */199 export class ChecksFailed extends Schema.TaggedError<ChecksFailed>()(79 unmodified lines279 where: Schema.Literals(["output", "tree"]),280 }281 ) {}282 283+/**284+ * A held-back check in this area enforces something no public clause states,285+ * so it cannot enter the suite: a sealed check must cite what it holds.286+ */287+export class UnstatedRequirement extends Schema.TaggedError<UnstatedRequirement>()(288+ "UnstatedRequirement",289+ { ...Final, ...nextIs(cli("check")), area: Label }290+) {}291+292 // Decision293 294 /** Landing would change the project's posture, which takes a decider. */295 export class PostureChange extends Schema.TaggedError<PostureChange>()(296 "PostureChange",297 { ...Final, ...nextIs(cli("today")), from: Posture, to: Posture }298 ) {}299 300+/** Only one of the project's deciders may do this. */301+export class NotDecider extends Schema.TaggedError<NotDecider>()("NotDecider", {302+ ...Final,303+ ...nextIs(cli("status")),304+}) {}305+306+/** The decision was already taken, or expired to its default. */307+export class DecisionClosed extends Schema.TaggedError<DecisionClosed>()(308+ "DecisionClosed",309+ { ...Final, ...nextIs(cli("today")), decision: DecisionId }310+) {}311+312+// Lookup313+314+/** No project has this name. */315+export class UnknownProject extends Schema.TaggedError<UnknownProject>()(316+ "UnknownProject",317+ { ...Final, ...nextIs(cli("asks")), project: ProjectName }318+) {}319+320+/** The project has no ask with this name. */321+export class UnknownAsk extends Schema.TaggedError<UnknownAsk>()("UnknownAsk", {322+ ...Final,323+ ...nextIs(cli("asks")),324+ ask: AskId,325+}) {}326+327+/** The project has no commit with this id. */328+export class UnknownCommit extends Schema.TaggedError<UnknownCommit>()(329+ "UnknownCommit",330+ { ...Final, ...nextIs("git fetch"), sha: CommitSha }331+) {}332+333+/** The project has no decision with this id. */334+export class UnknownDecision extends Schema.TaggedError<UnknownDecision>()(335+ "UnknownDecision",336+ { ...Final, ...nextIs(cli("today")), decision: DecisionId }337+) {}338+339+// Setup340+341+/** A project with this name already exists. */342+export class ProjectExists extends Schema.TaggedError<ProjectExists>()(343+ "ProjectExists",344+ { ...Final, ...nextIs(cli("asks")), project: ProjectName }345+) {}346+347+/** The repo to import could not be read; `reason` says what went wrong. */348+export class ImportFailed extends Schema.TaggedError<ImportFailed>()(349+ "ImportFailed",350+ { ...Retryable, ...nextIs(cli("init")), reason: Label }351+) {}352+353+// Env354+355+/** The project's env shape has no item with this key. */356+export class UnknownEnvItem extends Schema.TaggedError<UnknownEnvItem>()(357+ "UnknownEnvItem",358+ { ...Final, ...nextIs(cli("env", "shape")), key: EnvKey }359+) {}360+361+/** Only an `@sensitive` env item holds a write-only value, and this one is not. */362+export class NotSensitive extends Schema.TaggedError<NotSensitive>()(363+ "NotSensitive",364+ { ...Final, ...nextIs(cli("env", "shape")), key: EnvKey }365+) {}366+367+/**368+ * The value is shorter than the item asks for. The refusal names the minimum369+ * only: never the value, and never its length.370+ */371+export class ValueTooShort extends Schema.TaggedError<ValueTooShort>()(372+ "ValueTooShort",373+ { ...Final, key: EnvKey, minimum: Schema.Int }374+) {375+ static readonly of = (key: EnvKey, minimum: number) =>376+ new ValueTooShort({377+ key,378+ minimum,379+ next: cli("env", "set", key, "--acknowledge-short"),380+ });381+}382+383 const pushAndClaim = [384 NotClaimed,385 ClaimLapsed,386 NotVouched,387 CapReached,388 AskFull,389 NoAsk,390 RepoBusy,391+ DirectPush,392+ AskBlocked,393+ Denounced,394 ] as const;395 396 // These accumulate, so one push hears about every one at once.397 const accumulating = [398 OutOfScope,399 TouchedJudge,400 Weakened,401 PrivatePathInPublicTree,402+ ReachedInternals,403 ] as const;404 256-const merge = [StaleBase] as const;405+const merge = [StaleBase, StaleLayer] as const;406 407 const checks = [ChecksFailed, HeldBackFailed, AttemptsExhausted] as const;408 409 const neverCounted = [Flake, VerifierBlocked] as const;410 411 const atAskOpen = [NotRedFirst, WeakCheck, IncompleteBrief] as const;412 264-const maintainersOnly = [LayerContentInPublicTree, SecretInOutput] as const;413+const maintainersOnly = [414+ LayerContentInPublicTree,415+ SecretInOutput,416+ UnstatedRequirement,417+] as const;418 266-const decision = [PostureChange] as const;419+const decision = [PostureChange, NotDecider, DecisionClosed] as const;420 421+const lookup = [422+ UnknownProject,423+ UnknownAsk,424+ UnknownCommit,425+ UnknownDecision,426+] as const;427+428+const setup = [ProjectExists, ImportFailed] as const;429+430+const env = [UnknownEnvItem, NotSensitive, ValueTooShort] as const;431+432 /**433 * The union's members by group, in union order. The reference docs file each434 * refusal under its group; a new refusal joins its group here and in the union.435 */5 unmodified lines441 { members: neverCounted, name: "Never counted against the answerer" },442 { members: atAskOpen, name: "At ask open" },443 { members: maintainersOnly, name: "Maintainers only" },444 { members: decision, name: "Decision" },445+ { members: lookup, name: "Lookup" },446+ { members: setup, name: "Setup" },447+ { members: env, name: "Env" },448 ] as const;449 450 /** The closed union. Each member's tag is public: rename one only with an alias. */451 export const Refusal = Schema.Union([4 unmodified lines456 ...neverCounted,457 ...atAskOpen,458 ...maintainersOnly,459 ...decision,460+ ...lookup,461+ ...setup,462+ ...env,463 ]);464 465 export type Refusal = typeof Refusal.Type;modified:packages/protocol/src/render.ts+26 added
8 unmodified lines9 10 // Reasons name only what the refusal's reader may see: held-back checks give11 // their area and suite, never a case or an input.12 const reason = Match.typeTags<Refusal, string>()({13+ AskBlocked: ({ ask, blockedBy }) =>14+ `${ask} waits on ${list(blockedBy)} to land first`,15 AskFull: ({ ask }) => `someone else holds the claim on ${ask}`,16 AttemptsExhausted: ({ area, resetsAt }) =>17 `no attempts left on ${area} until ${DateTime.formatIso(resetsAt)}`,18 CapReached: ({ cap }) =>19 `you already hold ${cap} claims, the most this project allows`,20 ChecksFailed: ({ lane, logRef }) =>21 `the ${lane} checks failed; the log is at ${logRef}`,22 ClaimLapsed: ({ ask }) => `your claim on ${ask} lapsed`,23+ DecisionClosed: ({ decision }) =>24+ `${decision} was already decided, or expired to its default`,25+ Denounced: () =>26+ "this project's vouch file denounces you, so it takes no claims or proposals from you",27+ DirectPush: ({ ref }) =>28+ `main moves only by a landing, so ${ref} takes no direct push; push your answer to your claim's fork`,29 Flake: ({ lane }) =>30 `the ${lane} checks failed, then passed on the same tree; the platform will run them again`,31 HeldBackFailed: ({ area, suite }) =>32 `a held-back check failed in ${area}, suite ${suite}`,33+ ImportFailed: (refusal) => `the import failed: ${refusal.reason}`,34 IncompleteBrief: ({ missing }) => `the brief is missing ${list(missing)}`,35 LayerContentInPublicTree: ({ paths }) =>36 `a layer's files would enter a public tree: ${list(paths)}`,37 NoAsk: () => "this push names no open ask",38 NotClaimed: ({ ask }) => `you hold no claim on ${ask}`,39+ NotDecider: () => "only one of this project's deciders may do this",40 NotRedFirst: () =>41 "the ask's check must fail on main twice in the same way, by an assertion",42+ NotSensitive: ({ key }) =>43+ `${key} is not @sensitive, so it holds no write-only value`,44 NotVouched: () => "no member of this project has vouched for you",45 OutOfScope: ({ paths }) =>46 `changes paths outside the ask's territory: ${list(paths)}`,47 PostureChange: ({ from, to }) =>48 `landing would change the posture from ${from} to ${to}, which takes a decider`,49 PrivatePathInPublicTree: ({ paths }) =>50 `would put held-back paths in a public tree: ${list(paths)}`,51+ ProjectExists: ({ project }) => `a project named ${project} already exists`,52+ ReachedInternals: ({ from, to }) =>53+ `${from} reaches into ${to}, which its module does not export`,54 RepoBusy: () => "the repo was busy with another push",55 SecretInOutput: ({ item, where }) =>56 `the write-only value ${item} appeared in the ${where}`,57 StaleBase: ({ base, conflicts, main }) =>58 conflicts.length === 059 ? `main moved to ${short(main)}, past your base ${short(base)}`60 : `main moved to ${short(main)}, past your base ${short(base)}; conflicts in ${list(conflicts)}`,61+ StaleLayer: ({ layer }) =>62+ `the ${layer} layer moved since this answer was checked; it will be checked again`,63 TouchedJudge: ({ paths }) =>64 `changes files that decide what the checks do: ${list(paths)}`,65+ UnknownAsk: ({ ask }) => `this project has no ask named ${ask}`,66+ UnknownCommit: ({ sha }) => `this project has no commit ${sha}`,67+ UnknownDecision: ({ decision }) => `this project has no decision ${decision}`,68+ UnknownEnvItem: ({ key }) => `the env shape has no item ${key}`,69+ UnknownProject: ({ project }) => `no project is named ${project}`,70+ UnstatedRequirement: ({ area }) =>71+ `a held-back check in ${area} enforces something no public clause states`,72+ ValueTooShort: ({ key, minimum }) =>73+ `the value for ${key} is shorter than the ${minimum} characters it needs`,74 VerifierBlocked: () =>75 "the platform could not run the checks; it will run them again",76 WeakCheck: ({ weakness }) => `the ask's check is weak: ${weakness}`,77 Weakened: ({ weakening }) => {35 unmodified linesmodified:packages/protocol/src/testing.ts+2 added-2 removed
4 unmodified lines5 */6 import { Effect, Layer } from "effect";7 8 import { Handle } from "./ids.ts";9-import { Authenticated, CurrentPrincipal } from "./principal.ts";9+import { Authenticated, CurrentPrincipal, Person } from "./principal.ts";10 11 /** A server side that takes every call as `handle`, for tests with several people. */12 export const asPerson = (handle: Handle): Layer.Layer<Authenticated> =>13 Layer.succeed(Authenticated, (effect) =>14- Effect.provideService(effect, CurrentPrincipal, { handle })14+ Effect.provideService(effect, CurrentPrincipal, Person.make({ handle }))15 );16 17 /** A server side that takes every call as one person, for tests about other things. */18 export const asTester: Layer.Layer<Authenticated> = asPerson(2 unmodified linesadded:packages/protocol/test/fixtures/domain.json+1792 added
1+{2+ "$comment": "Encoded values, as a client sends them or reads them back. domain.test.ts decodes each roundTrip example and encodes it back unchanged, and expects each refused value to fail to decode as its schema. Paths say config/ where a project's config folder would be, and commands say cli, since only packages/brand spells the name.",3+ "refused": {4+ "a policy whose run block is still the FromCI marker": {5+ "schema": "Policy",6+ "value": {7+ "agents": "trailer",8+ "asks": [9+ {10+ "askedBy": "alice",11+ "blockedBy": [],12+ "brief": {13+ "context": ["ISO 8601 weeks start on Monday."],14+ "current": "Week 1 of 2027 parses as week 53 of 2026.",15+ "outOfScope": ["Locale-specific weeks"],16+ "terms": ["ISO week"],17+ "want": "An ISO week date parses to the Monday of that week."18+ },19+ "check": {20+ "_tag": "RedThenGreen",21+ "path": "packages/parse/test/iso-week.test.ts"22+ },23+ "file": "config/asks/iso-week.ask.ts",24+ "id": "iso-week",25+ "kind": "fix",26+ "mentor": "bob",27+ "reserve": "newcomers",28+ "territory": {29+ "module": "@datekit/parse",30+ "paths": ["packages/parse/**"],31+ "publicFiles": ["packages/parse/src/index.ts"]32+ },33+ "openedAt": "2026-10-07T12:00:00.000Z",34+ "openedIn": "4444444444444444444444444444444444444444",35+ "parent": "drop-moment",36+ "project": "datekit",37+ "state": "open"38+ }39+ ],40+ "at": "4444444444444444444444444444444444444444",41+ "budget": {42+ "decisionsPerDay": 5,43+ "expireDays": 1444+ },45+ "caps": {46+ "claimsPerPerson": 3,47+ "proposalsPerPerson": 248+ },49+ "claims": {50+ "lapseAfterMs": 86400000,51+ "warnAfterMs": 720000052+ },53+ "deciders": [54+ {55+ "handles": ["alice"],56+ "paths": "**"57+ }58+ ],59+ "functions": {60+ "admit": false,61+ "opensAlone": true62+ },63+ "judge": {64+ "paths": ["config/**", ".env.schema"],65+ "pointers": ["package.json#/scripts"]66+ },67+ "kinds": [68+ {69+ "checkKind": "redThenGreen",70+ "claimers": "vouched",71+ "finish": "optional",72+ "name": "fix",73+ "oneWay": false,74+ "race": 1,75+ "requires": ["want", "check", "territory"],76+ "strength": "assertion"77+ }78+ ],79+ "modules": [80+ {81+ "module": "@datekit/parse",82+ "paths": ["packages/parse/**"],83+ "publicFiles": ["packages/parse/src/index.ts"]84+ }85+ ],86+ "ratchets": [87+ {88+ "measure": {89+ "_tag": "Metric",90+ "command": "bun run size",91+ "path": "/total"92+ },93+ "name": "bundleSize"94+ }95+ ],96+ "record": {97+ "countsAfterDays": 30,98+ "windowDays": 36599+ },100+ "run": {101+ "_tag": "FromCI"102+ },103+ "source": "config",104+ "vouch": {105+ "file": "config/vouched.td",106+ "mode": "forCode"107+ },108+ "vouches": [109+ {110+ "denounced": false,111+ "handle": "alice"112+ },113+ {114+ "denounced": true,115+ "handle": "mallory",116+ "note": "spam"117+ }118+ ],119+ "weakening": {120+ "markers": [".skip(", "@ts-ignore"]121+ }122+ }123+ },124+ "a policy whose deciders are still the owners marker": {125+ "schema": "Policy",126+ "value": {127+ "agents": "trailer",128+ "asks": [129+ {130+ "askedBy": "alice",131+ "blockedBy": [],132+ "brief": {133+ "context": ["ISO 8601 weeks start on Monday."],134+ "current": "Week 1 of 2027 parses as week 53 of 2026.",135+ "outOfScope": ["Locale-specific weeks"],136+ "terms": ["ISO week"],137+ "want": "An ISO week date parses to the Monday of that week."138+ },139+ "check": {140+ "_tag": "RedThenGreen",141+ "path": "packages/parse/test/iso-week.test.ts"142+ },143+ "file": "config/asks/iso-week.ask.ts",144+ "id": "iso-week",145+ "kind": "fix",146+ "mentor": "bob",147+ "reserve": "newcomers",148+ "territory": {149+ "module": "@datekit/parse",150+ "paths": ["packages/parse/**"],151+ "publicFiles": ["packages/parse/src/index.ts"]152+ },153+ "openedAt": "2026-10-07T12:00:00.000Z",154+ "openedIn": "4444444444444444444444444444444444444444",155+ "parent": "drop-moment",156+ "project": "datekit",157+ "state": "open"158+ }159+ ],160+ "at": "4444444444444444444444444444444444444444",161+ "budget": {162+ "decisionsPerDay": 5,163+ "expireDays": 14164+ },165+ "caps": {166+ "claimsPerPerson": 3,167+ "proposalsPerPerson": 2168+ },169+ "claims": {170+ "lapseAfterMs": 86400000,171+ "warnAfterMs": 7200000172+ },173+ "deciders": [174+ {175+ "handles": "owners",176+ "paths": "**"177+ }178+ ],179+ "functions": {180+ "admit": false,181+ "opensAlone": true182+ },183+ "judge": {184+ "paths": ["config/**", ".env.schema"],185+ "pointers": ["package.json#/scripts"]186+ },187+ "kinds": [188+ {189+ "checkKind": "redThenGreen",190+ "claimers": "vouched",191+ "finish": "optional",192+ "name": "fix",193+ "oneWay": false,194+ "race": 1,195+ "requires": ["want", "check", "territory"],196+ "strength": "assertion"197+ }198+ ],199+ "modules": [200+ {201+ "module": "@datekit/parse",202+ "paths": ["packages/parse/**"],203+ "publicFiles": ["packages/parse/src/index.ts"]204+ }205+ ],206+ "ratchets": [207+ {208+ "measure": {209+ "_tag": "Metric",210+ "command": "bun run size",211+ "path": "/total"212+ },213+ "name": "bundleSize"214+ }215+ ],216+ "record": {217+ "countsAfterDays": 30,218+ "windowDays": 365219+ },220+ "run": {221+ "checks": {222+ "lint": "bun run lint",223+ "types": "bun run typecheck",224+ "unit": "bun run test"225+ },226+ "doctor": "bun run doctor",227+ "image": "checker:default",228+ "setup": "bun install --frozen-lockfile --ignore-scripts",229+ "setupEgress": ["registry.npmjs.org"],230+ "test": "bun test {path}"231+ },232+ "source": "config",233+ "vouch": {234+ "file": "config/vouched.td",235+ "mode": "forCode"236+ },237+ "vouches": [238+ {239+ "denounced": false,240+ "handle": "alice"241+ },242+ {243+ "denounced": true,244+ "handle": "mallory",245+ "note": "spam"246+ }247+ ],248+ "weakening": {249+ "markers": [".skip(", "@ts-ignore"]250+ }251+ }252+ },253+ "a caller named by an untagged handle": {254+ "schema": "Principal",255+ "value": {256+ "handle": "alice"257+ }258+ },259+ "an envelope of a version the CLI does not know": {260+ "schema": "Envelope",261+ "value": {262+ "command": "asks",263+ "data": {264+ "asks": []265+ },266+ "ok": true,267+ "v": 2268+ }269+ },270+ "an ok envelope without its data": {271+ "schema": "Envelope",272+ "value": {273+ "command": "asks",274+ "ok": true,275+ "v": 1276+ }277+ }278+ },279+ "roundTrip": {280+ "AgentTrailer": [281+ {282+ "harness": "pi",283+ "verified": false284+ }285+ ],286+ "AnswerReceipt": [287+ {288+ "ask": "iso-week",289+ "base": "1111111111111111111111111111111111111111",290+ "head": "3333333333333333333333333333333333333333",291+ "outcome": {292+ "_tag": "Checking",293+ "stage": "merge"294+ },295+ "project": "datekit",296+ "requestId": "push-33333333"297+ }298+ ],299+ "AnswerView": [300+ {301+ "ask": "iso-week",302+ "at": "2026-10-07T12:00:00.000Z",303+ "head": "3333333333333333333333333333333333333333",304+ "outcome": {305+ "_tag": "Checking",306+ "stage": "checks"307+ },308+ "requestId": "push-33333333"309+ }310+ ],311+ "Ask": [312+ {313+ "askedBy": "alice",314+ "blockedBy": [],315+ "brief": {316+ "context": ["ISO 8601 weeks start on Monday."],317+ "current": "Week 1 of 2027 parses as week 53 of 2026.",318+ "outOfScope": ["Locale-specific weeks"],319+ "terms": ["ISO week"],320+ "want": "An ISO week date parses to the Monday of that week."321+ },322+ "check": {323+ "_tag": "RedThenGreen",324+ "path": "packages/parse/test/iso-week.test.ts"325+ },326+ "file": "config/asks/iso-week.ask.ts",327+ "id": "iso-week",328+ "kind": "fix",329+ "mentor": "bob",330+ "reserve": "newcomers",331+ "territory": {332+ "module": "@datekit/parse",333+ "paths": ["packages/parse/**"],334+ "publicFiles": ["packages/parse/src/index.ts"]335+ },336+ "openedAt": "2026-10-07T12:00:00.000Z",337+ "openedIn": "4444444444444444444444444444444444444444",338+ "parent": "drop-moment",339+ "project": "datekit",340+ "state": "open"341+ }342+ ],343+ "AskInput": [344+ {345+ "askedBy": "alice",346+ "blockedBy": [],347+ "brief": {348+ "context": ["ISO 8601 weeks start on Monday."],349+ "current": "Week 1 of 2027 parses as week 53 of 2026.",350+ "outOfScope": ["Locale-specific weeks"],351+ "terms": ["ISO week"],352+ "want": "An ISO week date parses to the Monday of that week."353+ },354+ "check": {355+ "_tag": "RedThenGreen",356+ "path": "packages/parse/test/iso-week.test.ts"357+ },358+ "file": "config/asks/iso-week.ask.ts",359+ "id": "iso-week",360+ "kind": "fix",361+ "mentor": "bob",362+ "reserve": "newcomers",363+ "territory": {364+ "module": "@datekit/parse",365+ "paths": ["packages/parse/**"],366+ "publicFiles": ["packages/parse/src/index.ts"]367+ }368+ }369+ ],370+ "AskKind": [371+ {372+ "checkKind": "redThenGreen",373+ "claimers": "vouched",374+ "finish": "optional",375+ "name": "fix",376+ "oneWay": false,377+ "race": 1,378+ "requires": ["want", "check", "territory"],379+ "strength": "assertion"380+ },381+ {382+ "checkKind": "redThenGreen",383+ "claimers": {384+ "record": {385+ "area": "parse",386+ "atLeast": 2387+ }388+ },389+ "finish": "optional",390+ "name": "fix",391+ "oneWay": false,392+ "race": 1,393+ "requires": ["want", "check", "territory"],394+ "strength": "assertion"395+ },396+ {397+ "checkKind": "redThenGreen",398+ "claimers": {399+ "newcomer": {400+ "mentor": "bob"401+ }402+ },403+ "finish": "optional",404+ "name": "fix",405+ "oneWay": false,406+ "race": 1,407+ "requires": ["want", "check", "territory"],408+ "strength": "assertion"409+ }410+ ],411+ "AskListing": [412+ {413+ "ask": "iso-week",414+ "blockedBy": ["drop-moment"],415+ "claimed": false,416+ "kind": "fix",417+ "reserve": "newcomers",418+ "territory": "@datekit/parse",419+ "want": "An ISO week date parses to the Monday of that week."420+ }421+ ],422+ "Brief": [423+ {424+ "context": ["ISO 8601 weeks start on Monday."],425+ "current": "Week 1 of 2027 parses as week 53 of 2026.",426+ "outOfScope": ["Locale-specific weeks"],427+ "terms": ["ISO week"],428+ "want": "An ISO week date parses to the Monday of that week."429+ }430+ ],431+ "CheckSpec": [432+ {433+ "_tag": "RedThenGreen",434+ "path": "packages/parse/test/iso-week.test.ts"435+ },436+ {437+ "_tag": "LintToZero",438+ "command": "bunx oxlint --format json",439+ "rule": "no-explicit-any",440+ "territory": "@datekit/parse"441+ },442+ {443+ "_tag": "Ratchet",444+ "ratchet": "anyCount"445+ },446+ {447+ "_tag": "Migrate",448+ "count": "bun scripts/count.ts",449+ "from": "parseDate",450+ "to": "parse"451+ },452+ {453+ "_tag": "SymbolAbsent",454+ "count": "bun scripts/count.ts",455+ "symbol": "parseDate"456+ }457+ ],458+ "ClaimView": [459+ {460+ "ask": "iso-week",461+ "base": "1111111111111111111111111111111111111111",462+ "checkCommand": "cli check",463+ "claimant": "alice",464+ "fork": "datekit--iso-week--alice",465+ "lapsesAt": "2026-10-08T12:00:00.000Z",466+ "lastPushAt": "2026-10-07T12:00:00.000Z",467+ "openedAt": "2026-10-07T12:00:00.000Z",468+ "project": "datekit",469+ "remote": "https://example.com/git/datekit--iso-week--alice",470+ "state": "live",471+ "suite": "sha256:7777777777777777777777777777777777777777777777777777777777777777",472+ "warnsAt": "2026-10-07T14:00:00.000Z"473+ }474+ ],475+ "Credit": [476+ {477+ "handle": "alice",478+ "role": "Asked-by"479+ }480+ ],481+ "CreditSummary": [482+ {483+ "area": "@datekit/parse",484+ "count": 4,485+ "project": "datekit",486+ "role": "Signed-off-by"487+ }488+ ],489+ "Decision": [490+ {491+ "decided": {492+ "at": "2026-10-07T14:00:00.000Z",493+ "by": "alice",494+ "choice": "accept",495+ "note": "Worth it."496+ },497+ "deciders": ["alice"],498+ "default": "decline",499+ "evidence": [500+ {501+ "href": "https://example.com/7",502+ "label": "lanes",503+ "value": "3/3"504+ }505+ ],506+ "expiresAt": "2026-10-21T12:00:00.000Z",507+ "id": "dec-000001",508+ "openedAt": "2026-10-07T12:00:00.000Z",509+ "project": "datekit",510+ "subject": {511+ "_tag": "OpenProposal",512+ "proposal": "prop-000001"513+ }514+ },515+ {516+ "decided": {517+ "at": "2026-10-07T14:00:00.000Z",518+ "by": "alice",519+ "choice": "accept",520+ "note": "Worth it."521+ },522+ "deciders": ["alice"],523+ "default": "decline",524+ "evidence": [525+ {526+ "href": "https://example.com/7",527+ "label": "lanes",528+ "value": "3/3"529+ }530+ ],531+ "expiresAt": "2026-10-21T12:00:00.000Z",532+ "id": "dec-000001",533+ "openedAt": "2026-10-07T12:00:00.000Z",534+ "project": "datekit",535+ "subject": {536+ "_tag": "Finish",537+ "ask": "iso-week",538+ "head": "3333333333333333333333333333333333333333"539+ }540+ },541+ {542+ "decided": {543+ "at": "2026-10-07T14:00:00.000Z",544+ "by": "alice",545+ "choice": "accept",546+ "note": "Worth it."547+ },548+ "deciders": ["alice"],549+ "default": "decline",550+ "evidence": [551+ {552+ "href": "https://example.com/7",553+ "label": "lanes",554+ "value": "3/3"555+ }556+ ],557+ "expiresAt": "2026-10-21T12:00:00.000Z",558+ "id": "dec-000001",559+ "openedAt": "2026-10-07T12:00:00.000Z",560+ "project": "datekit",561+ "subject": {562+ "_tag": "RaiseRatchet",563+ "after": 12,564+ "ask": "iso-week",565+ "before": 10,566+ "ratchet": "anyCount",567+ "territory": "@datekit/parse"568+ }569+ },570+ {571+ "decided": {572+ "at": "2026-10-07T14:00:00.000Z",573+ "by": "alice",574+ "choice": "accept",575+ "note": "Worth it."576+ },577+ "deciders": ["alice"],578+ "default": "decline",579+ "evidence": [580+ {581+ "href": "https://example.com/7",582+ "label": "lanes",583+ "value": "3/3"584+ }585+ ],586+ "expiresAt": "2026-10-21T12:00:00.000Z",587+ "id": "dec-000001",588+ "openedAt": "2026-10-07T12:00:00.000Z",589+ "project": "datekit",590+ "subject": {591+ "_tag": "Waiver",592+ "ask": "iso-week",593+ "at": {594+ "line": 3,595+ "path": "packages/parse/test/a.test.ts"596+ },597+ "marker": ".skip(",598+ "reason": "Waits on the upstream fix."599+ }600+ },601+ {602+ "decided": {603+ "at": "2026-10-07T14:00:00.000Z",604+ "by": "alice",605+ "choice": "accept",606+ "note": "Worth it."607+ },608+ "deciders": ["alice"],609+ "default": "decline",610+ "evidence": [611+ {612+ "href": "https://example.com/7",613+ "label": "lanes",614+ "value": "3/3"615+ }616+ ],617+ "expiresAt": "2026-10-21T12:00:00.000Z",618+ "id": "dec-000001",619+ "openedAt": "2026-10-07T12:00:00.000Z",620+ "project": "datekit",621+ "subject": {622+ "_tag": "StrayPush",623+ "after": "3333333333333333333333333333333333333333",624+ "before": "1111111111111111111111111111111111111111",625+ "ref": "refs/heads/main"626+ }627+ },628+ {629+ "decided": {630+ "at": "2026-10-07T14:00:00.000Z",631+ "by": "alice",632+ "choice": "accept",633+ "note": "Worth it."634+ },635+ "deciders": ["alice"],636+ "default": "decline",637+ "evidence": [638+ {639+ "href": "https://example.com/7",640+ "label": "lanes",641+ "value": "3/3"642+ }643+ ],644+ "expiresAt": "2026-10-21T12:00:00.000Z",645+ "id": "dec-000001",646+ "openedAt": "2026-10-07T12:00:00.000Z",647+ "project": "datekit",648+ "subject": {649+ "_tag": "PostureChange",650+ "from": "open",651+ "to": "openWithSealedEvidence"652+ }653+ },654+ {655+ "decided": {656+ "at": "2026-10-07T14:00:00.000Z",657+ "by": "alice",658+ "choice": "accept",659+ "note": "Worth it."660+ },661+ "deciders": ["alice"],662+ "default": "decline",663+ "evidence": [664+ {665+ "href": "https://example.com/7",666+ "label": "lanes",667+ "value": "3/3"668+ }669+ ],670+ "expiresAt": "2026-10-21T12:00:00.000Z",671+ "id": "dec-000001",672+ "openedAt": "2026-10-07T12:00:00.000Z",673+ "project": "datekit",674+ "subject": {675+ "_tag": "Vouch",676+ "handle": "dave"677+ }678+ },679+ {680+ "decided": {681+ "at": "2026-10-07T14:00:00.000Z",682+ "by": "alice",683+ "choice": "accept",684+ "note": "Worth it."685+ },686+ "deciders": ["alice"],687+ "default": "decline",688+ "evidence": [689+ {690+ "href": "https://example.com/7",691+ "label": "lanes",692+ "value": "3/3"693+ }694+ ],695+ "expiresAt": "2026-10-21T12:00:00.000Z",696+ "id": "dec-000001",697+ "openedAt": "2026-10-07T12:00:00.000Z",698+ "project": "datekit",699+ "subject": {700+ "_tag": "SecretInTree",701+ "ask": "iso-week",702+ "item": "PAYMENTS_KEY"703+ }704+ },705+ {706+ "decided": {707+ "at": "2026-10-07T14:00:00.000Z",708+ "by": "alice",709+ "choice": "accept",710+ "note": "Worth it."711+ },712+ "deciders": ["alice"],713+ "default": "decline",714+ "evidence": [715+ {716+ "href": "https://example.com/7",717+ "label": "lanes",718+ "value": "3/3"719+ }720+ ],721+ "expiresAt": "2026-10-21T12:00:00.000Z",722+ "id": "dec-000001",723+ "openedAt": "2026-10-07T12:00:00.000Z",724+ "project": "datekit",725+ "subject": {726+ "_tag": "ProxyWidened",727+ "hosts": ["api.stripe.com"],728+ "item": "PAYMENTS_KEY"729+ }730+ }731+ ],732+ "EnvSchemaView": [733+ {734+ "at": "4444444444444444444444444444444444444444",735+ "currentEnvKey": "APP_ENV",736+ "file": ".env.schema",737+ "imports": ["./.env.shared.schema"],738+ "items": [739+ {740+ "deprecated": false,741+ "description": "The payment provider's key.",742+ "docs": "https://example.com/docs/keys",743+ "key": "PAYMENTS_KEY",744+ "placeholder": "pk_placeholder",745+ "proxy": {746+ "block": false,747+ "domains": ["api.stripe.com"],748+ "method": "POST",749+ "path": "/v1/*"750+ },751+ "required": true,752+ "sensitive": true,753+ "tags": ["payments"],754+ "type": "string(startsWith=sk_)",755+ "value": {756+ "setAt": "2026-10-07T12:00:00.000Z",757+ "setBy": "alice"758+ }759+ },760+ {761+ "key": "APP_ENV",762+ "required": "depends",763+ "sensitive": false,764+ "tags": []765+ }766+ ],767+ "project": "datekit"768+ }769+ ],770+ "Envelope": [771+ {772+ "command": "asks",773+ "data": {774+ "asks": [775+ {776+ "ask": "iso-week",777+ "blockedBy": ["drop-moment"],778+ "claimed": false,779+ "kind": "fix",780+ "reserve": "newcomers",781+ "territory": "@datekit/parse",782+ "want": "An ISO week date parses to the Monday of that week."783+ }784+ ]785+ },786+ "ok": true,787+ "v": 1788+ },789+ {790+ "command": "claim",791+ "ok": false,792+ "refusals": [793+ {794+ "_tag": "NotClaimed",795+ "ask": "iso-week",796+ "next": "cli claim iso-week",797+ "retryable": true798+ }799+ ],800+ "v": 1801+ }802+ ],803+ "Evidence": [804+ {805+ "label": "lanes",806+ "value": "3/3"807+ }808+ ],809+ "FrontPageEntry": [810+ {811+ "ask": {812+ "ask": "iso-week",813+ "blockedBy": ["drop-moment"],814+ "claimed": false,815+ "kind": "fix",816+ "reserve": "newcomers",817+ "territory": "@datekit/parse",818+ "want": "An ISO week date parses to the Monday of that week."819+ },820+ "posture": "open",821+ "project": "datekit",822+ "takeable": true823+ }824+ ],825+ "LandingView": [826+ {827+ "ask": "iso-week",828+ "assisted": [829+ {830+ "harness": "claude-code",831+ "model": "haiku",832+ "verified": true833+ }834+ ],835+ "author": "carol",836+ "credits": [837+ {838+ "handle": "alice",839+ "role": "Asked-by"840+ },841+ {842+ "handle": "carol",843+ "role": "Signed-off-by"844+ }845+ ],846+ "heldBackTrailer": "Held-back: parse 7/7 @ sha256:7777777777777777777777777777777777777777777777777777777777777777",847+ "landedAt": "2026-10-07T12:00:00.000Z",848+ "parent": "1111111111111111111111111111111111111111",849+ "project": "datekit",850+ "requestId": "push-33333333",851+ "sha": "4444444444444444444444444444444444444444",852+ "verdict": {853+ "ask": "iso-week",854+ "at": "2026-10-07T12:00:00.000Z",855+ "base": "1111111111111111111111111111111111111111",856+ "checkVersion": "redThenGreen@0.0.0+abc123",857+ "head": "3333333333333333333333333333333333333333",858+ "heldBack": [859+ {860+ "area": "parse",861+ "passed": 7,862+ "suite": "sha256:7777777777777777777777777777777777777777777777777777777777777777",863+ "total": 7864+ }865+ ],866+ "lanes": [867+ {868+ "command": "bun run lint",869+ "durationMs": 1200,870+ "lane": "lint",871+ "result": "passed"872+ },873+ {874+ "command": "bun run test",875+ "durationMs": 3400,876+ "lane": "unit",877+ "logRef": "logs/datekit/7",878+ "result": "failed"879+ }880+ ],881+ "outcome": {882+ "_tag": "Landed",883+ "sha": "4444444444444444444444444444444444444444"884+ },885+ "patchId": "6666666666666666666666666666666666666666666666666666666666666666",886+ "project": "datekit",887+ "stage": "checks",888+ "tree": "5555555555555555555555555555555555555555",889+ "verifier": "platform"890+ }891+ }892+ ],893+ "Ledger": [894+ {895+ "entries": [896+ {897+ "_tag": "LayerDeclared",898+ "at": "2026-10-07T12:00:00.000Z",899+ "disclose": "sealed",900+ "kinds": ["checks"],901+ "layer": "maintainers",902+ "seq": 1903+ },904+ {905+ "_tag": "CountChanged",906+ "area": "parse",907+ "at": "2026-10-07T12:00:00.000Z",908+ "count": 7,909+ "layer": "maintainers",910+ "seq": 2911+ },912+ {913+ "_tag": "CommitmentPublished",914+ "area": "parse",915+ "at": "2026-10-07T12:00:00.000Z",916+ "authors": 2,917+ "checks": 7,918+ "seq": 3,919+ "suite": "sha256:7777777777777777777777777777777777777777777777777777777777777777"920+ },921+ {922+ "_tag": "Admitted",923+ "area": "parse",924+ "at": "2026-10-07T12:00:00.000Z",925+ "knownBadCaught": 1,926+ "mainRuns": 3,927+ "seq": 4,928+ "suite": "sha256:7777777777777777777777777777777777777777777777777777777777777777"929+ },930+ {931+ "_tag": "Released",932+ "at": "2026-10-07T12:00:00.000Z",933+ "by": "alice",934+ "landing": "4444444444444444444444444444444444444444",935+ "layer": "maintainers",936+ "paths": 2,937+ "seq": 5938+ },939+ {940+ "_tag": "PostureChanged",941+ "at": "2026-10-07T12:00:00.000Z",942+ "decision": "dec-000001",943+ "from": "open",944+ "seq": 6,945+ "to": "openWithSealedEvidence"946+ },947+ {948+ "_tag": "ValueSet",949+ "at": "2026-10-07T12:00:00.000Z",950+ "by": "alice",951+ "key": "PAYMENTS_KEY",952+ "seq": 7953+ }954+ ],955+ "layers": [956+ {957+ "audience": "maintainers",958+ "disclose": "sealed",959+ "holds": ["checks"],960+ "maxDays": 365,961+ "name": "maintainers",962+ "reason": "Held-back checks for the parser.",963+ "repo": "datekit--maintainers",964+ "sunsetDays": 90965+ }966+ ],967+ "posture": "openWithSealedEvidence",968+ "postureLabel": "Open with sealed evidence",969+ "project": "datekit"970+ }971+ ],972+ "Outcome": [973+ {974+ "_tag": "Checking",975+ "stage": "merge"976+ },977+ {978+ "_tag": "Landed",979+ "sha": "4444444444444444444444444444444444444444"980+ },981+ {982+ "_tag": "WaitingOnParent",983+ "ask": "drop-moment"984+ },985+ {986+ "_tag": "AwaitingFinish",987+ "decider": "alice"988+ },989+ {990+ "_tag": "AwaitingDecision",991+ "decision": "dec-000001"992+ },993+ {994+ "_tag": "Refused",995+ "refusals": [996+ {997+ "_tag": "NotClaimed",998+ "ask": "iso-week",999+ "next": "cli claim iso-week",1000+ "retryable": true1001+ }1002+ ]1003+ }1004+ ],1005+ "Policy": [1006+ {1007+ "agents": "trailer",1008+ "asks": [1009+ {1010+ "askedBy": "alice",1011+ "blockedBy": [],1012+ "brief": {1013+ "context": ["ISO 8601 weeks start on Monday."],1014+ "current": "Week 1 of 2027 parses as week 53 of 2026.",1015+ "outOfScope": ["Locale-specific weeks"],1016+ "terms": ["ISO week"],1017+ "want": "An ISO week date parses to the Monday of that week."1018+ },1019+ "check": {1020+ "_tag": "RedThenGreen",1021+ "path": "packages/parse/test/iso-week.test.ts"1022+ },1023+ "file": "config/asks/iso-week.ask.ts",1024+ "id": "iso-week",1025+ "kind": "fix",1026+ "mentor": "bob",1027+ "reserve": "newcomers",1028+ "territory": {1029+ "module": "@datekit/parse",1030+ "paths": ["packages/parse/**"],1031+ "publicFiles": ["packages/parse/src/index.ts"]1032+ },1033+ "openedAt": "2026-10-07T12:00:00.000Z",1034+ "openedIn": "4444444444444444444444444444444444444444",1035+ "parent": "drop-moment",1036+ "project": "datekit",1037+ "state": "open"1038+ }1039+ ],1040+ "at": "4444444444444444444444444444444444444444",1041+ "budget": {1042+ "decisionsPerDay": 5,1043+ "expireDays": 141044+ },1045+ "caps": {1046+ "claimsPerPerson": 3,1047+ "proposalsPerPerson": 21048+ },1049+ "claims": {1050+ "lapseAfterMs": 86400000,1051+ "warnAfterMs": 72000001052+ },1053+ "deciders": [1054+ {1055+ "handles": ["alice"],1056+ "paths": "**"1057+ }1058+ ],1059+ "functions": {1060+ "admit": false,1061+ "opensAlone": true1062+ },1063+ "judge": {1064+ "paths": ["config/**", ".env.schema"],1065+ "pointers": ["package.json#/scripts"]1066+ },1067+ "kinds": [1068+ {1069+ "checkKind": "redThenGreen",1070+ "claimers": "vouched",1071+ "finish": "optional",1072+ "name": "fix",1073+ "oneWay": false,1074+ "race": 1,1075+ "requires": ["want", "check", "territory"],1076+ "strength": "assertion"1077+ }1078+ ],1079+ "modules": [1080+ {1081+ "module": "@datekit/parse",1082+ "paths": ["packages/parse/**"],1083+ "publicFiles": ["packages/parse/src/index.ts"]1084+ }1085+ ],1086+ "ratchets": [1087+ {1088+ "measure": {1089+ "_tag": "Metric",1090+ "command": "bun run size",1091+ "path": "/total"1092+ },1093+ "name": "bundleSize"1094+ }1095+ ],1096+ "record": {1097+ "countsAfterDays": 30,1098+ "windowDays": 3651099+ },1100+ "run": {1101+ "checks": {1102+ "lint": "bun run lint",1103+ "types": "bun run typecheck",1104+ "unit": "bun run test"1105+ },1106+ "doctor": "bun run doctor",1107+ "image": "checker:default",1108+ "setup": "bun install --frozen-lockfile --ignore-scripts",1109+ "setupEgress": ["registry.npmjs.org"],1110+ "test": "bun test {path}"1111+ },1112+ "source": "config",1113+ "vouch": {1114+ "file": "config/vouched.td",1115+ "mode": "forCode"1116+ },1117+ "vouches": [1118+ {1119+ "denounced": false,1120+ "handle": "alice"1121+ },1122+ {1123+ "denounced": true,1124+ "handle": "mallory",1125+ "note": "spam"1126+ }1127+ ],1128+ "weakening": {1129+ "markers": [".skip(", "@ts-ignore"]1130+ }1131+ }1132+ ],1133+ "PolicyInput": [1134+ {1135+ "agents": "trailer",1136+ "asks": [1137+ {1138+ "askedBy": "alice",1139+ "blockedBy": [],1140+ "brief": {1141+ "context": ["ISO 8601 weeks start on Monday."],1142+ "current": "Week 1 of 2027 parses as week 53 of 2026.",1143+ "outOfScope": ["Locale-specific weeks"],1144+ "terms": ["ISO week"],1145+ "want": "An ISO week date parses to the Monday of that week."1146+ },1147+ "check": {1148+ "_tag": "RedThenGreen",1149+ "path": "packages/parse/test/iso-week.test.ts"1150+ },1151+ "file": "config/asks/iso-week.ask.ts",1152+ "id": "iso-week",1153+ "kind": "fix",1154+ "mentor": "bob",1155+ "reserve": "newcomers",1156+ "territory": {1157+ "module": "@datekit/parse",1158+ "paths": ["packages/parse/**"],1159+ "publicFiles": ["packages/parse/src/index.ts"]1160+ }1161+ }1162+ ],1163+ "budget": {1164+ "decisionsPerDay": 5,1165+ "expireDays": 141166+ },1167+ "caps": {1168+ "claimsPerPerson": 3,1169+ "proposalsPerPerson": 21170+ },1171+ "claims": {1172+ "lapseAfterMs": 86400000,1173+ "warnAfterMs": 72000001174+ },1175+ "deciders": [1176+ {1177+ "handles": "owners",1178+ "paths": "**"1179+ }1180+ ],1181+ "functions": {1182+ "admit": false,1183+ "opensAlone": true1184+ },1185+ "kinds": [1186+ {1187+ "checkKind": "redThenGreen",1188+ "claimers": "vouched",1189+ "finish": "optional",1190+ "name": "fix",1191+ "oneWay": false,1192+ "race": 1,1193+ "requires": ["want", "check", "territory"],1194+ "strength": "assertion"1195+ }1196+ ],1197+ "ratchets": [1198+ {1199+ "measure": {1200+ "_tag": "Metric",1201+ "command": "bun run size",1202+ "path": "/total"1203+ },1204+ "name": "bundleSize"1205+ }1206+ ],1207+ "record": {1208+ "countsAfterDays": 30,1209+ "windowDays": 3651210+ },1211+ "run": {1212+ "_tag": "FromCI"1213+ },1214+ "source": "config",1215+ "vouch": {1216+ "file": "config/vouched.td",1217+ "mode": "forCode"1218+ },1219+ "weakening": {1220+ "markers": [".skip(", "@ts-ignore"]1221+ }1222+ },1223+ {1224+ "agents": "trailer",1225+ "asks": [1226+ {1227+ "askedBy": "alice",1228+ "blockedBy": [],1229+ "brief": {1230+ "context": ["ISO 8601 weeks start on Monday."],1231+ "current": "Week 1 of 2027 parses as week 53 of 2026.",1232+ "outOfScope": ["Locale-specific weeks"],1233+ "terms": ["ISO week"],1234+ "want": "An ISO week date parses to the Monday of that week."1235+ },1236+ "check": {1237+ "_tag": "RedThenGreen",1238+ "path": "packages/parse/test/iso-week.test.ts"1239+ },1240+ "file": "config/asks/iso-week.ask.ts",1241+ "id": "iso-week",1242+ "kind": "fix",1243+ "mentor": "bob",1244+ "reserve": "newcomers",1245+ "territory": {1246+ "module": "@datekit/parse",1247+ "paths": ["packages/parse/**"],1248+ "publicFiles": ["packages/parse/src/index.ts"]1249+ }1250+ }1251+ ],1252+ "budget": {1253+ "decisionsPerDay": 5,1254+ "expireDays": 141255+ },1256+ "caps": {1257+ "claimsPerPerson": 3,1258+ "proposalsPerPerson": 21259+ },1260+ "claims": {1261+ "lapseAfterMs": 86400000,1262+ "warnAfterMs": 72000001263+ },1264+ "deciders": [1265+ {1266+ "handles": ["alice", "bob"],1267+ "paths": "packages/parse/**"1268+ }1269+ ],1270+ "functions": {1271+ "admit": false,1272+ "opensAlone": true1273+ },1274+ "kinds": [1275+ {1276+ "checkKind": "redThenGreen",1277+ "claimers": "vouched",1278+ "finish": "optional",1279+ "name": "fix",1280+ "oneWay": false,1281+ "race": 1,1282+ "requires": ["want", "check", "territory"],1283+ "strength": "assertion"1284+ }1285+ ],1286+ "ratchets": [1287+ {1288+ "measure": {1289+ "_tag": "Metric",1290+ "command": "bun run size",1291+ "path": "/total"1292+ },1293+ "name": "bundleSize"1294+ }1295+ ],1296+ "record": {1297+ "countsAfterDays": 30,1298+ "windowDays": 3651299+ },1300+ "run": {1301+ "checks": {1302+ "lint": "bun run lint",1303+ "types": "bun run typecheck",1304+ "unit": "bun run test"1305+ },1306+ "doctor": "bun run doctor",1307+ "image": "checker:default",1308+ "setup": "bun install --frozen-lockfile --ignore-scripts",1309+ "setupEgress": ["registry.npmjs.org"],1310+ "test": "bun test {path}"1311+ },1312+ "source": "config",1313+ "vouch": {1314+ "file": "config/vouched.td",1315+ "mode": "forCode"1316+ },1317+ "weakening": {1318+ "markers": [".skip(", "@ts-ignore"]1319+ }1320+ }1321+ ],1322+ "Principal": [1323+ {1324+ "_tag": "Person",1325+ "handle": "alice"1326+ },1327+ {1328+ "_tag": "Anonymous"1329+ }1330+ ],1331+ "ProjectEvent": [1332+ {1333+ "_tag": "AskOpened",1334+ "ask": {1335+ "ask": "iso-week",1336+ "blockedBy": ["drop-moment"],1337+ "claimed": false,1338+ "kind": "fix",1339+ "reserve": "newcomers",1340+ "territory": "@datekit/parse",1341+ "want": "An ISO week date parses to the Monday of that week."1342+ },1343+ "at": "2026-10-07T12:00:00.000Z",1344+ "seq": 11345+ },1346+ {1347+ "_tag": "AskClosed",1348+ "ask": "iso-week",1349+ "at": "2026-10-07T12:00:00.000Z",1350+ "landing": "4444444444444444444444444444444444444444",1351+ "seq": 21352+ },1353+ {1354+ "_tag": "Claimed",1355+ "ask": "iso-week",1356+ "at": "2026-10-07T12:00:00.000Z",1357+ "claimant": "alice",1358+ "seq": 31359+ },1360+ {1361+ "_tag": "Released",1362+ "ask": "iso-week",1363+ "at": "2026-10-07T12:00:00.000Z",1364+ "seq": 41365+ },1366+ {1367+ "_tag": "Warned",1368+ "ask": "iso-week",1369+ "at": "2026-10-07T12:00:00.000Z",1370+ "seq": 51371+ },1372+ {1373+ "_tag": "Lapsed",1374+ "ask": "iso-week",1375+ "at": "2026-10-07T12:00:00.000Z",1376+ "seq": 61377+ },1378+ {1379+ "_tag": "Pushed",1380+ "ask": "iso-week",1381+ "at": "2026-10-07T12:00:00.000Z",1382+ "head": "3333333333333333333333333333333333333333",1383+ "seq": 71384+ },1385+ {1386+ "_tag": "Judged",1387+ "ask": "iso-week",1388+ "at": "2026-10-07T12:00:00.000Z",1389+ "head": "3333333333333333333333333333333333333333",1390+ "outcome": {1391+ "_tag": "Refused",1392+ "refusals": [1393+ {1394+ "_tag": "NotClaimed",1395+ "ask": "iso-week",1396+ "next": "cli claim iso-week",1397+ "retryable": true1398+ }1399+ ]1400+ },1401+ "seq": 81402+ },1403+ {1404+ "_tag": "Landed",1405+ "at": "2026-10-07T12:00:00.000Z",1406+ "landing": {1407+ "ask": "iso-week",1408+ "assisted": [1409+ {1410+ "harness": "claude-code",1411+ "model": "haiku",1412+ "verified": true1413+ }1414+ ],1415+ "author": "carol",1416+ "credits": [1417+ {1418+ "handle": "alice",1419+ "role": "Asked-by"1420+ },1421+ {1422+ "handle": "carol",1423+ "role": "Signed-off-by"1424+ }1425+ ],1426+ "heldBackTrailer": "Held-back: parse 7/7 @ sha256:7777777777777777777777777777777777777777777777777777777777777777",1427+ "landedAt": "2026-10-07T12:00:00.000Z",1428+ "parent": "1111111111111111111111111111111111111111",1429+ "project": "datekit",1430+ "requestId": "push-33333333",1431+ "sha": "4444444444444444444444444444444444444444",1432+ "verdict": {1433+ "ask": "iso-week",1434+ "at": "2026-10-07T12:00:00.000Z",1435+ "base": "1111111111111111111111111111111111111111",1436+ "checkVersion": "redThenGreen@0.0.0+abc123",1437+ "head": "3333333333333333333333333333333333333333",1438+ "heldBack": [1439+ {1440+ "area": "parse",1441+ "passed": 7,1442+ "suite": "sha256:7777777777777777777777777777777777777777777777777777777777777777",1443+ "total": 71444+ }1445+ ],1446+ "lanes": [1447+ {1448+ "command": "bun run lint",1449+ "durationMs": 1200,1450+ "lane": "lint",1451+ "result": "passed"1452+ },1453+ {1454+ "command": "bun run test",1455+ "durationMs": 3400,1456+ "lane": "unit",1457+ "logRef": "logs/datekit/7",1458+ "result": "failed"1459+ }1460+ ],1461+ "outcome": {1462+ "_tag": "Landed",1463+ "sha": "4444444444444444444444444444444444444444"1464+ },1465+ "patchId": "6666666666666666666666666666666666666666666666666666666666666666",1466+ "project": "datekit",1467+ "stage": "checks",1468+ "tree": "5555555555555555555555555555555555555555",1469+ "verifier": "platform"1470+ }1471+ },1472+ "seq": 91473+ },1474+ {1475+ "_tag": "ProposalOpened",1476+ "at": "2026-10-07T12:00:00.000Z",1477+ "proposal": "prop-000001",1478+ "seq": 101479+ },1480+ {1481+ "_tag": "Decided",1482+ "at": "2026-10-07T12:00:00.000Z",1483+ "choice": "accept",1484+ "decision": "dec-000001",1485+ "seq": 111486+ },1487+ {1488+ "_tag": "LedgerAppended",1489+ "at": "2026-10-07T12:00:00.000Z",1490+ "entry": {1491+ "_tag": "ValueSet",1492+ "at": "2026-10-07T12:00:00.000Z",1493+ "by": "alice",1494+ "key": "PAYMENTS_KEY",1495+ "seq": 71496+ },1497+ "seq": 121498+ }1499+ ],1500+ "ProjectListing": [1501+ {1502+ "landedAt": "2026-10-07T12:00:00.000Z",1503+ "openAsks": 3,1504+ "posture": "open",1505+ "project": "datekit"1506+ },1507+ {1508+ "openAsks": 0,1509+ "posture": "open",1510+ "project": "burrow"1511+ }1512+ ],1513+ "Proposal": [1514+ {1515+ "expiresAt": "2026-10-21T12:00:00.000Z",1516+ "files": ["config/asks/iso-week.ask.ts"],1517+ "flags": "drop-moment",1518+ "id": "prop-000001",1519+ "openedAt": "2026-10-07T12:00:00.000Z",1520+ "project": "datekit",1521+ "proposer": "dave",1522+ "sealed": {1523+ "fork": "datekit--me--dave",1524+ "head": "3333333333333333333333333333333333333333"1525+ },1526+ "state": "open",1527+ "territory": "@datekit/parse",1528+ "want": "An ISO week date parses to the Monday of that week."1529+ }1530+ ],1531+ "RatchetSpec": [1532+ {1533+ "measure": {1534+ "_tag": "Count",1535+ "command": "bunx oxlint --format json",1536+ "rule": "no-explicit-any"1537+ },1538+ "name": "anyCount",1539+ "territory": "@datekit/parse"1540+ }1541+ ],1542+ "RunBlock": [1543+ {1544+ "checks": {1545+ "lint": "bun run lint",1546+ "types": "bun run typecheck",1547+ "unit": "bun run test"1548+ },1549+ "doctor": "bun run doctor",1550+ "image": "checker:default",1551+ "setup": "bun install --frozen-lockfile --ignore-scripts",1552+ "setupEgress": ["registry.npmjs.org"],1553+ "test": "bun test {path}"1554+ },1555+ {1556+ "checks": {},1557+ "test": "npm test"1558+ }1559+ ],1560+ "Territory": [1561+ {1562+ "module": "@datekit/parse",1563+ "paths": ["packages/parse/**"],1564+ "publicFiles": ["packages/parse/src/index.ts"]1565+ }1566+ ],1567+ "Today": [1568+ {1569+ "budget": {1570+ "finishes": 1,1571+ "total": 5,1572+ "used": 21573+ },1574+ "decider": "alice",1575+ "decisions": [1576+ {1577+ "decided": {1578+ "at": "2026-10-07T14:00:00.000Z",1579+ "by": "alice",1580+ "choice": "accept",1581+ "note": "Worth it."1582+ },1583+ "deciders": ["alice"],1584+ "default": "decline",1585+ "evidence": [1586+ {1587+ "href": "https://example.com/7",1588+ "label": "lanes",1589+ "value": "3/3"1590+ }1591+ ],1592+ "expiresAt": "2026-10-21T12:00:00.000Z",1593+ "id": "dec-000001",1594+ "openedAt": "2026-10-07T12:00:00.000Z",1595+ "project": "datekit",1596+ "subject": {1597+ "_tag": "OpenProposal",1598+ "proposal": "prop-000001"1599+ }1600+ }1601+ ],1602+ "expiringSoon": ["dec-000001"],1603+ "newcomers": ["dave"],1604+ "overflow": 0,1605+ "unattended": [1606+ {1607+ "ask": "iso-week",1608+ "assisted": [1609+ {1610+ "harness": "claude-code",1611+ "model": "haiku",1612+ "verified": true1613+ }1614+ ],1615+ "author": "carol",1616+ "credits": [1617+ {1618+ "handle": "alice",1619+ "role": "Asked-by"1620+ },1621+ {1622+ "handle": "carol",1623+ "role": "Signed-off-by"1624+ }1625+ ],1626+ "heldBackTrailer": "Held-back: parse 7/7 @ sha256:7777777777777777777777777777777777777777777777777777777777777777",1627+ "landedAt": "2026-10-07T12:00:00.000Z",1628+ "parent": "1111111111111111111111111111111111111111",1629+ "project": "datekit",1630+ "requestId": "push-33333333",1631+ "sha": "4444444444444444444444444444444444444444",1632+ "verdict": {1633+ "ask": "iso-week",1634+ "at": "2026-10-07T12:00:00.000Z",1635+ "base": "1111111111111111111111111111111111111111",1636+ "checkVersion": "redThenGreen@0.0.0+abc123",1637+ "head": "3333333333333333333333333333333333333333",1638+ "heldBack": [1639+ {1640+ "area": "parse",1641+ "passed": 7,1642+ "suite": "sha256:7777777777777777777777777777777777777777777777777777777777777777",1643+ "total": 71644+ }1645+ ],1646+ "lanes": [1647+ {1648+ "command": "bun run lint",1649+ "durationMs": 1200,1650+ "lane": "lint",1651+ "result": "passed"1652+ },1653+ {1654+ "command": "bun run test",1655+ "durationMs": 3400,1656+ "lane": "unit",1657+ "logRef": "logs/datekit/7",1658+ "result": "failed"1659+ }1660+ ],1661+ "outcome": {1662+ "_tag": "Landed",1663+ "sha": "4444444444444444444444444444444444444444"1664+ },1665+ "patchId": "6666666666666666666666666666666666666666666666666666666666666666",1666+ "project": "datekit",1667+ "stage": "checks",1668+ "tree": "5555555555555555555555555555555555555555",1669+ "verifier": "platform"1670+ }1671+ }1672+ ]1673+ }1674+ ],1675+ "Verdict": [1676+ {1677+ "ask": "iso-week",1678+ "at": "2026-10-07T12:00:00.000Z",1679+ "base": "1111111111111111111111111111111111111111",1680+ "checkVersion": "redThenGreen@0.0.0+abc123",1681+ "head": "3333333333333333333333333333333333333333",1682+ "heldBack": [1683+ {1684+ "area": "parse",1685+ "passed": 7,1686+ "suite": "sha256:7777777777777777777777777777777777777777777777777777777777777777",1687+ "total": 71688+ }1689+ ],1690+ "lanes": [1691+ {1692+ "command": "bun run lint",1693+ "durationMs": 1200,1694+ "lane": "lint",1695+ "result": "passed"1696+ },1697+ {1698+ "command": "bun run test",1699+ "durationMs": 3400,1700+ "lane": "unit",1701+ "logRef": "logs/datekit/7",1702+ "result": "failed"1703+ }1704+ ],1705+ "outcome": {1706+ "_tag": "Refused",1707+ "refusals": [1708+ {1709+ "_tag": "NotClaimed",1710+ "ask": "iso-week",1711+ "next": "cli claim iso-week",1712+ "retryable": true1713+ }1714+ ]1715+ },1716+ "patchId": "6666666666666666666666666666666666666666666666666666666666666666",1717+ "project": "datekit",1718+ "stage": "checks",1719+ "tree": "5555555555555555555555555555555555555555",1720+ "verifier": "platform"1721+ }1722+ ]1723+ },1724+ "withoutDefaults": {1725+ "asks": [1726+ {1727+ "askedBy": "alice",1728+ "blockedBy": [],1729+ "brief": {1730+ "context": ["ISO 8601 weeks start on Monday."],1731+ "current": "Week 1 of 2027 parses as week 53 of 2026.",1732+ "outOfScope": ["Locale-specific weeks"],1733+ "terms": ["ISO week"],1734+ "want": "An ISO week date parses to the Monday of that week."1735+ },1736+ "check": {1737+ "_tag": "RedThenGreen",1738+ "path": "packages/parse/test/iso-week.test.ts"1739+ },1740+ "file": "config/asks/iso-week.ask.ts",1741+ "id": "iso-week",1742+ "kind": "fix",1743+ "mentor": "bob",1744+ "reserve": "newcomers",1745+ "territory": {1746+ "module": "@datekit/parse",1747+ "paths": ["packages/parse/**"],1748+ "publicFiles": ["packages/parse/src/index.ts"]1749+ }1750+ }1751+ ],1752+ "deciders": [1753+ {1754+ "handles": "owners",1755+ "paths": "**"1756+ }1757+ ],1758+ "functions": {1759+ "admit": false,1760+ "opensAlone": true1761+ },1762+ "kinds": [1763+ {1764+ "checkKind": "redThenGreen",1765+ "claimers": "vouched",1766+ "finish": "optional",1767+ "name": "fix",1768+ "oneWay": false,1769+ "race": 1,1770+ "requires": ["want", "check", "territory"],1771+ "strength": "assertion"1772+ }1773+ ],1774+ "ratchets": [1775+ {1776+ "measure": {1777+ "_tag": "Metric",1778+ "command": "bun run size",1779+ "path": "/total"1780+ },1781+ "name": "bundleSize"1782+ }1783+ ],1784+ "run": {1785+ "_tag": "FromCI"1786+ },1787+ "source": "config",1788+ "weakening": {1789+ "markers": [".skip(", "@ts-ignore"]1790+ }1791+ }1792+}modified:packages/protocol/test/cli.test.ts+11 added-2 removed
6 unmodified lines7 import { TestConsole } from "effect/testing";8 9 import { toCommand } from "../src/cli.ts";10 import { Client, Contracts, ListAsks, SubmitAnswer } from "../src/contracts.ts";11-import { CommitSha } from "../src/ids.ts";11+import { CommitSha, KindName } from "../src/ids.ts";12 import { StaleBase } from "../src/refusal.ts";13 import { asTester } from "../src/testing.ts";14 import { ask, base, main, path } from "./examples.ts";15 3 unmodified lines19 const quiet = Contracts.toLayer({20 listAsks: ({ project }) =>21 Effect.succeed({22 asks: [23- { ask, claimed: false, territory: project, want: "Parse a comma" },23+ {24+ ask,25+ blockedBy: [],26+ claimed: false,27+ kind: KindName.make("fix"),28+ territory: project,29+ want: "Parse a comma",30+ },31 ],32 }),33 submitAnswer: () => Effect.succeed({ main }),34 });51 unmodified lines86 expect(yield* Schema.decodeEffect(Json)(out.join("\n"))).toStrictEqual({87 asks: [88 {89 ask: "fix-parser",90+ blockedBy: [],91 claimed: false,92+ kind: "fix",93 territory: "demo",94 want: "Parse a comma",95 },96 ],70 unmodified linesadded:packages/protocol/test/domain.test.ts+244 added
1+import { describe, expect, it } from "@effect/vitest";2+import { Brand } from "@repo/brand";3+import { Result, Schema } from "effect";4+5+import { AnswerReceipt, AnswerView, Verdict } from "../src/domain/answer.ts";6+import { Ask, AskListing, Brief } from "../src/domain/ask.ts";7+import { CheckSpec, RatchetSpec } from "../src/domain/check.ts";8+import { ClaimView } from "../src/domain/claim.ts";9+import { Evidence } from "../src/domain/common.ts";10+import { AgentTrailer, Credit } from "../src/domain/credit.ts";11+import { Decision, Today } from "../src/domain/decision.ts";12+import { EnvSchemaView } from "../src/domain/env.ts";13+import { ProjectEvent } from "../src/domain/event.ts";14+import { FrontPageEntry, ProjectListing } from "../src/domain/front-page.ts";15+import { AskKind } from "../src/domain/kind.ts";16+import { LandingView } from "../src/domain/landing.ts";17+import { Outcome } from "../src/domain/outcome.ts";18+import { AskInput, Policy, PolicyInput } from "../src/domain/policy.ts";19+import { Proposal } from "../src/domain/proposal.ts";20+import { CreditSummary } from "../src/domain/record.ts";21+import { RunBlock } from "../src/domain/run.ts";22+import { Territory } from "../src/domain/territory.ts";23+import { Ledger } from "../src/domain/visibility.ts";24+import { Envelope } from "../src/envelope.ts";25+import {26+ AreaName,27+ AskId,28+ BlobSha,29+ CheckVersion,30+ DecisionId,31+ EnvKey,32+ Handle,33+ KindName,34+ LandedSha,35+ LandingId,36+ LaneName,37+ LayerName,38+ PatchId,39+ ProjectName,40+ ProposalId,41+ RatchetName,42+ RepoName,43+ RequestId,44+ SuiteRoot,45+ TreeSha,46+} from "../src/ids.ts";47+import { Anonymous, Person, Principal } from "../src/principal.ts";48+import wire from "./fixtures/domain.json" with { type: "json" };49+50+/** The fixture file: hand-written encoded values, as JSON carries them. */51+const Fixture = Schema.Struct({52+ refused: Schema.Record(53+ Schema.String,54+ Schema.Struct({ schema: Schema.NonEmptyString, value: Schema.Json })55+ ),56+ roundTrip: Schema.Record(Schema.String, Schema.NonEmptyArray(Schema.Json)),57+ withoutDefaults: Schema.Json,58+});59+60+const fixture = Schema.decodeUnknownSync(Fixture)(wire);61+62+/** A `--json` envelope around `listAsks`'s result. */63+const Listed = Envelope(Schema.Struct({ asks: Schema.Array(AskListing) }));64+65+/** Every schema the fixture has examples for, by its key there. */66+const schemas = {67+ AgentTrailer,68+ AnswerReceipt,69+ AnswerView,70+ Ask,71+ AskInput,72+ AskKind,73+ AskListing,74+ Brief,75+ CheckSpec,76+ ClaimView,77+ Credit,78+ CreditSummary,79+ Decision,80+ EnvSchemaView,81+ Envelope: Listed,82+ Evidence,83+ FrontPageEntry,84+ LandingView,85+ Ledger,86+ Outcome,87+ Policy,88+ PolicyInput,89+ Principal,90+ ProjectEvent,91+ ProjectListing,92+ Proposal,93+ RatchetSpec,94+ RunBlock,95+ Territory,96+ Today,97+ Verdict,98+} as const;99+100+const schemaNamed = new Map<string, Schema.Codec<unknown, unknown>>(101+ Object.entries(schemas)102+);103+104+const examples = Object.entries(schemas).flatMap(([name, schema]) =>105+ (fixture.roundTrip[name] ?? []).map((example, index) => ({106+ example,107+ name: `${name} #${index + 1}`,108+ schema,109+ }))110+);111+112+const refusals = Object.entries(fixture.refused).map(113+ ([description, { schema, value }]) => ({114+ description,115+ schema: schemaNamed.get(schema),116+ value,117+ })118+);119+120+const refuses = (schema: Schema.Codec<unknown, unknown>, input: Schema.Json) =>121+ Result.isFailure(Schema.decodeResult(schema)(input));122+123+describe("the domain schemas", () => {124+ it("have examples for every schema, and a schema for every example", () => {125+ expect(Object.keys(fixture.roundTrip).toSorted()).toStrictEqual(126+ Object.keys(schemas).toSorted()127+ );128+ expect(129+ refusals.flatMap(({ description, schema }) =>130+ schema === undefined ? [description] : []131+ )132+ ).toStrictEqual([]);133+ });134+135+ it.each(examples)(136+ "$name decodes its example and encodes it back unchanged",137+ ({ example, schema }) => {138+ expect(139+ Schema.encodeSync(schema)(Schema.decodeUnknownSync(schema)(example))140+ ).toStrictEqual(example);141+ }142+ );143+144+ it.each(refusals)("refuse $description", ({ schema, value }) => {145+ expect(schema !== undefined && refuses(schema, value)).toBeTruthy();146+ });147+148+ // MCP tool schemas and the reference docs come from these documents. A bare149+ // `Schema.Number` admits "Infinity" and "NaN"; a bare `Schema.optional`150+ // admits `null`.151+ it.each([152+ ["Policy", Policy],153+ ["Verdict", Verdict],154+ ["Outcome", Outcome],155+ ["ProjectEvent", ProjectEvent],156+ ] as const)(157+ "%s has a JSON Schema with no non-finite numbers and no nulls",158+ (_name, schema) => {159+ const document = JSON.stringify(Schema.toJsonSchemaDocument(schema));160+161+ expect(document).not.toMatch(/Infinity|NaN|"null"/u);162+ }163+ );164+165+ it("fill the defaults for every key the config folder may leave out", () => {166+ expect(167+ Schema.decodeUnknownSync(PolicyInput)(fixture.withoutDefaults)168+ ).toMatchObject({169+ agents: "trailer",170+ budget: { decisionsPerDay: 5, expireDays: 14 },171+ caps: { claimsPerPerson: 3, proposalsPerPerson: 2 },172+ claims: { lapseAfterMs: 86_400_000, warnAfterMs: 7_200_000 },173+ record: { countsAfterDays: 30, windowDays: 365 },174+ vouch: { file: `${Brand.configDir}/vouched.td`, mode: "forCode" },175+ });176+ });177+});178+179+describe("names and ids", () => {180+ it.each(["a--b", "-a", "a-", "A", "a_b", ""])(181+ "a project or an ask may not be named %j",182+ (name) => {183+ expect(refuses(ProjectName, name)).toBeTruthy();184+ expect(refuses(AskId, name)).toBeTruthy();185+ }186+ );187+188+ it.each(["a", "a-b", "iso-week-2", "datekit"])(189+ "a project or an ask may be named %j",190+ (name) => {191+ expect(refuses(ProjectName, name)).toBeFalsy();192+ expect(refuses(AskId, name)).toBeFalsy();193+ }194+ );195+196+ // `--` separates a fork's parts, and `me` and `layer` stand where an ask's197+ // name would in a working fork's or a layer's repo name.198+ it.each(["me", "layer"])("an ask may not be named %j", (name) => {199+ expect(refuses(AskId, name)).toBeTruthy();200+ expect(refuses(ProjectName, name)).toBeFalsy();201+ });202+203+ const tree = "5555555555555555555555555555555555555555";204+205+ const patchId = "6".repeat(64);206+207+ const suite = `sha256:${"7".repeat(64)}`;208+209+ it.each([210+ ["LandedSha", "4".repeat(40), "4444", LandedSha],211+ ["TreeSha", tree, "g".repeat(40), TreeSha],212+ ["BlobSha", tree, `${tree}0`, BlobSha],213+ ["PatchId", patchId, tree, PatchId],214+ ["RequestId", "push-33333333", "short", RequestId],215+ ["ProposalId", "prop-000001", "prop-1", ProposalId],216+ ["DecisionId", "dec-0a1b2c", "dec_0a1b2c", DecisionId],217+ ["LandingId", "land-000001", "-000001", LandingId],218+ ["KindName", "lintToZero", "1fix", KindName],219+ ["LayerName", "maintainers", "Maintainers", LayerName],220+ ["AreaName", "parse", "parse/iso", AreaName],221+ ["LaneName", "unit", "unit tests", LaneName],222+ ["RatchetName", "anyCount", "any_count", RatchetName],223+ ["EnvKey", "PAYMENTS_KEY", "PAYMENTS-KEY", EnvKey],224+ ["SuiteRoot", suite, patchId, SuiteRoot],225+ ["CheckVersion", "redThenGreen@0.0.0+abc", "", CheckVersion],226+ ["RepoName", "datekit--iso-week--alice", "datekit/iso", RepoName],227+ ] as const)("%s takes %j and refuses %j", (_name, good, bad, schema) => {228+ expect(refuses(schema, good)).toBeFalsy();229+ expect(refuses(schema, bad)).toBeTruthy();230+ });231+});232+233+describe("the caller", () => {234+ it("is a person named by their handle, or anyone at all", () => {235+ expect(236+ (fixture.roundTrip.Principal ?? []).map((principal) =>237+ Schema.decodeUnknownSync(Principal)(principal)238+ )239+ ).toStrictEqual([240+ Person.make({ handle: Handle.make("alice") }),241+ Anonymous.make({}),242+ ]);243+ });244+});modified:packages/protocol/test/examples.ts+52 added-1 removed
1 import { DateTime } from "effect";2 3-import { AskId, CommitSha, RepoPath } from "../src/ids.ts";3 import {4+ AskId,5+ CommitSha,6+ DecisionId,7+ EnvKey,8+ ProjectName,9+ RepoPath,10+} from "../src/ids.ts";11+import {12+ AskBlocked,13 AskFull,14 AttemptsExhausted,15 CapReached,16 ChecksFailed,17 ClaimLapsed,18+ DecisionClosed,19+ Denounced,20+ DirectPush,21 Flake,22 HeldBackFailed,23+ ImportFailed,24 IncompleteBrief,25 LayerContentInPublicTree,26 NoAsk,27 NotClaimed,28+ NotDecider,29 NotRedFirst,30+ NotSensitive,31 NotVouched,32 OutOfScope,33 PostureChange,34 PrivatePathInPublicTree,35+ ProjectExists,36+ ReachedInternals,37 RepoBusy,38 SecretInOutput,39 StaleBase,40+ StaleLayer,41 TouchedJudge,42+ UnknownAsk,43+ UnknownCommit,44+ UnknownDecision,45+ UnknownEnvItem,46+ UnknownProject,47+ UnstatedRequirement,48+ ValueTooShort,49 VerifierBlocked,50 WeakCheck,51 Weakened,52 } from "../src/refusal.ts";6 unmodified lines59 export const main = CommitSha.make("2222222222222222222222222222222222222222");60 61 export const path = RepoPath.make("src/a.ts");62 63+const project = ProjectName.make("datekit");64+65+const decision = DecisionId.make("dec-000001");66+67+const key = EnvKey.make("PAYMENTS_KEY");68+69 // One of each member, in the union's order.70 export const examples: readonly Refusal[] = [71 NotClaimed.of(ask),72 ClaimLapsed.of(ask),1 unmodified line74 new CapReached({ cap: 3 }),75 new AskFull({ ask }),76 new NoAsk({}),77 new RepoBusy({}),78+ new DirectPush({ ref: "refs/heads/main" }),79+ AskBlocked.of(ask, [AskId.make("drop-moment")]),80+ new Denounced({}),81 new OutOfScope({ paths: [path] }),82 new TouchedJudge({ paths: [path] }),83 new Weakened({84 at: { line: 3, path },85 weakening: { marker: "it.skip", reason: "flaky on CI" },86 }),87 new PrivatePathInPublicTree({ paths: [path] }),88+ new ReachedInternals({89+ at: { line: 1, path },90+ from: path,91+ to: "@datekit/format/src/internal.ts",92+ }),93 new StaleBase({ base, conflicts: [path], main }),94+ new StaleLayer({ layer: "maintainers" }),95 new ChecksFailed({96 lane: "test",97 logRef: "logs/7",98 next: "bun test src/a.test.ts",9 unmodified lines108 new WeakCheck({ weakness: "no assertion" }),109 new IncompleteBrief({ missing: ["territory"] }),110 new LayerContentInPublicTree({ paths: [path] }),111 new SecretInOutput({ item: "PAYMENTS_KEY", where: "output" }),112+ new UnstatedRequirement({ area: "parser" }),113 new PostureChange({ from: "open", to: "openCore" }),114+ new NotDecider({}),115+ new DecisionClosed({ decision }),116+ new UnknownProject({ project }),117+ new UnknownAsk({ ask }),118+ new UnknownCommit({ sha: main }),119+ new UnknownDecision({ decision }),120+ new ProjectExists({ project }),121+ new ImportFailed({ reason: "the repo needs a sign-in to read" }),122+ new UnknownEnvItem({ key }),123+ new NotSensitive({ key }),124+ ValueTooShort.of(key, 32),125 ];modified:packages/protocol/test/mcp.test.ts+5 added-1 removed
3 unmodified lines4 import { Rpc, RpcGroup } from "effect/rpc";5 6 import { Description, NeedsApproval } from "../src/annotations.ts";7 import { Client, Contracts, ListAsks, SubmitAnswer } from "../src/contracts.ts";8-import { AskId, CommitSha, ProjectName } from "../src/ids.ts";8+import { AskId, CommitSha, KindName, ProjectName } from "../src/ids.ts";9 import { listTools, toJsonSchema, toToolkit } from "../src/mcp.ts";10 import { StaleBase } from "../src/refusal.ts";11 import { ask, base, main, path } from "./examples.ts";12 import { serve } from "./mcp.ts";206 unmodified lines219 Effect.succeed({220 asks: [221 {222 ask: AskId.make("fix-parser"),223+ blockedBy: [],224 claimed: false,225+ kind: KindName.make("fix"),226 territory: "packages/parser",227 want: "Parse a trailing comma",228 },229 ],16 unmodified lines246 structuredContent: {247 asks: [248 {249 ask: "fix-parser",250+ blockedBy: [],251 claimed: false,252+ kind: "fix",253 territory: "packages/parser",254 want: "Parse a trailing comma",255 },256 ],5 unmodified linesmodified:packages/protocol/test/refusal.test.ts+86 added
53 unmodified lines54 )55 ).toStrictEqual(Refusal.members.map((member) => member.identifier));56 });57 58+ it("lists all forty tags in union order, group by group", () => {59+ expect(Refusal.members.map((member) => member.identifier)).toStrictEqual([60+ // Push and claim61+ "NotClaimed",62+ "ClaimLapsed",63+ "NotVouched",64+ "CapReached",65+ "AskFull",66+ "NoAsk",67+ "RepoBusy",68+ "DirectPush",69+ "AskBlocked",70+ "Denounced",71+ // Shape72+ "OutOfScope",73+ "TouchedJudge",74+ "Weakened",75+ "PrivatePathInPublicTree",76+ "ReachedInternals",77+ // Merge78+ "StaleBase",79+ "StaleLayer",80+ // Checks81+ "ChecksFailed",82+ "HeldBackFailed",83+ "AttemptsExhausted",84+ // Never counted against the answerer85+ "Flake",86+ "VerifierBlocked",87+ // At ask open88+ "NotRedFirst",89+ "WeakCheck",90+ "IncompleteBrief",91+ // Maintainers only92+ "LayerContentInPublicTree",93+ "SecretInOutput",94+ "UnstatedRequirement",95+ // Decision96+ "PostureChange",97+ "NotDecider",98+ "DecisionClosed",99+ // Lookup100+ "UnknownProject",101+ "UnknownAsk",102+ "UnknownCommit",103+ "UnknownDecision",104+ // Setup105+ "ProjectExists",106+ "ImportFailed",107+ // Env108+ "UnknownEnvItem",109+ "NotSensitive",110+ "ValueTooShort",111+ ]);112+ expect(groups.map((group) => group.name)).toStrictEqual([113+ "Push and claim",114+ "Shape",115+ "Merge",116+ "Checks",117+ "Never counted against the answerer",118+ "At ask open",119+ "Maintainers only",120+ "Decision",121+ "Lookup",122+ "Setup",123+ "Env",124+ ]);125+ });126+127 // A failure here means a tag was added, removed or renamed, or a refusal128 // changed whether retrying helps. Both are public contract: rename a tag only129 // with an alias, and update the reference docs.130 it("is closed: exactly these tags, each saying whether retrying can help", () => {4 unmodified lines135 Object.fromEntries(136 examples.map((refusal) => [refusal._tag, refusal.retryable])137 )138 ).toStrictEqual({139+ AskBlocked: true,140 AskFull: true,141 AttemptsExhausted: true,142 CapReached: true,143 ChecksFailed: false,144 ClaimLapsed: true,145+ DecisionClosed: false,146+ Denounced: false,147+ DirectPush: false,148 Flake: true,149 HeldBackFailed: false,150+ ImportFailed: true,151 IncompleteBrief: false,152 LayerContentInPublicTree: false,153 NoAsk: false,154 NotClaimed: true,155+ NotDecider: false,156 NotRedFirst: false,157+ NotSensitive: false,158 NotVouched: false,159 OutOfScope: false,160 PostureChange: false,161 PrivatePathInPublicTree: false,162+ ProjectExists: false,163+ ReachedInternals: false,164 RepoBusy: true,165 SecretInOutput: false,166 StaleBase: true,167+ StaleLayer: true,168 TouchedJudge: false,169+ UnknownAsk: false,170+ UnknownCommit: false,171+ UnknownDecision: false,172+ UnknownEnvItem: false,173+ UnknownProject: false,174+ UnstatedRequirement: false,175+ ValueTooShort: false,176 VerifierBlocked: true,177 WeakCheck: false,178 Weakened: false,179 });2 unmodified linesmodified:packages/protocol/test/render.test.ts+34 added
1 import { describe, expect, it } from "@effect/vitest";2 import { Brand } from "@repo/brand";3 4+import { EnvKey } from "../src/ids.ts";5 import {6+ DirectPush,7 OutOfScope,8 StaleBase,9 TouchedJudge,10+ ValueTooShort,11 Weakened,12 } from "../src/refusal.ts";13 import { explain, headline } from "../src/render.ts";14 import { base, examples, main, path } from "./examples.ts";58 unmodified lines73 expect(explain([refusal])[0]).toMatch(74 new RegExp(`^${refusal._tag}: \\S`, "u")75 );76 });77+78+ it.each(examples)(79+ "explains $_tag with every field it names filled in",80+ (refusal) => {81+ expect(explain([refusal]).join("\n")).not.toMatch(82+ /undefined|null|\[object Object\]/u83+ );84+ }85+ );86+87+ it("tells a direct push to main where answers go instead", () => {88+ expect(explain([new DirectPush({ ref: "refs/heads/main" })])).toStrictEqual(89+ [90+ "DirectPush: main moves only by a landing, so refs/heads/main takes no direct push; push your answer to your claim's fork",91+ ` next: ${Brand.cli} asks`,92+ " retryable: no",93+ ]94+ );95+ });96+97+ // The refusal never holds the value, so no reader learns it, or its length,98+ // from the reason.99+ it("says a value is too short by the minimum alone", () => {100+ expect(101+ explain([ValueTooShort.of(EnvKey.make("PAYMENTS_KEY"), 32)])102+ ).toStrictEqual([103+ "ValueTooShort: the value for PAYMENTS_KEY is shorter than the 32 characters it needs",104+ ` next: ${Brand.cli} env set PAYMENTS_KEY --acknowledge-short`,105+ " retryable: no",106+ ]);107+ });108 });added:packages/protocol/test/testing.test.ts+61 added
1+import { describe, expect, it } from "@effect/vitest";2+import { Effect, Layer } from "effect";3+import { RpcTest } from "effect/rpc";4+5+import { Contracts } from "../src/contracts.ts";6+import { AskId, Handle, KindName, ProjectName } from "../src/ids.ts";7+import { CurrentPrincipal, Principal } from "../src/principal.ts";8+import { NotClaimed } from "../src/refusal.ts";9+import { asPerson, asTester } from "../src/testing.ts";10+11+/** Contracts whose one listed ask wants whoever called: their handle, or `anyone`. */12+const echoCaller = Contracts.toLayer({13+ listAsks: () =>14+ Effect.gen(function* () {15+ const caller = Principal.match(yield* CurrentPrincipal, {16+ Anonymous: () => "anyone",17+ Person: ({ handle }) => handle,18+ });19+20+ return {21+ asks: [22+ {23+ ask: AskId.make("whoami"),24+ blockedBy: [],25+ claimed: false,26+ kind: KindName.make("fix"),27+ territory: ".",28+ want: caller,29+ },30+ ],31+ };32+ }),33+ submitAnswer: ({ ask }) => Effect.fail(NotClaimed.of(ask)),34+});35+36+/** Who the server side took the call to be, as `echoCaller` reports it. */37+const caller = Effect.gen(function* () {38+ const client = yield* RpcTest.makeClient(Contracts);39+40+ const { asks } = yield* client.listAsks({41+ project: ProjectName.make("datekit"),42+ });43+44+ return asks.map(({ want }) => want);45+});46+47+describe("the test principals", () => {48+ it.effect("asPerson runs every call as the person it names", () =>49+ Effect.gen(function* () {50+ expect(yield* caller).toStrictEqual(["alice"]);51+ }).pipe(52+ Effect.provide(Layer.mergeAll(echoCaller, asPerson(Handle.make("alice"))))53+ )54+ );55+56+ it.effect("asTester runs every call as one person, the tester", () =>57+ Effect.gen(function* () {58+ expect(yield* caller).toStrictEqual(["tester"]);59+ }).pipe(Effect.provide(Layer.mergeAll(echoCaller, asTester)))60+ );61+});modified:packages/protocol/package.json+2 added
3 unmodified lines4 "type": "module",5 "exports": {6 "./cli": "./src/cli.ts",7 "./contracts": "./src/contracts.ts",8+ "./domain/*": "./src/domain/*.ts",9+ "./envelope": "./src/envelope.ts",10 "./ids": "./src/ids.ts",11 "./mcp": "./src/mcp.ts",12 "./posture": "./src/posture.ts",13 "./principal": "./src/principal.ts",21 unmodified linesmodified:scripts/lib/gen.ts+53 added-1 removed
14 unmodified lines15 ReadOnly,16 SurfaceName,17 Surfaces,18 } from "@repo/protocol/contracts";19-import { AskId, CommitSha, RepoPath } from "@repo/protocol/ids";19+import {20+ AskId,21+ CommitSha,22+ DecisionId,23+ EnvKey,24+ ProjectName,25+ RepoPath,26+} from "@repo/protocol/ids";27 import { listTools, toJsonSchema, toToolkit } from "@repo/protocol/mcp";28 import type { ToolListing } from "@repo/protocol/mcp";29 import {30+ AskBlocked,31 AskFull,32 AttemptsExhausted,33 CapReached,34 ChecksFailed,35 ClaimLapsed,36+ DecisionClosed,37+ Denounced,38+ DirectPush,39 Flake,40 groups,41 HeldBackFailed,42+ ImportFailed,43 IncompleteBrief,44 LayerContentInPublicTree,45 NoAsk,46 NotClaimed,47+ NotDecider,48 NotRedFirst,49+ NotSensitive,50 NotVouched,51 OutOfScope,52 PostureChange,53 PrivatePathInPublicTree,54+ ProjectExists,55+ ReachedInternals,56 Refusal,57 RepoBusy,58 SecretInOutput,59 StaleBase,60+ StaleLayer,61 TouchedJudge,62+ UnknownAsk,63+ UnknownCommit,64+ UnknownDecision,65+ UnknownEnvItem,66+ UnknownProject,67+ UnstatedRequirement,68+ ValueTooShort,69 VerifierBlocked,70 WeakCheck,71 Weakened,72 } from "@repo/protocol/refusal";132 unmodified lines205 const main = CommitSha.make("2222222222222222222222222222222222222222");206 207 const path = RepoPath.make("src/a.ts");208 209+const project = ProjectName.make("datekit");210+211+const decision = DecisionId.make("dec-000001");212+213+const key = EnvKey.make("PAYMENTS_KEY");214+215 /**216 * One example of every refusal, for the reason each section quotes. Keyed by217 * tag, so a refusal added to the union fails the typecheck until it has one.218 */219 const examples = {220+ AskBlocked: AskBlocked.of(ask, [AskId.make("drop-moment")]),221 AskFull: new AskFull({ ask }),222 AttemptsExhausted: new AttemptsExhausted({223 area: "parser",224 resetsAt: DateTime.makeUnsafe("2026-10-07T00:00:00Z"),4 unmodified lines229 logRef: "logs/7",230 next: "bun test src/a.test.ts",231 }),232 ClaimLapsed: ClaimLapsed.of(ask),233+ DecisionClosed: new DecisionClosed({ decision }),234+ Denounced: new Denounced({}),235+ DirectPush: new DirectPush({ ref: "refs/heads/main" }),236 Flake: new Flake({ lane: "test" }),237 HeldBackFailed: new HeldBackFailed({ area: "parser", suite: "edge-cases" }),238+ ImportFailed: new ImportFailed({239+ reason: "the repo needs a sign-in to read",240+ }),241 IncompleteBrief: new IncompleteBrief({ missing: ["territory"] }),242 LayerContentInPublicTree: new LayerContentInPublicTree({ paths: [path] }),243 NoAsk: new NoAsk({}),244 NotClaimed: NotClaimed.of(ask),245+ NotDecider: new NotDecider({}),246 NotRedFirst: new NotRedFirst({}),247+ NotSensitive: new NotSensitive({ key }),248 NotVouched: new NotVouched({}),249 OutOfScope: new OutOfScope({ paths: [path] }),250 PostureChange: new PostureChange({ from: "open", to: "openCore" }),251 PrivatePathInPublicTree: new PrivatePathInPublicTree({ paths: [path] }),252+ ProjectExists: new ProjectExists({ project }),253+ ReachedInternals: new ReachedInternals({254+ from: path,255+ to: "@datekit/format/src/internal.ts",256+ }),257 RepoBusy: new RepoBusy({}),258 SecretInOutput: new SecretInOutput({ item: "PAYMENTS_KEY", where: "output" }),259 StaleBase: new StaleBase({ base, conflicts: [path], main }),260+ StaleLayer: new StaleLayer({ layer: "maintainers" }),261 TouchedJudge: new TouchedJudge({ paths: [path] }),262+ UnknownAsk: new UnknownAsk({ ask }),263+ UnknownCommit: new UnknownCommit({ sha: main }),264+ UnknownDecision: new UnknownDecision({ decision }),265+ UnknownEnvItem: new UnknownEnvItem({ key }),266+ UnknownProject: new UnknownProject({ project }),267+ UnstatedRequirement: new UnstatedRequirement({ area: "parser" }),268+ ValueTooShort: ValueTooShort.of(key, 32),269 VerifierBlocked: new VerifierBlocked({}),270 WeakCheck: new WeakCheck({ weakness: "no assertion" }),271 Weakened: new Weakened({272 weakening: { marker: "it.skip", reason: "flaky on CI" },379 unmodified linesmodified:tsconfig.base.json+6 added
111 unmodified lines112 "allowedUnstableApis": ["effect/ai", "effect/cli", "effect/rpc"]113 }114 },115 {116+ "include": ["packages/protocol/src/domain/**/*.ts"],117+ "options": {118+ "allowedUnstableApis": []119+ }120+ },121+ {122 "include": ["packages/protocol/test/**/*.ts"],123 "options": {124 "allowedUnstableApis": [125 "effect/ai",17 unmodified lines