CAT-K4: a record is written in a draft, one section a call: open, write, remove, order, submit, drop, take-over

A draft is a key of the state drafts (author, fields, sections as title, digest and the sequence of their write-section);
write puts the text into the record's history at once, submit makes the draft a version through the rules propose is
judged by and writes no section again. Only the author writes; take-over hands a draft, a proposal or a reserved number
to the caller with the reason in the next version's message. A new version of an effort starts from the served sections
and keeps its title, date and deciders (the rows of the commit folded in, now run over the ledger too). A tool call is
named to the ledger so the runtime stamps the caller it proved.

Issue 1966.

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
2026-11-04 11:52:53 +01:00
parent 285099a940
commit 17ba95bca6
9 changed files with 1066 additions and 114 deletions
@@ -80,3 +80,28 @@ func (sdkPipe) Call(method string, req, answer any) error {
}
return json.Unmarshal(raw, answer)
}
// callIDOf is the id of the tool call that was handed args, as the tool runner names it in the call's `_meta` under
// buscalls.MetaCall: wired to the SDK where it offers it (a request to the SDK's owner: stdio.CallIDOf); until then no
// call is named, and an operation carries the module's own account alone.
var callIDOf = func(args map[string]any) string { return "" }
// noteCall holds the call a caller's write serves for as long as it runs, and ctxFor names it to the ledger: the tool
// runner stamps the caller it proved for that call as the operation's author (ADR 0597 §7), never a name the caller or
// the module gives. A caller's writes are serialised by the module, so one note per proven caller is the call in flight.
func (k *KB) noteCall(caller string, args map[string]any) func() {
id := callIDOf(args)
if id == "" || !proven(caller) {
return func() {}
}
k.calls.Store(caller, id)
return func() { k.calls.Delete(caller) }
}
// ctxFor is the context of a write by caller: the call it serves, when it serves one.
func (k *KB) ctxFor(caller string) context.Context {
if id, ok := k.calls.Load(caller); ok {
return withCall(context.Background(), id.(string))
}
return context.Background()
}