Skip to content

Latest commit

 

History

History
270 lines (242 loc) · 56.6 KB

LESSONS.md

File metadata and controls

270 lines (242 loc) · 56.6 KB

LESSONS: what v0 taught us, one row per incident

Purpose: record every concrete failure observed while running dev.factory v0 (CHANGELOG, DESIGN, five handoffs, the provider-agnostic design notes) so the v1 rewrite ports the learning, not the code.

How v1 uses it: every v1 feature cites an L-nn from this file or a real ticket need. A feature with neither does not enter. Every test row becomes a v1 test that fails without the rule. by-design rows need no code: the new design removes the failure class. Owner decision at M0: the alpha keeps every v0 capability, so no row is deferred (the former out-of-alpha rows were redesigned; see docs/parity-map.md).

Origin shorthand: CL = v0 CHANGELOG entry (the Unreleased section is cited by title); DS §n = v0 DESIGN section; H1 = Handoffs/2026-11-13-falhas-observadas-lote-escopos (item #); H2 = Handoffs/2026-11-23-analise-runs; H3 = Handoffs/2026-11-24-pendencias-pos-agnosticidade; H4 = Handoffs/real-run-C-sessao-principal (item #); H5 = Handoffs/real-run-D-sessao-principal; PA = docs/design/provider-agnostic.md and docs/research/2026-11-23-providers-e-instalacao-unificada.md; run NNNN = a real run.

Neutral vocabulary is deliberate: tracker, SCM, change request, design source, MCP server.

A. Proof integrity (evidence, gates, binding)

id origin concrete failure v1 destination
L-01 DS intro; v0 effectiveness audit 2026-11-12 An AC was passed from reading code, with no executed check behind it (the main escape path of the predecessor). test: gate verify fails for an AC that has no pass evidence record from verify.
L-02 CL "Collectors" (fail fast, DS §13) A test or red-green check that ran zero tests ("No tests found", "collected 0 items") was recorded as pass. test: a cmd check whose output matches a zero-tests marker is setup, never pass.
L-03 DS §0, §2.6 A setup failure (exit 126/127/9009, "command not found", "Cannot find module", "No such file or directory", localized shell errors) was taken as the expected reproduction failure. test: setup markers and exit codes 126/127 are setup, and reproduce never counts setup as reproduced.
L-04 DS §2.6 An expect_fail_pattern such as ., .* or \w+ matched any failure, so any breakage "reproduced" the bug. test: the plan gate rejects a pattern under 6 characters or with fewer than 4 literal word characters.
L-05 DS §2.3, §2.6 A non-zero exit whose output lacked the expected failure text was still recorded as a reproduction. test: failure without expect_pattern match is setup/error, not reproduced.
L-06 DS §2.1 (quality.setup) A failing worktree restore command (dependency install) was read as the check failing for the right reason. test: a failing worktree setup command is an error that blocks the check, never a reproduction.
L-07 DS §2.4 Evidence collected on a dirty worktree (untracked files count) could pass while not matching committed code. test: evidence from a dirty worktree is recorded but never satisfies gate verify (clean worktree is mandatory).
L-08 DS §0, §2.6 A proof or review stayed valid after a later commit (stale proof carried past a change). test: gate verify needs a pass at the current HEAD of every affected repo; a new commit invalidates it.
L-09 CL "Fast verification" (check digest) Evidence stayed valid after the check spec or a file it reads was edited. test: evidence carries the check-spec hash and is stale when it differs from the locked hash.
L-10 CL "Fast verification"; real run B 54 checks spent 21.8 h in prove, with passing checks re-run 15-20 times at the same SHA. test: same SHA + same spec hash + an existing pass is reused, not re-run.
L-11 CL "Fast verification"; real run B A newly added check ran last and failed after 27 minutes, after everything else had been re-run. test: verify orders checks last-failed first, then new or changed, then cheapest type first.
L-12 CL "Fast verification" (run_heads) A runtime check's pass was reused although another repo it exercised had a new HEAD. test: evidence of a runtime check records the HEAD of every repo served; reuse requires all unchanged.
L-13 DS §14 (--fast, hot_reload) A pass from a fast mode, or from a hot-reloading dev server that nobody proved had reloaded, was accepted as final. test: evidence records the SHA the served process was started at; a mismatch is an error, and there is no weaker evidence mode that gates accept.
L-14 DS §14 (flaky) A browser assertion failed, passed on retry, and the result was either lost or counted as a clean pass. test: a retry that passes is recorded as flaky with both attempts in the events, and is never silently a clean pass.
L-15 CL "evidence history"; real run D evidence/<id>.json was overwritten on every attempt, losing the earlier failure of a check that passed alone. by-design: evidence records are append-only lines in the run's events.jsonl.
L-16 DS §2.6 digests; DS §0 residual risk Evidence could be hand-written and a matching digest event appended through a script, and every gate accepted it. by-design: the record is bound to check-spec hash, SHA and clean worktree and produced only by verify; v1 states the residual risk (cooperative model) and offers CI as optional extra authority instead of a digest chain.
L-17 DS §0 "Future work"; CL guard entries Local files writable by the orchestrator can never be tamper-proof; v0 spent six audit rounds trying to make them so. by-design: trust by binding evidence to what was proved, not by guarding writes (threat model unchanged, guards removed).
L-18 DS §2.5, §2.6 A review stayed in force after the plan or the code changed. test: a review records SHA and plan hash; gate review and gate ship re-check both.
L-19 AGENTS anti-patterns; DS §3 gates A green pipeline was treated as proof of an AC or a fix. test: ACs are proved only by verify records; a pipeline result is only the optional extra gate ship condition.
L-20 DS §3 feedback gate A pipeline waiver did not say which pipeline it covered, so it could cover a later red one. test: a waiver must name the pipeline id and carry the user's words, and stops covering after a new pipeline.
L-21 PA §3 contracts; DS §0 A remote fact used as proof (green pipeline, readback) came from a payload the agent wrote by hand. test: a contract used as proof needs source: adapter or a recorded user confirmation; source: agent is accepted only for ticket text.
L-22 DS §2.5 (qa ac_coverage) A check that could not fail (asserted nothing about its AC) was accepted by the QA review. test: review record is refused unless every AC has an explicit exercises entry, and exercises: false cannot be approved.
L-23 DS §2.5 A review approved with gaps, not-checked items or major findings. test: review record rejects APPROVE with gap > 0, not_checked > 0 or any blocker/major finding.
L-24 H1 #10 (run 8342) A human-only check counted as not_checked, so QA said CHANGES, the review loop hit its cap and the run blocked twice on one check. test: a human check is satisfied only by factory confirm --user-said bound to the current SHAs (a new commit asks again), never alone satisfies a bug or design AC, and is listed in the ship body.
L-25 DS §2.4 The dirty check could not see files hidden by .git/info/exclude or a global ignore file. by-design: accepted residual risk of the cooperative threat model, documented, not guarded.
L-26 H2 backlog; H3 §6 No test ever drove a run from intake to done/report through the gates, so gate wiring regressions went unseen. test: one end-to-end test drives a fixture run intake to ship purely through factory next.

B. Bugs: reproduction and red-green

id origin concrete failure v1 destination
L-27 CL "first reproduction attempt uses the ticket's own scenario"; runs 16-23 Nov; H5 Reproduction used a synthetic scenario while the ticket described another user, entity and data shape; one run lost about 2 h, another was abandoned. test: gate reproduce requires diagnosis.md to carry a scenario section that states "ticket scenario used" or lists each deviation with its reason.
L-28 CL "ticket media"; runs 16-23 Nov; H5 (video analysed only after the user downloaded it) Reproduction ignored the ticket's own screenshots and videos. test: gate intake fails for every media attachment of the ticket contract not recorded as seen (with file) or as unseen with an open question naming it.
L-29 CL "intake-skill-metrics review" (probe_media) Media matching broke on Image/PNG or application/octet-stream mimes, on manifest.json used as an entry's file, on two same-named attachments sharing one entry, and on any resolved question that merely contained the file name. test: media entries are matched by attachment id, mime is case-normalized (extension when missing), one file per entry, and an unseen entry needs a question that names attachment:<id>.
L-30 CL "ticket media"; H2 backlog A video or unfetchable file was summarised from its name; also the gate proves a file exists, not that anyone looked at it. by-design: unseen media forces a question to the user (test in L-28); that someone actually viewed a file is an accepted residual of the cooperative model.
L-31 H4 #1 (real run C) A bug ticket started as a feature (type not derived from the tracker), so reproduce and red-green were skipped; the run was archived and recreated twice. test: run kind comes from the ticket contract type; a bug-typed ticket in a feature run fails gate intake.
L-32 H4 #1; CL run retype Changing a run's type required deleting and recreating the run and hand-recovering drafts from a zip. by-design: type is fixed at intake before any lock exists; changing it re-runs gate intake, nothing is archived.
L-33 DS §8 A bug AC had no failing check on the unfixed code, so the "fix" was never shown necessary. test: gate reproduce requires every bug AC to have a check that fails on the base worktree with its expected pattern.
L-34 DS §8 red-green The red side ran on the fix tree, or the test file existed only in the run dir, so the proof tested something other than the delivered code. test: red-green runs the check at fix_commit~1 (with test files from the fix commit) and at fix_commit, and must fail then pass.
L-35 H4 #6 (real run C) The red-green cmd copied a test file from the run folder into the base worktree; the committed file could diverge so the check tested the run file, not the delivered code. test: test files for the red side come from git (test_files in the fix commit), never from files copied out of the run directory.
L-36 H5 item 4; CL "prove --repro after the fix is committed" After a check-only replan the runtime repro needed a clean worktree at the merge-base, forcing a manual git checkout --detach in the run worktree. by-design: reproduce always runs against a throwaway worktree of the base, never the run worktree.
L-37 CL "repro never reports success with the env left down" prove --repro exited 0 after stopping the run's own env to serve the base and failing to start it again. test: any failure to restore the env after reproduce exits non-zero with an env-kind reason.
L-38 DS §8 diagnosis.md Fixes started without a stated root cause, evidence and ruled-out causes. test: gate reproduce requires non-empty ## Root cause, ## Evidence, ## Ruled out in diagnosis.md.
L-39 H5 item 5; CL "builders never change product behaviour to fit a check" A builder raised a toast duration from 5 s to 20 s so a check's timing would pass, and it reached the review. test: review record requires a changed-values scan field (durations, timeouts, retries, flags, copy changed in the diff, each justified) and is refused without it.
L-40 H5 item 6; CL env.warmup The first browser check of a batch failed on a cold dev server and passed alone, so a bug looked like a product failure. test: [repo.env] warmup paths are requested once after env up; a failure is env kind warmup, not a product failure.
L-41 H5 "Pendência principal"; real run D Reproduction at the mirror target only ran test checks, runtime checks only on the base target. test: verify --mirror runs every mirror: true check, runtime included, served from the mirror worktree.

C. Check execution (cmd, http, browser)

id origin concrete failure v1 destination
L-42 CL "Fail fast and recovery"; DS §13 Browser checks ran with 360 s test and 180 s network-idle waits, so one broken check burned minutes. test: every check has a wall-clock cap (per-check timeout_s, else a project default) after which it is killed and recorded timeout.
L-43 DS §13 "per-check cap" On timeout only the parent process died; child processes (dev server, browser) stayed alive. test: a timeout kills the whole process tree, on Windows too.
L-44 H3 §5; H2 §6 (test_install_snapshot) A test spawning the CLI with stdin open hung on Windows for 12 hours and blocked a merge. test: every child process spawned by the CLI gets stdin closed (devnull), and every test has a hard timeout.
L-45 H4 #7 (real run C) A test runner printed localized words ("Com falha", "Aprovado"), so patterns like Failed never matched. test: child commands run with a forced English locale, and expect_pattern is secondary to the exit code.
L-46 DS §13 "Env failures stop the batch" After the env died, the remaining runtime checks each waited for their own timeout. test: an env-kind failure marks the repo's remaining runtime checks skipped: env and exits with a distinct code.
L-47 DS §13 Identical failures repeated until every check had failed the same way. test: two consecutive failures with the same kind and first line stop the runtime batch.
L-48 DS §13 (machine-readable lines) Agents parsed prose to tell a product failure from an infra one and retried the wrong thing. test: verify exit codes separate pass (0), check failure (1), usage (2) and env failure (3), and --json carries kind.
L-49 DS §14 (ENV_BODY_CLASSES); H5 item 3 A degraded database made the API answer 500 "SSL Authentication Error" and it looked like a product bug. test: [repo.env] env_patterns that match an http or browser failure output turn the result into kind env.
L-50 CL "env data preflight" ; H5 item 3 Test projects expired in the nightly dump, and the resulting 500 looked like infra. test: preflight commands run after health (failure kind data); seed/reset run with the run-derived data prefix, and verify resets once before the runtime batch.
L-51 H1 #7; CL "adapter" visual/style could only load a static route; open drawers, popovers, toasts and drag states were unreachable. test: a visual or style check may name a state_spec that the runner executes before capture or probe, so a drawer, popover or toast state is reachable.
L-52 H1 #8 The api check made one request with no session, so authenticated endpoints could not be checked. test: an http check with session sends the headers that login_http produced, kept in memory only and never written to evidence.
L-53 H1 #9; H4 #10 No way to check SQL/data-dependent behaviour; permissions scripts and a data-driven root cause stayed "not verified". by-design: v0 had no sql check either; a cmd check runs any read-only query script, so no check type is needed.
L-54 CL "Style probe" A style check passed with an empty expected text, and an expected borderWidth > 0 passed against a missing border. test: the style probe fails an empty expected text, an expected borderWidth > 0 against a missing border, and a computed normal line height.
L-55 CL "visual crops the design png" A visual diff failed from the shadow margin of an exported design image. test: the design PNG is cropped to the node box using render_box and effect margins before the pixel diff, so an export's shadow margin does not count.
L-56 CL "Visual evidence on request"; DS §12 The screenshot-on-request flow (before/after images, user question at plan) added a gate, a check type and a ship table. test: a screenshot check is artifact-only (before on base in reproduce, after at HEAD in verify), never satisfies an AC, and is listed in the ship body.
L-57 CL "batched browser checks"; DS §14 Each browser spec booted the runner and reloaded login state (20-40 s of overhead, about 30 checks per run). test: the runner batch runs a repo's browser, visual and style checks in one browser with a per-entry timeout and result; one failing entry does not stop the others.
L-58 H1 #13; CL "Files generated under checks/" A screenshot written by a spec under checks/ counted as "plan files changed" and forced a replan. test: the plan lock hashes only declared spec files; check output goes to the evidence directory.
L-59 CL "Collectors" (expect_timeout_ms) A slow remote database made assertion timeouts fire too early; the cap was tuned by editing the check. test: the assertion timeout is per-check configuration with a default and it is part of the locked spec hash.
L-60 CL "scoped quality" (quality_fast) Full quality commands ran on every prove although only changed files mattered. test: a quality check's scoped template receives {changed_files} from branch_point..HEAD, and the full command still runs before gate review.
L-61 H1 #15; CL "evidence history"; H3 §6 A flaky base test made the baseline record 0 failures, so each flake became "1 new failure" and prove had to be repeated up to three times. test: factory baseline runs a quality check up to 3 times at branch_point and quarantines unstable failure ids; only new stable ids fail verify.
L-62 CL "Quality delta" Absolute worktree paths in failure ids made baseline errors look new in the run worktree. test: quality failure ids are normalized (worktree paths stripped) before the baseline comparison.
L-63 H1 #16 QUALITY-<repo> and rule checks could not be run alone, so per-check proving skipped them. by-design: v1 verify --check <id> runs any declared check; quality commands are ordinary cmd checks.

D. Environment and runtime

id origin concrete failure v1 destination
L-64 H1 #4; H5 item 1; CL env.files_from_main A new worktree had no gitignored .env and every page answered 500, which blocked an author. test: env.files_from_main copies listed files into new worktrees, and env up fails with kind files when one is missing.
L-65 CL "files_from_main never writes outside the worktree" (review, junction case) The copy followed a junction in a worktree directory and landed outside it; a copied file could also be one git add -A away from a commit. test: the copy refuses links/reparse points, out-of-worktree destinations and non-regular sources, and removes a copy that is not gitignored.
L-66 H5 item 2; CL "env log capture on Windows" The env log stayed empty because a console-less cmd.exe shim dropped the redirected output of the process it spawned. test: an env started through a .cmd shim chain on Windows produces a non-empty log (hidden-console creation, unbuffered env vars).
L-67 H1 #23; H5 item 2 A dependency server (a local web server) and an orphan dev server stayed up after the starter exited. by-design: the factory records the process group it started and stops exactly that group on env down.
L-68 DS §13 "process safety"; CL "env pid create time" env down could kill an unrelated process that reused a recorded pid, or the factory's own ancestors. test: the pid record stores create time; a pid whose create time differs or cannot be read is reported and never killed.
L-69 H1 #5; DS §13 The running env served another run's or the main checkout's code, so runtime evidence came from the wrong tree. test: runtime checks require the served process's recorded path and SHA to match the checked worktree HEAD, else error (stale), with one restart attempt.
L-70 CL "env up refuses unknown server" env up assumed success because something already answered the health URL. test: env up fails when the health URL answers before the factory started anything on that port.
L-71 H1 #3 env up --run started the dependency API from the main checkout, on an unrelated branch, so the UI was proved against the wrong API. test: depends_on repos are served from the run's worktree for that repo when it has one, else from the main path with an explicit warning in the evidence record.
L-72 H1 #25; H5 item 6 Worktrees shared node_modules through a link to the main checkout: wrong dependency versions, a shared dev-server cache, an install that mutated the main checkout, and worktree remove --force crossing the link. test: a worktree gets its own dependencies from the declared setup command and never a link into another checkout; cleanup never follows links.
L-73 DS §13 "env check" Health judged by exact 200 or by following redirects misreported servers; HTTP.sys (PID 4) looked like a foreign process. test: healthy means status below 500 with redirects not followed.
L-74 DS §13 Windows HTTP.sys/IIS port ownership by PID 4 blocked a start although the server was healthy. test: when a port is held by a process the factory did not start, env up names the owning pid and process (system pids included) and kills nothing.
L-75 H1 #1; CL "lease heartbeat" A 15-minute lease TTL expired in the middle of a long prove and another run reclaimed the env. by-design: v1 has one lock per env file and no leases, TTLs or heartbeats between runs.
L-76 H1 #5, #6, #20; DS §11 Releasing a lease left the env up, one env per workspace made UI proof serial, and six parallel sessions exhausted usage with a stale lease. by-design: no leases or FIFO queue daemons; one lock per env (per slot when slots are used), env up --wait for queueing, and shareable for read-only sharing.
L-77 DS §11 "legacy lease marker" Older and newer lease formats had to coexist through a marker file. by-design: no leases, so no compatibility marker.
L-78 H1 #6; DS §11 slots Several runs on one repo needed per-slot ports, per-slot login state and cross-repo placeholders. test: env up --slot n applies the local.toml port offset, takes a lock per slot, and evidence records the slot's base URL.
L-79 DS §11 login handoff A legacy login redirected to a fixed URL, so the session did not complete on a shifted port. test: the login spec receives the served slot's base URL, and a redirect to another origin fails login with kind env.
L-80 DS §3 env login Test credentials had to reach the browser login without appearing in argv or chat. test: credentials reach child processes only as environment variables, never as arguments or output.
L-81 DS §3 runtime resolution A ticket needed another test user than the default one, requiring per-user login state. test: plan login_user selects the <KEY>_<slug> secrets and a login state file per user.
L-82 CL "Phase 4 review" (preflight origin) An env preflight/warmup URL could point at a foreign server and send stored cookies to it. test: the CLI makes no network call except to the local env origin declared in the config, and http checks refuse a foreign origin.
L-83 CL "Phase 4 review" Preflight failure text quoted the response body. test: http check failures state the status and the failed expectation, never the response body.
L-84 H1 #19; DS §13 "Waiting" sleep was blocked for workers and a worker could not wait for a pipeline or env. by-design: env up waits itself (ready_timeout_s); no worker role guard, so no wait command.
L-85 CL "env.hot_reload"; DS §14 A dev server following commits (HMR) made the HEAD binding meaningless, so --final had to restart it. test: a repo with a hot-reloading server is judged by the served process's recorded start SHA; evidence from a process started before the HEAD is an error.
L-86 DS §0 audit; PA §10 Missing runtime env made every verify INCOMPLETE; a bad selector cost a full replan. test: gate plan requires env capability for every runtime check in one consolidated message, and new http/browser checks get a dry run at plan time.
L-87 CL "env_only repos" (hotfix real run A) Repos registered only to start their env from a worktree made the build gate demand commits from them. by-design: the set of affected repos is separate from env dependencies, which are never gated for commits.
L-88 CL "resolve dependency from epic sibling run" A dependency without a worktree in the run was served from a sibling epic run, then from target_paths. test: in an epic, a dependency without a worktree in the run is served from the sibling child's worktree, else from the main path with a warning.

E. Git, worktrees, commits

id origin concrete failure v1 destination
L-89 H1 #11; CL "commit header check ignores commits the run did not create" Eight gate failures in three runs, and 17-20 commits per change request, came from inherited commits that did not match the header regex. test: commit-format checks span only branch_point..HEAD, with the branch point recorded when the worktree is created.
L-90 CL "merge-commit edge cases" An evil merge (a resolution adding code or a forbidden trailer) escaped because merge commits were skipped entirely. test: merges that only integrate the base skip the header check, never the forbidden-trailer check.
L-91 CL "gate build treats commits of merged change requests as inherited" A dependency branch deleted after merge turned its commits into "foreign" ones. test: commit checks span branch_point..HEAD, and a stacked branch's branch_point is its dependency's head, so commits of merged or other open dependency changes are never checked as the run's own.
L-92 CL "commit checks skip commits reachable from another remote branch" Commits inherited from other open change requests on epic branches failed the run's checks. test: commit checks span branch_point..HEAD, and a stacked branch's branch_point is its dependency's head, so commits of merged or other open dependency changes are never checked as the run's own.
L-93 H4 #3 (real run C) The default hotfix branch format omitted {target}, so base and mirror branches collided at git worktree add. test: mirror branch names include {target}, and a name collision is refused before git worktree add.
L-94 H4 #2; CL target_branches A logical target was a different branch name in each repo, so one global target list failed. by-design: each [[repo]] in factory.toml names its own base branch.
L-95 H4 #4; H5 mirror; CL "mirror diff gate" A cherry-pick conflict resolution moved tests to another file and reformatted a whole file; every gate passed and the user found it after the change requests existed. test: on a hotfix, gate ship needs mirror diff to be equal (or a user decision naming the divergent files); moved tests and whole-file reformatting show as divergence.
L-96 CL "mirror diff gate catches relocated hunks and whitespace" The mirror diff gate missed relocated hunks, CRLF/LF and trailing-space changes and did not run at the right gate. test: mirror diff normalizes EOL and trailing whitespace and matches relocated hunks per file.
L-97 CL "mirror diff gate tolerates moved-module imports" A legitimate, user-approved hotfix failed the diff gate over moved-module import specifiers and differing context. test: moved-module import specifiers are listed as a separate divergence class that a user decision can accept.
L-98 CL "safe target switching for hotfix envs" A hotfix run restarted or stopped an env that another run or a hand start owned; dependency restarts followed the wrong order. test: mirror verification restarts only envs the factory started for this run, dependencies first by depends_on.
L-99 CL "hotfix mirror runtime checks"; real run D CHK-n@pack checks all failed because the env served the base worktree; fail-fast then cancelled the right target's checks too. test: mirror runtime checks are served from the mirror worktree, and fail-fast in one target never cancels the other target's checks.
L-100 CL run target-ticket; real run D A hotfix with two tickets titled both change requests with the first ticket. test: each mirror change is titled with its own target ticket key.
L-101 CL "hotfix base target serves a dependency from target_paths[<base>]" A dependency without a run worktree was served from whichever branch the main checkout was on. by-design: a depends_on repo is served from the run worktree or from the main path with a warning (L-71); no second-checkout target paths.
L-102 H2 §5, H3 §4 (base + mirror redesign) Per-target evidence ids (CHK-n@target), --target flags and target_paths spread through env, prove, gates and ship. by-design: one run builds, verifies and reviews the base. The mirror is a post-approval cherry-pick with its own verify --mirror and the same-diff gate, so no CHK-n@target ids or --target flags spread through the core.
L-103 H1 #24; CL run close Runs stayed in build forever after the branches were rebased, force-pushed and the worktrees removed; no command could close them. test: factory status reports a missing head or worktree explicitly, and factory run close --reason ends a run without gates.
L-104 H1 #22 A prior review batch vanished from the run list with no recorded reason. by-design: run state lives in .factory/runs/ of the project; the CLI never archives or moves a run on its own.
L-105 H4 #1; CL run delete Deleting a run required --yes, archived zips piled up, and parents had to be deleted with children. by-design: runs are plain directories; run delete --yes removes one directory, with no zip archive and no parent/child protocol.
L-106 CL "git safety"; AGENTS A destructive command (hard reset, stash, force-push) was always a risk; one run's branches were force-pushed by hand. test: the CLI never runs reset, stash, clean or force-push, asserted by a grep-style test over its git call sites.
L-107 DS §2.5; CL "review record accepts short SHAs" Auditors were refused for a short SHA and for repos given as a list, and succeeded only on the second try. test: review record accepts a SHA prefix of at least 7 hex characters, stores the full SHA, and a bad repos shape is rejected with the expected shape.
L-108 CL "ship plan behind-count" A change was stale against its target and the plan did not say so, or compared against an unfetched ref. test: ship plan reports commits behind the target and says when a fetch is needed first.

F. Guards and trust (why v1 binds evidence instead of guarding writes)

id origin concrete failure v1 destination
L-109 H1 #17; H4 #5; H5 item 7; CL "protect hook decides by the write target" 24+ read-only commands were blocked ("mentions run files with a write verb"): cp to scratch, sed -i on a scratch file, inline Python that only printed. by-design: no write guard in the core; hooks are optional hardening and gates do not depend on them.
L-110 CL "protect hook falls back to the coarse rule" (review of ~520 probes) The target-aware rewrite let through globs, braces, copies into the run folder, odd spellings (run.json., OWILL~1, \\?\, ::$DATA), rm $(...) and link creation. by-design: regex/grammar write guards are bypassable by construction; trust comes from evidence binding.
L-111 CL "protect hook lifts a coarse denial only for provably safe commands" (third audit, 6069 probes, ~157 real writes) Writes got through via functions/aliases defined in another segment, xargs -I, junction aliases of the profile, bash escapes, odd flag spellings, carets and Push-Location. by-design: same; the per-segment certainty logic is dropped, not rebuilt.
L-112 CL "protect hook narrows the provably-safe grammar" (fourth audit R1-R4) /proc/cygdrive drive aliases, PowerShell 5.1 re-quoting of arguments with spaces, mv of a folder holding a junction before a cp, and git -C with core.worktree pointed at the run reached protected files. by-design: same.
L-113 CL "protect hook refuses write targets that are MSYS link files"; "no longer lifts a denial for commands that write a file" (fifth and sixth audits) A planted Cygwin/MSYS cookie, .lnk shortcut, .exe twin or Interix link made a scratch write land in run.json; every safe-root/real-path fix produced the next bypass. by-design: v0 deleted the safe-root checks after five rounds; v1 never relies on path-based write guards.
L-114 CL "protect hook closes pre-existing write bypasses" sed 'w file', awk '{print > "f"}', tee >(cat > f), text piped into a shell, Tee-Object, patch, compressors, git --work-tree, `python -m zipfile shutil, os.systemin inline code, glob aftercd` into the tree, trailing dot/space/NTFS stream paths all wrote protected files.
L-115 H2 backlog; H3 §6 protect.js had no try/catch (an exception exits 1 and lets the command pass), > /dev/null in PowerShell 5.1 writes <drive>:\dev\null, and xargs rm < file was never analysed. by-design: no hook is load-bearing, so a hook failing open cannot pass a gate.
L-116 H4 #5; DS §5 "cat > dest workaround" Guard false positives pushed agents to the Write tool, which no shell hook sees: the incentive was to bypass the guard. by-design: nothing in v1 punishes honest reads and copies of run files.
L-117 H2 §6 "Entrega" A reviewer could not rerun review-finding reproduction scripts because the hook blocked scripts touching run files, even from scratch copies. by-design: no read/write guard on run files.
L-118 DS §5 worker-guard (verb-token MCP classifier) A tool name with an unlisted verb, or 19 new write tools added by server parity, could be treated as read; ambiguous names were all blocked. by-design: the factory has no tool allow/deny lists; remote writes happen only through ship intents run by the orchestrator after approval.
L-119 PA §6, §9 Per-agent disallowedTools lists named provider tools and had to be edited per server; wildcard forms were not accepted. by-design: adapters list no tools; no provider-named tool lists exist.
L-120 PA §5 (profile approve, file_sha256); CL guard entries A tampered or draft provider profile could change which commands the guard treated as remote writes; profiles needed approval records and digests. by-design: no profiles and no guard patterns; adapters are user scripts and their raw output is stored with the contract.
L-121 PA §3, --format native A "native" contract could be written by the agent claiming it needed no mapping, and a forged contract looked like an ingested one. test: every contract records source (adapter or agent) with the raw payload hash; native-style unmapped contracts do not exist, and proof-grade facts need source: adapter.
L-122 PA §3 A contract stayed valid after its raw file changed. test: the contract records the raw payload hash and gate fails when the raw differs.
L-123 DS §0 residual A raw payload could be written by hand instead of read from the provider. by-design: source: agent is explicit and accepted for ticket text; proof-grade facts need an adapter (L-21).
L-124 PA §4 (mapping DSL, regex timeout, rich-text tree) The mapping language needed operators, depth caps, a regex timeout and text_from_tree; real payloads kept exceeding it. by-design: no mapping DSL; users write adapters in their own language.
L-125 PA §8 risk 8; migrations A profile edit could silently change what an old contract meant; in-flight runs needed migrate apply and a deliberate plan-lock re-seal. by-design: no profiles; v0 runs do not migrate (M5 transition note).
L-126 DS §0; H3 §6 The orchestrator could record a --by user decision with nothing proving the user spoke. test: a user decision needs non-empty --user-said text, is consumed once by --decision, and is shown in next; forging it remains an accepted residual risk.
L-127 DS §0, §5 (FACTORY_ROLE) A builder could record a review or replan by setting an environment variable; role separation rested on a hook. by-design: roles are advice; reviews are bound to SHA and plan hash (L-18) and review record stores recorder hints as audit trail only.
L-128 H1 #18 A scout could not write notes outside a run folder; the scratchpad save was refused by the tool root rules. by-design: no role-specific write limits.
L-129 CL "install.py ... masks secrets" An installer diff printed secret-looking values. test: init and every command print no secret values; factory.toml holds secret key names only, values come from environment or the user-level env file.
L-130 DS §5 snapshot factory.cmd re-parsed unquoted `& ^ %VAR%` in arguments.

G. Intake, contracts, plan lock, loops

id origin concrete failure v1 destination
L-131 DS §2.6; CL "plan lock fills replan.changed" A workspace change after plan (caps, limits, quality commands) could loosen proof without any gate noticing. test: the plan lock hashes the effective check commands and caps from factory.toml; gate verify fails with "config changed after plan" until plan amend.
L-132 DS §2.6 A check or plan file edited after the lock let a lazier proof replace the planned one. test: plan.json and check-file hashes are locked; any change fails the gates until plan amend --reason.
L-133 CL run amend-check; DS §14 Fixing a check's timeout or selector cost a full replan and counted against the replan cap. by-design: plan amend --reason is one command; it counts in the loop limit unless a recorded user decision is attached.
L-134 CL "loop counters say what happened"; runs of 11-23 Nov loops.replan was inflated by amends, replan.changed was empty in 34 of 36 replans, and a rewind with a user decision left no trace. test: each amend/rewind event records changed check and AC ids and its decision id, and counters are derived from the events.
L-135 CL "run rewind caps the sum of build and prove loops" Rewinds to prove had their own budget, doubling the allowed loops. test: one loop budget covers build and prove rewinds, approved ones excluded.
L-136 DS §2.6 "replan/rewind authority" Replans and rewinds were uncapped when agents chose them freely. test: past the autonomy cap the command refuses and blocks the run; a recorded user --decision is consumed once and exempts one loop.
L-137 H1 #14; H2 §4 item 14; H3 §6 A replan that changed only checks invalidated the code review, forcing two auditors again each time. test: a code review binds to SHA and the non-check plan content hash; a checks-only amend keeps it and invalidates only the QA review.
L-138 H1 #10; CL "pending human checks do not count as review loops" A review round cap blocked a run because of one unautomatable check. test: pending human checks never count as review loops; review rounds count only blocker/major findings.
L-139 CL "minor findings of Phase 4 branch" is_flaky counted timeouts and env failures followed by a pass as flaky. test: only an earlier assertion failure followed by a pass is flaky; env, timeout and setup recoveries are not.
L-140 H4 #8; CL "infra and tooling blocker kinds" run block rejected decision, infra and tooling with a bare argparse error, so agents mislabelled blockers. test: an invalid blocker kind is refused with the list of valid kinds and one-line meanings.
L-141 H4 #8 (real run C) A test module failed to import (No module named ...) when run from another directory. test: the suite and the CLI run from any cwd, and config discovery climbs from the cwd (with --project as override).
L-142 H4 #9; CL "ship title default" With a null title format the change was titled Draft: ABC-1 - ABC-1 (key twice, summary lost). test: the default title is [key] - summary and a null format does not produce a doubled key.
L-143 H4 #9 The change had no reviewer because only the tracker account id was configured, not the SCM username. test: reviewers are configured with separate tracker and SCM identities, validated by factory check.
L-144 H4 #9; CL "ship description" The generated description linked to run-local evidence paths that 404 in the SCM, and 90% of a log excerpt was compiler warnings. test: ship verify fails on local links (](evidence/, ](C:, file://), and the body table shows command, exit code, result and a limited trailing excerpt.
L-145 H4 #9 The user wanted no ticket comment or transition, but the workspace config forced both. test: ship plan --ticket none|comment|transition controls the ticket intents; they are never auto-executed.
L-146 H5 item 8; CL "ship plan keeps follow-ups from every review round" Minor findings of round 1 vanished from the description when round 2 approved with none; a plan with six open minors listed no follow-ups. test: ship plan lists unresolved minors from all rounds, de-duplicated, capped at 20 with a count.
L-147 CL "resolved ... clears from every round"; "review follow-ups edge cases" A bare resolved id dropped a different finding because auditors reuse ids, and a finding carried across rounds stayed open. test: resolved entries are round:id (a bare id means the previous round), and resolving clears the same id and text in earlier rounds only.
L-148 CL "snapshot shims never fall back to the current checkout" An empty PYTHONPATH item resolved to the cwd ahead of the stdlib, so the CLI silently imported whichever checkout the shell stood in. test: the CLI never imports from the cwd; a test runs it from a directory holding a decoy factory package with PYTHONPATH empty and unset.
L-149 CL "installed CLI runs from a snapshot" Another session's syntax error in the working tree stopped every factory command of a live run, and an uncommitted branch served a whole run. by-design: the CLI is installed (pipx/uv) apart from the working tree; a project can pin it.
L-150 CL "factory --version ... behind source" Users could not tell which build or SHA ran a run. test: factory --version prints version and build identity; events record the CLI version.
L-151 CL "ship events came in pairs" ship verify and gate ship both logged the same readback, and a re-verification after a push was dropped. test: the ship event de-dups an identical verified state but records a new one when the head changed.
L-152 CL "conflict blockers and ship record one event each" A mirror-conflict blocker and a capped-loop blocker were stored without the event that block writes. test: every blocker write appends exactly one event in events.jsonl.
L-153 H4 #9; DS §3 ship verify ship verify compared with the local snapshot, so a hand-edited remote description or state diverged unseen. test: ship verify compares a readback saved after the action (title, draft, branches, head SHA, description) with the plan.
L-154 CL "ship plan visual"; PA §8 Draft state came from a flag or a title prefix depending on the provider, and ship compared the wrong one. test: the change contract carries one draft boolean computed by the adapter, and ship verify compares it.
L-155 DS §3 feedback gate A green pipeline for an older SHA satisfied the feedback/ship gate. test: the pipeline contract's SHA must equal the pushed head and be the latest, with status success.
L-156 PA §2.5 "no profile"; run 8342 Ticket and change fields differed per provider (draft, state enums, thread shapes), and unmapped values were guessed. test: contract validation rejects an unmapped enum or a null required field instead of inferring it.
L-157 PA §14 item 7 Provider ids such as 3544:5710 or group/proj#42 are unsafe as filenames, and two could collide. test: ids map to safe filenames and a collision is an error naming both.
L-158 CL "FETCH lines with save_to" Missing remote files produced instructions the agent mistyped (relative Windows paths, hand-pasted payloads). test: next prints absolute forward-slash paths for every file it expects, and never asks the model to relay a payload.
L-159 DS §1; PA Large payloads relayed through chat cost tokens and drifted. by-design: adapters and ingest --stdin write raw payloads to files; the model never relays them.
L-160 PA §10 "install"; DS §5 install The CLI, skill, agents and hooks were installed into a profile directory, and a second profile held stale copies of references older than the repo. by-design: adapters are generated by factory init --harness from the CLI (at most 100 lines each); no copies to drift.
L-161 CL "install.py ... running host blocks editing config" Editing the host settings and merging hook entries was fragile (backups, running app lock, PATH hints). test: init --harness --hooks merges hook entries into host settings idempotently, keeps other keys, writes a backup, and refuses a locked file with a clear message.
L-162 PA §10 cross-platform table The installer was Windows-only, with cmd shims lacking escapes, an apostrophe in the home path breaking the sh shim, and case-insensitive path comparison only on nt. test: CI matrix on Windows and Linux; path comparison uses samefile, and paths with spaces and apostrophes work.
L-163 CL "write_json uses unique temp files" Atomic replace of a JSON state file failed on Windows sharing violations. test: atomic state writes retry on Windows sharing errors and never leave a torn file.
L-164 H1 #2; CL "safe run writes (rev counter)" A concurrent run human/run decide from another session during a prove aborted the prove, losing all its evidence. by-design: events.jsonl is append-only, and verify appends only its own records, so another writer cannot invalidate it.
L-165 DS §14 Two prove processes on one run lost history entries (read-modify-replace without a lock). test: concurrent appenders to events.jsonl do not lose or tear lines.
L-166 H1 #2 conflict of protocol A parent session had to record user answers in child runs while a child proved. test: a parent session answers for a child with factory answer --run <child>, and concurrent appends from both sessions keep every line.
L-167 DS §0, DS §13 Hashes over plan files depended on key order and whitespace of JSON. test: plan and config hashes are computed over canonical JSON.

H. Process and orchestration

id origin concrete failure v1 destination
L-168 CL "worker contract"; DS §13 Workers retried env up/prove after the first infra failure (up to 360 s timeouts, loops on the same failing command). test: after two identical env-kind failures in events.jsonl, factory next reports the run blocked with the infra reason and refuses to re-run the same command.
L-169 CL "cap of 2 consecutive blocked hand-backs" (runs 16-23 Nov) A worker returned blocked several times in a row on the same step before anyone changed the approach. by-design: no worker contract; next surfaces the pending gate and its reason, and loops are capped mechanically.
L-170 CL "main session answers in the user's language and delegates" (11 runs) The main session edited specs and product code itself and drifted into English with a Portuguese-speaking user. by-design: scout/author roles are removed; who writes a file does not matter because evidence binds to commands and SHAs; language stays one adapter line.
L-171 CL "SKILL.md 133 lines (cap 150)"; test_prompt_rules Prompt files grew and rules were stated only in prose. test: each harness adapter is at most 100 lines and contains no rule the CLI does not enforce.
L-172 PA §11 (grep test); AGENTS Provider and tool names crept into code, guard lists, installer, fixtures and docs. test: a grep test over the repo (code, tests, docs) rejects provider, vendor and tool names.
L-173 H2 §6 The test suite took 27-28 minutes, run serially (74 modules on a 16-core machine), and blocked every merge. test: the suite finishes in at most 120 s in parallel on Windows and Linux, with git fixture repos created once and copied.
L-174 H2 §6; H3 §2.2 One failure in 968 tests appeared when two suites ran at once, and its name was lost. test: tests use temp directories and no fixed ports so two suites can run at once; the runner always writes full output to a file.
L-175 CL "Skill: UAT checkpoint after first gate build" UI runs found problems only at the end. test: after the first verify pass of a UI run, next proposes the non-blocking UAT action with the screenshot and visual artifacts.
L-176 CL "authors write notes/design.md"; DS (design note) N+1 queries, loops over lists and architecture risks were caught only late by review. test: when risk is medium or high, gate plan requires notes/design.md with ## Approach, ## Complexity, ## Reuse and ## Architecture risks.
L-177 CL "run human --type" (real run D, 18 human notes) Decisions, approvals, env hints and corrections were counted as one number, human_interventions. test: human events carry a type, and metrics counts each type separately.
L-178 H5 metrics; real run D A run spent 3.45 h in plan, almost all searching for the reproduction, with no timing split showing it. test: metrics derives time per phase from events.jsonl and reports reproduce separately.
L-179 CL "metrics report is recomputed at final states" (runs 11-23 Nov) A stored metrics report went stale after run close, and blocked or idle waits (31 min at the ship gate, 1.2 h of open questions) counted as work. by-design: metrics are derived on demand from the events and not stored; blocked and idle time are separate fields (tested in L-180).
L-180 same Time under an open blocker and idle stretches were mixed into phase hours. test: metrics excludes time under open blockers and reports it as blocked_hours.
L-181 CL "escaped_findings counts only major findings after the prove gate" A run with 18 minor findings reported 19 escaped; one with 50 minors reported 51. test: metrics counts only blocker/major findings recorded after the first verify pass, once each, with a stable dedup key.
L-182 CL "metrics find transcripts only through registered sessions" (11 runs) Metrics guessed transcripts by scanning every profile and attributed tokens to the wrong runs; session ids with * or paths read arbitrary files. by-design: the core never scans transcripts (pivot §2.10). Tokens come only from an optional [metrics] tokens adapter keyed by registered session and run, stored as events.
L-183 CL "metrics refresh keeps the token fields"; H3 §6 A refresh overwrote real token numbers with nothing, and one session handling N runs counted its tokens in each. test: tokens events are stored per session and run, and are never overwritten by an empty value.
L-184 CL "orchestration.max_parallel"; H1 #20 Six child sessions exhausted the usage limit together and stopped mid-run with a stuck lease. test: factory claim records an owner session; next from another session refuses without --takeover, and a parent lists at most max_parallel ready children.
L-185 DS §6, §7; CL "review runs" Epics (parent/child runs, waves, stacked branches) and review runs added phase machines, batch status and a 26-item backlog. test: epic waves come from depends_on (cycles rejected), and review runs go through intake, plan, verify, review and report with intents that are never auto-run.
L-186 PA §3 design pillar; DS §2.7 "design fidelity" Design frames, approximate mockups, style maps checked against design properties and visual diffs added a whole contract kind and collectors. test: gate plan requires at least one visual and one style check per design frame named by an AC, against valid design_frame/design_image contracts.
L-187 CL "style maps" ("never invent values") Expected style values could come from the model rather than from the design. test: gate plan rejects a style-map value that is not a fact of the frame contract through the fixed property table.
L-188 CL "visual max_diff_ratio and tolerance_px limits" A plan could loosen visual thresholds past a ceiling to go green. test: max_diff_ratio and tolerance_px above the [limits] ceilings (or limits.approx for approx frames) fail gate plan, and the limits are part of the locked config hash.
L-189 DS §14 "prove --estimate" The orchestrator could not answer "how long will this take" without running everything. test: verify --estimate prints reuse or run per check with the median duration from past events.
L-190 H1 #21 A user decision "screenshots: yes" made gate plan demand a screenshot check, and the only exit was another decision only the parent session could record. test: the screenshot requirement and the design requirement are plan data set from answered questions or ticket links in the same run, enforced by gate plan; no decision from another session is needed.

Summary

Total: 190 rows. By destination:

destination rows
test 143
by-design 47
out-of-alpha 0

Status at 1.0.0-alpha (M7): 0 lessons pending. All 143 test rows have a tagged test (tests/test_lessons.py, sets M1 to M7); the 47 by-design rows need none.

The ten lessons that matter most for the alpha design

  1. L-17 / L-109 to L-115: regex and grammar write guards are bypassable by construction (six audit rounds, hundreds of probes); v1 trusts evidence bound to spec hash, SHA and clean worktree, and keeps hooks optional.
  2. L-01, L-08, L-09, L-10: only verify writes evidence, a gate needs a pass at the current HEAD with the locked spec hash, and the same SHA plus spec hash is never re-run.
  3. L-02 to L-05: setup failure, zero tests and a loose failure pattern must never count as a pass or a reproduction.
  4. L-131, L-132, L-136: lock the plan, the check files and the effective config caps; every change goes through plan amend with a counted loop or a recorded user decision.
  5. L-27, L-28, L-33 to L-35: a bug needs a reproduction on the base that uses the ticket's own scenario and media, and red-green must test committed files, not run-folder copies.
  6. L-69, L-71, L-72, L-64: runtime evidence must prove which code the env served (path and SHA), from the run's worktree, with its own dependencies and .env.
  7. L-42, L-43, L-44, L-46, L-168: every check has a cap that kills the process tree, stdin is always closed, and env-kind failures stop the batch and block next after two repeats.
  8. L-21, L-121, L-155: remote facts used as proof need source: adapter (or a recorded user confirmation); agent-written contracts are fine for ticket text only.
  9. L-164, L-165, L-15: append-only events.jsonl removes lost-write, overwritten-evidence and concurrent-writer failures at once.
  10. L-173, L-148, L-44: the suite budget (parallel, temp dirs, fixture repos copied) and the cwd/PYTHONPATH/stdin rules are what made v0 slow and fragile on Windows.

Ambiguities for the owner

  • L-137 (checks-only amend keeps the code review) and L-39 (changed-values scan in the review record) are new mechanisms inferred from v0 prose rules; confirm in M0.
  • L-89: v1 keeps the commit-format check (parity), over branch_point..HEAD.
  • Parity decision (owner, M0): every former out-of-alpha row is now test or by-design. In particular, human checks (L-24, L-138), screenshots on request (L-56, L-190), quality baseline (L-60 to L-62), slots (L-78), hotfix/mirror (L-41, L-93, L-95 to L-100), epics and review runs (L-185), and tokens (L-183) are back. The mapping is docs/parity-map.md.