Merge project/discussions into main
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Conflicts: the budget removal and discussions both took migration 3 and the deciders' and rows' budget lines. The budget stays gone, drop_budget_days stays 3 (it is on prod) and discussions becomes 4. The proposal field kept both its description and the discussion field; the discussion fields now say what they take. The dev seed moved the refused round and the stray push after the discussions it added, and the Today pins count its third open proposal.
authored by oscabriel · committed by oscabriel · parents 7bbe189, 7f85b26 · Browse files · 73 files·+2302 added−39 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
73 files+2302 added−39 removed
- tests:+984 added−16 removed
- other:+1318 added−23 removed
Provenance
- Commit
29b0353- Tree
e791f72- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
7bbe189- Parent 2
7f85b26
73 files changed+2302 added−39 removed
modified:apps/cli/src/render.ts+77 added
6 unmodified lines7 Finish,8 FrontPage,9 LedgerOf,10 ListAsks,11+ ListDiscussions,12 ListProjects,13 PolicyOf,14+ PostDiscussion,15 ShowAsk,16+ ShowDiscussion,17 Status,18 SubmitAnswer,19 TodayOf,20 VerdictOf,3 unmodified lines24 import { LandReceipt } from "@repo/protocol/domain/answer";25 import type { AnswerReceipt } from "@repo/protocol/domain/answer";26 import type { ClaimView } from "@repo/protocol/domain/claim";27 import { DecisionSubject } from "@repo/protocol/domain/decision";28+import type { Discussion } from "@repo/protocol/domain/discussion";29 import { Outcome } from "@repo/protocol/domain/outcome";30 import type {31 ImportSource,32 PolicyPending,169 unmodified lines202 );203 204 const ask = viewOf(ShowAsk.successSchema, ({ brief }) => prose(brief));205 206+const discussionStates = {207+ closed: "closed",208+ open: "open",209+ proposed: "became a proposal",210+} as const satisfies Record<Discussion["state"], string>;211+212+const discussions = viewOf(213+ ListDiscussions.successSchema,214+ ({ discussions: listed }) =>215+ joined(216+ table(217+ ["discussion", "title", "opener", "posts", "last post", "state"],218+ listed.map(219+ ({ id, lastPostAt, opener, posts, proposal, state, title }) => [220+ id,221+ title,222+ opener,223+ String(posts),224+ when(lastPostAt),225+ proposal === undefined226+ ? discussionStates[state]227+ : `${discussionStates[state]} ${proposal}`,228+ ]229+ ),230+ "No discussions yet."231+ ),232+ prose(233+ `Read one with \`${Brand.cli} discussion <discussion>\`; open one with \`${Brand.cli} discussion post --title "<title>" --body "<post>"\`.`234+ )235+ )236+);237+238+const onward = (discussion: Discussion) => {239+ if (discussion.state === "open") {240+ return `Reply with \`${Brand.cli} discussion post ${discussion.id} --body "<post>"\`.`;241+ }242+243+ return discussion.proposal === undefined244+ ? "This discussion is closed."245+ : `This discussion became ${discussion.proposal}: read it with \`${Brand.cli} proposal ${discussion.proposal}\`.`;246+};247+248+const thread = (discussion: Discussion): View =>249+ joined(250+ prose(`# ${discussion.title}`),251+ fields([252+ ["Discussion", discussion.id],253+ ["Opened by", `${discussion.opener} at ${when(discussion.openedAt)}`],254+ [255+ "State",256+ discussion.proposal === undefined257+ ? discussionStates[discussion.state]258+ : `${discussionStates[discussion.state]} ${discussion.proposal}`,259+ ],260+ ]),261+ ...discussion.posts.map(({ at, body, by }) =>262+ prose(`**${by}** at ${when(at)}\n\n${body}`)263+ ),264+ prose(onward(discussion))265+ );266+267+const discussion = viewOf(268+ ShowDiscussion.successSchema,269+ ({ discussion: shown }) => thread(shown)270+);271+272+const posted = viewOf(PostDiscussion.successSchema, ({ discussion: shown }) =>273+ thread(shown)274+);275+276 /** Where the receipt is read: in a clone of the project or not, and what the fork's remote may be called. */277 export interface Place {278 readonly inClone: boolean;279 readonly remoteName: string;373 unmodified lines653 finish: finished,654 frontPage: front,655 ledger,656 listAsks: asks,657+ listDiscussions: discussions,658 listProjects: projects,659+ postDiscussion: posted,660 projectPolicy: policy,661 showAsk: ask,662+ showDiscussion: discussion,663 status,664 submitAnswer: submitted,665 today,666 verdict,9 unmodified linesmodified:apps/platform/src/adapters/do-projects.ts+5 added
94 unmodified lines95969798991001011021031041051061071086 unmodified lines11511611711811912012112212312475 unmodified lines94 unmodified lines layerAccess: (caller, layer) => on("layerAccess", [caller, layer]), layerFacts: (caller) => on("layerFacts", [caller]), ledger: (caller) => assumingMade(on("ledger", [caller])), listAsks: (caller) => assumingMade(on("listAsks", [caller])), listDiscussions: (caller) => assumingMade(on("listDiscussions", [caller])), onAlarm: () => on("onAlarm", []), openAsk: (caller, input) => assumingMade(on("openAsk", [caller, input])), policy: () => on("policy", []), postDiscussion: (caller, input) => assumingMade(on("postDiscussion", [caller, input])), proposeAsk: (caller, input) => assumingMade(on("proposeAsk", [caller, input])), recordAdmission: (input) => on("recordAdmission", [input]), recordFirstPush: (caller, head) => on("recordFirstPush", [caller, head]),6 unmodified lines release: (caller, ask) => assumingMade(on("release", [caller, ask])), scanForValues: (input) => on("scanForValues", [input]), setEnv: (caller, input) => assumingMade(on("setEnv", [caller, input])), showAsk: (caller, ask) => assumingMade(on("showAsk", [caller, ask])), showDiscussion: (caller, discussion) => assumingMade(on("showDiscussion", [caller, discussion])), showProposal: (caller, proposal) => assumingMade(on("showProposal", [caller, proposal])), standing: () => on("standing", []), status: (caller) => assumingMade(on("status", [caller])),75 unmodified linesmodified:apps/platform/src/adapters/rate-limits.ts+7 added-1 removed
7 unmodified lines8 9 export interface Limits {10 readonly claim: number;11 readonly draft: number;12+ readonly post: number;13 readonly proposal: number;14 }15 16 // Mirrors each binding's `simple.limit` in wrangler.jsonc: a binding can't say its own limit.17 export const WorkerCaps = {18 claim: 10,19 draft: 2,20+ post: 5,21 proposal: 5,22 } as const satisfies Limits;23 24 const LIMIT_OF = {25 claim: "claims",26 draft: "drafts",27+ post: "discussions",28 proposal: "proposals",29 } as const satisfies Record<Limited, CapReached["limit"]>;30 31 // A binding can't say when its window resets, so the whole 60 s period is the honest upper bound.16 unmodified lines48 RateLimits,49 RateLimits.of({50 check: (kind, handle) =>51 Effect.tryPromise(() =>49- bindings[kind].limit({ key: handle.toLowerCase() })52+ // A post is counted by the proposal binding, under its own cap.53+ bindings[kind === "post" ? "proposal" : kind].limit({54+ key: handle.toLowerCase(),55+ })56 ).pipe(57 Effect.orDie,58 Effect.flatMap(({ success }) =>59 success ? Effect.void : Effect.fail(capped(WorkerCaps, kind))32 unmodified linesmodified:apps/platform/src/handlers.ts+16 added
259 unmodified lines260 listAsks: ({ project }) =>261 Effect.flatMap(caller, (who) =>262 on(project, (api) => api.listAsks(who))263 ),264+ listDiscussions: ({ project }) =>265+ Effect.flatMap(caller, (who) =>266+ on(project, (api) => api.listDiscussions(who))267+ ),268 listPaths: ({ at, project }) =>269 code(project, (of) => pathsOf(of, Option.fromUndefinedOr(at))),270 listProjects: () =>271 frontPage.projects().pipe(21 unmodified lines293 openAsk: ({ project, ...input }) =>294 Effect.flatMap(person, (who) =>295 on(project, (api) => api.openAsk(who, input))296 ),297+ postDiscussion: ({ project, ...input }) =>298+ Effect.gen(function* () {299+ const who = yield* person;300+301+ yield* rateLimits.check("post", who.handle);302+303+ return yield* on(project, (api) => api.postDiscussion(who, input));304+ }),305 projectPolicy: ({ project }) => on(project, (api) => api.policy()),306 proposeAsk: ({ project, ...input }) =>307 Effect.gen(function* () {308 const who = yield* person;29 unmodified lines338 on(project, (api) => api.showAsk(who, ask))339 ),340 showCommit: ({ at, project, sha }) =>341 code(project, (of) => commitOf(of, sha, Option.fromUndefinedOr(at))),342+ showDiscussion: ({ discussion, project }) =>343+ Effect.flatMap(caller, (who) =>344+ on(project, (api) => api.showDiscussion(who, discussion))345+ ),346 showProposal: ({ project, proposal }) =>347 Effect.flatMap(caller, (who) =>348 on(project, (api) => api.showProposal(who, proposal))349 ),60 unmodified linesmodified:apps/platform/src/project-calls.ts+3 added
88 unmodified lines89 layerAccess: callOf(MethodSchemas.layerAccess),90 layerFacts: callOf(MethodSchemas.layerFacts),91 ledger: callOf(MethodSchemas.ledger),92 listAsks: callOf(MethodSchemas.listAsks),93+ listDiscussions: callOf(MethodSchemas.listDiscussions),94 onAlarm: callOf(MethodSchemas.onAlarm),95 openAsk: callOf(MethodSchemas.openAsk),96 policy: callOf(MethodSchemas.policy),97+ postDiscussion: callOf(MethodSchemas.postDiscussion),98 proposeAsk: callOf(MethodSchemas.proposeAsk),99 recordAdmission: callOf(MethodSchemas.recordAdmission),100 recordFirstPush: callOf(MethodSchemas.recordFirstPush),101 recordHeldBack: callOf(MethodSchemas.recordHeldBack),4 unmodified lines106 release: callOf(MethodSchemas.release),107 scanForValues: callOf(MethodSchemas.scanForValues),108 setEnv: callOf(MethodSchemas.setEnv),109 showAsk: callOf(MethodSchemas.showAsk),110+ showDiscussion: callOf(MethodSchemas.showDiscussion),111 showProposal: callOf(MethodSchemas.showProposal),112 standing: callOf(MethodSchemas.standing),113 status: callOf(MethodSchemas.status),114 submitAnswer: callOf(MethodSchemas.submitAnswer),59 unmodified linesmodified:apps/platform/src/rate-limits.ts+2 added-1 removed
1 unmodified line2 import type { CapReached } from "@repo/protocol/refusal";3 import { Context } from "effect";4 import type { Effect } from "effect";5 6+/** A post shares the proposal binding's window: both are words put to a project's maintainers. */6-export type Limited = "claim" | "proposal" | "draft";7+export type Limited = "claim" | "proposal" | "draft" | "post";8 9 export class RateLimits extends Context.Service<10 RateLimits,11 {6 unmodified linesmodified:apps/platform/test/do-projects.test.ts+10 added
8 unmodified lines9 import { ProjectsMemory } from "@repo/project/projects/memory";10 import {11 CommitSha,12 DecisionId,13+ DiscussionId,14 EnvKey,15 keyOf,16 LandedSha,17 LayerName,124 unmodified lines142 layerAccess: settled("layerAccess", api.layerAccess(alice, layer)),143 layerFacts: settled("layerFacts", api.layerFacts(bob)),144 ledger: settled("ledger", api.ledger(anyone)),145 listAsks: settled("listAsks", api.listAsks(anyone)),146+ listDiscussions: settled("listDiscussions", api.listDiscussions(anyone)),147 onAlarm: settled("onAlarm", api.onAlarm()),148 openAsk: settled(149 "openAsk",150 api.openAsk(bob, { ask: parseIso, files: askFiles() })151 ),152 policy: settled("policy", api.policy()),153+ postDiscussion: settled(154+ "postDiscussion",155+ api.postDiscussion(carol, { title: "Which day starts a week?" })156+ ),157 proposeAsk: settled(158 "proposeAsk",159 api.proposeAsk(carol, { want: "Parse ISO week dates." })160 ),38 unmodified lines199 value: Redacted.make("a-value-long-enough-0123"),200 })201 ),202 showAsk: settled("showAsk", api.showAsk(anyone, parseIso)),203+ showDiscussion: settled(204+ "showDiscussion",205+ api.showDiscussion(anyone, DiscussionId.make("disc-000001"))206+ ),207 showProposal: settled(208 "showProposal",209 api.showProposal(anyone, ProposalId.make("prop-000001"))210 ),158 unmodified linesmodified:apps/platform/test/handlers.fixtures.ts+2 added
116 unmodified lines117 readonly frontPage?: FrontPageSeed;118 readonly limits?: {119 readonly claim: number;120 readonly draft?: number;121+ readonly post?: number;122 readonly proposal: number;123 };124 }125 17 unmodified lines143 FrontPageMemory.layer(options.frontPage ?? noFrontPage),144 MemoryRateLimits({145 claim: options.limits?.claim ?? 100,146 draft: options.limits?.draft ?? 100,147+ post: options.limits?.post ?? 100,148 proposal: options.limits?.proposal ?? 100,149 }),150 EvidenceStoreMemory151 ).pipe(Layer.provideMerge(RepoHostMemory));30 unmodified linesmodified:apps/platform/test/handlers.test.ts+155 added-1 removed
9 unmodified lines10 import type { Proposal } from "@repo/protocol/domain/proposal";11 import {12 AskId,13 CommitSha,14+ DiscussionId,15 EnvKey,16 Handle,17 KindName,18 ProjectName,8 unmodified lines27 } from "@repo/protocol/principal";28 import {29 AskFull,30 CapReached,31+ Denounced,32+ DiscussionClosed,33 NotClaimed,34 NotDecider,35 UnknownEnvItem,36 ProjectExists,23 unmodified lines60 import type { WorldOptions } from "./handlers.fixtures.ts";61 62 const people = ["bob", "carol"];63 64+// spam is denounced in datekit's vouch file; the others are vouched for.65 const datekit = aProject({ people }).pipe(62- withVouches(people),66+ withVouches(people, ["spam"]),67 withAsk({ id: "parse-iso", territory: "packages/parser" }),68 withAsk({ id: "trim-input", territory: "packages/trim" })69 );70 274 unmodified lines345 }).pipe(Effect.provide(platform({ limits: { claim: 5, proposal: 1 } })))346 );347 });348 349+describe("discussions", () => {350+ it.effect(351+ "take a thread and a reply from anyone not denounced, list and show them, and refuse the denounced",352+ () =>353+ Effect.gen(function* () {354+ yield* made;355+356+ const bob = yield* as("bob");357+ const carol = yield* as("carol");358+ const spam = yield* as("spam");359+360+ const { discussion } = yield* bob.postDiscussion({361+ body: "Weeks start on Monday in ISO 8601; which does parseISO assume?",362+ project: datekit.project,363+ title: "Which day starts a week?",364+ });365+366+ yield* advanceTo("2026-10-07T12:05:00Z");367+368+ const replied = yield* carol.postDiscussion({369+ body: "ISO, always.",370+ discussion: discussion.id,371+ project: datekit.project,372+ });373+374+ const refused = yield* Effect.all({375+ spamOpens: Effect.flip(376+ spam.postDiscussion({377+ project: datekit.project,378+ title: "Buy dates",379+ })380+ ),381+ spamReplies: Effect.flip(382+ spam.postDiscussion({383+ body: "Buy dates",384+ discussion: discussion.id,385+ project: datekit.project,386+ })387+ ),388+ });389+390+ const threads = yield* bob.listDiscussions({391+ project: datekit.project,392+ });393+394+ const shown = yield* carol.showDiscussion({395+ discussion: discussion.id,396+ project: datekit.project,397+ });398+399+ expect(discussion).toMatchObject({400+ id: "disc-000001",401+ opener: "bob",402+ state: "open",403+ });404+ expect(replied.discussion.posts.map(({ by }) => by)).toStrictEqual([405+ "bob",406+ "carol",407+ ]);408+ expect(refused).toStrictEqual({409+ spamOpens: new Denounced({}),410+ spamReplies: new Denounced({}),411+ });412+ expect(413+ threads.discussions.map(({ id, posts, state }) => [id, posts, state])414+ ).toStrictEqual([["disc-000001", 2, "open"]]);415+ expect(shown.discussion).toStrictEqual(replied.discussion);416+ }).pipe(Effect.provide(platform()))417+ );418+419+ it.effect(420+ "become a proposal by a maintainer alone, and then take no more posts",421+ () =>422+ Effect.gen(function* () {423+ yield* made;424+425+ const alice = yield* as("alice");426+ const bob = yield* as("bob");427+428+ const { discussion } = yield* bob.postDiscussion({429+ project: datekit.project,430+ title: "Parse ISO week dates?",431+ });432+433+ const bobProposes = yield* Effect.flip(434+ bob.proposeAsk({435+ discussion: discussion.id,436+ project: datekit.project,437+ want: "Parse ISO week dates.",438+ })439+ );440+441+ const { proposal } = yield* alice.proposeAsk({442+ discussion: discussion.id,443+ project: datekit.project,444+ want: "Parse ISO week dates.",445+ });446+447+ const after = yield* bob.showDiscussion({448+ discussion: discussion.id,449+ project: datekit.project,450+ });451+452+ const reply = yield* Effect.flip(453+ bob.postDiscussion({454+ body: "Please",455+ discussion: discussion.id,456+ project: datekit.project,457+ })458+ );459+460+ expect(bobProposes).toStrictEqual(new NotDecider({}));461+ expect(after.discussion).toMatchObject({462+ proposal: proposal.id,463+ state: "proposed",464+ });465+ expect(reply).toStrictEqual(466+ new DiscussionClosed({ discussion: discussion.id })467+ );468+ }).pipe(Effect.provide(platform()))469+ );470+471+ it.effect("are rate-limited per person, as posts", () =>472+ Effect.gen(function* () {473+ yield* made;474+475+ const bob = yield* as("bob");476+ const carol = yield* as("carol");477+478+ yield* bob.postDiscussion({ project: datekit.project, title: "One" });479+480+ const second = yield* Effect.flip(481+ bob.postDiscussion({ project: datekit.project, title: "Two" })482+ );483+484+ const carols = yield* carol.postDiscussion({485+ project: datekit.project,486+ title: "Carol's",487+ });488+489+ expect(second).toStrictEqual(490+ new CapReached({ cap: 1, limit: "discussions", retryAfter: 60 })491+ );492+ expect(carols.discussion.id).toBe(DiscussionId.make("disc-000002"));493+ }).pipe(494+ Effect.provide(platform({ limits: { claim: 5, post: 1, proposal: 5 } }))495+ )496+ );497+});498+499 describe("calls that name no project", () => {500 it.effect(501 "show the caller's claims in every project the projection lists",502 () =>576 unmodified linesmodified:apps/platform/test/mcp.test.ts+22 added
11 unmodified lines12 import {13 AskId,14 CommitSha,15 DecisionId,16+ DiscussionId,17 Handle,18 LaneName,19 ProjectName,20 ProposalId,8 unmodified lines29 ProjectExists,30 UnknownAsk,31 UnknownCommit,32 UnknownDecision,33+ UnknownDiscussion,34 UnknownPath,35 UnknownProject,36 UnknownRevision,37 } from "@repo/protocol/refusal";378 unmodified lines416 listAsks: {417 args: { project: nowhere },418 refusal: new UnknownProject({ project: nowhere }),419 },420+ listDiscussions: {421+ args: { project: nowhere },422+ refusal: new UnknownProject({ project: nowhere }),423+ },424 listRefs: {425 args: { project: nowhere },426 refusal: new UnknownProject({ project: nowhere }),427 },4 unmodified lines432 openAsk: {433 args: { ask: nope, files: askFiles, project },434 refusal: new NotDecider({}),435 },436+ postDiscussion: {437+ args: {438+ body: "Hello",439+ discussion: DiscussionId.make("disc-000001"),440+ project,441+ },442+ refusal: new UnknownDiscussion({443+ discussion: DiscussionId.make("disc-000001"),444+ }),445+ },446 projectPolicy: {447 args: { project: nowhere },448 refusal: new UnknownProject({ project: nowhere }),449 },16 unmodified lines466 showAsk: {467 args: { ask: nope, project },468 refusal: new UnknownAsk({ ask: nope }),469 },470+ showDiscussion: {471+ args: { discussion: DiscussionId.make("disc-000001"), project },472+ refusal: new UnknownDiscussion({473+ discussion: DiscussionId.make("disc-000001"),474+ }),475+ },476 showProposal: {477 args: { project: nowhere, proposal: ProposalId.make("prop-000001") },478 refusal: new UnknownProject({ project: nowhere }),479 },535 unmodified linesadded:apps/web/src/client/discussion.ts+27 added
1+import type { DiscussionId, ProjectName } from "@repo/protocol/ids";2+import { Atom } from "effect/reactivity";3+4+import { ContractsClient } from "../surfaces.ts";5+import { keys } from "./keys.ts";6+7+export const discussionsAtom = Atom.family((project: ProjectName) =>8+ Atom.withServerValueInitial(9+ ContractsClient.query(10+ "listDiscussions",11+ { project },12+ { reactivityKeys: keys.discussions(project) }13+ )14+ )15+);16+17+export const discussionAtom = Atom.family((project: ProjectName) =>18+ Atom.family((discussion: DiscussionId) =>19+ Atom.withServerValueInitial(20+ ContractsClient.query(21+ "showDiscussion",22+ { discussion, project },23+ { reactivityKeys: keys.discussion(project, discussion) }24+ )25+ )26+ )27+);modified:apps/web/src/client/keys.ts+16 added-1 removed
1 // Each key is one string: Reactivity treats every element of a key list as a key of its own.2-import type { AskId, ProjectName, ProposalId } from "@repo/protocol/ids";2+import type {3+ AskId,4+ DiscussionId,5+ ProjectName,6+ ProposalId,7+} from "@repo/protocol/ids";8 9 export const keys = {10 ask: (project: ProjectName, ask: AskId): readonly string[] => [11 `ask:${project}/${ask}`,12 `project:${project}`,13 ],14 code: (project: ProjectName): readonly string[] => [`code:${project}`],15+ discussion: (16+ project: ProjectName,17+ discussion: DiscussionId18+ ): readonly string[] => [19+ `discussion:${project}/${discussion}`,20+ `discussions:${project}`,21+ ],22+ discussions: (project: ProjectName): readonly string[] => [23+ `discussions:${project}`,24+ ],25 // Not the project's key, so a page's reads can refetch without replaying every event.26 events: (project: ProjectName): readonly string[] => [`events:${project}`],27 front: (): readonly string[] => ["front"],28 ledger: (project: ProjectName): readonly string[] => [`ledger:${project}`],8 unmodified linesmodified:apps/web/src/client/watch.ts+4 added
50 unmodified lines51 AskClosed: () => [...keys.project(project), ...keys.front()],52 AskOpened: () => [...keys.project(project), ...keys.front()],53 Claimed: () => keys.project(project),54 Decided: () => keys.project(project),55+ DiscussionPosted: ({ discussion }) => [56+ ...keys.discussion(project, discussion),57+ ...keys.project(project),58+ ],59 Judged: ({ ask }) => keys.ask(project, ask),60 Landed: () => [61 ...keys.project(project),62 ...keys.front(),76 unmodified linesmodified:apps/web/src/dev/front-page.ts+1 added
78 unmodified lines79 Decided: () => rows,80 Judged: () => rows,81 Landed: () => rows,82 Lapsed: ({ ask }) => withClaims(rows, keyOf(project, ask), -1),83+ DiscussionPosted: () => rows,84 LedgerAppended: () => rows,85 ProposalDrafted: () => rows,86 ProposalOpened: () => rows,87 Pushed: () => rows,204 unmodified linesmodified:apps/web/src/dev/handlers.ts+12 added
226 unmodified lines227 on(project, (api) => api.landing(who, sha))228 ),229 ledger: ({ project }) =>230 Effect.flatMap(caller, (who) => on(project, (api) => api.ledger(who))),231+ listDiscussions: ({ project }) =>232+ Effect.flatMap(caller, (who) =>233+ on(project, (api) => api.listDiscussions(who))234+ ),235 listAsks: ({ project }) =>236 Effect.flatMap(caller, (who) =>237 on(project, (api) => api.listAsks(who))238 ),25 unmodified lines264 openAsk: ({ project, ...input }) =>265 Effect.flatMap(person, (who) =>266 on(project, (api) => api.openAsk(who, input))267 ),268+ postDiscussion: ({ project, ...input }) =>269+ Effect.flatMap(person, (who) =>270+ on(project, (api) => api.postDiscussion(who, input))271+ ),272 projectPolicy: ({ project }) => on(project, (api) => api.policy()),273 proposeAsk: ({ project, ...input }) =>274 Effect.flatMap(person, (who) =>275 on(project, (api) => api.proposeAsk(who, input))20 unmodified lines296 on(project, (api) => api.showAsk(who, ask))297 ),298 showCommit: ({ at, project, sha }) =>299 code(project, (of) => commitOf(of, sha, Option.fromUndefinedOr(at))),300+ showDiscussion: ({ discussion, project }) =>301+ Effect.flatMap(caller, (who) =>302+ on(project, (api) => api.showDiscussion(who, discussion))303+ ),304 showProposal: ({ project, proposal }) =>305 Effect.flatMap(caller, (who) =>306 on(project, (api) => api.showProposal(who, proposal))307 ),68 unmodified linesmodified:apps/web/src/dev/seed.ts+32 added-6 removed
222 unmodified lines223 224 return { claim, head, receipt, requestId };225 });226 227-const ROUNDS_MINUTE = 19;227+const ROUNDS_MINUTE = 25;228 229 /**230 * Bram's first answer to parse-iso-week, refused at Shape for a path outside231 * the ask's territory, then his second, still at the merge. The platform's104 unmodified lines336 ask: AskId.make("add-months-clamp"),337 reason: "Its check pins a common year only; leap years need a case too.",338 });339 340+ // Two discussions: one open, one a maintainer turned into a proposal.341+ yield* at(14);342+343+ const talked = yield* api.postDiscussion(as(visitors.regular), {344+ body: "Weeks start on Monday in ISO 8601, but on Sunday in the US; which does parseISO assume?",345+ title: "Which day starts a week?",346+ });347+348+ yield* api.postDiscussion(as(decider), {349+ body: "ISO, always: a locale never changes what a date string means.",350+ discussion: talked.discussion.id,351+ });352+353+ yield* at(15);354+355+ const asked = yield* api.postDiscussion(as(visitors.proposer), {356+ body: "Could parseISO take week dates like 2026-W41-3 too?",357+ title: "ISO week dates",358+ });359+360+ yield* at(16);361+ yield* api.proposeAsk(as(decider), {362+ discussion: asked.discussion.id,363+ want: "parseISO reads an ISO week date to the day it names.",364+ });365+366 yield* Effect.forEach(367 DECLINED,368 (want, index) =>369 Effect.gen(function* () {344- yield* at(11 + index * 2);370+ yield* at(17 + index * 2);371 372 const { proposal } = yield* api.proposeAsk(as(visitors.regular), {373 want,374 });375 350- yield* at(12 + index * 2);376+ yield* at(18 + index * 2);377 378 const decision = yield* decisionOn(api, decider, proposal.id);379 380 yield* api.decide(as(decider), {8 unmodified lines389 return api;390 });391 392 const seedBurrow = Effect.flatMap(367- started(burrow.project, operator, burrow.files, 15),368- (api) => opened(api, burrowPeople.decider, burrow.asks, 17)393+ started(burrow.project, operator, burrow.files, 21),394+ (api) => opened(api, burrowPeople.decider, burrow.asks, 23)395 );396 371-const STRAY_MINUTE = 21;397+const STRAY_MINUTE = 27;398 399 export const seedEnd = devMinute(STRAY_MINUTE);400 401 const strayPush = (api: ProjectApi) =>38 unmodified linesmodified:apps/web/src/features/answer/subject.ts+1 added
18 unmodified lines19 Decided: () => [],20 Judged: ({ ask }) => [ask],21 Landed: () => [],22 Lapsed: ({ ask }) => [ask],23+ DiscussionPosted: () => [],24 LedgerAppended: () => [],25 ProposalDrafted: () => [],26 ProposalOpened: () => [],27 Pushed: ({ ask }) => [ask],117 unmodified linesadded:apps/web/src/features/discussion/discussion-view.tsx+112 added
1+import { Brand } from "@repo/brand";2+import type {3+ Discussion,4+ DiscussionPost,5+} from "@repo/protocol/domain/discussion";6+import type { ProjectName, ProposalId } from "@repo/protocol/ids";7+import type { DateTime } from "effect";8+import type { ReactNode } from "react";9+10+import { CommandLine } from "../shared/command.tsx";11+import { FactBlock } from "../shared/facts.tsx";12+import { HandleLink } from "../shared/handle.tsx";13+import { AppLink } from "../shared/link.tsx";14+import { Workspace } from "../shared/shell/workspace.tsx";15+import { When } from "../shared/time.tsx";16+import { replyCommand, STATE_LABEL } from "./discussions-view.tsx";17+18+const LINK = "decoration-rule underline hover:decoration-current";19+20+const proposalPath = (project: ProjectName, proposal: ProposalId) =>21+ `/${project}/proposals/${proposal}`;22+23+const Post = ({24+ now,25+ post,26+}: {27+ readonly now: DateTime.Utc;28+ readonly post: DiscussionPost;29+}) => (30+ <article31+ className="border-rule flex min-w-0 flex-col gap-2 border-b py-3"32+ data-post={post.by}33+ >34+ <p className="text-label text-muted-foreground">35+ <HandleLink handle={post.by} />36+ {" · "}37+ <When at={post.at} now={now} />38+ </p>39+ <p className="text-ui max-w-(--measure) [overflow-wrap:anywhere] whitespace-pre-wrap">40+ {post.body}41+ </p>42+ </article>43+);44+45+const Became = ({ discussion }: { readonly discussion: Discussion }) =>46+ discussion.proposal === undefined ? null : (47+ <p className="text-ui" data-became={discussion.proposal}>48+ {"A maintainer turned this discussion into "}49+ <AppLink50+ className={`text-mono font-mono ${LINK}`}51+ to={proposalPath(discussion.project, discussion.proposal)}52+ >53+ {discussion.proposal}54+ </AppLink>55+ , which expires unless a maintainer accepts it.56+ </p>57+ );58+59+const ThreadFacts = ({ discussion }: { readonly discussion: Discussion }) => (60+ <FactBlock label="This discussion">61+ {discussion.state === "open" ? (62+ <>63+ <p className="text-ui">64+ Reply from a terminal; anyone not denounced may. A maintainer may turn65+ the thread into a proposal with{" "}66+ <code className="text-mono font-mono">{`${Brand.cli} propose --discussion ${discussion.id}`}</code>67+ .68+ </p>69+ <CommandLine command={replyCommand(discussion)} numbered />70+ </>71+ ) : (72+ <p className="text-ui">73+ {discussion.state === "closed"74+ ? "This discussion is closed: it takes no more posts."75+ : "This discussion became a proposal: it takes no more posts."}76+ </p>77+ )}78+ </FactBlock>79+);80+81+export const DiscussionView = ({82+ discussion,83+ now,84+}: {85+ readonly discussion: Discussion;86+ readonly now: DateTime.Utc;87+}): ReactNode => (88+ <Workspace89+ facts={<ThreadFacts discussion={discussion} />}90+ factsHeading="This discussion"91+ meta={92+ <>93+ <code className="text-mono font-mono">{discussion.id}</code>94+ {" · opened by "}95+ <HandleLink handle={discussion.opener} />{" "}96+ <When at={discussion.openedAt} now={now} />97+ </>98+ }99+ state={100+ <span data-state={discussion.state}>{STATE_LABEL[discussion.state]}</span>101+ }102+ title={discussion.title}103+ variant="document"104+ >105+ <Became discussion={discussion} />106+ <div className="border-rule flex flex-col border-t" data-posts="">107+ {discussion.posts.map((post, index) => (108+ <Post key={index} now={now} post={post} />109+ ))}110+ </div>111+ </Workspace>112+);added:apps/web/src/features/discussion/discussions-view.tsx+115 added
1+import { Brand } from "@repo/brand";2+import type {3+ DiscussionListing,4+ DiscussionState,5+} from "@repo/protocol/domain/discussion";6+import type { ProjectName } from "@repo/protocol/ids";7+import type { DateTime } from "effect";8+import type { ReactNode } from "react";9+10+import { CommandLine } from "../shared/command.tsx";11+import { EmptyState } from "../shared/empty.tsx";12+import { FactBlock } from "../shared/facts.tsx";13+import { HandleLink } from "../shared/handle.tsx";14+import { AppLink } from "../shared/link.tsx";15+import { discussionPath } from "../shared/paths.ts";16+import { Workspace } from "../shared/shell/workspace.tsx";17+import { When } from "../shared/time.tsx";18+19+const LINK = "decoration-rule underline hover:decoration-current";20+21+const plural = (count: number, one: string, many: string) =>22+ `${count} ${count === 1 ? one : many}`;23+24+/** Every state reads as a word beside its mark, never by colour alone. */25+export const STATE_LABEL = {26+ closed: "Closed",27+ open: "Open",28+ proposed: "Became a proposal",29+} as const satisfies Record<DiscussionState, string>;30+31+export const openCommand = (project: ProjectName) =>32+ `${Brand.cli} discussion post --project ${project} --title "<title>" --body "<post>"`;33+34+export const replyCommand = (35+ listing: Pick<DiscussionListing, "id" | "project">36+) =>37+ `${Brand.cli} discussion post ${listing.id} --project ${listing.project} --body "<post>"`;38+39+const Row = ({40+ listing,41+ now,42+}: {43+ readonly listing: DiscussionListing;44+ readonly now: DateTime.Utc;45+}) => (46+ <li47+ className="border-rule flex min-w-0 flex-col gap-1 border-b py-3"48+ data-discussion={listing.id}49+ data-state={listing.state}50+ >51+ <AppLink52+ className={`text-ui font-medium ${LINK}`}53+ to={discussionPath(listing.project, listing.id)}54+ >55+ {listing.title}56+ </AppLink>57+ <p className="text-label text-muted-foreground flex flex-wrap gap-x-3">58+ <span>59+ <code className="text-mono font-mono">{listing.id}</code>60+ </span>61+ <span>62+ {"opened by "}63+ <HandleLink handle={listing.opener} />64+ </span>65+ <span>{plural(listing.posts, "post", "posts")}</span>66+ <span>67+ {"last post "}68+ <When at={listing.lastPostAt} now={now} />69+ </span>70+ <span>{STATE_LABEL[listing.state]}</span>71+ </p>72+ </li>73+);74+75+const PostFacts = ({ project }: { readonly project: ProjectName }) => (76+ <FactBlock label="How to post">77+ <p className="text-ui">78+ Anyone not denounced may open a thread or reply, from a terminal. A79+ discussion lands nothing itself; a maintainer may turn one into a80+ proposal.81+ </p>82+ <CommandLine command={openCommand(project)} numbered />83+ </FactBlock>84+);85+86+export const DiscussionsView = ({87+ discussions,88+ now,89+ project,90+}: {91+ readonly discussions: readonly DiscussionListing[];92+ readonly now: DateTime.Utc;93+ readonly project: ProjectName;94+}): ReactNode => (95+ <Workspace96+ count={plural(discussions.length, "discussion", "discussions")}97+ facts={<PostFacts project={project} />}98+ factsHeading="Discussions here"99+ title="Discussions"100+ variant="list"101+ >102+ {discussions.length === 0 ? (103+ <EmptyState104+ command={openCommand(project)}105+ title="No discussions yet. Open one from a terminal; anyone not denounced may."106+ />107+ ) : (108+ <ul className="border-rule flex flex-col border-t" data-discussions="">109+ {discussions.map((listing) => (110+ <Row key={listing.id} listing={listing} now={now} />111+ ))}112+ </ul>113+ )}114+ </Workspace>115+);modified:apps/web/src/features/project/project-header.tsx+1 added-1 removed
1 /**2 * A project's one header (ADR 0041): its name, posture, description, facts3- * and three actions, then its eight tabs. Every page of the project draws it3+ * and three actions, then its nine tabs. Every page of the project draws it4 * the same; only the current tab moves.5 */6 import { Brand } from "@repo/brand";7 import type { Handle, ProjectName } from "@repo/protocol/ids";347 unmodified linesmodified:apps/web/src/features/shared/shell/sections.ts+12 added-1 removed
1 unmodified line2 import { Option } from "effect";3 4 import { INBOX_PATH, segmentsOf } from "../paths.ts";5 6-/** A project's eight tabs (ADR 0041), in the header's order. */6+/** A project's nine tabs (ADR 0041, with Discussions), in the header's order. */7 export type ProjectTab =8 | "asks"9 | "code"10+ | "discussions"11 | "landings"12 | "overview"13 | "people"14 | "policy"33 unmodified lines48 label: "Proposals",49 tab: "proposals",50 to: `/${project}`,51 },52+ { label: "Discussions", tab: "discussions", to: `/${project}/discussions` },53 { hash: "who-decides", label: "People", tab: "people", to: `/${project}` },54 { label: "Policy", tab: "policy", to: `/${project}/people` },55 { label: "Visibility", tab: "visibility", to: `/${project}/visibility` },56 ];5 unmodified lines62 blob: "code",63 commit: "landings",64 commits: "landings",65 decisions: "asks",66+ discussions: "discussions",67 people: "policy",68 proposals: "proposals",69 raw: "code",70 refs: "code",4 unmodified lines75 76 /** A crumb names the page itself, which may be narrower than its tab. */77 type PageSection =78 | "code"79+ | "discussions"80 | "landings"81 | "overview"82 | "people"83 | "refs"1 unmodified line85 86 const PAGE_TO = (project: string) =>87 ({88 code: `/${project}/tree/main`,89+ discussions: `/${project}/discussions`,90 landings: `/${project}/commits/main`,91 overview: `/${project}`,92 people: `/${project}/people`,93 refs: `/${project}/refs`,5 unmodified lines99 asks: "overview",100 blob: "code",101 commit: "landings",102 commits: "landings",103+ discussions: "discussions",104 people: "people",105 refs: "refs",106 tree: "code",107 visibility: "visibility",70 unmodified lines178 }179 180 const SECTION_LABEL = {181 code: "Code",182+ discussions: "Discussions",183 landings: "Landings",184 overview: "Asks",185 people: "Policy",186 refs: "Refs",52 unmodified lines239 commit: (project: string, sha: string) => [240 ...projectCrumbs(project, "landings", true),241 { label: sha.slice(0, 7), mono: true },242 ],243+ discussions: (project: string, discussion: string) => [244+ ...projectCrumbs(project, "discussions", true),245+ { label: discussion, mono: true },246+ ],247 decisions: (project: string, decision: string) => [248 { label: project, to: `/${project}` },249 { label: "Inbox", to: INBOX_PATH },250 { label: decision, mono: true },53 unmodified linesmodified:apps/web/src/features/shared/ask-progress.ts+1 added
97 unmodified lines98 Landed: constVoid,99 Lapsed: ({ ask }) => {100 change(ask, startedOver);101 },102+ DiscussionPosted: constVoid,103 LedgerAppended: constVoid,104 ProposalDrafted: constVoid,105 ProposalOpened: constVoid,106 Pushed: ({ ask, at, head }) => {109 unmodified linesmodified:apps/web/src/features/shared/paths.ts+9 added
1 import type {2 AskId,3 DecisionId,4+ DiscussionId,5 Handle,6 ProjectName,7 } from "@repo/protocol/ids";8 import { Result } from "effect";36 unmodified lines45 46 /** A handle is URL-safe by its schema. */47 export const personPath = (handle: Handle) => `/people/${handle}`;48 49+export const discussionsPath = (project: ProjectName) =>50+ `/${project}/discussions`;51+52+export const discussionPath = (53+ project: ProjectName,54+ discussion: DiscussionId55+) => `/${project}/discussions/${discussion}`;56+57 /** A project's Visibility tab (ADR 0041), and the regions on it a link may open. */58 export const visibilityPath = (project: ProjectName) =>59 `/${project}/visibility`;60 31 unmodified linesadded:apps/web/src/routes/$owner/$project/discussions/$discussion.tsx+120 added
1+import { useAtomMount, useAtomValue } from "@effect/atom-react";2+import { Client, ShowDiscussion } from "@repo/protocol/contracts";3+import { DiscussionId, ProjectName } from "@repo/protocol/ids";4+import { createFileRoute, notFound } from "@tanstack/react-router";5+import { createServerFn } from "@tanstack/react-start";6+import { env } from "cloudflare:workers";7+import { DateTime, Effect, Option, Schema } from "effect";8+import { AsyncResult } from "effect/reactivity";9+10+import { discussionAtom } from "../../../../client/discussion.ts";11+import { SeededAtoms, seedSuccess } from "../../../../client/seeded.ts";12+import { watchAtom } from "../../../../client/watch.ts";13+import { NotFoundView } from "../../../../features/ask/refused.tsx";14+import { DiscussionView } from "../../../../features/discussion/discussion-view.tsx";15+import { pageHead } from "../../../../features/shared/head.ts";16+import { notFoundFor, Refusals } from "../../../../features/shared/refusals.ts";17+import { branchPage } from "../../../../server/cache-headers.ts";18+import { serverClient } from "../../../../server/client.ts";19+20+type Shown = typeof ShowDiscussion.successSchema.Type;21+22+export const readDiscussion = (name: string, id: string) =>23+ Effect.gen(function* () {24+ const project = yield* Schema.decodeEffect(ProjectName)(name).pipe(25+ Effect.mapError(() => notFound())26+ );27+28+ const discussion = yield* Schema.decodeEffect(DiscussionId)(id).pipe(29+ Effect.mapError(() => notFound())30+ );31+32+ const client = yield* Client;33+34+ const shown = yield* client.showDiscussion({ discussion, project }).pipe(35+ Effect.catchTags({36+ UnknownDiscussion: notFoundFor,37+ UnknownProject: notFoundFor,38+ })39+ );40+41+ return yield* Schema.encodeEffect(ShowDiscussion.successSchema)(shown);42+ });43+44+const discussionPage = createServerFn({ method: "GET" })45+ .validator(46+ (params: { readonly discussion: string; readonly project: string }) =>47+ params48+ )49+ .handler(({ data }) =>50+ Effect.runPromise(51+ readDiscussion(data.project, data.discussion).pipe(52+ Effect.provide(serverClient(env))53+ )54+ )55+ );56+57+const FreshDiscussion = ({58+ project,59+ read,60+}: {61+ readonly project: ProjectName;62+ readonly read: Shown;63+}) => {64+ useAtomMount(watchAtom(project));65+66+ const { discussion } = Option.getOrElse(67+ AsyncResult.value(68+ useAtomValue(discussionAtom(project)(read.discussion.id))69+ ),70+ () => read71+ );72+73+ return <DiscussionView discussion={discussion} now={DateTime.nowUnsafe()} />;74+};75+76+const DiscussionPage = () => {77+ const read = Schema.decodeSync(ShowDiscussion.successSchema)(78+ Route.useLoaderData()79+ );80+81+ const { id, project } = read.discussion;82+83+ return (84+ <SeededAtoms85+ id={`${project}/${id}`}86+ seeds={[seedSuccess(discussionAtom(project)(id), read)]}87+ >88+ <FreshDiscussion project={project} read={read} />89+ </SeededAtoms>90+ );91+};92+93+const decodeRefusals = Schema.decodeUnknownOption(Refusals);94+95+const Unknown = ({ data }: { readonly data?: unknown }) => (96+ <NotFoundView97+ nothing="Nothing is at this address: a project's name is lowercase words joined by single dashes, and a discussion's id reads disc- and six digits."98+ refusals={Option.getOrUndefined(decodeRefusals(data))}99+ title="No such discussion"100+ />101+);102+103+export const Route = createFileRoute(104+ "/$owner/$project/discussions/$discussion"105+)({106+ staticData: { shell: "project" },107+ loader: ({ params }) => discussionPage({ data: params }),108+ headers: () => branchPage,109+ head: ({ loaderData, params: { discussion, project } }) =>110+ pageHead(111+ loaderData === undefined112+ ? { title: `${discussion} · ${project}` }113+ : {114+ description: loaderData.discussion.title,115+ title: `${loaderData.discussion.title} · ${project}`,116+ }117+ ),118+ component: DiscussionPage,119+ notFoundComponent: Unknown,120+});added:apps/web/src/routes/$owner/$project/discussions/index.tsx+102 added
1+import { useAtomMount, useAtomValue } from "@effect/atom-react";2+import { Client, ListDiscussions } from "@repo/protocol/contracts";3+import { ProjectName } from "@repo/protocol/ids";4+import { createFileRoute, notFound } from "@tanstack/react-router";5+import { createServerFn } from "@tanstack/react-start";6+import { env } from "cloudflare:workers";7+import { DateTime, Effect, Option, Schema } from "effect";8+import { AsyncResult } from "effect/reactivity";9+10+import { discussionsAtom } from "../../../../client/discussion.ts";11+import { SeededAtoms, seedSuccess } from "../../../../client/seeded.ts";12+import { watchAtom } from "../../../../client/watch.ts";13+import { DiscussionsView } from "../../../../features/discussion/discussions-view.tsx";14+import { UnknownProjectView } from "../../../../features/project/unknown-project.tsx";15+import { pageHead } from "../../../../features/shared/head.ts";16+import { branchPage } from "../../../../server/cache-headers.ts";17+import { serverClient } from "../../../../server/client.ts";18+19+type Listed = typeof ListDiscussions.successSchema.Type;20+21+export const readDiscussions = (name: string) =>22+ Effect.gen(function* () {23+ const project = yield* Schema.decodeEffect(ProjectName)(name).pipe(24+ Effect.mapError(() => notFound())25+ );26+27+ const client = yield* Client;28+29+ const listed = yield* client30+ .listDiscussions({ project })31+ .pipe(Effect.catchTag("UnknownProject", () => Effect.fail(notFound())));32+33+ return {34+ listed: yield* Schema.encodeEffect(ListDiscussions.successSchema)(listed),35+ project,36+ };37+ });38+39+const discussionsPage = createServerFn({ method: "GET" })40+ .validator((name: string) => name)41+ .handler(({ data }) =>42+ Effect.runPromise(43+ readDiscussions(data).pipe(Effect.provide(serverClient(env)))44+ )45+ );46+47+const FreshDiscussions = ({48+ project,49+ read,50+}: {51+ readonly project: ProjectName;52+ readonly read: Listed;53+}) => {54+ useAtomMount(watchAtom(project));55+56+ const { discussions } = Option.getOrElse(57+ AsyncResult.value(useAtomValue(discussionsAtom(project))),58+ () => read59+ );60+61+ return (62+ <DiscussionsView63+ discussions={discussions}64+ now={DateTime.nowUnsafe()}65+ project={project}66+ />67+ );68+};69+70+const DiscussionsPage = () => {71+ const { listed, project } = Route.useLoaderData();72+ const read = Schema.decodeSync(ListDiscussions.successSchema)(listed);73+ const name = ProjectName.make(project);74+75+ return (76+ <SeededAtoms77+ id={`${name}/discussions`}78+ seeds={[seedSuccess(discussionsAtom(name), read)]}79+ >80+ <FreshDiscussions project={name} read={read} />81+ </SeededAtoms>82+ );83+};84+85+const Unknown = () => {86+ const { project } = Route.useParams();87+88+ return <UnknownProjectView name={project} />;89+};90+91+export const Route = createFileRoute("/$owner/$project/discussions/")({92+ staticData: { shell: "project" },93+ loader: ({ params }) => discussionsPage({ data: params.project }),94+ headers: () => branchPage,95+ head: ({ params: { project } }) =>96+ pageHead({97+ title: `Discussions · ${project}`,98+ description: `${project}'s discussions: public threads that land nothing themselves.`,99+ }),100+ component: DiscussionsPage,101+ notFoundComponent: Unknown,102+});modified:apps/web/test/client-today.test.ts+2 added-2 removed
46 unmodified lines47 ).toStrictEqual({48 decider: "ines-v",49 newcomers: ["bram"],50 projects: ["oscabriel/datekit"],51- subjects: ["OpenProposal", "OpenProposal", "StrayPush"],51+ subjects: ["OpenProposal", "OpenProposal", "OpenProposal", "StrayPush"],52 unattended: ["diff-in-days-dst"],53 });54 })55 );43 unmodified lines99 100 expect(taken?.choice).toBe("decline");101 expect(102 taken === undefined ? undefined : DateTime.formatIso(taken.at)103- ).toBe("2026-10-07T09:21:00.000Z");103+ ).toBe("2026-10-07T09:27:00.000Z");104 105 const todayIn = (where: typeof registry) =>106 Effect.map(settled(where, todayAtom), (today) =>107 Exit.isSuccess(today)21 unmodified linesadded:apps/web/test/discussions.test.tsx+273 added
1+import { describe, expect, it } from "@effect/vitest";2+import { Brand } from "@repo/brand";3+import { Client, Contracts } from "@repo/protocol/contracts";4+import {5+ Discussion,6+ DiscussionListing,7+} from "@repo/protocol/domain/discussion";8+import { DiscussionId, ProjectName } from "@repo/protocol/ids";9+import { UnknownDiscussion, UnknownProject } from "@repo/protocol/refusal";10+import { asTester, unanswered } from "@repo/protocol/testing";11+import { isNotFound } from "@tanstack/react-router";12+import { DateTime, Effect, Layer, Schema } from "effect";13+import { RpcTest } from "effect/rpc";14+15+import { DiscussionView } from "../src/features/discussion/discussion-view.tsx";16+import { DiscussionsView } from "../src/features/discussion/discussions-view.tsx";17+import {18+ crumbsFor,19+ projectSections,20+ projectTabOf,21+} from "../src/features/shared/shell/sections.ts";22+import { readDiscussion } from "../src/routes/$owner/$project/discussions/$discussion.tsx";23+import { readDiscussions } from "../src/routes/$owner/$project/discussions/index.tsx";24+import { inOrder, markupOf, plainText } from "./ask-fixtures.ts";25+import { elementWith, mainOf } from "./records.ts";26+import { renderAt } from "./render.tsx";27+28+const datekit = ProjectName.make("oscabriel/datekit");29+30+const now = DateTime.makeUnsafe("2026-10-07T13:00:00Z");31+32+const first = DiscussionId.make("disc-000001");33+34+const second = DiscussionId.make("disc-000002");35+36+const open = Schema.decodeSync(Discussion)({37+ id: "disc-000001",38+ openedAt: "2026-10-07T12:00:00.000Z",39+ opener: "wren",40+ posts: [41+ {42+ at: "2026-10-07T12:00:00.000Z",43+ body: "Weeks start on Monday in ISO 8601; which does parseISO assume?",44+ by: "wren",45+ },46+ {47+ at: "2026-10-07T12:30:00.000Z",48+ body: "ISO, always.",49+ by: "ines-v",50+ },51+ ],52+ project: "oscabriel/datekit",53+ state: "open",54+ title: "Which day starts a week?",55+});56+57+const proposed = Schema.decodeSync(Discussion)({58+ id: "disc-000002",59+ openedAt: "2026-10-07T12:10:00.000Z",60+ opener: "tove",61+ posts: [62+ {63+ at: "2026-10-07T12:10:00.000Z",64+ body: "Could parseISO take week dates too?",65+ by: "tove",66+ },67+ ],68+ project: "oscabriel/datekit",69+ proposal: "prop-000001",70+ state: "proposed",71+ title: "ISO week dates",72+});73+74+const listings = Schema.decodeSync(Schema.Array(DiscussionListing))([75+ {76+ id: "disc-000001",77+ lastPostAt: "2026-10-07T12:30:00.000Z",78+ openedAt: "2026-10-07T12:00:00.000Z",79+ opener: "wren",80+ posts: 2,81+ project: "oscabriel/datekit",82+ state: "open",83+ title: "Which day starts a week?",84+ },85+ {86+ id: "disc-000002",87+ lastPostAt: "2026-10-07T12:10:00.000Z",88+ openedAt: "2026-10-07T12:10:00.000Z",89+ opener: "tove",90+ posts: 1,91+ project: "oscabriel/datekit",92+ proposal: "prop-000001",93+ state: "proposed",94+ title: "ISO week dates",95+ },96+]);97+98+const commandsOf = (markup: string) =>99+ [100+ ...markup.matchAll(/<code\b[^>]*select-all[^>]*>(?<line>.*?)<\/code>/gsu),101+ ].map((found) =>102+ plainText((found.groups?.line ?? "").replaceAll(/ \\\n\s*/gu, " ")).trim()103+ );104+105+const list = (106+ <DiscussionsView discussions={listings} now={now} project={datekit} />107+);108+109+describe("a project's discussions page", () => {110+ it("lists each thread by title, opener, posts, last post and state, each linked to its page", () => {111+ const markup = mainOf(markupOf(list));112+ const rows = elementWith(markup, "data-discussions");113+114+ expect(markup).toMatch(/<h1\b[^>]*>Discussions<\/h1>/u);115+ expect(rows).toContain('href="/oscabriel/datekit/discussions/disc-000001"');116+ expect(rows).toContain('href="/oscabriel/datekit/discussions/disc-000002"');117+ expect(118+ inOrder(plainText(rows), [119+ "Which day starts a week?",120+ "wren",121+ "2 posts",122+ "30 min ago",123+ "Open",124+ "ISO week dates",125+ "tove",126+ "1 post",127+ "Became a proposal",128+ ])129+ ).toBeTruthy();130+ });131+132+ it("shows the command to open a thread, copyable, and no form", () => {133+ const markup = markupOf(list);134+135+ expect(commandsOf(markup)).toContain(136+ `${Brand.cli} discussion post --project oscabriel/datekit --title "<title>" --body "<post>"`137+ );138+ expect(markup).not.toMatch(/<form\b|<textarea\b/u);139+ });140+141+ it("says so, with the command, when there are none", () => {142+ const markup = markupOf(143+ <DiscussionsView discussions={[]} now={now} project={datekit} />144+ );145+146+ expect(plainText(mainOf(markup))).toContain("No discussions yet");147+ expect(markup).not.toContain("data-discussions");148+ });149+150+ it.effect("is the Discussions tab, with its crumbs", () =>151+ Effect.gen(function* () {152+ const markup = yield* renderAt("/oscabriel/datekit/discussions", list);153+ const crumbs = elementWith(markup, 'aria-label="Breadcrumb"');154+155+ expect(plainText(crumbs)).toContain("Discussions");156+ expect(157+ projectSections("oscabriel/datekit").find(158+ ({ tab }) => tab === "discussions"159+ )160+ ).toStrictEqual({161+ label: "Discussions",162+ tab: "discussions",163+ to: "/oscabriel/datekit/discussions",164+ });165+ expect([166+ projectTabOf("/oscabriel/datekit/discussions"),167+ projectTabOf("/oscabriel/datekit/discussions/disc-000001"),168+ ]).toStrictEqual(["discussions", "discussions"]);169+ expect(170+ crumbsFor("/oscabriel/datekit/discussions/disc-000001")171+ ).toStrictEqual([172+ { label: "oscabriel/datekit", to: "/oscabriel/datekit" },173+ { label: "Discussions", to: "/oscabriel/datekit/discussions" },174+ { label: "disc-000001", mono: true },175+ ]);176+ })177+ );178+});179+180+describe("a discussion's page", () => {181+ it("shows the posts in order, each by its person and time, and the reply command while open", () => {182+ const markup = markupOf(<DiscussionView discussion={open} now={now} />);183+ const main = mainOf(markup);184+ const posts = elementWith(main, "data-posts");185+186+ expect(main).toMatch(/<h1\b[^>]*>Which day starts a week\?<\/h1>/u);187+ expect(188+ inOrder(plainText(posts), [189+ "wren",190+ "1 h ago",191+ "Weeks start on Monday in ISO 8601; which does parseISO assume?",192+ "ines-v",193+ "30 min ago",194+ "ISO, always.",195+ ])196+ ).toBeTruthy();197+ expect(posts).toMatch(/<a\b[^>]*href="\/people\/wren"[^>]*>wren<\/a>/u);198+ expect(commandsOf(markup)).toContain(199+ `${Brand.cli} discussion post disc-000001 --project oscabriel/datekit --body "<post>"`200+ );201+ expect(markup).not.toMatch(/<form\b|<textarea\b/u);202+ });203+204+ it("names the proposal a maintainer turned it into, linked, and offers no reply", () => {205+ const markup = markupOf(<DiscussionView discussion={proposed} now={now} />);206+207+ const became = elementWith(mainOf(markup), "data-became");208+209+ expect(became).toMatch(210+ /<a\b[^>]*href="\/oscabriel\/datekit\/proposals\/prop-000001"[^>]*>prop-000001<\/a>/u211+ );212+ expect(plainText(markup)).toContain("Became a proposal");213+ expect(plainText(markup)).toContain("takes no more posts");214+ expect(commandsOf(markup)).toStrictEqual([]);215+ });216+});217+218+const platformOf = () =>219+ Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(220+ Layer.provide(221+ Layer.mergeAll(222+ unanswered,223+ Contracts.toLayerHandler("listDiscussions", ({ project }) =>224+ project === datekit225+ ? Effect.succeed({ discussions: listings })226+ : Effect.fail(new UnknownProject({ project }))227+ ),228+ Contracts.toLayerHandler(229+ "showDiscussion",230+ ({ discussion, project }) => {231+ if (project !== datekit) {232+ return Effect.fail(new UnknownProject({ project }));233+ }234+235+ return discussion === first236+ ? Effect.succeed({ discussion: open })237+ : Effect.fail(new UnknownDiscussion({ discussion }));238+ }239+ ),240+ asTester241+ )242+ )243+ );244+245+describe("the discussion reads", () => {246+ it.effect("list a project's discussions and show one", () =>247+ Effect.gen(function* () {248+ const listed = yield* readDiscussions("oscabriel/datekit");249+ const shown = yield* readDiscussion("oscabriel/datekit", "disc-000001");250+251+ expect(listed.listed.discussions.map(({ id }) => id)).toStrictEqual([252+ "disc-000001",253+ "disc-000002",254+ ]);255+ expect(shown.discussion.id).toBe("disc-000001");256+ }).pipe(Effect.provide(platformOf()))257+ );258+259+ it.effect(260+ "are not-founds for an unknown project, discussion or address",261+ () =>262+ Effect.gen(function* () {263+ const failed = yield* Effect.all([264+ Effect.flip(readDiscussions("oscabriel/no-such-project")),265+ Effect.flip(readDiscussion("oscabriel/datekit", second)),266+ Effect.flip(readDiscussion("oscabriel/datekit", "not-an-id")),267+ Effect.flip(readDiscussions("Not_A-Project")),268+ ]);269+270+ expect(failed.map(isNotFound)).toStrictEqual([true, true, true, true]);271+ }).pipe(Effect.provide(platformOf()))272+ );273+});modified:apps/web/test/nav.test.tsx+2 added-1 removed
24 unmodified lines25 { href: "/oscabriel/datekit/tree/main", text: "Code" },26 { href: "/oscabriel/datekit#open-asks", text: "Asks" },27 { href: "/oscabriel/datekit/commits/main?show=landings", text: "Landings" },28 { href: "/oscabriel/datekit#proposals", text: "Proposals" },29+ { href: "/oscabriel/datekit/discussions", text: "Discussions" },30 { href: "/oscabriel/datekit#who-decides", text: "People" },31 { href: "/oscabriel/datekit/people", text: "Policy" },32 { href: "/oscabriel/datekit/visibility", text: "Visibility" },33 ].map((link) => ({ current: link.text === current, ...link }));34 35 describe("a project's tabs", () => {35- it("links all eight, in ADR 0041's order, and marks only the page being read", () => {36+ it("links all nine, in ADR 0041's order, and marks only the page being read", () => {37 const markup = renderToStaticMarkup(38 <ProjectTabs current="code" project={datekit} />39 );40 146 unmodified linesmodified:apps/web/test/project.test.tsx+1 added
128 unmodified lines129 "Code",130 "Asks",131 "Landings",132 "Proposals",133+ "Discussions",134 "People",135 "Policy",136 "Visibility",137 ];1391 unmodified linesmodified:packages/agent-kit/src/docs/run-a-project.ts+4 added
85 unmodified lines86 "## Proposals and drafts",87 "",88 `Anyone not denounced may propose an ask: ${cli('propose --project <owner>/<name> --want "<what should be true>"')}. A proposal expires unless a maintainer accepts it. With ${code("--draft")}, the platform's agent drafts the ask file and its failing check, runs them red first, and puts the draft to a maintainer with its evidence; ${cli("proposal <proposal> --project <owner>/<name>")} follows it, and ${cli("ask draft <proposal> --project <owner>/<name>")} asks for another round. Nothing lands until a maintainer accepts, and the landing discloses the agent in \`Assisted-by\`.`,89 "",90+ "## Discussions",91+ "",92+ `A discussion is a public, freeform thread in a project, open to anyone not denounced, that lands nothing itself. Open one with ${cli('discussion post --project <owner>/<name> --title "<what to talk about>" --body "<the first post>"')}, and reply with ${cli('discussion post <discussion> --project <owner>/<name> --body "<your post>"')}; ${cli("discussions --project <owner>/<name>")} lists them and ${cli("discussion <discussion> --project <owner>/<name>")} reads one. A maintainer may turn a thread into a proposal with ${cli('propose --project <owner>/<name> --discussion <discussion> --want "<what should be true>"')}, which marks it proposed and takes no more posts; its page then names the proposal it became.`,93+ "",94 "## Today",95 "",96 `A maintainer's Today is their open decisions, soonest to expire first, each with its evidence and a safe default taken if nobody decides before it expires. Read it on the web in [your inbox](/inbox), or with ${cli("today")}, and take one with ${cli("decide --project <owner>/<name> --decision <decision> --choice accept")} (or \`decline\`, \`adopt\`, \`revert\`).`,97 "",23 unmodified linesmodified:packages/agent-kit/src/command-doc.ts+10 added-1 removed
179 unmodified lines180 SchemaAST.isObjects(ast)181 ? ast.propertySignatures.map(({ name }) => String(name))182 : [];183 184+const requiredFieldsOf = (ast: SchemaAST.AST) =>185+ SchemaAST.isObjects(ast)186+ ? ast.propertySignatures.flatMap(({ name, type }) =>187+ type.context?.isOptional === true ? [] : [String(name)]188+ )189+ : [];190+191 export const contractCommandDocs = (192 group: typeof Contracts193 ): readonly CommandDoc[] =>194 [...group.requests.values()].flatMap((rpc) => {10 unmodified lines205 return [];206 }207 208 const positional = cli.positional ?? [];209+ const required = requiredFieldsOf(rpc.payloadSchema.ast);210 const readOnly = Context.get(annotations, ReadOnly);211 const needsApproval = Context.get(annotations, NeedsApproval);212 213 const flags = fieldsOf(rpc.payloadSchema.ast)10 unmodified lines224 ...(readOnly ? [] : ["--dry-run"]),225 ],226 needsApproval,227 path: [first, ...rest],220- positional: [...positional],228+ // An optional positional (a reply's discussion) is taken, not required, so the row leaves it out.229+ positional: positional.filter((field) => required.includes(field)),230 readOnly,231 source: "contract",232 summary: Context.get(annotations, Description),233 },9 unmodified linesmodified:packages/agent-kit/src/llms-sections.ts+1 added
103 unmodified lines104 AskClosed: "An ask closed, with the landing that answered it.",105 AskOpened: "A new ask opened.",106 Claimed: "Someone claimed an ask.",107 Decided: "A maintainer took a decision.",108+ DiscussionPosted: "Someone posted in a discussion: opened one, or replied.",109 Judged: "An answer was checked, with the outcome its verdict holds.",110 Landed:111 "A landing reached `main`, a project's adoption (its first push or its import) among them.",112 Lapsed: "A claim lapsed: no push for too long.",17 unmodified linesmodified:packages/agent-kit/src/refusals.ts+7 added-1 removed
52 unmodified lines53 next: cli("claim", "<ask>"),54 todo: "Your claim lapsed after a spell without a push: claim the ask again if it is still open.",55 },56 Denounced: {57- todo: "The project's vouch file denounces you: it takes no claims or proposals from you.",57+ todo: "The project's vouch file denounces you: it takes no claims, proposals or posts from you.",58 },59 DirectPush: {60 todo: "Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`.",61 },39 unmodified lines101 const elsewhere = {102 DecisionClosed: {103 todo: "Nothing to decide: it was taken already, or expired to its default.",104 },105+ DiscussionClosed: {106+ todo: "Nothing more is posted there: the discussion was closed, or a maintainer turned it into a proposal; `next` lists the open ones.",107+ },108 DraftInProgress: {109 next: cli("proposal", "<proposal>"),110 todo: "Wait: the platform is drafting this proposal's ask already, and `next` shows when it settles.",111 },34 unmodified lines146 },147 UnknownDecision: {148 todo: "Check the decision's id: `next` lists the decisions waiting on you.",149 },150+ UnknownDiscussion: {151+ todo: "Check the discussion's id: `next` lists the project's discussions.",152+ },153 UnknownEnvItem: {154 todo: "Name a key the project's env shape has: `next` lists them.",155 },156 UnknownPath: {140 unmodified linesmodified:packages/agent-kit/test/golden/agent-plugins-stdio.txt+1 added-1 removed
59 unmodified lines60 | `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |61 | `RepoBusy` | yes | 75 | `git push` | Push again. |62 | `DirectPush` | no | 77 | `__CLI__ fork --project <owner>/<name>` | Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`. |63 | `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |64-| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims or proposals from you. |64+| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims, proposals or posts from you. |65 | `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |66 | `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |67 | `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a maintainer to weigh, but one a maintainer declined stays out; never raise a ratchet. |68 | `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |29 unmodified linesmodified:packages/agent-kit/test/golden/agent-plugins.txt+1 added-1 removed
60 unmodified lines61 | `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |62 | `RepoBusy` | yes | 75 | `git push` | Push again. |63 | `DirectPush` | no | 77 | `__CLI__ fork --project <owner>/<name>` | Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`. |64 | `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |65-| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims or proposals from you. |65+| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims, proposals or posts from you. |66 | `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |67 | `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |68 | `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a maintainer to weigh, but one a maintainer declined stays out; never raise a ratchet. |69 | `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |26 unmodified linesmodified:packages/agent-kit/test/golden/agent-setup.txt+2 added-2 removed
127 unmodified lines128 - Checks: `ChecksFailed`, `HeldBackFailed` and `AttemptsExhausted`129 - Never counted against the answerer: `Flake` and `VerifierBlocked`130 - At ask open: `NotRedFirst`, `WeakCheck` and `IncompleteBrief`131 - Maintainers only: `LayerContentInPublicTree`, `SecretInOutput` and `UnstatedRequirement`132-- Decision: `PostureChange`, `NotDecider`, `DecisionClosed`, `ProposalClosed` and `DraftInProgress`133-- Lookup: `UnknownProject`, `UnknownAsk`, `UnknownCommit`, `UnknownDecision`, `UnknownPath`, `UnknownRevision` and `UnknownProposal`132+- Decision: `PostureChange`, `NotDecider`, `DecisionClosed`, `ProposalClosed`, `DraftInProgress` and `DiscussionClosed`133+- Lookup: `UnknownProject`, `UnknownAsk`, `UnknownCommit`, `UnknownDecision`, `UnknownPath`, `UnknownRevision`, `UnknownProposal` and `UnknownDiscussion`134 - Setup: `ProjectExists`, `NotYourNamespace` and `ImportFailed`135 - Env: `UnknownEnvItem`, `NotSensitive` and `ValueTooShort`modified:packages/agent-kit/test/golden/claude-plugin-stdio.txt+1 added-1 removed
58 unmodified lines59 | `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |60 | `RepoBusy` | yes | 75 | `git push` | Push again. |61 | `DirectPush` | no | 77 | `__CLI__ fork --project <owner>/<name>` | Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`. |62 | `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |63-| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims or proposals from you. |63+| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims, proposals or posts from you. |64 | `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |65 | `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |66 | `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a maintainer to weigh, but one a maintainer declined stays out; never raise a ratchet. |67 | `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |64 unmodified linesmodified:packages/agent-kit/test/golden/claude-plugin.txt+1 added-1 removed
59 unmodified lines60 | `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |61 | `RepoBusy` | yes | 75 | `git push` | Push again. |62 | `DirectPush` | no | 77 | `__CLI__ fork --project <owner>/<name>` | Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`. |63 | `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |64-| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims or proposals from you. |64+| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims, proposals or posts from you. |65 | `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |66 | `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |67 | `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a maintainer to weigh, but one a maintainer declined stays out; never raise a ratchet. |68 | `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |62 unmodified linesmodified:packages/agent-kit/test/golden/full-llms.txt+4 added-1 removed
64 unmodified lines65 | `NoAsk` | Push and claim | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |66 | `RepoBusy` | Push and claim | yes | 75 | `git push` | Push again. |67 | `DirectPush` | Push and claim | no | 77 | `__CLI__ fork --project <owner>/<name>` | Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`. |68 | `AskBlocked` | Push and claim | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |69-| `Denounced` | Push and claim | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims or proposals from you. |69+| `Denounced` | Push and claim | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims, proposals or posts from you. |70 | `OutOfScope` | Shape | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |71 | `TouchedJudge` | Shape | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |72 | `Weakened` | Shape | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a maintainer to weigh, but one a maintainer declined stays out; never raise a ratchet. |73 | `PrivatePathInPublicTree` | Shape | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |15 unmodified lines89 | `NotDecider` | Decision | no | 77 | `__CLI__ policy --project <owner>/<name>` | Only one of the project's maintainers may do this: ask one of them. |90 | `DecisionClosed` | Decision | no | 66 | `__CLI__ today` | Nothing to decide: it was taken already, or expired to its default. |91 | `ProposalClosed` | Decision | no | 66 | `__CLI__ today` | Nothing more is drafted for it: the proposal was accepted, declined or expired. |92 | `DraftInProgress` | Decision | yes | 75 | `__CLI__ proposal <proposal>` | Wait: the platform is drafting this proposal's ask already, and `next` shows when it settles. |93+| `DiscussionClosed` | Decision | no | 66 | `__CLI__ discussions` | Nothing more is posted there: the discussion was closed, or a maintainer turned it into a proposal; `next` lists the open ones. |94 | `UnknownProject` | Lookup | no | 66 | `__CLI__ projects` | Check the project's name: `next` lists every project. |95 | `UnknownAsk` | Lookup | no | 66 | `__CLI__ asks` | Check the ask's name: `next` lists the project's open asks. |96 | `UnknownCommit` | Lookup | no | 66 | `log {"project":"<owner>/<name>"}` | Name a commit the project holds: `next`, the MCP tool, lists its log. |97 | `UnknownDecision` | Lookup | no | 66 | `__CLI__ today` | Check the decision's id: `next` lists the decisions waiting on you. |98 | `UnknownPath` | Lookup | no | 66 | `readTree {"at":"main","project":"<owner>/<name>"}` | Name a path the commit holds: `next`, the MCP tool, lists a folder's entries; give it `at` the commit. |99 | `UnknownRevision` | Lookup | no | 66 | `listRefs {"project":"<owner>/<name>"}` | Name `main`, a commit the project holds or one of its tags: `next`, the MCP tool, lists its refs. |100 | `UnknownProposal` | Lookup | no | 66 | `__CLI__ today` | Check the proposal's id: `next` lists the proposals waiting on you. |101+| `UnknownDiscussion` | Lookup | no | 66 | `__CLI__ discussions` | Check the discussion's id: `next` lists the project's discussions. |102 | `ProjectExists` | Setup | no | 65 | `__CLI__ projects` | Pick another name: that one is taken. |103 | `NotYourNamespace` | Setup | no | 77 | | Make the project in your own namespace: `next` names it with your handle. |104 | `ImportFailed` | Setup | yes | 75 | `__CLI__ init --project <owner>/<name> --import <url>` | Read `reason`, then import again with `next`. |105 | `UnknownEnvItem` | Env | no | 66 | `__CLI__ env shape` | Name a key the project's env shape has: `next` lists them. |59 unmodified lines165 - `AskClosed`: An ask closed, with the landing that answered it.166 - `AskOpened`: A new ask opened.167 - `Claimed`: Someone claimed an ask.168 - `Decided`: A maintainer took a decision.169+- `DiscussionPosted`: Someone posted in a discussion: opened one, or replied.170 - `Judged`: An answer was checked, with the outcome its verdict holds.171 - `Landed`: A landing reached `main`, a project's adoption (its first push or its import) among them.172 - `Lapsed`: A claim lapsed: no push for too long.173 - `LedgerAppended`: The project's public ledger gained an entry.28 unmodified linesmodified:packages/agent-kit/test/golden/platform-skill.txt+1 added-1 removed
52 unmodified lines53 | `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |54 | `RepoBusy` | yes | 75 | `git push` | Push again. |55 | `DirectPush` | no | 77 | `__CLI__ fork --project <owner>/<name>` | Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`. |56 | `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |57-| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims or proposals from you. |57+| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims, proposals or posts from you. |58 | `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |59 | `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |60 | `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a maintainer to weigh, but one a maintainer declined stays out; never raise a ratchet. |61 | `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |15 unmodified linesmodified:packages/agent-kit/test/golden/project-skill.txt+2 added-2 removed
86 unmodified lines87 | `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |88 | `RepoBusy` | yes | 75 | `git push` | Push again. |89 | `DirectPush` | no | 77 | `__CLI__ fork --project <owner>/<name>` | Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`. |90 | `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |91-| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims or proposals from you. |91+| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims, proposals or posts from you. |92 | `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |93 | `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |94 | `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a maintainer to weigh, but one a maintainer declined stays out; never raise a ratchet. |95 | `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |102 unmodified lines198 | `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |199 | `RepoBusy` | yes | 75 | `git push` | Push again. |200 | `DirectPush` | no | 77 | `__CLI__ fork --project <owner>/<name>` | Main moves only by a landing. A contributor pushes the answer to the claim's fork; a maintainer makes a working fork with `next` and lands it with `land`. |201 | `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |202-| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims or proposals from you. |202+| `Denounced` | no | 77 | `__CLI__ policy --project <owner>/<name>` | The project's vouch file denounces you: it takes no claims, proposals or posts from you. |203 | `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |204 | `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |205 | `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a maintainer to weigh, but one a maintainer declined stays out; never raise a ratchet. |206 | `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |15 unmodified linesmodified:packages/agent-kit/test/docs.test.ts+1 added
184 unmodified lines185 "AskClosed",186 "AskOpened",187 "Claimed",188 "Decided",189+ "DiscussionPosted",190 "Judged",191 "Landed",192 "Lapsed",193 "LedgerAppended",66 unmodified linesmodified:packages/agent-kit/test/full-llms.test.ts+1 added
110 unmodified lines111 "AskClosed",112 "AskOpened",113 "Claimed",114 "Decided",115+ "DiscussionPosted",116 "Judged",117 "Landed",118 "Lapsed",119 "LedgerAppended",137 unmodified linesadded:packages/project/src/attention/discussions.ts+138 added
1+import type { Discussion } from "@repo/protocol/domain/discussion";2+import type { DiscussionId, ProjectName, ProposalId } from "@repo/protocol/ids";3+import type { Person } from "@repo/protocol/principal";4+import {5+ CapReached,6+ Denounced,7+ DiscussionClosed,8+} from "@repo/protocol/refusal";9+import { Array, Data, Option, Result } from "effect";10+import type { DateTime } from "effect";11+12+import { ProjectEventInput } from "../events.ts";13+import { AttentionEffect } from "./effects.ts";14+15+/** How many discussions one person outside the project's vouches may hold open at once. */16+export const DISCUSSIONS_PER_PERSON = 20;17+18+interface Poster {19+ readonly denounced: boolean;20+ readonly who: Person;21+}22+23+export type DiscussionCommand = Data.TaggedEnum<{24+ Open: Poster & {25+ readonly body: Option.Option<string>;26+ readonly capped: boolean;27+ readonly id: DiscussionId;28+ readonly openCount: number;29+ readonly project: ProjectName;30+ readonly title: string;31+ };32+ Reply: Poster & { readonly body: string; readonly discussion: Discussion };33+}>;34+35+export const DiscussionCommand = Data.taggedEnum<DiscussionCommand>();36+37+export interface Posted {38+ readonly discussion: Discussion;39+ readonly effects: readonly AttentionEffect[];40+}41+42+export type PostRefusal = Denounced | CapReached | DiscussionClosed;43+44+const posted = (discussion: Discussion, now: DateTime.Utc): Posted => ({45+ discussion,46+ effects: [47+ AttentionEffect.Emit({48+ event: ProjectEventInput.DiscussionPosted({49+ at: now,50+ by: Array.lastNonEmpty(discussion.posts).by,51+ discussion: discussion.id,52+ }),53+ }),54+ ],55+});56+57+const open = (58+ command: Data.TaggedEnum.Value<DiscussionCommand, "Open">,59+ now: DateTime.Utc60+): Result.Result<Posted, Denounced | CapReached> => {61+ if (command.denounced) {62+ return Result.fail(new Denounced({}));63+ }64+65+ if (command.capped && command.openCount >= DISCUSSIONS_PER_PERSON) {66+ return Result.fail(67+ new CapReached({ cap: DISCUSSIONS_PER_PERSON, limit: "discussions" })68+ );69+ }70+71+ const first = {72+ at: now,73+ body: Option.getOrElse(command.body, () => command.title),74+ by: command.who.handle,75+ };76+77+ return Result.succeed(78+ posted(79+ {80+ id: command.id,81+ openedAt: now,82+ opener: command.who.handle,83+ posts: [first],84+ project: command.project,85+ state: "open",86+ title: command.title,87+ },88+ now89+ )90+ );91+};92+93+const reply = (94+ command: Data.TaggedEnum.Value<DiscussionCommand, "Reply">,95+ now: DateTime.Utc96+): Result.Result<Posted, Denounced | DiscussionClosed> => {97+ if (command.denounced) {98+ return Result.fail(new Denounced({}));99+ }100+101+ const { discussion } = command;102+103+ if (discussion.state !== "open") {104+ return Result.fail(new DiscussionClosed({ discussion: discussion.id }));105+ }106+107+ return Result.succeed(108+ posted(109+ {110+ ...discussion,111+ posts: [112+ ...discussion.posts,113+ { at: now, body: command.body, by: command.who.handle },114+ ],115+ },116+ now117+ )118+ );119+};120+121+/** `transition(state, command, now)`: an open thread takes a post; a closed or proposed one refuses it. */122+export const post = (123+ command: DiscussionCommand,124+ now: DateTime.Utc125+): Result.Result<Posted, PostRefusal> =>126+ DiscussionCommand.$match(command, {127+ Open: (opening) => open(opening, now),128+ Reply: (replying) => reply(replying, now),129+ });130+131+/** A maintainer's proposal from a thread marks it proposed; only an open thread can be. */132+export const promoted = (133+ discussion: Discussion,134+ proposal: ProposalId135+): Result.Result<Discussion, DiscussionClosed> =>136+ discussion.state === "open"137+ ? Result.succeed({ ...discussion, proposal, state: "proposed" })138+ : Result.fail(new DiscussionClosed({ discussion: discussion.id }));modified:packages/project/src/project-store/memory.ts+1 added
73 unmodified lines74 asks: yield* all(state, Tables.asks),75 attempts: yield* all(state, Tables.attempts),76 claims: yield* all(state, Tables.claims),77 decisions: yield* all(state, Tables.decisions),78+ discussions: yield* all(state, Tables.discussions),79 envValues: yield* all(state, Tables.envValues),80 landings: yield* decodeAll(81 Tables.landings,82 Array.map(newest, ([, row]) => row)156 unmodified linesmodified:packages/project/src/project-store/migrations.ts+7 added
87 unmodified lines88 89 yield* sql`DROP TABLE budget_days`;90 });91 92+const discussions = Effect.gen(function* () {93+ const sql = yield* SqlClient;94+95+ yield* sql`CREATE TABLE discussions (id TEXT PRIMARY KEY, body TEXT NOT NULL)`;96+});97+98 const migrations = {99 "1_project_state": projectState,100 "2_visibility": visibility,101 "3_drop_budget_days": dropBudgetDays,102+ "4_discussions": discussions,103 };104 105 export const migrate: Effect.Effect<106 readonly (readonly [id: number, name: string])[],6 unmodified linesmodified:packages/project/src/project-store/rows.ts+5 added
1 import { Ask } from "@repo/protocol/domain/ask";2 import { AgentTrailer } from "@repo/protocol/domain/credit";3 import { Decision } from "@repo/protocol/domain/decision";4+import { Discussion } from "@repo/protocol/domain/discussion";5 import { ProjectEvent } from "@repo/protocol/domain/event";6 import { LandingView } from "@repo/protocol/domain/landing";7 import { ImportSource } from "@repo/protocol/domain/policy";8 import { Proposal } from "@repo/protocol/domain/proposal";76 unmodified lines85 export const DecisionRow = Decision;86 87 export type DecisionRow = typeof DecisionRow.Type;88 89+export const DiscussionRow = Discussion;90+91+export type DiscussionRow = typeof DiscussionRow.Type;92+93 export const RatchetRow = Schema.Struct({94 at: LandedSha,95 count: Schema.Int,96 ratchet: RatchetName,87 unmodified linesmodified:packages/project/src/project-store/sqlite.ts+1 added
178 unmodified lines179 asks: yield* all(Tables.asks),180 attempts: yield* all(Tables.attempts),181 claims: yield* all(Tables.claims),182 decisions: yield* all(Tables.decisions),183+ discussions: yield* all(Tables.discussions),184 envValues: yield* all(Tables.envValues),185 landings: yield* bodiesOf(186 Tables.landings,187 sql`SELECT body FROM landings21 unmodified linesmodified:packages/project/src/project-store/tables.ts+5 added
6 unmodified lines7 AskRow,8 AttemptRow,9 ClaimRow,10 DecisionRow,11+ DiscussionRow,12 EnvValueRow,13 LandingRow,14 LayerReadRow,15 LayerRow,58 unmodified lines74 })),75 decisions: tableOf("decisions", DecisionRow, ["id"], (row) => ({76 id: row.id,77 })),78+ discussions: tableOf("discussions", DiscussionRow, ["id"], (row) => ({79+ id: row.id,80+ })),81 envValues: tableOf("env_values", EnvValueRow, ["key"], (row) => ({82 key: row.key,83 })),84 landings: tableOf("landings", LandingRow, ["sha"], (row) => ({83 unmodified lines168 yield* upsert(QueueTable, writes.queue === undefined ? [] : [writes.queue]);169 yield* upsert(Tables.landings, writes.landings ?? []);170 yield* upsert(Tables.proposals, writes.proposals ?? []);171 yield* upsert(Tables.decisions, writes.decisions ?? []);172+ yield* upsert(Tables.discussions, writes.discussions ?? []);173 yield* upsert(Tables.ratchets, writes.ratchets ?? []);174 yield* upsert(Tables.pushEvents, writes.pushEvents ?? []);175 yield* upsert(EventTable, events);176 yield* upsert(Tables.outbox, writes.outbox ?? []);8 unmodified linesmodified:packages/project/src/projection-d1/projection.ts+1 added
209 unmodified lines210 ...wanted(ask.ask, ask.want),211 ],212 Claimed: ({ ask }) => [claims(ask, 1)],213 Decided: () => unkept,214+ DiscussionPosted: () => [],215 Judged: refusedRow,216 Landed: ({ landing }) => [217 ...landedRow({ landing }),218 sql`UPDATE projects SET landed_at = ${DateTime.formatIso(landing.landedAt)}112 unmodified linesmodified:packages/project/src/deciders.ts+172 added-4 removed
11 unmodified lines12 import type { ConfigFile, Evidence } from "@repo/protocol/domain/common";13 import type { AgentTrailer, Credit } from "@repo/protocol/domain/credit";14 import { DecisionSubject } from "@repo/protocol/domain/decision";15 import type { Choice, Decision, Today } from "@repo/protocol/domain/decision";16+import { listingOf as discussionListingOf } from "@repo/protocol/domain/discussion";17+import type {18+ Discussion,19+ DiscussionListing,20+} from "@repo/protocol/domain/discussion";21 import type { EnvSchemaView } from "@repo/protocol/domain/env";22 import type { LandingView } from "@repo/protocol/domain/landing";23 import { Outcome } from "@repo/protocol/domain/outcome";24 import type { Policy } from "@repo/protocol/domain/policy";5 unmodified lines30 import {31 AskId,32 CommitSha,33 DecisionId,34+ DiscussionId,35 LandedSha,36 ProposalId,37 RepoName,38 RepoPath,12 unmodified lines51 RepoBusy,52 StaleBase,53 TouchedJudge,54 UnknownAsk,55+ UnknownDiscussion,56 UnknownProposal,57 } from "@repo/protocol/refusal";58 import type {59 CapReached,60 DecisionClosed,61+ DiscussionClosed,62 DraftInProgress,63 IncompleteBrief,64 NotRedFirst,65 NotSensitive,28 unmodified lines94 expireDecisions,95 openDecision,96 } from "./attention/decisions.ts";97 import type { Decided } from "./attention/decisions.ts";98+import { DiscussionCommand, post, promoted } from "./attention/discussions.ts";99 import { AttentionEffect, platformHandle } from "./attention/effects.ts";100 import {101 draft,102 DraftCommand,92 unmodified lines195 readonly requestId: RequestId;196 }197 ) => Effect.Effect<LandReceipt, NotDecider | StaleBase | RepoBusy>;198 readonly ledger: (caller: Principal) => Effect.Effect<Ledger>;199+ readonly listDiscussions: (200+ caller: Principal201+ ) => Effect.Effect<{ readonly discussions: readonly DiscussionListing[] }>;202+ readonly postDiscussion: (203+ caller: Person,204+ input: {205+ readonly body?: string;206+ readonly discussion?: DiscussionId;207+ readonly title?: string;208+ }209+ ) => Effect.Effect<210+ { readonly discussion: Discussion },211+ UnknownDiscussion | DiscussionClosed | Denounced | CapReached212+ >;213 readonly proposeAsk: (214 caller: Person,215 input: {216+ readonly discussion?: DiscussionId;217 readonly draft?: true;218 readonly files?: Array.NonEmptyReadonlyArray<ComposedFile>;219 readonly sealed?: { readonly head: CommitSha };220 readonly territory?: string;221 readonly want: string;222 }223 ) => Effect.Effect<224 { readonly proposal: Proposal },201- Denounced | CapReached | NotVouched225+ | Denounced226+ | CapReached227+ | NotVouched228+ | NotDecider229+ | UnknownDiscussion230+ | DiscussionClosed231 >;232 readonly setEnv: (233 caller: Person,234 input: {15 unmodified lines250 ) => Effect.Effect<251 { readonly proposal: Proposal },252 UnknownProposal | ProposalClosed | NotDecider | DraftInProgress | CapReached253 >;254+ readonly showDiscussion: (255+ caller: Principal,256+ discussion: DiscussionId257+ ) => Effect.Effect<{ readonly discussion: Discussion }, UnknownDiscussion>;258 readonly showProposal: (259 caller: Principal,260 proposal: ProposalId261 ) => Effect.Effect<24 unmodified lines286 readonly row: ClaimRow;287 readonly state: ClaimState;288 }[];289 readonly decisions: readonly Decision[];290+ readonly discussions: readonly Discussion[];291 readonly landings: readonly LandingView[];292 readonly policy: Option.Option<Policy>;293 readonly project: Option.Option<ProjectRow>;294 readonly proposals: readonly Proposal[];295 }296 297 export interface DeciderWrites {298 readonly decisions: Map<DecisionId, Decision>;299+ readonly discussions: Map<DiscussionId, Discussion>;300 readonly events: ProjectEventInput[];301 readonly landings: LandingView[];302 readonly outbox: OutboxRow[];303 readonly project: Map<"row", ProjectRow>;401 unmodified lines705 706 const decisionsNow = (h: H, writes: W) =>707 overlaid(h.decisions, writes.decisions);708 709+ const discussionsNow = (h: H, writes: W) =>710+ overlaid(h.discussions, writes.discussions);711+712 const recordLanding = (713 h: H,714 writes: W,715 landing: LandingView,320 unmodified lines1036 const who = standing(policy, [], caller.handle);1037 const files = input.files ?? [];1038 const territory = Option.fromUndefinedOr(input.territory);1039 1040+ const id = ProposalId.make(1041+ minted("prop", proposalsNow(h, writes).length)1042+ );1043+1044+ // Only a maintainer turns a thread into a proposal, and only an open one.1045+ const fromThread = yield* Option.match(1046+ Option.fromUndefinedOr(input.discussion),1047+ {1048+ onNone: () => Effect.succeedNone,1049+ onSome: (named) =>1050+ Effect.gen(function* () {1051+ const thread = Array.findFirst(1052+ discussionsNow(h, writes),1053+ (each) => each.id === named1054+ );1055+1056+ if (Option.isNone(thread)) {1057+ return yield* new UnknownDiscussion({ discussion: named });1058+ }1059+1060+ if (!isDecider(policy, caller.handle)) {1061+ return yield* new NotDecider({});1062+ }1063+1064+ return Option.some(1065+ yield* Effect.fromResult(promoted(thread.value, id))1066+ );1067+ }),1068+ }1069+ );1070+1071 const area = Option.map(territory, (named) =>1072 Option.getOrElse(1073 Option.map(moduleOf(policy, named), ({ module }) => module),1074 () => named18 unmodified lines1093 ProposalCommand.Propose({1094 capped: capped(who),1095 denounced: who === "denounced",1096 files: files.map(({ path }) => path),1028- id: ProposalId.make(1029- minted("prop", proposalsNow(h, writes).length)1030- ),1097+ id,1098 openCount: openCountOf(h, writes, caller.handle),1099 project: name,1100 recordInArea,1101 sealed: Option.map(11 unmodified lines1113 now1114 )1115 );1116 1117+ if (Option.isSome(fromThread)) {1118+ writes.discussions.set(fromThread.value.id, fromThread.value);1119+ }1120+1121 if (input.draft === true) {1122 // A proposal just opened drafts its first round: nothing refuses it.1123 return yield* Effect.orDie(1124 startDraft(h, writes, now, {23 unmodified lines1148 row,1149 });1150 });1151 1152+ const openDiscussionsOf = (h: H, writes: W, handle: Handle) =>1153+ discussionsNow(h, writes).filter(1154+ ({ opener, state }) => state === "open" && sameHandle(opener, handle)1155+ ).length;1156+1157+ const postBody =1158+ (caller: Person, input: Parameters<DeciderApi["postDiscussion"]>[1]) =>1159+ (h: H, writes: W, now: DateTime.Utc) =>1160+ Effect.gen(function* () {1161+ const live = liveOf(h);1162+1163+ // Before a policy, nobody is denounced and the public cap holds.1164+ const who = Option.match(live, {1165+ onNone: () => "unknown" as const,1166+ onSome: ({ policy }) => standing(policy, [], caller.handle),1167+ });1168+1169+ const command = yield* Option.match(1170+ Option.fromUndefinedOr(input.discussion),1171+ {1172+ onNone: () =>1173+ Effect.succeed(1174+ DiscussionCommand.Open({1175+ body: Option.fromUndefinedOr(input.body),1176+ capped: capped(who),1177+ denounced: who === "denounced",1178+ id: DiscussionId.make(1179+ minted("disc", discussionsNow(h, writes).length)1180+ ),1181+ openCount: openDiscussionsOf(h, writes, caller.handle),1182+ project: name,1183+ // The contract's filter makes a title certain here.1184+ title: input.title ?? "",1185+ who: caller,1186+ })1187+ ),1188+ onSome: (named) =>1189+ Effect.map(1190+ Effect.fromOption(1191+ Array.findFirst(1192+ discussionsNow(h, writes),1193+ (each) => each.id === named1194+ )1195+ ).pipe(1196+ Effect.mapError(1197+ () => new UnknownDiscussion({ discussion: named })1198+ )1199+ ),1200+ (discussion) =>1201+ DiscussionCommand.Reply({1202+ // The contract's filter makes a body certain here.1203+ body: input.body ?? "",1204+ denounced: who === "denounced",1205+ discussion,1206+ who: caller,1207+ })1208+ ),1209+ }1210+ );1211+1212+ const { discussion, effects } = yield* Effect.fromResult(1213+ post(command, now)1214+ );1215+1216+ writes.discussions.set(discussion.id, discussion);1217+ emitted(writes, effects);1218+1219+ return { discussion };1220+ });1221+1222+ const byLastPost = Order.mapInput(1223+ Order.flip(DateTime.Order),1224+ (listing: DiscussionListing) => listing.lastPostAt1225+ );1226+1227+ const discussionsOf = Effect.map(kernel.read, (h) => ({1228+ discussions: Array.sort(h.discussions.map(discussionListingOf), byLastPost),1229+ }));1230+1231+ const discussionOf = (discussion: DiscussionId) =>1232+ Effect.flatMap(kernel.read, (h) =>1233+ Option.match(1234+ Array.findFirst(h.discussions, ({ id }) => id === discussion),1235+ {1236+ onNone: () => Effect.fail(new UnknownDiscussion({ discussion })),1237+ onSome: (found) => Effect.succeed({ discussion: found }),1238+ }1239+ )1240+ );1241+1242 const flagBody =1243 (caller: Person, input: Parameters<DeciderApi["flagAsk"]>[1]) =>1244 (h: H, writes: W, now: DateTime.Utc) =>1245 Effect.gen(function* () {1084 unmodified lines2330 queue: AnswerQueue,2331 caller: Person,2332 input: Parameters<DeciderApi["land"]>[1]2333 ) => kernel.write(queue, landBody(queue, caller, input)),2334+ listDiscussions: discussionsOf,2335+ postDiscussion: (2336+ queue: AnswerQueue,2337+ caller: Person,2338+ input: Parameters<DeciderApi["postDiscussion"]>[1]2339+ ) => kernel.write(queue, postBody(caller, input)),2340 proposeAsk: (2341 queue: AnswerQueue,2342 caller: Person,2343 input: Parameters<DeciderApi["proposeAsk"]>[1]2344 ) => kernel.write(queue, proposeBody(caller, input)),2345+ showDiscussion: discussionOf,2346 showProposal: proposalOf,2347 today: todayOf,2348 vouch: (2349 queue: AnswerQueue,5 unmodified linesmodified:packages/project/src/project-store.ts+3 added
7 unmodified lines8 AskRow,9 AttemptRow,10 ClaimRow,11 DecisionRow,12+ DiscussionRow,13 EnvValueRow,14 EventRow,15 LandingRow,16 LayerRead,17 unmodified lines34 readonly asks: readonly AskRow[];35 readonly attempts: readonly AttemptRow[];36 readonly claims: readonly ClaimRow[];37 readonly decisions: readonly DecisionRow[];38+ readonly discussions: readonly DiscussionRow[];39 readonly envValues: readonly EnvValueRow[];40 readonly landings: readonly LandingRow[];41 readonly lastSeq: number;42 readonly layers: readonly LayerRow[];10 unmodified lines53 readonly asks?: readonly AskRow[];54 readonly attempts?: readonly AttemptRow[];55 readonly claims?: readonly ClaimRow[];56 readonly decisions?: readonly DecisionRow[];57+ readonly discussions?: readonly DiscussionRow[];58 readonly envValues?: readonly EnvValueRow[];59 readonly events?: readonly ProjectEventInput[];60 readonly landings?: readonly LandingRow[];61 readonly layerReads?: readonly LayerRead[];48 unmodified linesmodified:packages/project/src/project.ts+52 added
62 unmodified lines63 Land,64 LandingOf,65 LedgerOf,66 ListAsks,67+ ListDiscussions,68 OpenAsk,69 PolicyOf,70+ PostDiscussion,71 ProposeAsk,72 Release,73 SetEnv,74 ShowAsk,75+ ShowDiscussion,76 ShowProposal,77 Status,78 SubmitAnswer,79 TodayOf,19 unmodified lines99 import type { Evidence } from "@repo/protocol/domain/common";100 import type { AgentTrailer, Credit } from "@repo/protocol/domain/credit";101 import { DecisionSubject } from "@repo/protocol/domain/decision";102 import type { Choice, Decision } from "@repo/protocol/domain/decision";103+import type { Discussion } from "@repo/protocol/domain/discussion";104 import { ProjectEvent } from "@repo/protocol/domain/event";105 import type { AskKind } from "@repo/protocol/domain/kind";106 import { LandingView } from "@repo/protocol/domain/landing";107 import { Outcome } from "@repo/protocol/domain/outcome";3 unmodified lines111 import type { Proposal } from "@repo/protocol/domain/proposal";112 import {113 AskId,114 CommitSha,115+ DiscussionId,116 EnvKey,117 Handle,118 LandedSha,119 LayerName,548 unmodified lines668 args: [Principal],669 error: ListAsks.errorSchema,670 success: ListAsks.successSchema,671 },672+ listDiscussions: {673+ args: [Principal],674+ error: Schema.Never,675+ success: ListDiscussions.successSchema,676+ },677 onAlarm: { args: [], error: Schema.Never, success: Schema.Void },678 openAsk: {679 args: [680 Person,6 unmodified lines687 args: [],688 error: Schema.Never,689 success: PolicyOf.successSchema,690 },691+ postDiscussion: {692+ args: [693+ Person,694+ PostDiscussion.payloadSchema.mapFields(Struct.omit(["project"])),695+ ],696+ error: PostDiscussion.errorSchema,697+ success: PostDiscussion.successSchema,698+ },699 proposeAsk: {700 args: [701 Person,702 // The check reads only `draft`, `files` and `sealed`, which it keeps.66 unmodified lines769 args: [Principal, AskId],770 error: ShowAsk.errorSchema,771 success: ShowAsk.successSchema,772 },773+ showDiscussion: {774+ args: [Principal, DiscussionId],775+ error: ShowDiscussion.errorSchema,776+ success: ShowDiscussion.successSchema,777+ },778 showProposal: {779 args: [Principal, ProposalId],780 error: ShowProposal.errorSchema,781 success: ShowProposal.successSchema,174 unmodified lines956 readonly answers: readonly Answered[];957 readonly asks: ReadonlyMap<AskId, Ask>;958 readonly claims: readonly Claimed[];959 readonly decisions: readonly Decision[];960+ readonly discussions: readonly Discussion[];961 readonly landings: readonly LandingView[];962 readonly lastSeq: number;963 readonly outbox: readonly OutboxRow[];964 readonly policy: Option.Option<Policy>;10 unmodified lines975 readonly asks: Map<AskId, Ask>;976 readonly attempts: Map<string, AttemptRow>;977 readonly claims: Map<string, ClaimRow>;978 readonly decisions: Map<DecisionId, Decision>;979+ readonly discussions: Map<DiscussionId, Discussion>;980 readonly envValues: Map<EnvKey, EnvValueRow>;981 readonly events: ProjectEventInput[];982 readonly landings: LandingView[];983 readonly layerReads: LayerRead[];12 unmodified lines996 asks: new Map(),997 attempts: new Map(),998 claims: new Map(),999 decisions: new Map(),1000+ discussions: new Map(),1001 envValues: new Map(),1002 events: [],1003 landings: [],1004 layerReads: [],13 unmodified lines1018 writes.asks.size,1019 writes.attempts.size,1020 writes.claims.size,1021 writes.decisions.size,1022+ writes.discussions.size,1023 writes.envValues.size,1024 writes.events.length,1025 writes.landings.length,1026 writes.layerReads.length,58 unmodified lines1085 Tables.decisions,1086 held.decisions,1087 writes.decisions.values()1088 ),1089+ discussions: overlaid(1090+ Tables.discussions,1091+ held.discussions,1092+ writes.discussions.values()1093+ ),1094 envValues: overlaid(1095 Tables.envValues,1096 held.envValues,1097 writes.envValues.values()812 unmodified lines1910 answers,1911 asks: new Map(snapshot.asks.map((ask) => [ask.id, ask])),1912 claims,1913 decisions: snapshot.decisions,1914+ discussions: snapshot.discussions,1915 landings: snapshot.landings,1916 lastSeq: snapshot.lastSeq,1917 outbox: snapshot.outbox,1918 policy,213 unmodified lines2132 asks: [...writes.asks.values()],2133 attempts: [...writes.attempts.values()],2134 claims: [...writes.claims.values()],2135 decisions: [...writes.decisions.values()],2136+ discussions: [...writes.discussions.values()],2137 envValues: [...writes.envValues.values()],2138 events: writes.events,2139 landings: writes.landings,2140 layerReads: writes.layerReads,3401 unmodified lines5542 ask.state === "closed" ? [] : [listingOf(ask)]5543 ),5544 }))5545 ),5546+ listDiscussions: (caller) =>5547+ checked(5548+ MethodSchemas.listDiscussions,5549+ [caller],5550+ decided.listDiscussions5551+ ),5552 onAlarm: () => checked(MethodSchemas.onAlarm, [], alarmed(api)),5553 openAsk: (caller, input) =>5554 checked(5555 MethodSchemas.openAsk,5556 [caller, input],5557 write(api, openBody(caller, input))5558 ),5559 policy: () => checked(MethodSchemas.policy, [], policyStatus),5560+ postDiscussion: (caller, input) =>5561+ checked(5562+ MethodSchemas.postDiscussion,5563+ [caller, input],5564+ decided.postDiscussion(api, caller, input)5565+ ),5566 proposeAsk: (caller, input) =>5567 checked(5568 MethodSchemas.proposeAsk,5569 [caller, input],93 unmodified lines5663 onSome: (ask) => Effect.succeed({ ask, brief: briefOf(ask) }),5664 })5665 )5666 ),5667+ showDiscussion: (caller, discussion) =>5668+ checked(5669+ MethodSchemas.showDiscussion,5670+ [caller, discussion],5671+ decided.showDiscussion(discussion)5672+ ),5673 showProposal: (caller, proposal) =>5674 checked(5675 MethodSchemas.showProposal,5676 [caller, proposal],37 unmodified linesadded:packages/project/test/discussions.test.ts+336 added
1+import { describe, expect, it } from "@effect/vitest";2+import { ProjectEvent } from "@repo/protocol/domain/event";3+import {4+ DiscussionId,5+ Handle,6+ ProposalId,7+ RepoName,8+ keyOf,9+} from "@repo/protocol/ids";10+import { Anonymous, Person } from "@repo/protocol/principal";11+import {12+ CapReached,13+ Denounced,14+ DiscussionClosed,15+ NotDecider,16+ UnknownDiscussion,17+} from "@repo/protocol/refusal";18+import { advanceTo } from "@repo/testkit/clock";19+import type { Files } from "@repo/testkit/git-client";20+import { aProject, withVouches } from "@repo/testkit/scenarios";21+import { Array, DateTime, Effect, Option } from "effect";22+23+import { DISCUSSIONS_PER_PERSON } from "../src/attention/discussions.ts";24+import { ProjectStore } from "../src/project-store.ts";25+import type { ProjectApi } from "../src/project.ts";26+import { projectService } from "../src/project.ts";27+import { Pusher, worldOf } from "./world.ts";28+import type { StoreKind } from "./world.ts";29+30+const people = ["bob", "carol", "dave", "erin"];31+32+// carol is vouched for, erin denounced, dave and bob unknown to the vouch file.33+const scenario = aProject({ people }).pipe(withVouches(["carol"], ["erin"]));34+35+const { project } = scenario;36+37+const repo = RepoName.make(keyOf(project));38+39+const person = (name: string) =>40+ Person.make({ handle: scenario.people.get(name) ?? scenario.initializer });41+42+const alice = person("alice");43+44+const carol = person("carol");45+46+const dave = person("dave");47+48+const erin = person("erin");49+50+const anyone = Anonymous.make({});51+52+const first = DiscussionId.make("disc-000001");53+54+const unknown = DiscussionId.make("disc-999999");55+56+const start: Files = [57+ ["package.json", '{ "name": "alice/datekit" }\n'],58+ ["src/parse.ts", "export const parse = (s) => ({});\n"],59+];60+61+const made = Effect.gen(function* () {62+ yield* advanceTo("2026-10-07T12:00:00Z");63+64+ const api = yield* projectService(project);65+66+ yield* api.initProject(alice, {});67+68+ const tip = yield* Pusher.use((pusher) =>69+ pusher.push(repo, Option.none(), start, "Start")70+ );71+72+ yield* api.recordFirstPush(alice, tip);73+74+ return api;75+});76+77+const minutesOn = (count: number) =>78+ advanceTo(79+ DateTime.formatIso(80+ DateTime.add(DateTime.makeUnsafe("2026-10-07T12:00:00Z"), {81+ minutes: count,82+ })83+ )84+ );85+86+const talking = (api: ProjectApi) =>87+ Effect.gen(function* () {88+ yield* minutesOn(1);89+90+ const opened = yield* api.postDiscussion(dave, {91+ body: "Weeks start on Monday in ISO 8601; which does parse assume?",92+ title: "Which day starts a week?",93+ });94+95+ yield* minutesOn(2);96+97+ const replied = yield* api.postDiscussion(carol, {98+ body: "ISO, always.",99+ discussion: opened.discussion.id,100+ });101+102+ yield* minutesOn(3);103+104+ const titleOnly = yield* api.postDiscussion(dave, {105+ title: "Does format take a locale?",106+ });107+108+ const refused = yield* Effect.all({109+ erinOpens: Effect.flip(110+ api.postDiscussion(erin, { body: "Hello", title: "A thread" })111+ ),112+ erinReplies: Effect.flip(113+ api.postDiscussion(erin, { body: "Hello", discussion: first })114+ ),115+ nowhere: Effect.flip(116+ api.postDiscussion(dave, { body: "Hello", discussion: unknown })117+ ),118+ });119+120+ const listed = yield* api.listDiscussions(anyone);121+ const shown = yield* api.showDiscussion(anyone, first);122+ const events = yield* api.events(0, 100);123+124+ return { events, listed, opened, refused, replied, shown, titleOnly };125+ });126+127+const promoting = (api: ProjectApi) =>128+ Effect.gen(function* () {129+ yield* minutesOn(1);130+131+ const { discussion } = yield* api.postDiscussion(dave, {132+ body: "Could parse take ISO week dates too?",133+ title: "ISO week dates",134+ });135+136+ const daveProposes = yield* Effect.flip(137+ api.proposeAsk(dave, {138+ discussion: discussion.id,139+ want: "Parse ISO week dates.",140+ })141+ );142+143+ const carolProposes = yield* Effect.flip(144+ api.proposeAsk(carol, {145+ discussion: discussion.id,146+ want: "Parse ISO week dates.",147+ })148+ );149+150+ const nowhere = yield* Effect.flip(151+ api.proposeAsk(alice, { discussion: unknown, want: "Parse ISO weeks." })152+ );153+154+ yield* minutesOn(2);155+156+ const { proposal } = yield* api.proposeAsk(alice, {157+ discussion: discussion.id,158+ want: "Parse ISO week dates.",159+ });160+161+ const after = yield* api.showDiscussion(anyone, discussion.id);162+163+ const closed = yield* Effect.all({164+ again: Effect.flip(165+ api.proposeAsk(alice, {166+ discussion: discussion.id,167+ want: "Parse ISO week dates, again.",168+ })169+ ),170+ reply: Effect.flip(171+ api.postDiscussion(carol, { body: "Yes", discussion: discussion.id })172+ ),173+ });174+175+ const stored = yield* ProjectStore.use((store) => store.load());176+177+ return {178+ after,179+ carolProposes,180+ closed,181+ daveProposes,182+ nowhere,183+ proposal,184+ stored: stored.discussions,185+ };186+ });187+188+const filling = (api: ProjectApi) =>189+ Effect.gen(function* () {190+ yield* Effect.forEach(191+ Array.range(1, DISCUSSIONS_PER_PERSON),192+ (index) =>193+ Effect.andThen(194+ minutesOn(index),195+ api.postDiscussion(dave, { title: `Thread ${index}` })196+ ),197+ { discard: true }198+ );199+200+ const daveAtCap = yield* Effect.flip(201+ api.postDiscussion(dave, { title: "One more" })202+ );203+204+ const daveReplies = yield* api.postDiscussion(dave, {205+ body: "Still talking",206+ discussion: first,207+ });208+209+ const carolBeyond = yield* Effect.forEach(210+ Array.range(1, DISCUSSIONS_PER_PERSON + 1),211+ (index) =>212+ api.postDiscussion(carol, { title: `Carol's thread ${index}` }),213+ { discard: true }214+ ).pipe(Effect.as("allowed"));215+216+ return { carolBeyond, daveAtCap, daveReplies };217+ });218+219+describe.each<StoreKind>(["memory", "sqlite"])(220+ "discussions over the %s store",221+ (kind) => {222+ const world = worldOf(scenario, kind);223+224+ const talked = Effect.flatMap(made, talking).pipe(Effect.provide(world));225+226+ const promoted = Effect.flatMap(made, promoting).pipe(227+ Effect.provide(world)228+ );229+230+ it.effect(231+ "take a thread from anyone not denounced, and a reply from them too",232+ () =>233+ Effect.map(talked, (run) => {234+ expect(run.opened.discussion).toMatchObject({235+ id: first,236+ opener: Handle.make("dave"),237+ project,238+ state: "open",239+ title: "Which day starts a week?",240+ });241+ expect(run.opened.discussion.posts).toHaveLength(1);242+ expect(243+ run.replied.discussion.posts.map(({ body, by }) => [by, body])244+ ).toStrictEqual([245+ [246+ "dave",247+ "Weeks start on Monday in ISO 8601; which does parse assume?",248+ ],249+ ["carol", "ISO, always."],250+ ]);251+ // A thread opened with a title alone reads the title as its first post.252+ expect(253+ run.titleOnly.discussion.posts.map(({ body }) => body)254+ ).toStrictEqual(["Does format take a locale?"]);255+ expect(run.refused).toStrictEqual({256+ erinOpens: new Denounced({}),257+ erinReplies: new Denounced({}),258+ nowhere: new UnknownDiscussion({ discussion: unknown }),259+ });260+ })261+ );262+263+ it.effect(264+ "list newest post first with the posts counted, show one whole, and tell each post",265+ () =>266+ Effect.map(talked, (run) => {267+ expect(run.shown.discussion).toStrictEqual(run.replied.discussion);268+ expect(269+ run.listed.discussions.map(({ id, posts, state }) => [270+ id,271+ posts,272+ state,273+ ])274+ ).toStrictEqual([275+ ["disc-000002", 1, "open"],276+ ["disc-000001", 2, "open"],277+ ]);278+ expect(279+ run.events.flatMap(({ event }) =>280+ ProjectEvent.guards.DiscussionPosted(event)281+ ? [[event.discussion, event.by]]282+ : []283+ )284+ ).toStrictEqual([285+ ["disc-000001", "dave"],286+ ["disc-000001", "carol"],287+ ["disc-000002", "dave"],288+ ]);289+ })290+ );291+292+ it.effect("become a proposal only by a maintainer", () =>293+ Effect.map(promoted, (run) => {294+ expect(run.daveProposes).toStrictEqual(new NotDecider({}));295+ expect(run.carolProposes).toStrictEqual(new NotDecider({}));296+ expect(run.nowhere).toStrictEqual(297+ new UnknownDiscussion({ discussion: unknown })298+ );299+ expect(run.proposal.id).toBe(ProposalId.make("prop-000001"));300+ expect(run.after.discussion).toMatchObject({301+ proposal: run.proposal.id,302+ state: "proposed",303+ });304+ })305+ );306+307+ it.effect(308+ "once proposed, take no more posts and no second proposal, and are kept so",309+ () =>310+ Effect.map(promoted, (run) => {311+ expect(run.closed).toStrictEqual({312+ again: new DiscussionClosed({ discussion: first }),313+ reply: new DiscussionClosed({ discussion: first }),314+ });315+ expect(run.stored).toStrictEqual([run.after.discussion]);316+ })317+ );318+ }319+);320+321+describe("the cap on open discussions", () => {322+ it.effect(323+ "holds a person the project has not vouched for to twenty, and a vouched one to none",324+ () =>325+ Effect.gen(function* () {326+ const run = yield* Effect.flatMap(made, filling);327+328+ expect(run.daveAtCap).toStrictEqual(329+ new CapReached({ cap: DISCUSSIONS_PER_PERSON, limit: "discussions" })330+ );331+ // The cap is on threads held open, not on posts.332+ expect(run.daveReplies.discussion.posts).toHaveLength(2);333+ expect(run.carolBeyond).toBe("allowed");334+ }).pipe(Effect.provide(worldOf(scenario, "memory")))335+ );336+});modified:packages/project/test/project-store-sqlite.test.ts+1 added
19 unmodified lines20 expect(yield* migrate).toStrictEqual([21 [1, "project_state"],22 [2, "visibility"],23 [3, "drop_budget_days"],24+ [4, "discussions"],25 ]);26 expect(yield* migrate).toStrictEqual([]);27 }).pipe(Effect.provide(database))28 );12 unmodified linesmodified:packages/project/test/project-store.contract.ts+3 added
21 unmodified lines22 AskRow,23 AttemptRow,24 ClaimRow,25 DecisionRow,26+ DiscussionRow,27 EnvValueRow,28 LandingRow,29 LayerReadRow,30 LayerRow,241 unmodified lines272 asks: Schema.Array(AskRow),273 attempts: Schema.Array(AttemptRow),274 claims: Schema.Array(ClaimRow),275 decisions: Schema.Array(DecisionRow),276+ discussions: Schema.Array(DiscussionRow),277 envValues: Schema.Array(EnvValueRow),278 landings: Schema.Array(LandingRow),279 lastSeq: Schema.Int,280 layers: Schema.Array(LayerRow),10 unmodified lines291 asks: [],292 attempts: [],293 claims: [],294 decisions: [],295+ discussions: [],296 envValues: [],297 landings: [],298 lastSeq: 0,299 layers: [],460 unmodified linesadded:packages/protocol/src/domain/discussion.ts+68 added
1+import { Array, Schema } from "effect";2+3+import { DiscussionId, Handle, ProjectName, ProposalId } from "../ids.ts";4+import { NoneOrMore } from "./common.ts";5+6+export const DiscussionState = Schema.Literals(["open", "closed", "proposed"]);7+8+export type DiscussionState = typeof DiscussionState.Type;9+10+export const DiscussionTitle = Schema.NonEmptyString.check(11+ Schema.isMaxLength(200)12+);13+14+export const PostBody = Schema.NonEmptyString.check(Schema.isMaxLength(10_000));15+16+export const DiscussionPost = Schema.Struct({17+ at: Schema.DateTimeUtcFromString,18+ body: PostBody,19+ by: Handle,20+});21+22+export type DiscussionPost = typeof DiscussionPost.Type;23+24+/** A thread: its first post is the opener's, and `proposal` names the proposal a maintainer turned it into. */25+export const Discussion = Schema.Struct({26+ id: DiscussionId,27+ openedAt: Schema.DateTimeUtcFromString,28+ opener: Handle,29+ posts: Schema.NonEmptyArray(DiscussionPost),30+ project: ProjectName,31+ proposal: Schema.optionalKey(ProposalId),32+ state: DiscussionState,33+ title: DiscussionTitle,34+});35+36+export type Discussion = typeof Discussion.Type;37+38+/** A thread in a list: its posts counted, not carried. */39+export const DiscussionListing = Schema.Struct({40+ id: DiscussionId,41+ lastPostAt: Schema.DateTimeUtcFromString,42+ openedAt: Schema.DateTimeUtcFromString,43+ opener: Handle,44+ posts: NoneOrMore,45+ project: ProjectName,46+ proposal: Schema.optionalKey(ProposalId),47+ state: DiscussionState,48+ title: DiscussionTitle,49+});50+51+export type DiscussionListing = typeof DiscussionListing.Type;52+53+export const listingOf = (discussion: Discussion): DiscussionListing => {54+ const listing = {55+ id: discussion.id,56+ lastPostAt: Array.lastNonEmpty(discussion.posts).at,57+ openedAt: discussion.openedAt,58+ opener: discussion.opener,59+ posts: discussion.posts.length,60+ project: discussion.project,61+ state: discussion.state,62+ title: discussion.title,63+ };64+65+ return discussion.proposal === undefined66+ ? listing67+ : { ...listing, proposal: discussion.proposal };68+};modified:packages/protocol/src/domain/event.ts+2 added
2 unmodified lines3 import {4 AskId,5 CommitSha,6 DecisionId,7+ DiscussionId,8 Handle,9 LandedSha,10 ProposalId,11 } from "../ids.ts";9 unmodified lines21 AskClosed: { ...stamp, ask: AskId, landing: LandedSha },22 AskOpened: { ...stamp, ask: AskListing },23 Claimed: { ...stamp, ask: AskId, claimant: Handle },24 Decided: { ...stamp, choice: Choice, decision: DecisionId },25+ DiscussionPosted: { ...stamp, by: Handle, discussion: DiscussionId },26 Judged: { ...stamp, ask: AskId, head: CommitSha, outcome: Outcome },27 Landed: { ...stamp, landing: LandingView },28 Lapsed: { ...stamp, ask: AskId },29 LedgerAppended: { ...stamp, entry: LedgerEntry },8 unmodified linesmodified:packages/protocol/src/contracts.ts+126 added-2 removed
32 unmodified lines33 WhyView,34 } from "./domain/code.ts";35 import { ConfigFile, NoneOrMore } from "./domain/common.ts";36 import { Choice, Decision, Today } from "./domain/decision.ts";37+import {38+ Discussion,39+ DiscussionListing,40+ DiscussionTitle,41+ PostBody,42+} from "./domain/discussion.ts";43 import { EnvSchemaView } from "./domain/env.ts";44 import { ProjectEvent } from "./domain/event.ts";45 import { FrontPageEntry, ProjectListing } from "./domain/front-page.ts";46 import { LandingView } from "./domain/landing.ts";5 unmodified lines52 import {53 AskId,54 CommitSha,55 DecisionId,56+ DiscussionId,57 EnvKey,58 Handle,59 KindName,60 LandedSha,11 unmodified lines72 CapReached,73 ClaimLapsed,74 DecisionClosed,75 Denounced,76+ DiscussionClosed,77 DraftInProgress,78 ImportFailed,79 NotYourNamespace,80 IncompleteBrief,12 unmodified lines93 TouchedJudge,94 UnknownAsk,95 UnknownCommit,96 UnknownDecision,97+ UnknownDiscussion,98 UnknownEnvItem,99 UnknownPath,100 UnknownProject,101 UnknownProposal,36 unmodified lines138 land: ["rpc", "mcp", "cli"],139 landing: SurfaceName.literals,140 ledger: SurfaceName.literals,141 listAsks: SurfaceName.literals,142+ listDiscussions: SurfaceName.literals,143 // A commit's diff and every path stay off MCP: no cap fits a transcript.144 // No command: git reads code locally.145 listPaths: ["rpc", "web"],146 listProjects: SurfaceName.literals,147 listRefs: ["rpc", "mcp", "web"],148 log: ["rpc", "mcp", "web"],149 openAsk: ["rpc", "mcp", "cli"],150+ // The web adds no form for what the CLI does: a post is made from a terminal.151+ postDiscussion: ["rpc", "mcp", "cli"],152 projectPolicy: SurfaceName.literals,153 proposeAsk: SurfaceName.literals,154 readFile: ["rpc", "mcp", "web"],155 readTree: ["rpc", "mcp", "web"],3 unmodified lines159 // A value must never pass through an agent's transcript, so never MCP.160 setEnv: ["rpc", "cli"],161 showAsk: SurfaceName.literals,162 showCommit: ["rpc", "web"],163+ showDiscussion: SurfaceName.literals,164 showProposal: SurfaceName.literals,165 status: SurfaceName.literals,166 submitAnswer: ["rpc", "mcp", "cli"],167 today: SurfaceName.literals,490 unmodified lines658 .annotate(NeedsApproval, false)659 .annotate(Cli, { name: "proposal", positional: ["proposal"] })660 .annotate(Surfaces, servedOn.showProposal) {}661 662+export class ListDiscussions extends Rpc.make("listDiscussions", {663+ error: UnknownProject,664+ payload: { project: ProjectName },665+ success: Schema.Struct({ discussions: Schema.Array(DiscussionListing) }),666+})667+ .annotate(668+ Description,669+ "List a project's discussions, newest post first: each thread's title, opener, state and the proposal it became."670+ )671+ .annotate(Audience, "public")672+ .annotate(Visibility, "public")673+ .annotate(ReadOnly, true)674+ .annotate(Idempotent, true)675+ .annotate(Destructive, false)676+ .annotate(NeedsApproval, false)677+ .annotate(Cli, { name: "discussions" })678+ .annotate(Surfaces, servedOn.listDiscussions) {}679+680+export class ShowDiscussion extends Rpc.make("showDiscussion", {681+ error: Schema.Union([UnknownProject, UnknownDiscussion]),682+ payload: {683+ discussion: described(DiscussionId, "The discussion to show"),684+ project: ProjectName,685+ },686+ success: Schema.Struct({ discussion: Discussion }),687+})688+ .annotate(689+ Description,690+ "Show one discussion: its posts in order, its state and the proposal it became."691+ )692+ .annotate(Audience, "public")693+ .annotate(Visibility, "public")694+ .annotate(ReadOnly, true)695+ .annotate(Idempotent, true)696+ .annotate(Destructive, false)697+ .annotate(NeedsApproval, false)698+ .annotate(Cli, { name: "discussion", positional: ["discussion"] })699+ .annotate(Surfaces, servedOn.showDiscussion) {}700+701 export class InitProject extends Rpc.make("initProject", {702 error: Schema.Union([ProjectExists, NotYourNamespace, ImportFailed]),703 payload: {704 import: Schema.optionalKey(ImportSource),64 unmodified lines769 : "a drafted proposal carries neither files nor a sealed answer"770 );771 772 export class ProposeAsk extends Rpc.make("proposeAsk", {721- error: Schema.Union([UnknownProject, Denounced, CapReached, NotVouched]),773+ error: Schema.Union([774+ UnknownProject,775+ Denounced,776+ CapReached,777+ NotVouched,778+ NotDecider,779+ UnknownDiscussion,780+ DiscussionClosed,781+ ]),782 payload: Schema.Struct({783+ /** The discussion this proposal comes from; a maintainer alone may name one, and it marks the thread proposed. */784+ discussion: Schema.optionalKey(785+ described(786+ DiscussionId,787+ "The discussion this proposal comes from; a maintainer alone may name one"788+ )789+ ),790 draft: Schema.optionalKey(791 described(792 Schema.Literal(true),793 "Have the platform's agent draft the ask file and its failing check"26 unmodified lines820 success: Schema.Struct({ proposal: Proposal }),821 })822 .annotate(823 Description,757- "Propose an ask, optionally with a sealed answer; the proposal expires unless a maintainer accepts it."824+ "Propose an ask, optionally with a sealed answer, or, as a maintainer, from a discussion; the proposal expires unless a maintainer accepts it."825 )826 .annotate(Audience, "signedIn")827 .annotate(Visibility, "public")828 .annotate(ReadOnly, false)58 unmodified lines887 .annotate(NeedsApproval, false)888 .annotate(Cli, { name: "ask flag", positional: ["ask"] })889 .annotate(Surfaces, servedOn.flagAsk) {}890 891+const titleOrBody = Schema.makeFilter(892+ (payload: {893+ readonly body?: string;894+ readonly discussion?: string;895+ readonly title?: string;896+ }) => {897+ if (payload.discussion === undefined) {898+ return payload.title === undefined899+ ? "opening a discussion takes a title"900+ : true;901+ }902+903+ return payload.body === undefined904+ ? "a reply takes a body"905+ : payload.title === undefined || "a reply takes no title";906+ }907+);908+909+export class PostDiscussion extends Rpc.make("postDiscussion", {910+ error: Schema.Union([911+ UnknownProject,912+ UnknownDiscussion,913+ DiscussionClosed,914+ Denounced,915+ CapReached,916+ ]),917+ payload: Schema.Struct({918+ body: Schema.optionalKey(described(PostBody, "Your post")),919+ discussion: Schema.optionalKey(920+ described(921+ DiscussionId,922+ "The discussion to reply in; leave out to open one"923+ )924+ ),925+ project: ProjectName,926+ title: Schema.optionalKey(927+ described(DiscussionTitle, "The title of the discussion you open")928+ ),929+ }).check(titleOrBody),930+ success: Schema.Struct({ discussion: Discussion }),931+})932+ .annotate(933+ Description,934+ "Post in a project's discussions: with no discussion named, open a thread with a title and an optional body; with one named, reply with a body. Anyone not denounced may."935+ )936+ .annotate(Audience, "signedIn")937+ .annotate(Visibility, "public")938+ .annotate(ReadOnly, false)939+ .annotate(Idempotent, false)940+ .annotate(Destructive, false)941+ .annotate(NeedsApproval, false)942+ .annotate(Cli, { name: "discussion post", positional: ["discussion"] })943+ .annotate(Surfaces, servedOn.postDiscussion) {}944+945 export class Decide extends Rpc.make("decide", {946 error: Schema.Union([947 UnknownProject,948 UnknownDecision,300 unmodified lines1249 ShowCommit,1250 WhyOf,1251 PolicyOf,1252 ShowProposal,1253+ ListDiscussions,1254+ ShowDiscussion,1255 InitProject,1256 OpenAsk,1257 ProposeAsk,1258 DraftAsk,1259 FlagAsk,1260+ PostDiscussion,1261 Decide,1262 Claim,1263 Release,1264 SubmitAnswer,55 unmodified linesmodified:packages/protocol/src/exit-code.ts+2 added
29 unmodified lines30 ChecksFailed: ExitCode.dataErr,31 DecisionClosed: ExitCode.noInput,32 Denounced: ExitCode.noPerm,33 DirectPush: ExitCode.noPerm,34+ DiscussionClosed: ExitCode.noInput,35 HeldBackFailed: ExitCode.dataErr,36 IncompleteBrief: ExitCode.dataErr,37 LayerContentInPublicTree: ExitCode.dataErr,38 NoAsk: ExitCode.noInput,12 unmodified lines51 TouchedJudge: ExitCode.dataErr,52 UnknownAsk: ExitCode.noInput,53 UnknownCommit: ExitCode.noInput,54 UnknownDecision: ExitCode.noInput,55+ UnknownDiscussion: ExitCode.noInput,56 UnknownEnvItem: ExitCode.noInput,57 UnknownPath: ExitCode.noInput,58 UnknownProject: ExitCode.noInput,59 UnknownProposal: ExitCode.noInput,31 unmodified linesmodified:packages/protocol/src/ids.ts+7 added
92 unmodified lines93 );94 95 export type ProposalId = typeof ProposalId.Type;96 97+export const DiscussionId = Schema.String.pipe(98+ Schema.check(Schema.isPattern(Minted)),99+ Schema.brand("DiscussionId")100+);101+102+export type DiscussionId = typeof DiscussionId.Type;103+104 export const DecisionId = Schema.String.pipe(105 Schema.check(Schema.isPattern(Minted)),106 Schema.brand("DecisionId")107 );392 unmodified linesmodified:packages/protocol/src/refusal.ts+17 added-2 removed
4 unmodified lines5 import {6 AskId,7 CommitSha,8 DecisionId,9+ DiscussionId,10 EnvKey,11 Handle,12 LandedSha,13 ProjectName,69 unmodified lines83 export class CapReached extends Schema.TaggedError<CapReached>()("CapReached", {84 ...Retryable,85 ...nextIs(cli("status")),86 cap: Schema.Int,86- /** Which limit: claims held (also when absent), proposals, or drafts. */87- limit: Schema.optionalKey(Schema.Literals(["claims", "proposals", "drafts"])),87+ /** Which limit: claims held (also when absent), proposals, drafts, or discussions. */88+ limit: Schema.optionalKey(89+ Schema.Literals(["claims", "proposals", "drafts", "discussions"])90+ ),91 /** For a rate limit: seconds until one more is let through. */92 retryAfter: Schema.optionalKey(93 Schema.Int.check(Schema.isGreaterThanOrEqualTo(1))94 ),217 unmodified lines312 "ProposalClosed",313 { ...Final, ...nextIs(cli("today")), proposal: ProposalId }314 ) {}315 316+export class DiscussionClosed extends Schema.TaggedError<DiscussionClosed>()(317+ "DiscussionClosed",318+ { ...Final, ...nextIs(cli("discussions")), discussion: DiscussionId }319+) {}320+321 export class DraftInProgress extends Schema.TaggedError<DraftInProgress>()(322 "DraftInProgress",323 { ...Retryable, proposal: ProposalId }324 ) {45 unmodified lines370 "UnknownProposal",371 { ...Final, ...nextIs(cli("today")), proposal: ProposalId }372 ) {}373 374+export class UnknownDiscussion extends Schema.TaggedError<UnknownDiscussion>()(375+ "UnknownDiscussion",376+ { ...Final, ...nextIs(cli("discussions")), discussion: DiscussionId }377+) {}378+379 export class ProjectExists extends Schema.TaggedError<ProjectExists>()(380 "ProjectExists",381 { ...Final, ...nextIs(cli("projects")), project: ProjectName }382 ) {}90 unmodified lines473 NotDecider,474 DecisionClosed,475 ProposalClosed,476 DraftInProgress,477+ DiscussionClosed,478 ] as const;479 480 const lookup = [481 UnknownProject,2 unmodified lines484 UnknownDecision,485 UnknownPath,486 UnknownRevision,487 UnknownProposal,488+ UnknownDiscussion,489 ] as const;490 491 const setup = [ProjectExists, NotYourNamespace, ImportFailed] as const;492 32 unmodified linesmodified:packages/protocol/src/render.ts+8 added-1 removed
20 unmodified lines21 // landed, a proposal decided; a proposal's draft rounds never lift.22 const held = {23 claims: (cap) =>24 `you already hold ${counted(cap, "claim")}, the most this project allows`,25+ discussions: (cap) =>26+ `you already have ${counted(cap, "open discussion")} here, the most this project allows`,27 drafts: (cap) =>28 `this proposal was already drafted ${cap === 1 ? "once" : `${cap} times`}, the most one proposal takes`,29 proposals: (cap) =>30 `you already have ${counted(cap, "open proposal")} here, the most this project allows`,31 } as const satisfies Record<CapLimit, (cap: number) => string>;32 33 const rated = {34 claims: { noun: "claim", verb: "made" },35+ discussions: { noun: "post", verb: "made" },36 drafts: { noun: "draft", verb: "started" },37 proposals: { noun: "proposal", verb: "made" },38 } as const satisfies Record<CapLimit, { noun: string; verb: string }>;39 47 unmodified lines87 ClaimLapsed: ({ ask }) => `your claim on ${ask} lapsed`,88 DecisionClosed: ({ decision }) =>89 `${decision} was already decided, or expired to its default`,90 Denounced: () =>88- "this project's vouch file denounces you, so it takes no claims or proposals from you",91+ "this project's vouch file denounces you, so it takes no claims, proposals or posts from you",92 DirectPush: ({ ref }) =>93 ref.startsWith(BRANCH)94 ? `main moves only by a landing, so ${ref} takes no direct push; a contributor pushes the answer to the claim's fork, and a maintainer makes a working fork with ${Brand.cli} fork and lands it with ${Brand.cli} land`95 : `${ref} is written by the platform, not pushed; a fork takes branches only, so push your answer with git push ${Brand.slug} HEAD:main`,96+ DiscussionClosed: ({ discussion }) =>97+ `${discussion} is closed, or became a proposal, so it takes no more posts`,98 DraftInProgress: ({ proposal }) =>99 `the platform is already drafting ${proposal}'s ask`,100 Flake: ({ lane }) =>101 `the ${lane} checks failed, then passed on the same tree; the platform will run them again`,45 unmodified lines147 `changes files that decide what the checks do: ${list(paths)}; the checks are fixed for this ask, so put them back, or flag the ask if a check is wrong`,148 UnknownAsk: ({ ask }) => `this project has no ask named ${ask}`,149 UnknownCommit: ({ sha }) => `this project has no commit ${sha}`,150 UnknownDecision: ({ decision }) => `this project has no decision ${decision}`,151+ UnknownDiscussion: ({ discussion }) =>152+ `this project has no discussion ${discussion}`,153 UnknownEnvItem: ({ key }) => `the env shape has no item ${key}`,154 UnknownPath: ({ commit, path }) =>155 `${short(commit)} has no file or folder at ${path}`,156 UnknownProject: ({ project }) => `no project is named ${project}`,66 unmodified linesmodified:packages/protocol/src/testing.ts+3 added
33 unmodified lines34 land: uncalled,35 landing: uncalled,36 ledger: uncalled,37 listAsks: uncalled,38+ listDiscussions: uncalled,39 listPaths: uncalled,40 listProjects: uncalled,41 listRefs: uncalled,42 log: uncalled,43 openAsk: uncalled,44+ postDiscussion: uncalled,45 projectPolicy: uncalled,46 proposeAsk: uncalled,47 readFile: uncalled,48 readTree: uncalled,1 unmodified line50 release: uncalled,51 setEnv: uncalled,52 showAsk: uncalled,53 showCommit: uncalled,54+ showDiscussion: uncalled,55 showProposal: uncalled,56 status: uncalled,57 submitAnswer: uncalled,58 today: uncalled,6 unmodified linesmodified:packages/protocol/test/fixtures/contracts.json+73 added
170 unmodified lines171 "flags": "iso-week"172 }173 }174 },175+ "postDiscussion": {176+ "payload": {177+ "body": "Weeks start on Monday in ISO 8601, but on Sunday in the US; which does parseISO assume?",178+ "project": "oscabriel/datekit",179+ "title": "Which day starts a week?"180+ },181+ "success": {182+ "discussion": {183+ "id": "disc-000001",184+ "openedAt": "2026-10-07T12:00:00.000Z",185+ "opener": "dave",186+ "posts": [187+ {188+ "at": "2026-10-07T12:00:00.000Z",189+ "body": "Weeks start on Monday in ISO 8601, but on Sunday in the US; which does parseISO assume?",190+ "by": "dave"191+ }192+ ],193+ "project": "oscabriel/datekit",194+ "state": "open",195+ "title": "Which day starts a week?"196+ }197+ }198+ },199 "fork": {200 "payload": {201 "project": "oscabriel/datekit"202 },800 unmodified lines1003 }1004 }1005 }1006 },1007+ "listDiscussions": {1008+ "payload": {1009+ "project": "oscabriel/datekit"1010+ },1011+ "success": {1012+ "discussions": [1013+ {1014+ "id": "disc-000001",1015+ "lastPostAt": "2026-10-07T12:30:00.000Z",1016+ "openedAt": "2026-10-07T12:00:00.000Z",1017+ "opener": "dave",1018+ "posts": 2,1019+ "project": "oscabriel/datekit",1020+ "state": "proposed",1021+ "proposal": "prop-000001",1022+ "title": "Which day starts a week?"1023+ }1024+ ]1025+ }1026+ },1027+ "showDiscussion": {1028+ "payload": {1029+ "discussion": "disc-000001",1030+ "project": "oscabriel/datekit"1031+ },1032+ "success": {1033+ "discussion": {1034+ "id": "disc-000001",1035+ "openedAt": "2026-10-07T12:00:00.000Z",1036+ "opener": "dave",1037+ "posts": [1038+ {1039+ "at": "2026-10-07T12:00:00.000Z",1040+ "body": "Weeks start on Monday in ISO 8601, but on Sunday in the US; which does parseISO assume?",1041+ "by": "dave"1042+ },1043+ {1044+ "at": "2026-10-07T12:30:00.000Z",1045+ "body": "ISO, always: a locale never changes what a date string means.",1046+ "by": "alice"1047+ }1048+ ],1049+ "project": "oscabriel/datekit",1050+ "state": "proposed",1051+ "proposal": "prop-000001",1052+ "title": "Which day starts a week?"1053+ }1054+ }1055+ },1056 "status": {1057 "payload": {1058 "project": "oscabriel/datekit"1059 },345 unmodified linesmodified:packages/protocol/test/cli.test.ts+3 added
598 unmodified lines599 "ledger",600 "env shape",601 "policy",602 "proposal",603+ "discussions",604+ "discussion",605 "ask open",606 "propose",607 "ask draft",608 "ask flag",609+ "discussion post",610 "decide",611 "claim",612 "release",613 "submit",22 unmodified linesmodified:packages/protocol/test/contracts.test.ts+39 added-1 removed
219 unmodified lines220 on: "RMCW",221 tag: "showProposal",222 },223 {224+ audience: "public",225+ cli: "discussions",226+ errors: ["UnknownProject"],227+ flags: "RI",228+ on: "RMCW",229+ tag: "listDiscussions",230+ },231+ {232+ audience: "public",233+ cli: "discussion <discussion>",234+ errors: ["UnknownProject", "UnknownDiscussion"],235+ flags: "RI",236+ on: "RMCW",237+ tag: "showDiscussion",238+ },239+ {240 audience: "signedIn",241 cli: "init",242 errors: ["ProjectExists", "NotYourNamespace", "ImportFailed"],243 flags: "A",19 unmodified lines263 },264 {265 audience: "signedIn",266 cli: "propose",251- errors: ["UnknownProject", "Denounced", "CapReached", "NotVouched"],267+ errors: [268+ "UnknownProject",269+ "Denounced",270+ "CapReached",271+ "NotVouched",272+ "NotDecider",273+ "UnknownDiscussion",274+ "DiscussionClosed",275+ ],276 flags: "",277 on: "RMCW",278 tag: "proposeAsk",279 },20 unmodified lines300 on: "RMC",301 tag: "flagAsk",302 },303 {304+ audience: "signedIn",305+ cli: "discussion post <discussion>",306+ errors: [307+ "UnknownProject",308+ "UnknownDiscussion",309+ "DiscussionClosed",310+ "Denounced",311+ "CapReached",312+ ],313+ flags: "",314+ on: "RMC",315+ tag: "postDiscussion",316+ },317+ {318 audience: "decider",319 cli: "decide",320 errors: [321 "UnknownProject",366 unmodified linesmodified:packages/protocol/test/examples.ts+7 added
2 unmodified lines3 import {4 AskId,5 CommitSha,6 DecisionId,7+ DiscussionId,8 EnvKey,9 Handle,10 ProjectName,11 ProposalId,8 unmodified lines20 ClaimLapsed,21 DecisionClosed,22 Denounced,23 DirectPush,24+ DiscussionClosed,25 DraftInProgress,26 Flake,27 HeldBackFailed,28 ImportFailed,19 unmodified lines48 TouchedJudge,49 UnknownAsk,50 UnknownCommit,51 UnknownDecision,52+ UnknownDiscussion,53 UnknownEnvItem,54 UnknownPath,55 UnknownProject,56 UnknownProposal,21 unmodified lines78 const key = EnvKey.make("PAYMENTS_KEY");79 80 const proposal = ProposalId.make("prop-000001");81 82+const discussion = DiscussionId.make("disc-000001");83+84 export const examples: readonly Refusal[] = [85 NotClaimed.of(ask),86 ClaimLapsed.of(ask),87 new NotVouched({}),40 unmodified lines128 new NotDecider({}),129 new DecisionClosed({ decision }),130 new ProposalClosed({ proposal }),131 DraftInProgress.of(proposal),132+ new DiscussionClosed({ discussion }),133 new UnknownProject({ project }),134 new UnknownAsk({ ask }),135 new UnknownCommit({ sha: main }),136 new UnknownDecision({ decision }),137 new UnknownPath({ commit: main, path }),138 new UnknownRevision({ rev: "v9.9.9" }),139 new UnknownProposal({ proposal }),140+ new UnknownDiscussion({ discussion }),141 new ProjectExists({ project }),142 NotYourNamespace.of(project, Handle.make("bob")),143 new ImportFailed({ reason: "the repo needs a sign-in to read" }),144 new UnknownEnvItem({ key }),3 unmodified linesmodified:packages/protocol/test/exit-code.test.ts+2 added
24 unmodified lines25 ClaimLapsed: 75,26 DecisionClosed: 66,27 Denounced: 77,28 DirectPush: 77,29+ DiscussionClosed: 66,30 DraftInProgress: 75,31 Flake: 75,32 HeldBackFailed: 65,33 ImportFailed: 75,19 unmodified lines53 TouchedJudge: 65,54 UnknownAsk: 66,55 UnknownCommit: 66,56 UnknownDecision: 66,57+ UnknownDiscussion: 66,58 UnknownEnvItem: 66,59 UnknownPath: 66,60 UnknownProject: 66,61 UnknownProposal: 66,42 unmodified linesmodified:packages/protocol/test/refusal.test.ts+5 added-1 removed
123 unmodified lines124 )125 ).toStrictEqual(Refusal.members.map((member) => member.identifier));126 });127 128- it("lists all forty-five tags in union order, group by group", () => {128+ it("lists all forty-seven tags in union order, group by group", () => {129 expect(Refusal.members.map((member) => member.identifier)).toStrictEqual([130 "NotClaimed",131 "ClaimLapsed",132 "NotVouched",26 unmodified lines159 "NotDecider",160 "DecisionClosed",161 "ProposalClosed",162 "DraftInProgress",163+ "DiscussionClosed",164 "UnknownProject",165 "UnknownAsk",166 "UnknownCommit",167 "UnknownDecision",168 "UnknownPath",169 "UnknownRevision",170 "UnknownProposal",171+ "UnknownDiscussion",172 "ProjectExists",173 "NotYourNamespace",174 "ImportFailed",175 "UnknownEnvItem",35 unmodified lines211 ClaimLapsed: true,212 DecisionClosed: false,213 Denounced: false,214 DirectPush: false,215+ DiscussionClosed: false,216 DraftInProgress: true,217 Flake: true,218 HeldBackFailed: false,219 ImportFailed: true,19 unmodified lines239 TouchedJudge: false,240 UnknownAsk: false,241 UnknownCommit: false,242 UnknownDecision: false,243+ UnknownDiscussion: false,244 UnknownEnvItem: false,245 UnknownPath: false,246 UnknownProject: false,247 UnknownProposal: false,9 unmodified linesmodified:packages/protocol/test/render.test.ts+33 added
9 unmodified lines10 EnvKey,11 Handle,12 LandedSha,13 ProjectName,14+ DiscussionId,15 ProposalId,16 RepoPath,17 RequestId,18 } from "../src/ids.ts";4 unmodified lines23 DraftInProgress,24 NotDecider,25 OutOfScope,26 PrivatePathInPublicTree,27+ DiscussionClosed,28 ProposalClosed,29 ReachedInternals,30 StaleBase,31 TouchedJudge,32 UnknownPath,33+ UnknownDiscussion,34 UnknownProposal,35 UnknownRevision,36 ValueTooShort,37 Weakened,266 unmodified lines304 refusal: new CapReached({ cap: 1, limit: "proposals" }),305 },306 {307 reason:308+ "you already have 20 open discussions here, the most this project allows",309+ refusal: new CapReached({ cap: 20, limit: "discussions" }),310+ },311+ {312+ reason:313+ "you made 5 posts in the last minute, the most the platform allows; try again in 60s",314+ refusal: new CapReached({ cap: 5, limit: "discussions", retryAfter: 60 }),315+ },316+ {317+ reason:318 "you started 2 drafts in the last minute, the most the platform allows; try again in 60s",319 refusal: new CapReached({ cap: 2, limit: "drafts", retryAfter: 60 }),320 },321 {55 unmodified lines377 refusal: new ProposalClosed({ proposal: ProposalId.make("prop-000007") }),378 },379 {380 lines: [381+ "UnknownDiscussion: this project has no discussion disc-000007",382+ ` next: ${Brand.cli} discussions`,383+ " retryable: no",384+ ],385+ refusal: new UnknownDiscussion({386+ discussion: DiscussionId.make("disc-000007"),387+ }),388+ },389+ {390+ lines: [391+ "DiscussionClosed: disc-000007 is closed, or became a proposal, so it takes no more posts",392+ ` next: ${Brand.cli} discussions`,393+ " retryable: no",394+ ],395+ refusal: new DiscussionClosed({396+ discussion: DiscussionId.make("disc-000007"),397+ }),398+ },399+ {400+ lines: [401 "DraftInProgress: the platform is already drafting prop-000007's ask",402 ` next: ${Brand.cli} proposal prop-000007`,403 " retryable: yes",404 ],138 unmodified linesmodified:scripts/lib/swarm/views/counter.ts+1 added
38 unmodified lines39 AskClosed: () => "",40 AskOpened: () => "",41 Claimed: ({ ask, claimant }) => `${claimant} claimed ${ask}`,42 Decided: () => "",43+ DiscussionPosted: () => "",44 Judged: () => "",45 Landed: ({ landing }) =>46 `${landing.ask ?? "main"} landed as ${short(landing.sha)}`,47 Lapsed: () => "",219 unmodified linesmodified:PRODUCT.md+2 added-1 removed
73 unmodified lines74 - Pages per job on the web:75 - **Landing** (`/`): what the gate does, the issue and pull-request flow beside the ask, answer and gate flow, the seven stages, and the latest landings and refused answers across projects. A signed-in reader goes on to the inbox.76 - **Explore** (`/explore`): every public project as a card with its posture, the projects taking answers first.77 - **Front page** (`/asks`): open asks across projects a viewer may take, grouped by project with each project's posture said once, in the group heading, filtered by kind, by open to take and by asks held for newcomers; a split family is one row with its children as a fan. The same list as Markdown by `Accept: text/markdown`.78- - **Project** (`/$project`, the Overview tab): a header that stays across the tabs (the name, the posture said once, a description, its facts and Watch, Clone and Contribute), then the tabs Overview, Code, Asks, Landings, Proposals, People, Policy and Visibility. Overview holds its asks, recent landings and README, beside an about column with how a change lands here and who decides. The same as the project's `llms.txt` by `Accept: text/markdown`.78+ - **Project** (`/$project`, the Overview tab): a header that stays across the tabs (the name, the posture said once, a description, its facts and Watch, Clone and Contribute), then the tabs Overview, Code, Asks, Landings, Proposals, Discussions, People, Policy and Visibility. Overview holds its asks, recent landings and README, beside an about column with how a change lands here and who decides. The same as the project's `llms.txt` by `Accept: text/markdown`.79 - **Code** (`/$project/tree/…`, `blob/…`, `why/…`, `commits/…`, `commit/…`, `refs`): the files at any commit, tag or answer fork with a persistent tree, highlighted code with `#L` links, why each line is there, the landings by day, each commit's diff, and the refs; raw bytes under a sandboxing CSP.80 - **Ask** (`/$project/asks/$ask`): the want, the territory, the check, who may claim, and the commands; the same as Markdown by `Accept: text/markdown` or at `/$project/asks/$ask.md`.81 - **Answer** (`/$project/answers/$ask`): the outcome, the gate's stages, the rounds, the lanes, held-back results as one line per area, the refusal, and the landing. A waiting answer says the one thing the contributor needs; a landed one is told as a sentence first, then credits its people, and only then shows its sealed roots.82 - **Person** (`/people/$handle`): their credits by role and area, in words, never a number or a score.83 - **Policy** (`/$project/people`): who decides which paths, who is vouched for or denounced, the limits and the agent rules, read from the config folder at the landed commit, with the commands that change them.84+ - **Discussions** (`/$project/discussions`, `/$project/discussions/$discussion`): a project's public, freeform threads, open to anyone not denounced, that land nothing themselves; each page shows its posts, the proposal a maintainer turned it into, and the command to post, since the web adds no form for it.85 - **Proposals** (`/$project/proposals/new`, `/$project/proposals/$proposal`): a want proposed from the web or the CLI, the platform's agent's draft if one was asked for (the ask file, the check, its red-first runs), and the decision it waits on.86 - **Inbox** (`/inbox`; `/home` and `/today` move here): the reader's own page. A maintainer's decisions in sections (due today, later), every open one, each with its evidence, safe default, expiry and one-tap choices whose consequence is written under each, with how many wait said as a sentence; the asks the reader holds and where each answer stands in the gate; the asks they may take next. Each decision has its own page (`/$project/decisions/$decision`), where a finish shows the answer's diff with refusals marked at their lines.87 - **Visibility** (`/$project/visibility`; `/$project/ledger` and `/$project/env` move here): the posture, each declared layer with its reason, each sealed area's count, authors, committed root and admission; the Environment, every item the project's committed `.env.schema` declares, parsed at the landed commit and never resolved, with who set a sensitive item's value and when, never a value; and the ledger, newest first.88 - **Settings** (`/settings`): the theme, the system's or its opposite, kept in this browser's `localStorage`, never a cookie.37 unmodified lines