{"file":"worker/project/refuse.ts","version":318,"total":52,"from":1,"to":52,"lines":[{"n":1,"text":"// Answer a refused publish or land, and list those refusals. Writes go","atom":"a0","author":"init","version":0},{"n":2,"text":"// through RefuseHost; today the host is Project.","atom":"a0","author":"init","version":0},{"n":3,"text":"","atom":"a0","author":"init","version":0},{"n":4,"text":"import { countRefusals } from \"./project-helpers.ts\";","atom":"a0","author":"init","version":0},{"n":5,"text":"import type { AgentState, Collision, Entry, Refusal, RefusalCounts } from \"./project-types.ts\";","atom":"a0","author":"init","version":0},{"n":6,"text":"import { SHARED, type Space } from \"./spaces.ts\";","atom":"a0","author":"init","version":0},{"n":7,"text":"","atom":"a0","author":"init","version":0},{"n":8,"text":"/** What recording a refusal and listing them needs from a project. */","atom":"a0","author":"init","version":0},{"n":9,"text":"export interface RefuseHost {","atom":"a0","author":"init","version":0},{"n":10,"text":"\tapply(entry: Entry): void;","atom":"a0","author":"init","version":0},{"n":11,"text":"\treadonly refusals: readonly Refusal[];","atom":"a0","author":"init","version":0},{"n":12,"text":"}","atom":"a0","author":"init","version":0},{"n":13,"text":"","atom":"a0","author":"init","version":0},{"n":14,"text":"/** Answer a refusal, and log it (an entry that changes nothing but the counts, and keeps a push's message). */","atom":"a1648","author":"speed","version":160},{"n":15,"text":"export function refuse(","atom":"a0","author":"init","version":0},{"n":16,"text":"\thost: RefuseHost,","atom":"a0","author":"init","version":0},{"n":17,"text":"\tagent: AgentState,","atom":"a0","author":"init","version":0},{"n":18,"text":"\tspace: Space,","atom":"a0","author":"init","version":0},{"n":19,"text":"\tvia: \"publish\" | \"land\",","atom":"a0","author":"init","version":0},{"n":20,"text":"\ttime: number,","atom":"a0","author":"init","version":0},{"n":21,"text":"\tcollisions: Collision[],","atom":"a0","author":"init","version":0},{"n":22,"text":"\tentries: Entry[],","atom":"a0","author":"init","version":0},{"n":23,"text":"\tmessage?: string,","atom":"a1648","author":"speed","version":160},{"n":24,"text":"): { ok: false; collisions: Collision[] } {","atom":"a0","author":"init","version":0},{"n":25,"text":"\tconst entry: Entry = {","atom":"a0","author":"init","version":0},{"n":26,"text":"\t\ttype: \"refused\",","atom":"a0","author":"init","version":0},{"n":27,"text":"\t\tagent: agent.name,","atom":"a0","author":"init","version":0},{"n":28,"text":"\t\t...(space.name !== SHARED ? { space: space.name } : {}),","atom":"a0","author":"init","version":0},{"n":29,"text":"\t\tvia,","atom":"a0","author":"init","version":0},{"n":30,"text":"\t\ttime,","atom":"a0","author":"init","version":0},{"n":31,"text":"\t\tcollisions: collisions.map((c) => ({","atom":"a0","author":"init","version":0},{"n":32,"text":"\t\t\tkind: c.kind,","atom":"a0","author":"init","version":0},{"n":33,"text":"\t\t\tfile: c.file,","atom":"a0","author":"init","version":0},{"n":34,"text":"\t\t\t...(c.name !== undefined ? { name: c.name } : {}),","atom":"a0","author":"init","version":0},{"n":35,"text":"\t\t})),","atom":"a0","author":"init","version":0},{"n":36,"text":"\t\t// A held push keeps its message: the settle that follows tells it as this side's reason.","atom":"a1648","author":"speed","version":160},{"n":37,"text":"\t\t...(message ? { message } : {}),","atom":"a1648","author":"speed","version":160},{"n":38,"text":"\t};","atom":"a0","author":"init","version":0},{"n":39,"text":"\tentries.push(entry);","atom":"a0","author":"init","version":0},{"n":40,"text":"\thost.apply(entry);","atom":"a0","author":"init","version":0},{"n":41,"text":"\treturn { ok: false, collisions };","atom":"a0","author":"init","version":0},{"n":42,"text":"}","atom":"a0","author":"init","version":0},{"n":43,"text":"","atom":"a0","author":"init","version":0},{"n":44,"text":"/** Refused publishes and lands, newest first (`limit` defaults to 50), with counts over all of them. */","atom":"a0","author":"init","version":0},{"n":45,"text":"export function refusals(","atom":"a0","author":"init","version":0},{"n":46,"text":"\thost: RefuseHost,","atom":"a0","author":"init","version":0},{"n":47,"text":"\toptions: { agent?: string; limit?: number } = {},","atom":"a0","author":"init","version":0},{"n":48,"text":"): { counts: RefusalCounts; refusals: Refusal[] } {","atom":"a0","author":"init","version":0},{"n":49,"text":"\tconst all = options.agent === undefined ? host.refusals : host.refusals.filter((r) => r.agent === options.agent);","atom":"a0","author":"init","version":0},{"n":50,"text":"\tconst limit = Number.isInteger(options.limit) && options.limit! > 0 ? options.limit! : 50;","atom":"a0","author":"init","version":0},{"n":51,"text":"\treturn { counts: countRefusals(all), refusals: all.slice(-limit).toReversed() };","atom":"a0","author":"init","version":0},{"n":52,"text":"}","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a1648","author":"speed","message":"","time":1791922236994,"timeIso":"2026-10-13T20:10:36.994Z","publish":{"draft":null,"version":160,"agent":"speed","message":"A held push keeps its message, and why tells every settle: the refusal stores the push's message; why on a line kept by abso settle --yours, --theirs or --both names the collision it was kept from, and both kinds of settle list the settler's held push with its reason; the settle's news and the change page carry it too, and a lone push's change now lists the refusals on its way","time":1791922755559,"timeIso":"2026-10-13T20:19:15.559Z"}}]}