oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

Copy specialist and failed-check routing

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 dc62df5 was merged into this branch as b24a13f6; it still uses protocol 20 and migration 0080. This implementation retains protocol 21 and migration

  1. The implementation and review fixes await human review and release.

Engineering → Copy when delegated and needed → Checks → Review → the existing merge gate. Copy grants no merge or deployment authority. This tooling change is merged outside Equipo by the human controller, so it does not encounter its own pending-copy gate.

Delegation and wording

An owner enables Copy can accept on my behalf per project in Settings. The default is off. Store the authenticated delegating owner and a revision; no migration, repository comment, notebook or deployment enables it. Paul must enable it for oficina/equipo after release. Without delegation Copy does not run, including proposal and learning calls. Current roster, owner role, delegation revision, task revision and attempt are rechecked within each write transaction, at dispatch and before publication. Revocation prevents queued and already-running attempts from publishing.

House rules come from repository guidance at the trusted base. Equipo's AGENTS.md requires plain words, no em dashes and no exclamation marks. Other repositories retain their own rules. Exact owner wording and placeholders are preserved. When wording is uncertain, Copy accepts its best version and adds a flag to the task. Ambiguous meaning produces a question and blocks acceptance until answered. A wording flag does not block Checks or Review.

Detection and contract

Compare each Engineering candidate with the last accepted candidate for the task, or its original base. Detect value changes regardless of acceptance markers. A marker without a matching server-side Copy record for the key, text hash, input candidate and current delegation is pending. Engineering cannot mint those records. Record skipped detection too. Rebase and later edits invalidate affected acceptance.

The optional .equipo/copy.json version 1 contract declares app paths, exclusions, extraction, application, acceptance, regeneration and classifier commands as argument arrays. Resolve validated repository-relative paths; never assemble shell text from logs. Both the contract and the executable scripts are pinned to the trusted base while reading candidate files. Candidate changes cannot broaden their permissions. Commands have bounded input/output, a timeout, and the existing runner containment. No credential, general network access or unsandboxed fallback is available to Copy.

Extraction returns version, and strings: key, path, byte start/end of the literal contents, old text, new text, context and placeholder constraints. For Equipo it includes constants and runtime diagnostics in copy.go. The changed set is determined from values and locations, never markers. Contract Copy is one structured model call, without a worktree session: {"version":1,"strings":[{"key":"...","text":"...","action":"accept|question","flag":"..."}]}. The runner rejects duplicate/unknown keys, missing reviews, invalid actions, placeholder changes and oversized output. It applies final text through the base-pinned script. Tests change only by exact old-to-new string-literal replacement, not substring replacement or assertion edits. Only the runner invokes acceptance, after the pass, for the intersection of extracted changed keys and reviewed accepted keys, backed by the server-side record. The model cannot invoke acceptance or edit bookkeeping. Validate the entire final diff before brokered commit and publication against the expected branch head.

Without a contract, only delegated projects are inspected. V1 generic mode is flag-only. The runner reads only diffed files in the supported Go, JS, TS, JSX, TSX, JSON and HTML/template formats, excluding vendor, generated files, 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. 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.

A Copy commit becomes progress.candidate, rather than using eng.CandidateSHA after Copy. Old Checks and Review no longer count. No-edit acceptance remains bound to the existing candidate. Track all editing model families for Review independence, preserving Engineering's identity.

Bookkeeping and release

python3 scripts/copy-status.py pending|accept|regenerate|verify computes real text hashes and synchronises copy.go markers and the consolidated Plan 3 inventory. Application uses exact literal values in source and tests. Validate all keys and hashes before writes; use a recoverable journal for multi-file replacement. A repeat is a no-op. Preserve unrelated and historical rows. Acceptance requires the runner's reviewed record; pending never creates one. Release refuses pending text, stale hashes and missing inventory entries. Historical human acceptances remain valid for their unchanged text.

This implementation's UI strings receive the controller-authorised delegated pass and the exact marker COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) in copy.go and the Plan 3 inventory. Runtime Copy uses its actual reviewer and bound record, never impersonates this historical pass. Rewrite AGENTS.md's copy section for the pending → reviewed → runner acceptance sequence. README prose is unchanged. General reference-allow reconciliation is deferred. The scoped python3 scripts/reference-allow.py command takes explicit path, line numbers and owner reason as bounded JSON, computes exact hashes, and preserves all unrelated entries. Recovery accepts those inputs from the authenticated owner.

Failure classification and repair rounds

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 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.

Hosted evidence consists of at most 20 HostedResult.Failed unit names and the final 60 log lines. A base-pinned classifier command receives {"version":1,"units":["..."],"log":"...","truncated":true|false}. It returns {"version":1,"complete":true|false,"failures":[{"unit":"...","test":"...","code":"...","subject":"...","category":"copy|bookkeeping|other"}]}. Every failed unit must be represented. Unknown units or diagnostics become other; malformed output, missing units, truncated evidence or failed classification produces an incomplete signature. A bounded deterministic recheck may supply complete evidence; a log never authorises a command. The generic runner has no Equipo-specific test names. Equipo's script recognises only explicit copy/inventory failures; broad test-lane failures cannot be declared copy-only without complete diagnostic evidence.

Persist version, completeness, adapter identity, normalised sorted failure set, hash, source step/attempt and candidate. Stable identities include gate, test/subtest, diagnostic code and subject, excluding time, temporary roots, commit IDs and line drift. Before the second automatic repair, stop only if both signatures are complete, adapter-classified and equal. Unknown never equals unknown, including two empty sets. Review-driven changes-requested rounds retain the normal cap. Partial overlap does not cause early stop.

Persist RepairRound on the task, shared across Engineering, Copy and bookkeeping, initialised from recorded Engineering rounds. A normal Copy pass following Engineering is part of that round. Restart or switching roles never resets it. Two automatic repairs remain the normal cap. A complete copy-only failure schedules Copy; accepted wording with missing bookkeeping schedules scripts without a model. Complete bookkeeping-only failures use only declared commands with established inputs. Mixed/other failures go to Engineering. Judgement, repeated failures and exhausted limits use the existing task-linked coordinator path with evidence, attempts, candidates and a recommendation.

Normal mechanical repairs consume the existing daily automatic allowance of three as well as the task cap. Preserve housekeeping source snapshots, consumed keys and transaction guards, including cancelled, held, folded, ended or merging tasks, removed owners and paused automation. A transient Copy stop gets the existing single retry only after proven termination. Terminal Copy failures and pre-launch budget holds expose Continue without Copy to the task creator. That authenticated decision is bound to the current candidate; it resumes Checks/Review without granting string acceptance. Disabling delegation withdraws queued Copy and releases waiting tasks. Started work is cancelled and must prove termination before the next step. Stale delegation at reconnect is a withdrawal, never a runner connection error. A repeated-failure round action requires the newest step to be done, so a second tap cannot queue another round.

Learning and limits

Only the delegating owner's own authenticated edits made in Equipo teach Copy. Imported copy-review results are submitted by that same authenticated owner through a bounded JSON import: version:1, stable source_id, and strings containing key, original text, final text and optional reason. 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, 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, commit-author or notebook inference supplies teaching evidence.

Store exact before/after examples and reasons in an owner/repository Copy feedback ledger, separate from coordinator and Assistant notes. V1 derives its notebook directly from those verified examples and makes no inferred rules or compaction model calls. Notes cannot grant authority. The notebook view is bounded at 40 entries, 400 bytes each and 6 KiB, within the existing 12 KiB notebook ceiling. Lookup errors deny dispatch; they never become an empty notebook. Notebook inspect/clear UI is deferred.

Before including learned examples, check housekeeping’s existing 37,500-token reservation against its shared four-turn/150,000-token daily budget. When turns or tokens are spent, or housekeeping is paused, leave new examples pending and keep reading the already learned notebook. Promotion is recorded once on each source event, scoped to its owner and repository. V1 reads verified edits directly, so it charges no learning model tokens or turns. An explicit owner correction on the current task is an instruction and applies even while notebook learning is deferred. Copy reviews use cheap/standard models, with a hard standard ceiling for both subscription and metered connections. No fallback above the ceiling. Default 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 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 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 to input/output; other providers include cache reads in input already. Unknown usage is charged as a full pass, allowing the remaining task budget to be used. A complete valid review is retained even on overrun or missing usage. Actual overruns remain charged. Script-only bookkeeping has no model spend.

Protocol, migration and rollout

ProtocolCopy is 21; app migration 0081 is additive and registered in Models and Schema. The runner uses idempotent additive schema statements, with no numbered migration sequence. Its new copy_attempts table preserves per-attempt usage and the structured result across restart and downgrade. Wire data binds comparison, review hashes, delegation revision, budget remainder and failure evidence to runner/task/step/attempt. Old peers never receive Copy disguised as Engineering and cannot silently lose required acceptance data. Review dispatch drops AvoidFamilies below protocol 21. Hold Copy steps until both peers support Copy, including after reconnect. Existing undelegated work continues on old peers.

No migration grants delegation or acceptance. Preserve existing repair counts and unknown signatures. Copy runs on the task’s existing primary runner, with the project’s delegating owner recorded separately; this preserves branch-publication ownership in teams with several owners. Deploy scripts and guards, then compatible runners and instance, then Paul enables the project setting in Settings. For downgrade, turn delegation off first and settle affected tasks as cancelled or merged. Then stop runners and run the previous version with additive columns/tables retained. Older instances do not enforce Copy, so do not downgrade the instance with pending Copy work. Never drop review, feedback, recovery or budget history.

Owner-triggered recovery

After the versioned release, Paul enables delegation and explicitly requests one recovery action per exact task ID and current candidate. This one-off is exempt from the daily automatic-round allowance. The same recovery key may retry a failed, terminated attempt, but cannot duplicate an active or successful attempt. It can run after the normal task cap. Persist a durable recovery key and preserve old round/spend history. Re-fetch current heads and checks; only complete copy/bookkeeping-only failures qualify. Unknown or truncated results remain held for judgement. For retained references the owner supplies exact paths, line numbers and reasons in the recovery form. No model or log supplies reference approval. Rebase legacy branches onto the reviewed tooling revision, resolving copy.go bookkeeping conflicts by extracting final literal values and regenerating markers/inventory with the pinned scripts. A conflict in product meaning asks the owner. Never run candidate-supplied recovery scripts.

| Task prefix (resolve to exact ID before acting) | Recovery | | --- | --- | | tk25j65kpelv, tkizl6frmnij, tknitqeua7yy | Reconfirm copy-only evidence, review strings, regenerate records, then fresh Checks and Review | | tk3j4tcivyrx | Reconfirm bookkeeping-only evidence and exact retained references; scoped repair, then fresh Checks and Review | | tkplvk6zce6q | Real conversation 500 still needs Engineering | | tkataquuxfrw | Real headless failures still need Engineering |

These are supplied observations, not fresh diagnoses. Never operate by prefix or recover mixed failures automatically. Merge remains the existing human policy. This branch is pushed and reviewed, never merged by its implementer.

Verification

Tests first, each observed failing before implementation. Mutate and restore guards for forged acceptance, out-of-scope edits, unknown-equals-unknown, non-owner learning and disabled delegation. Target browser checks at the setting and flagged-wording task card. Cover structured output, placeholders, trusted-base commands, recovery idempotence, shared rounds, candidate changes, model ceilings, interrupted bookkeeping, protocol mixed versions and additive migration/downgrade. Only targeted Go and browser tests run locally; hosted CI runs the rest. Run budget, dead-reference, lanes and copy-release checks. Record exact commands, failures, restored passes, CI SHA and recovery steps in ../report2.md and poll hosted CI to completion after pushing.