BG9, BN9, BI3: the build seats' steps with drop writes the hand-act log first

A drop of a kept detected-steps key records the act with the caller the bus proved, then deletes the key; a log that
refuses deletes nothing and is answered error; a drop without why is refused; fetch is asked unless drop.

Builds: design 47 G §463, §480

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 04:56:25 +01:00
parent 500c8c8cec
commit 247c422fbf
24 changed files with 272 additions and 14 deletions
@@ -38,6 +38,9 @@ type StepsAnswer struct {
Fingerprint string `json:"fingerprint,omitempty"`
Steps []DetectedStep `json:"steps"`
Kept bool `json:"kept,omitempty"`
// Dropped is the artifact whose key a drop deleted; Error why a drop deleted nothing, naming the hand-act log.
Dropped string `json:"dropped,omitempty"`
Error string `json:"error,omitempty"`
}
// detectSteps finds the steps of the package directories under dir.
@@ -77,26 +80,31 @@ func (m *Module) stepsTool() stdio.Tool {
return stdio.Tool{Name: Seat + "." + seat.VerbSteps,
Description: "Which pipeline steps a TypeScript artifact can run: the type-check as lint, always; unit tests where a package has a test script; " +
"integration tests where one has a test:integration script. A level with no test is not answered.",
Input: map[string]any{"type": "object", "required": []string{"module", "artifact", "fetch"}, "properties": map[string]any{
Input: map[string]any{"type": "object", "required": []string{"module", "artifact"}, "properties": map[string]any{
"module": map[string]any{"type": "string"},
"artifact": map[string]any{"type": "string", "description": "the artifact reference, <module>:<artifact>"},
"fingerprint": map[string]any{"type": "string"},
"fetch": map[string]any{"type": "object", "description": "what the fetch tool is asked: the repository, the full commit and the module's directory"},
"again": map[string]any{"type": "boolean", "description": "find them anew, not from the kept answer"},
"drop": map[string]any{"type": "boolean", "description": "delete the artifact's kept key instead of detecting; needs why (written in the hand-act log first)"},
"why": map[string]any{"type": "string", "description": "with drop, why: a non-empty text"},
}},
Run: m.Short(m.steps)}
}
func (m *Module) steps(ctx context.Context, args map[string]any) (any, error) {
str := func(k string) string { s, _ := args[k].(string); return s }
if str("artifact") == "" || str("module") == "" {
return nil, fmt.Errorf("steps: the module and the artifact are asked")
}
if drop, _ := args["drop"].(bool); drop {
return m.dropDetected(args, stdio.CallerOf(args))
}
fetch, _ := args["fetch"].(map[string]any)
req, err := sdkstep.ParseFetchRequest(fetch)
if err != nil {
return nil, err
}
if str("artifact") == "" || str("module") == "" {
return nil, fmt.Errorf("steps: the module and the artifact are asked")
}
artifact, fp := str("artifact"), str("fingerprint")
name := artifact
if _, n, ok := strings.Cut(artifact, ":"); ok {
@@ -126,6 +134,27 @@ func (m *Module) steps(ctx context.Context, args map[string]any) (any, error) {
return StepsAnswer{Artifact: artifact, Fingerprint: fp, Steps: steps}, nil
}
// dropDetected is `steps` with drop (§463, §480): the act is written in the hand-act log with the caller the bus proved,
// then the kept key is deleted; a log that refuses leaves the key.
func (m *Module) dropDetected(args map[string]any, caller string) (any, error) {
artifact, _ := args["artifact"].(string)
why, _ := args["why"].(string)
module, _ := args["module"].(string)
name := artifact
if _, n, ok := strings.Cut(artifact, ":"); ok {
name = n
}
key := seat.DetectedStepsByModuleArtifactKey(module, name)
failed, err := buildstep.DropDetected(artifact, why, caller, key, m.RecordAct, m.ForgetDetected)
if err != nil {
return nil, err
}
if failed != "" {
return StepsAnswer{Artifact: artifact, Error: failed}, nil
}
return StepsAnswer{Artifact: artifact, Dropped: artifact}, nil
}
// stepsOfTree fetches the commit alone (nothing installed) into a workspace removed at the end.
func (m *Module) stepsOfTree(ctx context.Context, req sdkstep.FetchRequest) ([]DetectedStep, error) {
if err := os.MkdirAll(m.Work, 0o700); err != nil {