Repository navigation
Factory autonomy thin slice (AM1): an owner-approved feature map compiled to tickets, each feature built by a Build Thread the runner drives, inside an envelope; nothing merges - #163
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 61870d32be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if item["depends_on"] and self.map["integration"] == "await_merge": | ||
| row["state"] = "waiting_owner_merge" | ||
| record(self.ledger, "feature_waiting", self.map_digest, {"feature": fid, "waits_for": list(item["depends_on"])}) | ||
| continue |
There was a problem hiding this comment.
Make waiting features resumable after owner merge
With integration: await_merge (the default), a dependent feature is marked waiting_owner_merge as soon as its dependencies are only ready_for_owner_merge. Nothing checks for a later owner merge or makes that feature eligible again; a new run resets the in-memory state and rebuilds the dependencies instead. Thus maps with dependencies cannot progress past this state.
Useful? React with 👍 / 👎.
| reserved: dict[tuple, dict] = {} | ||
| settled: dict[tuple, dict] = {} | ||
| stopped = None | ||
| for line in self.lines(): |
There was a problem hiding this comment.
Scope spend totals to the current envelope
After a run writes a stop line, issuing a replacement envelope under the same --home cannot resume it: totals() reads every historical line without checking its envelope_digest, so the old stop reason remains set and Loop.run exits before making a decision. Previous spend is also charged against the new grant. Filter lines by the current envelope digest or give each grant its own ledger.
Useful? React with 👍 / 👎.
| def room(self, tier: str, calls: int = 1) -> bool: | ||
| totals = self.totals() | ||
| return (totals["stopped"] is None and totals["dollars_left"] >= self.envelope["dollars"]["tiers"][tier] | ||
| and totals["calls_left"] >= calls and totals["seconds_left"] > 0) |
There was a problem hiding this comment.
Enforce the remaining seconds as an attempt limit
If seconds_total is positive but less than the next provider call or check takes, this condition still permits the attempt; the reservation records zero seconds, and the provider and checks use their own timeouts. The loop can therefore exceed the granted seconds before it checks the envelope again. Bound the attempt by the remaining time or refuse it when it cannot fit.
Useful? React with 👍 / 👎.
| line = {"schema": ENVELOPE_LINE_SCHEMA, "envelope_digest": envelope_digest(self.envelope), **line} | ||
| with self.path.open("a", encoding="utf-8", newline="\n") as handle: | ||
| handle.write(canonical(line) + "\n") | ||
| handle.flush() |
There was a problem hiding this comment.
Sync the reservation before external work
If the machine or kernel fails after the provider call starts, flush() alone does not make this reservation durable. The external call may have happened while its hold is lost, allowing a restart to spend beyond the envelope. Sync the reservation before _attempt performs external I/O.
AGENTS.md reference: AGENTS.md:L202-L204
Useful? React with 👍 / 👎.
Independent verification of #163 at
|
…motion record through C1's seam (the promote event, the approval it cites, the stored envelope, re-verified under --owner-public), retry_escalate_arm offers only the stronger arms so the recorded decision is the one that runs, one envelope ledger file per envelope digest so two maps or two grants in one home never share spend or a stop, stacking restores the owner's HEAD and refuses a dirty tree, the envelope ledger refuses negative or non-finite amounts, a kindless line, a second reserve and an orphan settle, a Rejected inside run() still writes the stop line and loop_stopped, the kill-switch path leaves the digest, scope paths compare case-folded without ./, risk_plan validates its weights, and the docs list the known limits and the deviations from C4 (#163 verification findings 1-10, 13) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
61870d3 to
a08169c
Compare
…motion record through C1's seam (the promote event, the approval it cites, the stored envelope, re-verified under --owner-public), retry_escalate_arm offers only the stronger arms so the recorded decision is the one that runs, one envelope ledger file per envelope digest so two maps or two grants in one home never share spend or a stop, stacking restores the owner's HEAD and refuses a dirty tree, the envelope ledger refuses negative or non-finite amounts, a kindless line, a second reserve and an orphan settle, a Rejected inside run() still writes the stop line and loop_stopped, the kill-switch path leaves the digest, scope paths compare case-folded without ./, risk_plan validates its weights, and the docs list the known limits and the deviations from C4 (#163 verification findings 1-10, 13) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
a08169c to
f9eaf2a
Compare
…iled to tickets on the ledger, each feature built by a Build Thread the runner drives, inside an envelope; nothing merges featuremap.py: feature-map.v1 over #154's spec object (sectioned Markdown -> spec; D2), mapcheck (schema, spec digest, coverage, acyclic DAG, declared scope conflicts, act class, size, hidden-check names, approval digest), the task graph (critical path, total work, work/critical ratio, Dilworth width, conflict graph), the risk plan (seven code-computed inputs, standardized scores, v_i = V * softmax(z_i / tau) above a floor that never moves) and one feature -> one ticket in ticket_from_spec's shape (D5). policy.py: FeaturePolicy with the five typed questions over closed option sets, OfflinePolicy (critical path first, cheapest tier that fits, retry then stronger arm then owner, park when spent, stop on the envelope) and ShadowPolicy (records what an injected second policy would answer; never acts on it). loop.py: refuses an unapproved or stale map and an unpromoted spec, writes one contract per feature, drives each attempt with `syberlabs run`'s Runner (D17), reserves and settles an envelope ledger shaped like the eval spend ledger (D13), and records every proposal, step and outcome as ledger events whose digests exclude thread ids, commits and times. autonomy_cli.py: `syberlabs factory autonomy check|approve|envelope|run|why`, hooked from one line at the end of cli.py. 17 tests on a three-feature fixture over factory_app with a stand-in proposer command: tickets on the ledger, F1 -> F3 -> F2 order, shadow disagreement recorded, envelope and kill switch stop the loop, await_merge leaves a dependent waiting, a failing or out-of-scope candidate is refused by the kernel and parked, same fixture gives the same event digests, no merge or network call in the modules. docs/FACTORY_AUTONOMY.md says what the slice does and does not do, the glossary, and the next packets (C5, C6, C9, C10). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…motion record through C1's seam (the promote event, the approval it cites, the stored envelope, re-verified under --owner-public), retry_escalate_arm offers only the stronger arms so the recorded decision is the one that runs, one envelope ledger file per envelope digest so two maps or two grants in one home never share spend or a stop, stacking restores the owner's HEAD and refuses a dirty tree, the envelope ledger refuses negative or non-finite amounts, a kindless line, a second reserve and an orphan settle, a Rejected inside run() still writes the stop line and loop_stopped, the kill-switch path leaves the digest, scope paths compare case-folded without ./, risk_plan validates its weights, and the docs list the known limits and the deviations from C4 (#163 verification findings 1-10, 13) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…d re-verifies the promotion's approval under the owner key the ledger pinned before the approval event (owner_key_unset and owner_key_mismatch refuse), autonomy run takes no --owner-public, the fixture bootstraps the key with set_owner_key and promotes through gate() as the CLI does, and the docs pin the key with factory owner Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…: promotion_record reads the pinned key through the ledger's verified lineage with its stored rotations, a lineage that does not verify refuses owner_key_lineage, the fixture gates with the ledger's loader, and the docs say map compilation honours the lineage Rebased onto syberlabs/factory-goal-gate at 9ff7573 (M3 of the #164 delta verification). The two branches touch disjoint files except the end-of-file hook in factory/cli.py; no conflicts. The adaptation #164's summary asked for: `loop.promotion_record` now calls `specmod.pinned_owner_key(prefix, ledger.load_rotation)` so a rotated ledger's envelopes can be checked, and `owner_key_lineage` propagates as the refusal instead of collapsing into `owner_key_unset`. The historical-prefix read (events with seq below the approval event's) still picks the key pinned at the time of the approval, so a later honest rotation does not unmake an earlier promotion. Because that prefix cannot see a pin appended after the approval, the whole ledger's lineage is verified first (`specmod.pinned_owner_key(events, ledger.load_rotation)`): a bare second `owner_key_set` appended with the hash chain intact leaves the ledger pinning nothing, and `Loop.compile` refuses `owner_key_lineage` rather than reading the earlier key. Tests (26, was 25): `EndToEnd::test_compile_reads_the_owner_key_through_the_ledgers_lineage` promotes a spec after an honest bootstrap -> rotation (approval signed by the second key) and compiles under the second key, shows the same lineage is unreadable without the loader, then appends the M3 repro (a bare `owner_key_set`) after an honest promotion on a second ledger: `compile` refuses `owner_key_lineage`, appends nothing, writes no contract. The fixture's `promoted_spec` passes `load_rotation=home.load_rotation` to `gate`, as the CLI does. Docs: FACTORY_AUTONOMY.md states that map compilation honours the ledger's owner-key lineage. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
f9eaf2a to
ced0397
Compare
Final stack verification, B: #163
|
Packet C4
autonomy-thin-slice(AM1) of the consolidation plan (reports/2026-11-01-syberfactory-consolidation.md§5), stacked on #154 (claude/factory-spacetime-v0, head6dbd2f4). It realises the first slice of the autonomous typed mode on top of #154's ledger, spec and tickets rather than beside them. $0, offline, no network, no model call: every "model" is a stand-in command.What is added (new files only;
factory/cli.pytakes one hook hunk at its very end)syberlabs/factory/featuremap.pyfeature-map.v1: the typed task DAG over #154's spec object (D2;spec_from_markdownturns a sectioned-Markdown spec into that object).mapcheck: schema, spec digest, coverage of every requirement, acyclic DAG, scope conflicts (an intersection must be declared with an order that agrees with the DAG), act class, size ceilings, hidden-check names (names only), owner-approval digest.taskgraph: critical path, total work, work/critical ratio, Dilworth width + maximum antichain, conflict graph.risk_plan: seven code-computed risk inputs, standardized scores,v_i = V·softmax(z_i/τ)as integer units above a floor (host checks, hidden checks, critic, gate) that is listed beside every allocation and never moves.compile_ticket: one feature → one ticket inticket_from_spec's shape (D5),human_ownermandatory,rubric_digestover hidden-check names,map_reffor thewhywalk.degenerate_map: the mapticket_from_specimplies.syberlabs/factory/policy.pyFeaturePolicyseam: the five typed questions (next_feature,proposer_arm,budget_tier,after_failure,worth_continuing) over closed option sets code builds;validaterefuses any answer outside them.OfflinePolicy(default: critical path first, cheapest arm/tier that fits, retry → stronger arm → owner, park when the cap is spent, stop on the envelope).ShadowPolicy: acts on one policy, records what an injected second one would have answered and whether it agrees; never acts on it. Nojev_apiimport, no socket.syberlabs/factory/loop.pycompilerefuses a map without a current human approval (map_unapproved), a spec not promoted, or any mapcheck finding; writes one contract per feature (scope = feature scope; checks = visible checks + the hidden checks the host holds under the ticket's names); logsmap_frozen+ticket_opened{source: map}.run: kill switch → eligibility → three policy proposals recorded on the ledger → envelope reservation → one unattended Build Thread → oneCommandProvidercall →syberlabs run'sRunnerdrives check/accept/recover (D17) → envelope settles from the journal → outcome recorded.EnvelopeLedgeris the eval spend ledger's shape generalised to attempts (D13).whywalks ticket → feature → map (approval) → spec.event_digestsexcludes volatilerefs, so one fixture gives one digest list.syberlabs/factory/autonomy_cli.pysyberlabs factory autonomy check | approve | envelope | run | why, registered byextend()from the hook at the end ofcli.py.tests/test_factory_autonomy.py+tests/fixtures/autonomy/factory_app(F1 → F2 chain, F3 independent) withstandin_proposer.pyas the process boundary andhidden_checks.jsonas the host's catalogue.docs/FACTORY_AUTONOMY.mdLedger events of the end-to-end test (in order)
Order is critical-path-first (F1 has a dependent; F3 is size M; F2 last). Under
integration: stack, F2's thread starts from F1's accepted commit; underawait_mergeF2 is recordedfeature_waitingbecause only the owner's merge releases it.mainnever moves; the terminal state is an accepted candidate onsyberlabs/<thread>plusfeature_ready{refs: thread, commit, target_ref}.Tests cover
map validates and the graph measures; cycle refused; undeclared scope conflict flagged (declared with an order is not a finding; an order contradicting the DAG is); coverage and unknown requirement; stale spec digest; stale approval after an edit; a model actor cannot approve; risk plan keeps the floor and sums to V, uniform at zero spread, τ below the minimum refused; ticket shape ⊇
ticket_from_spec's; offline rules; closed option sets; shadow disagreement recorded and an out-of-options shadow answer recorded not acted on; the end-to-end run; same fixture → same event digests; unapproved map refused with nothing logged; envelope (calls_total=2) stops the loop with F2 left open;await_mergeleaves the dependent waiting; a failing candidate is refused by the kernel (candidate_check_failed:*) and parked; an out-of-scope candidate never reaches accept; kill switch stops before the first decision; the modules hold no merge or network call.Verified
python -m unittest tests.test_factory_autonomy: 17 OK (Windows, Python 3.12.6).python -m unittest tests.test_factory: 35 OK, includingtest_repository_layering_has_no_drift(the new modules import onlyprimitivesandbuild-thread, the edgesdocs/architecture.declared.jsonalready declares forfactory).python -m conformance.run: 23 golden traces matched.python benchmarks/run_scenarios.py: 11 replayed, exit 0.index → autonomy check → approve → envelope → run → why → status: 3 features ready, 33 ledger events, chain verified,mainat the base commit.syberlabs/autonomy-thin-slice-ci(same commit); result in the thread.Deliberately not in this slice
No publish, no draft PR, no merge (C9). No live Jev and no adapter: the shadow is an injected callable (AM4 later). No replay grade (
replayarm, with the eval runner; C9/C10). No new ledger event kind:ledger.KINDSis owned byledger.pyand by the goal-gate packet editing it, so autonomy events arenote{body.note ∈ loop.EVENTS}and tickets use the existingticket_openedwithsource: map. No edit tospec.py,ledger.py,harness.py,static/factory.htmlor GAPS. Concurrency stays 1; the width and conflict graph are computed and logged for thec > 1question. Risk weights and τ are priors;risk_planlogs the propensities calibration needs (E8, C10).🤖 Generated with Claude Code