G V-8 (TS), A-17, test: the TypeScript writer is generic over the contract's bodies and names its events; findings-asked is mesh-conditions' event

The TypeScript writer holds no FindingBody of its own and works on the wire form (checkFinding, views reader findings laid out by
viewFindingBody); both writers name findings-asked as the seat mesh-conditions' event. The view-waits test waits on the raise,
not on a count of yields.

Builds: design 47 G §686, §640, §687, A-3, A-13, A-17
Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-11 21:45:07 +01:00
parent 43960cc925
commit 58bbc26219
6 changed files with 165 additions and 130 deletions
+46
View File
@@ -482,6 +482,52 @@ export function viewWaitsFinding(part: string, s: Status, at: Date): Finding {
};
}
/** The kinds a views reader's findings written through the part's writer are of, and the one that is urgent (design 47 G §687). */
const TOO_LARGE_KIND = "view-too-large";
/** A name as a key's part (design 47 G §73): a character outside letters, digits, `-`, `/` and `_` is `=` and its two lowercase hex digits per byte. */
export function escapeName(name: string): string {
let out = "";
for (const b of new TextEncoder().encode(name)) {
const c = String.fromCharCode(b);
out += /[A-Za-z0-9\-/_]/.test(c) ? c : `=${b.toString(16).padStart(2, "0")}`;
}
return out;
}
/**
* A views reader's finding laid out in its wire form by mesh-sdk (design 47 G §687): `kind` the finding's, `scope` module,
* `id` the finding's id escaped as a key's name is, `severity` warning but urgent for view-too-large, `source` views,
* `subject` the part's module on its node, `summary` and `headline` the finding's texts. The Go side's `views.WriterFindings`.
*/
export function viewFindingBody(f: Finding, module: string, node: string): Record<string, unknown> {
return {
kind: f.kind,
scope: "module",
id: escapeName(f.id),
severity: f.kind === TOO_LARGE_KIND ? "urgent" : "warning",
source: "views",
subject: { scope: "module", id: module, ...(node ? { machine: node } : {}) },
summary: f.summary,
...(f.headline ? { headline: f.headline } : {}),
...(f.at ? { at: f.at } : {}),
};
}
/** The part of a Writer a views reader's findings use, whatever the contract's body types. */
export interface WireWriter {
write(finding: any): Promise<void>;
clear(scope: string, id: string, kind: string, why: string): Promise<void>;
}
/** A views reader's findings written through the part's writer, as kinds of the reader's own (design 47 G §639, §687). */
export function writerFindings(writer: WireWriter, module: string, node: string): { put(f: Finding): Promise<void>; delete(f: Finding): Promise<void> } {
return {
put: (f) => writer.write(viewFindingBody(f, module, node)),
delete: (f) => writer.clear("module", escapeName(f.id), f.kind, "the part no longer observes it"),
};
}
/** A Follower's `said` that keeps its status at statusKey in the reader's state STATUS_STATE. */
export function keepStatus(st: State<Status>): (s: Status) => Promise<void> {
return async (s) => {