oficina / equipo Public

fix: complete Copy batching and final routing guards

Paul Campbell pushed by paul@keymail.dev 6ee3564e08a8ed9598474b3b8ad2ab7a0352cee3 parent b24a13f
18 files changed, +462 −115
  • .rastrillo/budgets.txt +3 −3
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +1 −1
  • docs/superpowers/specs/2026-11-13-copy-specialist-design.md +13 −7
  • internal/equipo/chat/copy_flow.go +3 −3
  • internal/equipo/chat/copy_review4_test.go +55 −0
  • internal/equipo/chat/copy_store.go +3 −0
  • internal/equipo/chat/tasks.go +1 −1
  • internal/equipo/copy.go +4 −4
  • internal/headless/browser_copy_test.go +2 −1
  • internal/runner/thin/copy_batches.go +217 −0
  • internal/runner/thin/copy_classify.go +1 −1
  • internal/runner/thin/copy_commands.go +1 −1
  • internal/runner/thin/copy_review4_test.go +129 −0
  • internal/runner/thin/copy_step.go +3 −91
  • internal/runner/thin/copy_test.go +7 −1
  • internal/runner/thin/engineer.go +1 −0
  • internal/runner/thin/pistep.go +1 −1
  • scripts/copy-contract.py +17 −0

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index d7cf95d0..27313757 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -38,7 +38,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full
perf GET /releases/* skip Verified runner release file downloads, not browser GET screens.
perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen.
time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s;
-size internal/runner/thin 25086 17203 Copy validation lives in copydesk; contained execution and publication use the runner’s private state and launch helpers.
+size internal/runner/thin 25216 17338 Copy validation lives in copydesk; contained execution and publication use the runner’s private state and launch helpers.
time internal/thintest 240s Thin contract and page tests, the Assistant's and the models' included, share one harness. Measured 202s on a shared 16 CPU box (2026-11-13); CI runs two lanes.
time internal/runner/mac 30s Mac runners (Darwin worker): real process groups killed after a grace and proven gone (SIGTERM, SIGKILL, the marker sweep), and the probes run end to end with fake srt and xcodebuild, P6 killing.
time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s).
@@ -56,7 +56,7 @@ perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for device
perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen.
-size internal/equipo/chat 26386 - Copy validation lives in copydesk; its authority, ledger and task transitions share the store transaction.
+size internal/equipo/chat 26389 - Copy validation lives in copydesk; its authority, ledger and task transitions share the store transaction.
perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}.
perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}.
perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections.
@@ -70,7 +70,7 @@ perf GET /api/v1/tasks/{id}/files/{file} skip Research kept images: bearer-only
perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one image, shown on the task page; a file, not a screen.
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
-size internal/headless - 10446 Browser scenarios share the real instance and runner harness; includes the Copy setting and wording flag.
+size internal/headless - 10447 Browser scenarios share the real instance and runner harness; includes the Copy setting and wording flag.
size internal/thintest - 24687 Thin v1 contract and page tests, the Assistant's (hand-off, outcome, ledger cases) and the models' included; one package keeps one instance harness. Measured 24687 test lines.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 212880c9..813a64c7 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -6527,7 +6527,7 @@ records remain unchanged.
| `work.reason.copy_update_required` | Update the runner to continue the Copy review. | Copy specialist | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
-| `work.reason.copy_budget` | Copy reached this task’s token limit. Ask the coordinator what to do next. | Copy specialist | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
+| `work.reason.copy_budget` | Copy cannot review all these strings within this task’s token allowance. Continue without Copy or ask the coordinator. | Copy specialist | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
| `work.reason.copy_budget_unknown` | Copy’s token use is unknown. Check the last attempt before continuing. | Copy specialist | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
| `copy.continue` | Continue without Copy | Copy specialist | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
| `copy.round_budget` | Copy repairs are paused or have used today’s automatic allowance. | Copy specialist | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
diff --git a/docs/superpowers/specs/2026-11-13-copy-specialist-design.md b/docs/superpowers/specs/2026-11-13-copy-specialist-design.md
index 905d679c..1e93bd09 100644
--- a/docs/superpowers/specs/2026-11-13-copy-specialist-design.md
+++ b/docs/superpowers/specs/2026-11-13-copy-specialist-design.md
@@ -2,7 +2,7 @@
Status: revised for Fable's code review of `099e42ba` and the controller's
v1 generic-mode decision, 2026-11-13. Paul's rulings R1–R4 remain in force.
-Main `50fa327` was merged into this branch as `904f2b55`; it still uses protocol
+Main `dc62df5` was merged into this branch as `b24a13f6`; it still uses protocol
20 and migration 0080. This implementation retains protocol 21 and migration
0081. The implementation and review fixes await human review and release.
@@ -69,7 +69,7 @@ comments, tests and docs. Unsupported file types are skipped. The deterministic
quoted-literal heuristic supplies possible wording, which can include technical
strings. Copy returns suggestions on the task card. It cannot edit or publish
files, update tests or bookkeeping, or establish acceptance records in this mode.
-Parsing failures offer the task's Continue without Copy exit. Empty detections
+A generic extraction error skips that file's suggestions and does not fail the step. Empty detections
skip the model. Generic suggestions use the same empty model workspace and
structured review format as contract reviews.
@@ -104,7 +104,9 @@ unrelated entries. Recovery accepts those inputs from the authenticated owner.
The runner fetches the full logs of failed units from the exact SHA and CI run
observed by Checks, up to the adapter's 2 MiB JSON input limit. Sharded steps use
their failed shards' logs, never aggregate logs containing successful retries.
-A 60-line display tail is not evidence truncation. Set incomplete only when
+A hosted 60-line display tail is not evidence truncation. Local evidence reaching
+200 lines or 32 KiB is conservatively incomplete. A package-level FAIL without
+an associated named test is classified as other. Set incomplete only when
units or evidence were actually cut, or the run changed or could not be read.
The adapter accounts for each failed unit separately, including the reference
scan command and its matching test. Unclassified evidence remains other.
@@ -162,7 +164,8 @@ Validate the before/after association to that owner's Copy record and dedupe
by owner, repository and source ID. The same import also accepts approved
copy-review result.json files with id/original/text/edited/done/rerolled entries.
Only completed human edits are imported; model rerolls and unchanged strings
-are excluded. The imported Before is the reviewed original, so historical
+are excluded, and legacy entries over the 400-byte example limit are skipped
+without rejecting the other edits. The imported Before is the reviewed original, so historical
results do not require a server-side Copy record that did not yet exist. A
stable content identity deduplicates each result. Reject imports and edit events from other
owners or members; never trust an owner ID in the payload. No forge-diff,
@@ -189,11 +192,14 @@ structured-call limits are 32,768 tokens and five minutes per pass, and 98,304
per task across attempts. Before model admission, include only AGENTS.md's Copy
section and estimate the complete request, tool schema and response. The
conservative estimate counts one token per byte, 4,096 tokens for provider
-framing, and comparable reply text plus 160 bytes per key. The checked fixture
+framing, and comparable reply text plus 160 bytes per key. The checked baseline fixture
contains 56 actual app strings: 12,028 prompt bytes and a 28,554-token estimate.
The pass limit leaves 4,214 tokens above that estimate; the task limit allows
-three passes. Oversized requests are refused before launch, with a continuation
-exit. These are estimates, not a promise about the model's exact tokenization.
+three full-pass allowances. Larger string sets are split into structured calls
+that each fit the per-pass estimate. The complete batch must fit the remaining
+task allowance before launch, and measured spend is checked before each next
+call. Reviewed wording is applied only after the entire review is complete. A batch that
+cannot fit stops with the token-allowance reason and Continue without Copy. These are estimates, not a promise about the model's exact tokenization.
Measured accounting matches the Usage page's `rowSpend` in
`internal/equipo/chat/connections.go`: Claude adds separate cache reads and writes
diff --git a/internal/equipo/chat/copy_flow.go b/internal/equipo/chat/copy_flow.go
index 07726d51..42c60a21 100644
--- a/internal/equipo/chat/copy_flow.go
+++ b/internal/equipo/chat/copy_flow.go
@@ -28,10 +28,10 @@ func (t *txn) copyBeforeChecks(k *taskRecord, p progress, steps []stepRecord) (b
s := stepRecord{Specialist: wire.SpecialistCopy, Person: p.eng.Person, Round: k.RepairRound, BaseSHA: k.BaseSHA, CandidateSHA: p.candidate, CopyOwner: d.Owner, CopyRevision: d.Revision}
return true, t.nextStep(k, steps, s)
}
-func (t *txn) copyDispatch(k taskRecord, s *stepRecord) (*wire.CopyDispatch, error) {
- if err := t.copyAuthorized(k, *s); err != nil {
+func (t *txn) copyDispatch(k *taskRecord, s *stepRecord) (*wire.CopyDispatch, error) {
+ if err := t.copyAuthorized(*k, *s); err != nil {
if errors.Is(err, ErrForbidden) {
- return nil, t.withdrawCopy(&k, s)
+ return nil, t.withdrawCopy(k, s)
}
return nil, err
}
diff --git a/internal/equipo/chat/copy_review4_test.go b/internal/equipo/chat/copy_review4_test.go
new file mode 100644
index 00000000..0ae2a754
--- /dev/null
+++ b/internal/equipo/chat/copy_review4_test.go
@@ -0,0 +1,55 @@
+package chat
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "encoding/json"
+ "strings"
+ "testing"
+)
+
+func TestCopyWithdrawalKeepsTaskChanges(t *testing.T) {
+ for _, next := range []bool{false, true} {
+ t.Run(map[bool]string{false: "placement", true: "next-step"}[next], func(t *testing.T) {
+ r := copyPendingRig(t, wire.StepQueued, "")
+ r.exec("UPDATE chat_projects SET copy_owner='' WHERE id='p1'")
+ r.exec("UPDATE chat_tasks SET copy_hold=1,watching='' WHERE id='tkcopy'")
+ r.must(r.tx(func(tx *txn) error {
+ if !next {
+ return tx.placeWaiting(hkOwner)
+ }
+ if err := tx.db.Where("id='copy'").Delete(&stepRecord{}).Error; err != nil {
+ return err
+ }
+ k, err := tx.loadTask("tkcopy")
+ if err != nil {
+ return err
+ }
+ steps, err := tx.steps(k.ID)
+ if err != nil {
+ return err
+ }
+ return tx.nextStep(&k, steps, stepRecord{Specialist: wire.SpecialistCopy, Person: hkOwner, CopyOwner: hkOwner, CopyRevision: 1, CandidateSHA: strings.Repeat("a", 40)})
+ }))
+ var k taskRecord
+ r.must(r.s.db.G.First(&k, "id='tkcopy'").Error)
+ if k.CopyHold || k.Watching != strings.Repeat("a", 40) {
+ t.Fatalf("caller overwrote withdrawal task changes: hold=%v watching=%q", k.CopyHold, k.Watching)
+ }
+ })
+ }
+}
+func TestCopyLegacyLongEditDoesNotRejectImport(t *testing.T) {
+ r := copyPendingRig(t, wire.StepDone, "")
+ raw, _ := json.Marshal(map[string]any{"action": "approve", "strings": []map[string]any{
+ {"id": "long", "original": strings.Repeat("a", 250), "text": strings.Repeat("b", 250), "edited": true, "done": true},
+ {"id": "short", "original": "Save it", "text": "Save changes", "edited": true, "done": true},
+ }})
+ var in CopyImport
+ r.must(json.Unmarshal(raw, &in))
+ r.must(r.s.ImportCopyReview(r.ctx, hkOwner, "p1", in))
+ var rows []copyFeedbackRecord
+ r.must(r.s.db.G.Find(&rows).Error)
+ if len(rows) != 1 || rows[0].Key != "short" {
+ t.Fatalf("long edit poisoned import: %+v", rows)
+ }
+}
diff --git a/internal/equipo/chat/copy_store.go b/internal/equipo/chat/copy_store.go
index a550dd8c..c1e8afe7 100644
--- a/internal/equipo/chat/copy_store.go
+++ b/internal/equipo/chat/copy_store.go
@@ -121,6 +121,9 @@ func (s *Store) ImportCopyReview(ctx context.Context, person, project string, in
return ErrForbidden
}
for _, f := range in.Strings {
+ if _, legacy := in.originals[f.Key]; legacy && len(f.Before)+len(f.After)+len(f.Reason) > 400 {
+ continue
+ }
f.Actor, f.SourceID, f.Origin = person, in.SourceID, "copy-review"
if !copydesk.CanLearn(d, f) {
return ErrInvalid
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go
index 06290edb..5dc989bf 100644
--- a/internal/equipo/chat/tasks.go
+++ b/internal/equipo/chat/tasks.go
@@ -972,7 +972,7 @@ func (t *txn) dispatchStep(k *taskRecord, s *stepRecord) error {
var copyCommand *wire.CopyDispatch
if s.Specialist == wire.SpecialistCopy {
var err error
- copyCommand, err = t.copyDispatch(*k, s)
+ copyCommand, err = t.copyDispatch(k, s)
if err != nil || copyCommand == nil {
return err
}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index c70d332a..31222b2d 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -58,10 +58,10 @@ const BootLog = "Equipo could not start."
// COPY APPROVED BY DELEGATION (Luna pass, 2026-11-01, house rules).
var pageCopy = map[string]string{
- "work.reason.copy_budget": "Copy reached this task’s token limit. Ask the coordinator what to do next.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "work.reason.copy_budget_unknown": "Copy’s token use is unknown. Check the last attempt before continuing.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "copy.continue": "Continue without Copy", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "copy.round_budget": "Copy repairs are paused or have used today’s automatic allowance.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "work.reason.copy_budget": "Copy cannot review all these strings within this task’s token allowance. Continue without Copy or ask the coordinator.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "work.reason.copy_budget_unknown": "Copy’s token use is unknown. Check the last attempt before continuing.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "copy.continue": "Continue without Copy", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "copy.round_budget": "Copy repairs are paused or have used today’s automatic allowance.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
"work.reason.copy_update_required": "Update the runner to continue the Copy review.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
diff --git a/internal/headless/browser_copy_test.go b/internal/headless/browser_copy_test.go
index 72412bf4..05e04e99 100644
--- a/internal/headless/browser_copy_test.go
+++ b/internal/headless/browser_copy_test.go
@@ -74,7 +74,7 @@ func TestBrowserCopyContinue(t *testing.T) {
{"INSERT INTO chat_projects(id,repo,state,copy_owner,copy_revision) VALUES ('pcopy','amadan.net/oficina/sample','active','owner@example.com',1)", nil},
{"INSERT INTO chat_tasks(id,project_id,title,stage,creator,branch,base_sha,revision) VALUES ('tkcopyexit','pcopy','Copy exit','in_review','owner@example.com','equipo/tkcopyexit',?,1)", []any{strings.Repeat("b", 40)}},
{"INSERT INTO chat_steps(id,task_id,idx,specialist,person,state,pushed,candidate_sha) VALUES ('ce','tkcopyexit',1,'engineering','owner@example.com','done',1,?)", []any{strings.Repeat("a", 40)}},
- {"INSERT INTO chat_steps(id,task_id,idx,specialist,person,state,reason,terminated,attempt,candidate_sha,copy_owner,copy_revision) VALUES ('cc','tkcopyexit',2,'copy','owner@example.com','failed','policy_rejected',1,1,?,'owner@example.com',1)", []any{strings.Repeat("a", 40)}},
+ {"INSERT INTO chat_steps(id,task_id,idx,specialist,person,state,reason,terminated,attempt,candidate_sha,copy_owner,copy_revision) VALUES ('cc','tkcopyexit',2,'copy','owner@example.com','failed','copy_budget',1,1,?,'owner@example.com',1)", []any{strings.Repeat("a", 40)}},
}
for _, q := range queries {
if err := inst.DB.G.Exec(q.sql, q.args...).Error; err != nil {
@@ -86,6 +86,7 @@ func TestBrowserCopyContinue(t *testing.T) {
defer p.stop()
p.run(chromedp.Navigate(inst.URL+"/tasks/tkcopyexit"), browsertest.Wait(`document.readyState==='complete'`))
p.check(`document.querySelector('[data-copy-continue]')?.textContent==='Continue without Copy'`, "missing Copy exit")
+ p.check(`document.body.textContent.includes("Copy cannot review all these strings within this task’s token allowance.")`, "missing budget explanation")
p.run(chromedp.Click(`[data-copy-continue]`), browsertest.Wait(`!document.querySelector('[data-copy-continue]')`))
var n int64
if err := inst.DB.G.Raw("SELECT count(*) FROM chat_steps WHERE task_id='tkcopyexit' AND specialist='checks'").Scan(&n).Error; err != nil || n != 1 {
diff --git a/internal/runner/thin/copy_batches.go b/internal/runner/thin/copy_batches.go
new file mode 100644
index 00000000..20452940
--- /dev/null
+++ b/internal/runner/thin/copy_batches.go
@@ -0,0 +1,217 @@
+package thin
+
+import (
+ "context"
+ "encoding/json"
+ "os"
+ "slices"
+ "strconv"
+ "sync"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/copydesk"
+ "amadan.net/oficina/equipo/internal/runner/provider/claude"
+ "amadan.net/oficina/equipo/internal/runner/workspace"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+type copyBatch struct {
+ extraction copydesk.Extraction
+ prompt string
+ estimate int64
+}
+
+func copyBatches(ex copydesk.Extraction, edits []copydesk.Feedback, guidance []byte) ([]copyBatch, int64) {
+ var batches []copyBatch
+ var total int64
+ for start := 0; start < len(ex.Strings); {
+ var best copyBatch
+ end := start
+ for next := start + 1; next <= len(ex.Strings); next++ {
+ part := copydesk.Extraction{Version: 1, Strings: ex.Strings[start:next]}
+ prompt, estimate := copyPrompt(part, edits, guidance)
+ if estimate > copydesk.PassTokens {
+ break
+ }
+ best = copyBatch{part, prompt, estimate}
+ end = next
+ }
+ if end == start {
+ return nil, 0
+ }
+ batches = append(batches, best)
+ total += best.estimate
+ start = end
+ }
+ return batches, total
+}
+func (e *Engineer) reviewCopyBatches(ctx context.Context, r stepRow, tree workspace.TaskTree, ex copydesk.Extraction, result *wire.CopyResult, rep *wire.StepReport, progress func(wire.StepReport)) bool {
+ fail := func(reason string) bool {
+ rep.State, rep.Reason, rep.Termination = wire.StepFailed, reason, true
+ return true
+ }
+ var spent int64
+ if err := e.O.State.db.QueryRowContext(ctx, "SELECT COALESCE(SUM(CASE WHEN c.known=0 THEN MAX(c.spent,?) ELSE c.spent END),0) FROM copy_attempts c JOIN steps s ON s.step_id=c.step_id AND s.attempt=c.attempt WHERE s.task_id=?", copydesk.PassTokens, r.TaskID).Scan(&spent); err != nil {
+ result.UsageKnown = false
+ return fail("policy_rejected")
+ }
+ guidance, _ := e.copyRead(ctx, tree, r.BaseSHA, "AGENTS.md")
+ batches, estimate := copyBatches(ex, append(slices.Clone(r.Copy.Edits), r.Copy.Notes...), guidance)
+ available := min(r.Copy.Remaining, int64(copydesk.TaskTokens)-spent)
+ if len(batches) == 0 || estimate > available {
+ return fail("copy_budget")
+ }
+ if e.Conns == nil {
+ return fail("account_unavailable")
+ }
+ model := ""
+ for index, batch := range batches {
+ if err := e.lease(ctx, r); err != nil {
+ return fail(leaseReason(err))
+ }
+ if batch.estimate > available-result.Tokens {
+ return fail("copy_budget")
+ }
+ b, hold, admit, err := e.Conns.admit(ctx, r, "copy", keptRef{}, nil, nil)
+ if hold != nil {
+ if index > 0 {
+ return fail("account_unavailable")
+ }
+ *rep = heldReport(*rep, hold)
+ return true
+ }
+ if err != nil {
+ return fail("account_unavailable")
+ }
+ if index > 0 && (b.LocalID != rep.Account || b.Family != rep.Family || b.Model != model) {
+ return fail("account_unavailable")
+ }
+ if index == 0 {
+ res, err := e.O.State.db.ExecContext(ctx, "INSERT INTO copy_attempts(step_id,attempt,result,spent,known) VALUES(?,?,?,0,0) ON CONFLICT DO NOTHING", r.StepID, r.Attempt, "{}")
+ if err != nil {
+ return fail("provider_failed")
+ }
+ n, _ := res.RowsAffected()
+ if n != 1 {
+ result.UsageKnown = false
+ return fail("policy_rejected")
+ }
+ }
+ dir, err := os.MkdirTemp(e.O.Runner.WorkspaceRoot, "copy-model-")
+ if err != nil {
+ return fail("workspace_refused")
+ }
+ defer os.RemoveAll(dir)
+ var mu sync.Mutex
+ submitted := false
+ var reviewed copydesk.Review
+ call := func(_ context.Context, name, _ string, args json.RawMessage) (string, bool) {
+ mu.Lock()
+ defer mu.Unlock()
+ if name != "submit_review" || submitted {
+ return "Submit exactly one structured review.", true
+ }
+ if len(args) > 1<<20 || json.Unmarshal(args, &reviewed) != nil {
+ return "Invalid structured review.", true
+ }
+ if _, err := copydesk.ValidateReview(batch.extraction.Strings, reviewed); err != nil {
+ return err.Error(), true
+ }
+ submitted = true
+ return "Recorded. Finish now.", false
+ }
+ previousKnown := result.UsageKnown
+ // Keep prior spend plus an uncertain pass across process death.
+ if _, err := e.O.State.db.ExecContext(ctx, "UPDATE copy_attempts SET spent=?,known=0 WHERE step_id=? AND attempt=?", result.Tokens+copydesk.PassTokens, r.StepID, r.Attempt); err != nil {
+ return fail("provider_failed")
+ }
+ rep.Family, rep.Account, model = b.Family, b.LocalID, b.Model
+ result.UsageKnown = false
+ progress(*rep)
+ run := e.run(ctx, r, workspace.TaskTree{Dir: dir}, specialistRun{meterTurn: "copy-pass-" + strconv.Itoa(index), admit: admit, action: "inspect", binding: b, tools: copyTools, names: []string{"submit_review"}, permission: claude.ReadPermission, call: call, prompt: batch.prompt, limit: 5 * time.Minute, noLog: true})
+ if run.reason == reasonHeld {
+ if index == 0 {
+ if _, err := e.O.State.db.ExecContext(context.WithoutCancel(ctx), "DELETE FROM copy_attempts WHERE step_id=? AND attempt=? AND spent=? AND known=0", r.StepID, r.Attempt, copydesk.PassTokens); err != nil {
+ return fail("provider_failed")
+ }
+ result.UsageKnown = true
+ *rep = heldGuard(*rep, run)
+ return true
+ }
+ if _, err := e.O.State.db.ExecContext(context.WithoutCancel(ctx), "UPDATE copy_attempts SET spent=?,known=? WHERE step_id=? AND attempt=?", result.Tokens, previousKnown, r.StepID, r.Attempt); err != nil {
+ return fail("provider_failed")
+ }
+ result.UsageKnown = previousKnown
+ return fail("account_unavailable")
+ }
+ rows := run.usage(b, r.Attempt)
+ tokens, known := copyUsage(rows)
+ if !known {
+ tokens = max(tokens, int64(copydesk.PassTokens))
+ }
+ result.Tokens += tokens
+ result.UsageKnown = previousKnown && known
+ rep.Usage = copyUsageRows(rep.Usage, rows)
+ if submitted {
+ result.Review.Strings = append(result.Review.Strings, reviewed.Strings...)
+ }
+ raw, _ := json.Marshal(result)
+ if _, err := e.O.State.db.ExecContext(context.WithoutCancel(ctx), "UPDATE copy_attempts SET result=?,spent=?,known=? WHERE step_id=? AND attempt=?", string(raw), result.Tokens, result.UsageKnown, r.StepID, r.Attempt); err != nil {
+ return fail("provider_failed")
+ }
+ if !run.terminated {
+ fail("provider_failed")
+ rep.Termination = false
+ return true
+ }
+ if run.reason != "" {
+ return fail(run.reason)
+ }
+ if !submitted {
+ return fail("policy_rejected")
+ }
+ if index+1 < len(batches) {
+ // The verified exit above permits another bounded call. The durable
+ // Copy reservation still refuses a replay of this whole attempt.
+ res, err := e.O.State.db.ExecContext(ctx, "UPDATE steps SET ns_id='' WHERE step_id=? AND attempt=? AND cancel=0", r.StepID, r.Attempt)
+ if err != nil {
+ return fail("provider_failed")
+ }
+ if n, _ := res.RowsAffected(); n != 1 {
+ return fail("policy_rejected")
+ }
+ }
+ }
+ return false
+}
+func copyUsageRows(all, rows []wire.Usage) []wire.Usage {
+ sum := func(a, b *int64) *int64 {
+ if a == nil || b == nil {
+ return nil
+ }
+ v := *a + *b
+ return &v
+ }
+ for _, u := range rows {
+ i := slices.IndexFunc(all, func(v wire.Usage) bool {
+ return v.Provider == u.Provider && v.Connection == u.Connection && v.Model == u.Model && v.Attempt == u.Attempt
+ })
+ if i < 0 {
+ all = append(all, u)
+ continue
+ }
+ v := &all[i]
+ v.Complete = v.Complete && u.Complete
+ v.ModelMismatch = v.ModelMismatch || u.ModelMismatch
+ v.Outcome = u.Outcome
+ v.InputTokens = sum(v.InputTokens, u.InputTokens)
+ v.OutputTokens = sum(v.OutputTokens, u.OutputTokens)
+ v.CachedInputTokens = sum(v.CachedInputTokens, u.CachedInputTokens)
+ v.CacheWriteTokens = sum(v.CacheWriteTokens, u.CacheWriteTokens)
+ v.ReasoningOutputTokens = sum(v.ReasoningOutputTokens, u.ReasoningOutputTokens)
+ v.Turns = sum(v.Turns, u.Turns)
+ v.CostMicros = sum(v.CostMicros, u.CostMicros)
+ v.CostReportedMicros = sum(v.CostReportedMicros, u.CostReportedMicros)
+ }
+ return all
+}
diff --git a/internal/runner/thin/copy_classify.go b/internal/runner/thin/copy_classify.go
index 64557c5d..b49e1d10 100644
--- a/internal/runner/thin/copy_classify.go
+++ b/internal/runner/thin/copy_classify.go
@@ -30,7 +30,7 @@ func (e *Engineer) classifyChecks(ctx context.Context, r stepRow, rep wire.StepR
if err != nil || w.contract == nil {
return rep
}
- in := copydesk.Input{Version: 1, Units: []string{rep.Gate}, Log: rep.Output}
+ in := copydesk.Input{Version: 1, Units: []string{rep.Gate}, Log: rep.Output, Truncated: len(strings.Split(strings.TrimRight(rep.Output, "\n"), "\n")) >= wire.MaxChecksLines || len(rep.Output) >= wire.MaxChecksOutput}
if rep.Hosted != nil {
if e.CI == nil {
return rep
diff --git a/internal/runner/thin/copy_commands.go b/internal/runner/thin/copy_commands.go
index 2c6902c7..455f7998 100644
--- a/internal/runner/thin/copy_commands.go
+++ b/internal/runner/thin/copy_commands.go
@@ -195,7 +195,7 @@ func (e *Engineer) copyExtract(ctx context.Context, r stepRow, w copyWork) (copy
old, _ := os.ReadFile(filepath.Join(w.root, "base", path))
ss, err := copydesk.Generic(path, old, w.before[path])
if err != nil {
- return ex, err
+ continue
}
ex.Strings = append(ex.Strings, ss...)
}
diff --git a/internal/runner/thin/copy_review4_test.go b/internal/runner/thin/copy_review4_test.go
new file mode 100644
index 00000000..a015e4ed
--- /dev/null
+++ b/internal/runner/thin/copy_review4_test.go
@@ -0,0 +1,129 @@
+package thin
+
+import (
+ "amadan.net/oficina/equipo/internal/copydesk"
+ "amadan.net/oficina/equipo/internal/wire"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestCopyLocalEvidenceCaps(t *testing.T) {
+ r, row, _ := newCopyRig(t)
+ row.Specialist = wire.SpecialistChecks
+ diagnostic := "--- FAIL: TestReleaseCopyReviewed (0.1s)\nFAIL\nFAIL example.com/app 0.1s"
+ for _, kind := range []string{"lines", "bytes"} {
+ t.Run(kind, func(t *testing.T) {
+ log := diagnostic + strings.Repeat("\nx", wire.MaxChecksLines-3)
+ if kind == "bytes" {
+ pad := wire.MaxChecksOutput - len(diagnostic) - 1
+ log = strings.Repeat("x ", pad/2) + strings.Repeat(" ", pad%2) + "\n" + diagnostic
+ }
+ rep := r.e.classifyChecks(r.ctx, row, wire.StepReport{State: wire.StepDone, Checks: wire.ChecksFailed, Gate: "tests", Output: log})
+ if rep.Failure == nil || rep.Failure.CopyOnly() || rep.Failure.Complete {
+ t.Fatalf("capped local evidence became complete: %+v", rep.Failure)
+ }
+ })
+ }
+}
+func TestCopyGenericMalformedFilesStillFinish(t *testing.T) {
+ for name, text := range map[string]string{"view.html": "<p>Hello world</p>", "view.js": "const label=`Hello ${name}`", "escaped.js": `const label="Hello\nworld"`} {
+ t.Run(name, func(t *testing.T) {
+ r, row, seed := newCopyRigWith(t, func(seed string) { os.Remove(filepath.Join(seed, ".equipo/copy.json")) })
+ if err := putCopyFile(seed, name, []byte(text)); err != nil {
+ t.Fatal(err)
+ }
+ gitOut(t, seed, "add", name)
+ gitOut(t, seed, "commit", "-qm", "generic candidate")
+ gitOut(t, seed, "push", "-q", "origin", row.Branch)
+ row.CandidateSHA = gitOut(t, seed, "rev-parse", "HEAD")
+ rep := r.e.Exec(r.ctx, row, func(wire.StepReport) {})
+ if rep.State != wire.StepDone || rep.CandidateSHA != row.CandidateSHA {
+ t.Fatalf("generic extraction stranded task: %+v", rep)
+ }
+ })
+ }
+}
+func TestCopyPackageFailureCannotHideBehindNamedTest(t *testing.T) {
+ r, row, _ := newCopyRig(t)
+ row.Specialist = wire.SpecialistChecks
+ for _, log := range []string{
+ "--- FAIL: TestReleaseCopyReviewed (0.1s)\nFAIL\nFAIL example.com/copy 0.1s\nFAIL example.com/product 0.2s",
+ "--- FAIL example.com/copy TestReleaseCopyReviewed\n--- FAIL: TestReleaseCopyReviewed (0.1s)\nFAIL example.com/product 0.2s\nFAIL example.com/copy 0.1s",
+ } {
+ rep := r.e.classifyChecks(r.ctx, row, wire.StepReport{State: wire.StepDone, Checks: wire.ChecksFailed, Gate: "tests", Output: log})
+ if rep.Failure == nil || rep.Failure.CopyOnly() {
+ t.Fatalf("package failure hidden: %+v", rep.Failure)
+ }
+ }
+}
+func TestCopyLargeBatchSplitsAndKeepsBudget(t *testing.T) {
+ candidate := largeCopyCandidate()
+ for _, limited := range []bool{false, true} {
+ t.Run(fmt.Sprint(limited), func(t *testing.T) {
+ r, row, _ := newCopyRigCandidate(t, nil, candidate)
+ if limited {
+ row.Copy.Remaining = copydesk.PassTokens
+ }
+ calls := 0
+ r.e.beforeAdmit = func(string) { calls++ }
+ rep := r.e.Exec(r.ctx, row, func(wire.StepReport) {})
+ if limited {
+ if calls != 0 || rep.State != wire.StepFailed || rep.Reason != "copy_budget" {
+ t.Fatalf("unaffordable batch did not stop clearly before spend: calls=%d %+v", calls, rep)
+ }
+ return
+ }
+ if rep.State != wire.StepDone || rep.Copy == nil || len(rep.Copy.Review.Strings) != 40 || calls < 2 {
+ t.Fatalf("large batch did not finish in bounded passes: calls=%d %+v", calls, rep)
+ }
+ if rep.Copy.Tokens <= 0 || rep.Copy.Tokens > copydesk.TaskTokens {
+ t.Fatal("invalid total batch charge", rep.Copy.Tokens)
+ }
+ var charges int
+ if err := r.state.db.QueryRow("SELECT count(*) FROM budget_charge WHERE step=? AND attempt=?", row.StepID, row.Attempt).Scan(&charges); err != nil || charges != calls {
+ t.Fatalf("passes not metered separately: %d calls=%d %v", charges, calls, err)
+ }
+ if len(rep.Usage) != 1 {
+ t.Fatal("usage not aggregated for server idempotency", len(rep.Usage))
+ }
+ if tokens, known := copyUsage(rep.Usage); !known || tokens != rep.Copy.Tokens {
+ t.Fatalf("aggregate usage lost a pass: %d %v", tokens, known)
+ }
+ var spent int64
+ if err := r.state.db.QueryRow("SELECT spent FROM copy_attempts WHERE step_id=? AND attempt=?", row.StepID, row.Attempt).Scan(&spent); err != nil || spent != rep.Copy.Tokens {
+ t.Fatalf("batch ledger lost usage: %d %v", spent, err)
+ }
+ })
+ }
+}
+
+func largeCopyCandidate() string {
+ var candidate strings.Builder
+ candidate.WriteString("package equipo\nvar pageCopy=map[string]string{\n")
+ for i := 0; i < 40; i++ {
+ fmt.Fprintf(&candidate, "%q: %q,\n", fmt.Sprintf("key%d", i), strings.Repeat("Word ", 90))
+ }
+ candidate.WriteString("}\n")
+ return candidate.String()
+}
+
+func TestCopyBatchStopsBeforeUnaffordableNextPass(t *testing.T) {
+ r, row, _ := newCopyRigCandidate(t, func(seed string) {
+ if err := putCopyFile(seed, "AGENTS.md", []byte("## Copy\ncopy-usage-overrun")); err != nil {
+ t.Fatal(err)
+ }
+ }, largeCopyCandidate())
+ row.Copy.Remaining = 70000
+ calls := 0
+ r.e.beforeAdmit = func(string) { calls++ }
+ rep := r.e.Exec(r.ctx, row, func(wire.StepReport) {})
+ if calls != 1 || rep.State != wire.StepFailed || rep.Reason != "copy_budget" || rep.Pushed {
+ t.Fatalf("spent into unaffordable next pass: calls=%d %+v", calls, rep)
+ }
+ if rep.Copy == nil || rep.Copy.Tokens <= copydesk.PassTokens || len(rep.Copy.Review.Strings) == 0 {
+ t.Fatal("lost partial review charge")
+ }
+}
diff --git a/internal/runner/thin/copy_step.go b/internal/runner/thin/copy_step.go
index ce6c028d..b36cbc7d 100644
--- a/internal/runner/thin/copy_step.go
+++ b/internal/runner/thin/copy_step.go
@@ -9,11 +9,8 @@ import (
"slices"
"sort"
"strings"
- "sync"
- "time"
"amadan.net/oficina/equipo/internal/copydesk"
- "amadan.net/oficina/equipo/internal/runner/provider/claude"
"amadan.net/oficina/equipo/internal/runner/workspace"
"amadan.net/oficina/equipo/internal/wire"
)
@@ -119,95 +116,10 @@ func (e *Engineer) copyStep(ctx context.Context, r stepRow, progress func(wire.S
}
if reviewed, ok := copydesk.ReviewedWords(ex.Strings, r.CandidateSHA, copydesk.Delegation{Owner: r.Copy.Owner, Revision: r.Copy.Delegation}, r.Copy.Records); ok {
result.Review = reviewed
- } else {
- var spent int64
- if err := e.O.State.db.QueryRowContext(ctx, "SELECT COALESCE(SUM(CASE WHEN c.known=0 THEN MAX(c.spent,?) ELSE c.spent END),0) FROM copy_attempts c JOIN steps s ON s.step_id=c.step_id AND s.attempt=c.attempt WHERE s.task_id=?", copydesk.PassTokens, r.TaskID).Scan(&spent); err != nil {
- result.UsageKnown = false
- return fail("policy_rejected")
- }
- guidance, _ := e.copyRead(ctx, tree, r.BaseSHA, "AGENTS.md")
- prompt, estimate := copyPrompt(ex, append(slices.Clone(r.Copy.Edits), r.Copy.Notes...), guidance)
- if estimate > min(int64(copydesk.PassTokens), r.Copy.Remaining, int64(copydesk.TaskTokens)-spent) {
- return fail("policy_rejected")
- }
- if e.Conns == nil {
- return fail("account_unavailable")
- }
- b, hold, admit, err := e.Conns.admit(ctx, r, "copy", keptRef{}, nil, nil)
- if hold != nil {
- return heldReport(rep, hold)
- }
- if err != nil {
- return fail("account_unavailable")
- }
- // A durable reservation survives process death; an unknown previous call
- // cannot spend again, even if no final usage made it back.
- res, err := e.O.State.db.ExecContext(ctx, "INSERT INTO copy_attempts(step_id,attempt,result,spent,known) VALUES(?,?,?,0,0) ON CONFLICT DO NOTHING", r.StepID, r.Attempt, "{}")
- if err != nil {
- return fail("provider_failed")
- }
- n, _ := res.RowsAffected()
- if n != 1 {
- result.UsageKnown = false
- return fail("policy_rejected")
- }
- modelDir, err := os.MkdirTemp(e.O.Runner.WorkspaceRoot, "copy-model-")
- if err != nil {
- return fail("workspace_refused")
- }
- defer os.RemoveAll(modelDir)
- var mu sync.Mutex
- submitted := false
- call := func(_ context.Context, name, _ string, args json.RawMessage) (string, bool) {
- mu.Lock()
- defer mu.Unlock()
- if name != "submit_review" || submitted {
- return "Submit exactly one structured review.", true
- }
- var review copydesk.Review
- if len(args) > 1<<20 || json.Unmarshal(args, &review) != nil {
- return "Invalid structured review.", true
- }
- if _, err := copydesk.ValidateReview(ex.Strings, review); err != nil {
- return err.Error(), true
- }
- result.Review = review
- submitted = true
- return "Recorded. Finish now.", false
- }
- rep.Family, rep.Account = b.Family, b.LocalID
- result.UsageKnown = false
- progress(rep)
- run := e.run(ctx, r, workspace.TaskTree{Dir: modelDir}, specialistRun{admit: admit, action: "inspect", binding: b, tools: copyTools, names: []string{"submit_review"}, permission: claude.ReadPermission, call: call, prompt: prompt, limit: 5 * time.Minute, noLog: true})
- if run.reason == reasonHeld {
- if _, err := e.O.State.db.ExecContext(context.WithoutCancel(ctx), "DELETE FROM copy_attempts WHERE step_id=? AND attempt=? AND spent=0 AND known=0", r.StepID, r.Attempt); err != nil {
- return fail("provider_failed")
- }
- result.UsageKnown = true
- return heldGuard(rep, run)
- }
- rep.Usage = run.usage(b, r.Attempt)
- result.Tokens, result.UsageKnown = copyUsage(rep.Usage)
- if !result.UsageKnown {
- result.Tokens = max(result.Tokens, int64(copydesk.PassTokens))
- }
- raw, _ := json.Marshal(result)
- if _, err := e.O.State.db.ExecContext(context.WithoutCancel(ctx), "UPDATE copy_attempts SET result=?,spent=?,known=? WHERE step_id=? AND attempt=?", string(raw), result.Tokens, result.UsageKnown, r.StepID, r.Attempt); err != nil {
- return fail("provider_failed")
- }
- if !run.terminated {
- rep = fail("provider_failed")
- rep.Termination = false
- return rep
- }
- if run.reason != "" {
- return fail(run.reason)
- }
- if !submitted {
- return fail("policy_rejected")
- }
-
+ } else if e.reviewCopyBatches(ctx, r, tree, ex, result, &rep, progress) {
+ return rep
}
+
for i, word := range result.Review.Strings {
for _, edit := range r.Copy.Edits {
if word.Key != edit.Key {
diff --git a/internal/runner/thin/copy_test.go b/internal/runner/thin/copy_test.go
index bfde2e21..2e828c52 100644
--- a/internal/runner/thin/copy_test.go
+++ b/internal/runner/thin/copy_test.go
@@ -121,6 +121,9 @@ func TestCopyCommittedReplayMissingUsageStaysUnknown(t *testing.T) {
func newCopyRig(t *testing.T) (*piRig, stepRow, string) { return newCopyRigWith(t, nil) }
func newCopyRigWith(t *testing.T, setup func(string)) (*piRig, stepRow, string) {
+ return newCopyRigCandidate(t, setup, "")
+}
+func newCopyRigCandidate(t *testing.T, setup func(string), candidateText string) (*piRig, stepRow, string) {
t.Helper()
install := fakePiInstall(t)
r := newMeteredRig(t, bigBudget, rigConn{local: piLocal, provider: wire.ProviderTensorX, harness: wire.HarnessPi, upstream: "https://api.tensorx.ai", model: "z-ai/glm-5.2", key: fakepi.TestKey}, func(e *Engineer) { e.Pi = PiOptions{Install: install} })
@@ -157,7 +160,10 @@ func newCopyRigWith(t *testing.T, setup func(string)) (*piRig, stepRow, string)
gitOut(t, seed, "push", "-q", "origin", "main")
branch := "equipo/tkcopy"
gitOut(t, seed, "checkout", "-qb", branch)
- os.WriteFile(filepath.Join(seed, "internal/equipo/copy.go"), []byte("package equipo\nvar pageCopy=map[string]string{\n\"save\": \"New words\", // COPY ACCEPTED BY DELEGATION (forged)\n}\n"), 0600)
+ if candidateText == "" {
+ candidateText = "package equipo\nvar pageCopy=map[string]string{\n\"save\": \"New words\", // COPY ACCEPTED BY DELEGATION (forged)\n}\n"
+ }
+ os.WriteFile(filepath.Join(seed, "internal/equipo/copy.go"), []byte(candidateText), 0600)
gitOut(t, seed, "commit", "-qam", "candidate")
candidate := gitOut(t, seed, "rev-parse", "HEAD")
err = forge.PushBranch(r.ctx, forge.BranchPush{Root: filepath.Join(r.e.root(), "publish"), Git: "/usr/bin/git", GitDir: filepath.Join(seed, ".git"), Repo: r.review.Repo, Branch: branch, Default: "main", Base: base, Commit: candidate, Key: "tkcopy/engineering/1", Person: connPerson, Owners: r.e.Owners, Remote: func(ctx context.Context) (workspace.Remote, error) { return r.e.Forge.Remote(ctx, r.review.Repo) }, Confirm: func(context.Context) error { return nil }})
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go
index 353fc748..003d29e9 100644
--- a/internal/runner/thin/engineer.go
+++ b/internal/runner/thin/engineer.go
@@ -669,6 +669,7 @@ func (e *Engineer) fromTree(r stepRow) string {
// specialistRun is one specialist launch: the action profile, the
// account, the pinned tools and how they are answered, and the prompt.
type specialistRun struct {
+ meterTurn string // Distinguishes separately charged calls within one Copy attempt.
action string
binding runner.AccountBinding
tools []any
diff --git a/internal/runner/thin/pistep.go b/internal/runner/thin/pistep.go
index 732be64f..04c4c313 100644
--- a/internal/runner/thin/pistep.go
+++ b/internal/runner/thin/pistep.go
@@ -65,7 +65,7 @@ func (e *Engineer) runPi(ctx context.Context, r stepRow, tree workspace.TaskTree
}
// The attempt runs on the model the choice bound (§16.5): the guard
// admits it only while that model is allowed and proven healthy.
- h := metered.Holder{Step: r.StepID, Attempt: r.Attempt, Role: meteredRole(spec.action), Model: b.Model}
+ h := metered.Holder{Turn: spec.meterTurn, Step: r.StepID, Attempt: r.Attempt, Role: meteredRole(spec.action), Model: b.Model}
var res stepResult
var priced []wire.Usage
var admit func(*sql.Tx) error
diff --git a/scripts/copy-contract.py b/scripts/copy-contract.py
index e8b62c00..372a5223 100644
--- a/scripts/copy-contract.py
+++ b/scripts/copy-contract.py
@@ -327,6 +327,23 @@ def classify(v):
subjects = [hashlib.sha256(stable.encode()).hexdigest()]
failures.append(dict(unit=units[0], test=name, code='failed',
subject=','.join(sorted(set(subjects))), category=category))
+ explained, pending, current_package = set(), False, None
+ for line in log.splitlines():
+ explicit = re.match(r'--- FAIL (\S+) (Test\S+)', line)
+ if explicit:
+ explained.add(explicit[1])
+ current_package = explicit[1]
+ if current_package is None and re.search(r'--- FAIL: Test\S+', line):
+ pending = True
+ package = re.match(r'\s*FAIL[ \t]+(\S+)', line)
+ if package:
+ if not pending and package[1] not in explained:
+ failures.append(dict(unit=units[0], test='package', code='failed', subject=package[1], category='other'))
+ if pending:
+ explained.add(package[1])
+ pending = False
+ if current_package == package[1]:
+ current_package = None
if re.search(r'panic:|build failed|undefined:', log):
failures.append(dict(unit=units[0], test='unclassified', code='other', subject='', category='other'))
else: