oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Copy specialist and failed-check routing
2
3Status: revised for Fable's code review of `099e42ba` and the controller's
4v1 generic-mode decision, 2026-11-13. Paul's rulings R1–R4 remain in force.
5Main `dc62df5` was merged into this branch as `b24a13f6`; it still uses protocol
620 and migration 0080. This implementation retains protocol 21 and migration
70081. The implementation and review fixes await human review and release.
8
9Engineering → Copy when delegated and needed → Checks → Review → the existing
10merge gate. Copy grants no merge or deployment authority. This tooling change
11is merged outside Equipo by the human controller, so it does not encounter
12its own pending-copy gate.
13
14## Delegation and wording
15
16An owner enables **Copy can accept on my behalf** per project in Settings.
17The default is off. Store the authenticated delegating owner and a revision;
18no migration, repository comment, notebook or deployment enables it. Paul
19must enable it for oficina/equipo after release. Without delegation Copy does
20not run, including proposal and learning calls. Current roster, owner role,
21delegation revision, task revision and attempt are rechecked within each
22write transaction, at dispatch and before publication. Revocation prevents
23queued and already-running attempts from publishing.
24
25House rules come from repository guidance at the trusted base. Equipo's
26AGENTS.md requires plain words, no em dashes and no exclamation marks. Other
27repositories retain their own rules. Exact owner wording and placeholders
28are preserved. When wording is uncertain, Copy accepts its best version and
29adds a flag to the task. Ambiguous meaning produces a question and blocks
30acceptance until answered. A wording flag does not block Checks or Review.
31
32## Detection and contract
33
34Compare each Engineering candidate with the last accepted candidate for the
35task, or its original base. Detect value changes regardless of acceptance
36markers. A marker without a matching server-side Copy record for the key,
37text hash, input candidate and current delegation is pending. Engineering
38cannot mint those records. Record skipped detection too. Rebase and later
39edits invalidate affected acceptance.
40
41The optional `.equipo/copy.json` version 1 contract declares app paths,
42exclusions, extraction, application, acceptance, regeneration and classifier
43commands as argument arrays. Resolve validated repository-relative paths;
44never assemble shell text from logs. Both the contract and the executable
45scripts are pinned to the trusted base while reading candidate files.
46Candidate changes cannot broaden their permissions. Commands have bounded
47input/output, a timeout, and the existing runner containment. No credential,
48general network access or unsandboxed fallback is available to Copy.
49
50Extraction returns `version`, and `strings`: key, path, byte start/end of the
51literal contents, old text, new text, context and placeholder constraints.
52For Equipo it includes constants and runtime diagnostics in copy.go. The
53changed set is determined from values and locations, never markers.
54Contract Copy is one structured model call, without a worktree session:
55`{"version":1,"strings":[{"key":"...","text":"...","action":"accept|question","flag":"..."}]}`.
56The runner rejects duplicate/unknown keys, missing reviews, invalid actions,
57placeholder changes and oversized output. It applies final text through the
58base-pinned script. Tests change only by exact old-to-new string-literal
59replacement, not substring replacement or assertion edits. Only the runner
60invokes acceptance, after the pass, for the intersection of extracted changed
61keys and reviewed accepted keys, backed by the server-side record. The model
62cannot invoke acceptance or edit bookkeeping. Validate the entire final diff
63before brokered commit and publication against the expected branch head.
64
65Without a contract, only delegated projects are inspected. V1 generic mode is
66flag-only. The runner reads only diffed files in the supported Go, JS, TS,
67JSX, TSX, JSON and HTML/template formats, excluding vendor, generated files,
68comments, tests and docs. Unsupported file types are skipped. The deterministic
69quoted-literal heuristic supplies possible wording, which can include technical
70strings. Copy returns suggestions on the task card. It cannot edit or publish
71files, update tests or bookkeeping, or establish acceptance records in this mode.
72A generic extraction error skips that file's suggestions and does not fail the step. Empty detections
73skip the model. Generic suggestions use the same empty model workspace and
74structured review format as contract reviews.
75
76A Copy commit becomes `progress.candidate`, rather than using
77`eng.CandidateSHA` after Copy. Old Checks and Review no longer count. No-edit
78acceptance remains bound to the existing candidate. Track all editing model
79families for Review independence, preserving Engineering's identity.
80
81## Bookkeeping and release
82
83`python3 scripts/copy-status.py pending|accept|regenerate|verify` computes real
84text hashes and synchronises copy.go markers and the consolidated Plan 3
85inventory. Application uses exact literal values in source and tests. Validate
86all keys and hashes before writes; use a recoverable journal for multi-file
87replacement. A repeat is a no-op. Preserve unrelated and historical rows.
88Acceptance requires the runner's reviewed record; pending never creates one.
89Release refuses pending text, stale hashes and missing inventory entries.
90Historical human acceptances remain valid for their unchanged text.
91
92This implementation's UI strings receive the controller-authorised delegated
93pass and the exact marker `COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)` in
94copy.go and the Plan 3 inventory. Runtime Copy uses its actual reviewer and
95bound record, never impersonates this historical pass. Rewrite AGENTS.md's
96copy section for the pending → reviewed → runner acceptance sequence. README
97prose is unchanged. General reference-allow reconciliation is deferred. The scoped
98`python3 scripts/reference-allow.py` command takes explicit path, line numbers
99and owner reason as bounded JSON, computes exact hashes, and preserves all
100unrelated entries. Recovery accepts those inputs from the authenticated owner.
101
102## Failure classification and repair rounds
103
104The runner fetches the full logs of failed units from the exact SHA and CI run
105observed by Checks, up to the adapter's 2 MiB JSON input limit. Sharded steps use
106their failed shards' logs, never aggregate logs containing successful retries.
107A hosted 60-line display tail is not evidence truncation. Local evidence reaching
108200 lines or 32 KiB is conservatively incomplete. A package-level FAIL without
109an associated named test is classified as other. Set incomplete only when
110units or evidence were actually cut, or the run changed or could not be read.
111The adapter accounts for each failed unit separately, including the reference
112scan command and its matching test. Unclassified evidence remains other.
113
114Hosted evidence consists of at most 20 `HostedResult.Failed` unit names and
115the final 60 log lines. A base-pinned classifier command receives
116`{"version":1,"units":["..."],"log":"...","truncated":true|false}`.
117It returns `{"version":1,"complete":true|false,"failures":[{"unit":"...","test":"...","code":"...","subject":"...","category":"copy|bookkeeping|other"}]}`.
118Every failed unit must be represented. Unknown units or diagnostics become
119`other`; malformed output, missing units, truncated evidence or failed
120classification produces an incomplete signature. A bounded deterministic
121recheck may supply complete evidence; a log never authorises a command.
122The generic runner has no Equipo-specific test names. Equipo's script
123recognises only explicit copy/inventory failures; broad test-lane failures
124cannot be declared copy-only without complete diagnostic evidence.
125
126Persist version, completeness, adapter identity, normalised sorted failure
127set, hash, source step/attempt and candidate. Stable identities include gate,
128test/subtest, diagnostic code and subject, excluding time, temporary roots,
129commit IDs and line drift. Before the second automatic repair, stop only if
130both signatures are complete, adapter-classified and equal. Unknown never
131equals unknown, including two empty sets. Review-driven changes-requested
132rounds retain the normal cap. Partial overlap does not cause early stop.
133
134Persist `RepairRound` on the task, shared across Engineering, Copy and
135bookkeeping, initialised from recorded Engineering rounds. A normal Copy pass
136following Engineering is part of that round. Restart or switching roles never
137resets it. Two automatic repairs remain the normal cap. A complete copy-only
138failure schedules Copy; accepted wording with missing bookkeeping schedules
139scripts without a model. Complete bookkeeping-only failures use only declared
140commands with established inputs. Mixed/other failures go to Engineering.
141Judgement, repeated failures and exhausted limits use the existing task-linked
142coordinator path with evidence, attempts, candidates and a recommendation.
143
144Normal mechanical repairs consume the existing daily automatic allowance of
145three as well as the task cap. Preserve housekeeping source snapshots,
146consumed keys and transaction guards, including cancelled, held, folded,
147ended or merging tasks, removed owners and paused automation. A transient
148Copy stop gets the existing single retry only after proven termination. Terminal
149Copy failures and pre-launch budget holds expose Continue without Copy to the
150task creator. That authenticated decision is bound to the current candidate;
151it resumes Checks/Review without granting string acceptance. Disabling delegation
152withdraws queued Copy and releases waiting tasks. Started work is cancelled and
153must prove termination before the next step. Stale delegation at reconnect is
154a withdrawal, never a runner connection error. A repeated-failure round action
155requires the newest step to be done, so a second tap cannot queue another round.
156
157## Learning and limits
158
159Only the delegating owner's own authenticated edits made in Equipo teach
160Copy. Imported copy-review results are submitted by that same authenticated
161owner through a bounded JSON import: `version:1`, stable `source_id`, and
162`strings` containing key, original text, final text and optional reason.
163Validate the before/after association to that owner's Copy record and dedupe
164by owner, repository and source ID. The same import also accepts approved
165copy-review result.json files with id/original/text/edited/done/rerolled entries.
166Only completed human edits are imported; model rerolls and unchanged strings
167are excluded, and legacy entries over the 400-byte example limit are skipped
168without rejecting the other edits. The imported Before is the reviewed original, so historical
169results do not require a server-side Copy record that did not yet exist. A
170stable content identity deduplicates each result. Reject imports and edit events from other
171owners or members; never trust an owner ID in the payload. No forge-diff,
172commit-author or notebook inference supplies teaching evidence.
173
174Store exact before/after examples and reasons in an owner/repository Copy
175feedback ledger, separate from coordinator and Assistant notes. V1 derives
176its notebook directly from those verified examples and makes no inferred
177rules or compaction model calls. Notes cannot grant authority. The notebook
178view is bounded at 40 entries, 400 bytes each and 6 KiB, within the existing
17912 KiB notebook ceiling. Lookup errors deny dispatch; they never become an
180empty notebook. Notebook inspect/clear UI is deferred.
181
182Before including learned examples, check housekeeping’s existing
18337,500-token reservation against its shared four-turn/150,000-token daily
184budget. When turns or tokens are spent, or housekeeping is paused, leave new examples
185pending and keep reading the already learned notebook. Promotion is recorded
186once on each source event, scoped to its owner and repository. V1 reads verified edits directly, so it charges no learning
187model tokens or turns. An explicit owner correction on the current task is
188an instruction and applies even while notebook learning is deferred.
189Copy reviews use cheap/standard models, with a hard standard ceiling for both
190subscription and metered connections. No fallback above the ceiling. Default
191structured-call limits are 32,768 tokens and five minutes per pass, and 98,304
192per task across attempts. Before model admission, include only AGENTS.md's Copy
193section and estimate the complete request, tool schema and response. The
194conservative estimate counts one token per byte, 4,096 tokens for provider
195framing, and comparable reply text plus 160 bytes per key. The checked baseline fixture
196contains 56 actual app strings: 12,028 prompt bytes and a 28,554-token estimate.
197The pass limit leaves 4,214 tokens above that estimate; the task limit allows
198three full-pass allowances. Larger string sets are split into structured calls
199that each fit the per-pass estimate. The complete batch must fit the remaining
200task allowance before launch, and measured spend is checked before each next
201call. Reviewed wording is applied only after the entire review is complete. A batch that
202cannot fit stops with the token-allowance reason and Continue without Copy. These are estimates, not a promise about the model's exact tokenization.
203
204Measured accounting matches the Usage page's `rowSpend` in
205`internal/equipo/chat/connections.go`: Claude adds separate cache reads and writes
206to input/output; other providers include cache reads in input already. Unknown
207usage is charged as a full pass, allowing the remaining task budget to be used.
208A complete valid review is retained even on overrun or missing usage. Actual
209overruns remain charged. Script-only bookkeeping has no model spend.
210
211## Protocol, migration and rollout
212
213ProtocolCopy is 21; app migration 0081 is additive and registered in Models
214and Schema. The runner uses idempotent additive schema statements, with no numbered
215migration sequence. Its new `copy_attempts` table preserves per-attempt
216usage and the structured result across restart and downgrade. Wire data binds comparison, review hashes, delegation revision,
217budget remainder and failure evidence to runner/task/step/attempt. Old peers
218never receive Copy disguised as Engineering and cannot silently lose required
219acceptance data. Review dispatch drops AvoidFamilies below protocol 21. Hold Copy steps until both peers support Copy, including
220after reconnect. Existing undelegated work continues on old peers.
221
222No migration grants delegation or acceptance. Preserve existing repair counts
223and unknown signatures. Copy runs on the task’s existing primary runner,
224with the project’s delegating owner recorded separately; this preserves
225branch-publication ownership in teams with several owners. Deploy scripts and guards, then compatible runners
226and instance, then Paul enables the project setting in Settings. For downgrade,
227turn delegation off first and settle affected tasks as cancelled or merged.
228Then stop runners and run the previous version with additive columns/tables
229retained. Older instances do not enforce Copy, so do not downgrade the instance
230with pending Copy work. Never drop review, feedback, recovery or budget history.
231
232## Owner-triggered recovery
233
234After the versioned release, Paul enables delegation and explicitly requests
235one recovery action per exact task ID and current candidate. This one-off is
236exempt 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
237task cap. Persist a durable recovery key and preserve old round/spend history.
238Re-fetch current heads and checks; only complete copy/bookkeeping-only failures
239qualify. Unknown or truncated results remain held for judgement. For retained
240references the owner supplies exact paths, line numbers and reasons in the
241recovery form. No model or log supplies reference approval. Rebase legacy branches onto the reviewed tooling revision, resolving
242copy.go bookkeeping conflicts by extracting final literal values and
243regenerating markers/inventory with the pinned scripts. A conflict in product
244meaning asks the owner. Never run candidate-supplied recovery scripts.
245
246| Task prefix (resolve to exact ID before acting) | Recovery |
247| --- | --- |
248| tk25j65kpelv, tkizl6frmnij, tknitqeua7yy | Reconfirm copy-only evidence, review strings, regenerate records, then fresh Checks and Review |
249| tk3j4tcivyrx | Reconfirm bookkeeping-only evidence and exact retained references; scoped repair, then fresh Checks and Review |
250| tkplvk6zce6q | Real conversation 500 still needs Engineering |
251| tkataquuxfrw | Real headless failures still need Engineering |
252
253These are supplied observations, not fresh diagnoses. Never operate by prefix
254or recover mixed failures automatically. Merge remains the existing human
255policy. This branch is pushed and reviewed, never merged by its implementer.
256
257## Verification
258
259Tests first, each observed failing before implementation. Mutate and restore
260guards for forged acceptance, out-of-scope edits, unknown-equals-unknown,
261non-owner learning and disabled delegation. Target browser checks at the
262setting and flagged-wording task card. Cover structured output, placeholders,
263trusted-base commands, recovery idempotence, shared rounds, candidate changes,
264model ceilings, interrupted bookkeeping, protocol mixed versions and additive
265migration/downgrade. Only targeted Go and browser tests run locally; hosted CI
266runs the rest. Run budget, dead-reference, lanes and copy-release checks.
267Record exact commands, failures, restored passes, CI SHA and recovery steps in
268`../report2.md` and poll hosted CI to completion after pushing.
269