S1 kept call paced: carry the ask id, pace at the settings' defaults with jitter, stop at the caller's bound
The kept call is made again on a transport fault after kept-call-pace-first (1 s) doubling to kept-call-pace-max (30 s), each wait within 20 %, until the caller's bound; past it the answer names every call's time and words. One journal line per seat at the first fault, then at most once a minute. The ask id travels in the header x-ask; a holder reads it with process.AskOf, a bundle with stdio.AskIDOf (TypeScript askIdOf) from the call's _meta mesh/ask. Builds: design 47 H2 §775; H-A-351
This commit is contained in:
+19
-1
@@ -17,6 +17,12 @@ export const META_CALLER = "mesh/caller";
|
||||
/** Where in a `tools/call`'s `_meta` the runtime names the id of the call in flight (`buscalls.MetaCall`). */
|
||||
export const META_CALL = "mesh/call";
|
||||
|
||||
/**
|
||||
* Where in a `tools/call`'s `_meta` the runtime names the ask id a kept call carried (the Go side's `stdio.MetaAsk`;
|
||||
* design 47 H2 §775, H-A-351): what a holder takes the ask once by.
|
||||
*/
|
||||
export const META_ASK = "mesh/ask";
|
||||
|
||||
// A bus user's name: `<node>.<module>`, `person.<name>`, `controller`; anything else is no caller.
|
||||
const busUser = /^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*$/;
|
||||
// A call's id: one subject-safe token.
|
||||
@@ -25,6 +31,7 @@ const callID = /^[A-Za-z0-9_-]{1,128}$/;
|
||||
interface InFlight {
|
||||
readonly caller: string;
|
||||
readonly call: string;
|
||||
readonly ask: string;
|
||||
}
|
||||
|
||||
// The caller and the call's id of every call while its tool runs, by the arguments object that call was handed.
|
||||
@@ -42,12 +49,18 @@ export function callIn(meta: unknown): string {
|
||||
return typeof s === "string" && callID.test(s) ? s : "";
|
||||
}
|
||||
|
||||
/** The ask id a `tools/call`'s `_meta` names, or empty: one subject-safe token, as a call's id is. */
|
||||
export function askIn(meta: unknown): string {
|
||||
const s = meta && typeof meta === "object" ? (meta as Record<string, unknown>)[META_ASK] : undefined;
|
||||
return typeof s === "string" && callID.test(s) ? s : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Run `run` with the caller and the call's id `meta` names held for `args` while it runs: the stdio session does this
|
||||
* for every `tools/call`.
|
||||
*/
|
||||
export async function runAs<T>(meta: unknown, args: object, run: () => Promise<T>): Promise<T> {
|
||||
calls.set(args, { caller: callerIn(meta), call: callIn(meta) });
|
||||
calls.set(args, { caller: callerIn(meta), call: callIn(meta), ask: askIn(meta) });
|
||||
try {
|
||||
return await run();
|
||||
} finally {
|
||||
@@ -65,6 +78,11 @@ export function callIdOf(args: object | undefined | null): string {
|
||||
return (args && calls.get(args)?.call) || "";
|
||||
}
|
||||
|
||||
/** The ask id the call that was handed `args` carried (H-A-351), or empty. Valid while the tool runs. */
|
||||
export function askIdOf(args: object | undefined | null): string {
|
||||
return (args && calls.get(args)?.ask) || "";
|
||||
}
|
||||
|
||||
/**
|
||||
* A module's trusted list of who may call it (ADR 0459 §2): an entry is a module (on any machine), exactly
|
||||
* `<machine>.<module>`, or exactly `person.<name>`. A wildcard is no entry and an unproven caller never matches.
|
||||
|
||||
Reference in New Issue
Block a user