@defrex/autobuild 0.14.0 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +13 -6
  2. package/SPEC.md +657 -100
  3. package/docs/architecture.md +230 -5
  4. package/docs/assets/headline-wide.png +0 -0
  5. package/docs/configuration.md +118 -14
  6. package/docs/hosted-service.md +18 -0
  7. package/docs/integration-tree.md +117 -0
  8. package/docs/landing-policy.md +150 -0
  9. package/docs/mcp.md +24 -0
  10. package/docs/migration-1.0.md +68 -0
  11. package/docs/operator-api.md +19 -8
  12. package/docs/remote-store-protocol.md +30 -7
  13. package/docs/remote-ticket-protocol.md +26 -5
  14. package/docs/restacking.md +79 -0
  15. package/docs/setup.md +53 -6
  16. package/docs/ticket-dependencies.md +69 -0
  17. package/docs/ticket-migration.md +8 -0
  18. package/package.json +3 -3
  19. package/packages/core/src/cli/attention.ts +25 -2
  20. package/packages/core/src/cli/build-control.ts +65 -41
  21. package/packages/core/src/cli/context.ts +54 -2
  22. package/packages/core/src/cli/dashboard/actions.ts +6 -3
  23. package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
  24. package/packages/core/src/cli/dashboard/live.ts +5 -0
  25. package/packages/core/src/cli/dashboard/model.ts +142 -18
  26. package/packages/core/src/cli/dashboard/poll.ts +15 -9
  27. package/packages/core/src/cli/dashboard/refresh.ts +183 -0
  28. package/packages/core/src/cli/dashboard/render.ts +78 -28
  29. package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
  30. package/packages/core/src/cli/dashboard/selection.ts +7 -1
  31. package/packages/core/src/cli/dashboard/tree.ts +107 -0
  32. package/packages/core/src/cli/dispatch-frontend.ts +156 -105
  33. package/packages/core/src/cli/dispatch.ts +257 -139
  34. package/packages/core/src/cli/dispatcher-liveness.ts +15 -2
  35. package/packages/core/src/cli/help.ts +52 -33
  36. package/packages/core/src/cli/init-validation.ts +43 -2
  37. package/packages/core/src/cli/keyboard.ts +6 -0
  38. package/packages/core/src/cli/landings.ts +18 -0
  39. package/packages/core/src/cli/main.ts +49 -15
  40. package/packages/core/src/cli/mcp.ts +9 -0
  41. package/packages/core/src/cli/publication-settlement.ts +168 -2
  42. package/packages/core/src/cli/repository-status.ts +11 -0
  43. package/packages/core/src/cli/status.ts +72 -5
  44. package/packages/core/src/cli/terminal-restore.ts +54 -0
  45. package/packages/core/src/cli/terminal.ts +16 -2
  46. package/packages/core/src/cli/terminals.ts +98 -79
  47. package/packages/core/src/cli/ticket-editor.ts +10 -3
  48. package/packages/core/src/cli/ticket.ts +113 -18
  49. package/packages/core/src/cli/upgrade-commit.ts +4 -0
  50. package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
  51. package/packages/core/src/cli/upgrade-landing.ts +69 -0
  52. package/packages/core/src/cli/upgrade.ts +16 -0
  53. package/packages/core/src/cli/wait.ts +115 -19
  54. package/packages/core/src/cli/watch.ts +51 -12
  55. package/packages/core/src/config/landing.ts +22 -0
  56. package/packages/core/src/config/live.ts +1 -0
  57. package/packages/core/src/config/schema.ts +3 -0
  58. package/packages/core/src/events/catalog.ts +48 -3
  59. package/packages/core/src/events/payloads.ts +295 -6
  60. package/packages/core/src/events/repository.ts +31 -0
  61. package/packages/core/src/integration/harness.ts +10 -0
  62. package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +1030 -239
  63. package/packages/core/src/kernel/auto-merge-default.ts +1 -0
  64. package/packages/core/src/kernel/auto-merge.ts +12 -3
  65. package/packages/core/src/kernel/build-identity.ts +94 -0
  66. package/packages/core/src/kernel/change-presence.ts +179 -0
  67. package/packages/core/src/kernel/dispatch-status.ts +17 -1
  68. package/packages/core/src/kernel/engine.ts +89 -2
  69. package/packages/core/src/kernel/generators/build-log.ts +23 -0
  70. package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
  71. package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
  72. package/packages/core/src/kernel/generators/repository-journals.ts +11 -0
  73. package/packages/core/src/kernel/integration-completeness.ts +81 -0
  74. package/packages/core/src/kernel/integration-landing.ts +263 -0
  75. package/packages/core/src/kernel/integration-stack.ts +36 -0
  76. package/packages/core/src/kernel/integration-state.ts +135 -0
  77. package/packages/core/src/kernel/landing-policy.ts +47 -0
  78. package/packages/core/src/kernel/landing-publication.ts +41 -0
  79. package/packages/core/src/kernel/landing-readiness.ts +67 -0
  80. package/packages/core/src/kernel/landing-state.ts +96 -0
  81. package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
  82. package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
  83. package/packages/core/src/kernel/log-index.ts +35 -5
  84. package/packages/core/src/kernel/node-landing.ts +439 -0
  85. package/packages/core/src/kernel/node-parent.ts +184 -0
  86. package/packages/core/src/kernel/node-restack-state.ts +191 -0
  87. package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
  88. package/packages/core/src/kernel/node-restack.ts +274 -0
  89. package/packages/core/src/kernel/read-facts.ts +70 -3
  90. package/packages/core/src/kernel/reconcile-head.ts +51 -0
  91. package/packages/core/src/kernel/reconcile-restack.ts +560 -0
  92. package/packages/core/src/kernel/reducer-registry.ts +16 -0
  93. package/packages/core/src/kernel/reducer.ts +121 -6
  94. package/packages/core/src/kernel/snapshot-parent.ts +33 -0
  95. package/packages/core/src/ontology.ts +9 -1
  96. package/packages/core/src/operator/annotations.ts +12 -0
  97. package/packages/core/src/operator/control.ts +6 -0
  98. package/packages/core/src/operator/index.ts +4 -0
  99. package/packages/core/src/operator/landings.ts +35 -0
  100. package/packages/core/src/operator/presentation.ts +1 -0
  101. package/packages/core/src/operator/protocol.ts +12 -3
  102. package/packages/core/src/operator/query.ts +3 -1
  103. package/packages/core/src/operator/registry.ts +48 -19
  104. package/packages/core/src/operator/requests.ts +1 -8
  105. package/packages/core/src/operator/tickets.ts +55 -9
  106. package/packages/core/src/plugins/load.ts +3 -4
  107. package/packages/core/src/ports/forge/contract.ts +91 -3
  108. package/packages/core/src/ports/forge/fake.ts +142 -4
  109. package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
  110. package/packages/core/src/ports/forge/github-readiness.ts +421 -0
  111. package/packages/core/src/ports/forge/github.ts +631 -35
  112. package/packages/core/src/ports/forge/local-git.ts +119 -5
  113. package/packages/core/src/ports/forge/readiness.ts +99 -0
  114. package/packages/core/src/ports/tickets/contract.ts +41 -0
  115. package/packages/core/src/ports/tickets/create.ts +8 -1
  116. package/packages/core/src/ports/tickets/fake.ts +32 -1
  117. package/packages/core/src/ports/tickets/file-codec.ts +7 -0
  118. package/packages/core/src/ports/tickets/file.ts +18 -1
  119. package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
  120. package/packages/core/src/ports/tickets/linear.ts +124 -4
  121. package/packages/core/src/ports/tickets/migration.ts +25 -1
  122. package/packages/core/src/ports/tickets/operations.ts +7 -2
  123. package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
  124. package/packages/core/src/ports/tickets/remote.ts +10 -1
  125. package/packages/core/src/ports/tickets/revision.ts +3 -1
  126. package/packages/core/src/ports/tickets/tree.ts +148 -0
  127. package/packages/core/src/ports/tickets/update.ts +15 -2
  128. package/packages/core/src/ports/types.ts +135 -5
  129. package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
  130. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
  131. package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
  132. package/packages/core/src/processes/build-runner.ts +530 -23
  133. package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
  134. package/packages/core/src/processes/dispatcher.ts +2145 -203
  135. package/packages/core/src/processes/execution-no-progress.ts +46 -1
  136. package/packages/core/src/processes/publication-state.ts +30 -5
  137. package/packages/core/src/processes/repo-view.ts +21 -2
  138. package/packages/core/src/store/build-scope.ts +18 -0
  139. package/packages/core/src/store/contract.ts +658 -0
  140. package/packages/core/src/store/digest.ts +52 -4
  141. package/packages/core/src/store/local/schema.ts +25 -13
  142. package/packages/core/src/store/local/store.ts +117 -1
  143. package/packages/core/src/store/memory.ts +62 -1
  144. package/packages/core/src/store/phase-session.ts +17 -0
  145. package/packages/core/src/store/reduced-reads.ts +2 -1
  146. package/packages/core/src/store/reducer-value-shapes.json +10707 -6440
  147. package/packages/core/src/store/remote/client.ts +45 -0
  148. package/packages/core/src/store/remote/compatibility.ts +25 -9
  149. package/packages/core/src/store/remote/protocol.ts +11 -0
  150. package/packages/core/src/store/repo-state-events.ts +2 -0
  151. package/packages/core/src/store/session-handle.ts +15 -0
  152. package/packages/core/src/store/subscribe.ts +1 -1
  153. package/packages/core/src/store/types.ts +34 -4
  154. package/packages/core/src/testing/index.ts +2 -0
  155. package/packages/core/src/testing/reduced-read-budget.ts +48 -8
  156. package/packages/core/src/testing/refresh-scheduler.ts +32 -0
  157. package/skills/guide/SKILL.md +117 -64
  158. package/skills/guide/references/integration-tree.md +117 -0
  159. package/skills/guide/references/landing-policy.md +150 -0
  160. package/skills/guide/references/migration-1.0.md +68 -0
  161. package/skills/guide/references/operator-api.md +12 -5
  162. package/skills/guide/references/plugin-authoring.md +42 -3
  163. package/skills/guide/references/remote-store-protocol.md +30 -7
  164. package/skills/guide/references/remote-ticket-protocol.md +26 -5
  165. package/skills/guide/references/restacking.md +79 -0
  166. package/skills/guide/references/setup.md +53 -6
  167. package/skills/guide/references/ticket-dependencies.md +69 -0
  168. package/skills/guide/references/ticket-migration.md +8 -0
  169. package/skills/operate/SKILL.md +55 -5
  170. package/skills/reconcile/SKILL.md +55 -48
  171. package/skills/spec/SKILL.md +67 -1
  172. package/skills/tickets/SKILL.md +55 -2
  173. package/templates/autobuild.toml +3 -0
@@ -230,6 +230,11 @@ the requested historical run. A never-started fresh invocation does not request
230
230
  historical correlation. Stopped dispatcher history is not copied into every
231
231
  current read.
232
232
 
233
+ Hosted project build listings use the optional backing-store
234
+ `listBuildsForRepo` capability with the authenticated repository. Postgres filters
235
+ build rows in SQL before hosted ticket readable-id projection. Admin listings
236
+ remain global; adapters without the capability retain application filtering.
237
+
233
238
  **Operator and CLI reads.** Build listings and details, repository and Harvest
234
239
  status, dispatcher decisions, operator API queries, MCP delegation and web
235
240
  dashboard refreshes use the same typed persisted read helpers. Shared projection
@@ -365,7 +370,7 @@ selection (applied at the planner's `ab done` in `packages/core/src/cli/terminal
365
370
  snapshotted by the engine at approval), and
366
371
  `packages/core/src/kernel/verify-applicability.ts` matches changed paths against a step's
367
372
  selectors, resolved by the build runner via `git diff` against the initial
368
- branch-cut base (or the refreshed base promoted by a completed reconcile).
373
+ branch-cut base (or the effective base promoted by successful restack/reconcile publication).
369
374
  This verify-only base is deliberately independent from implementation's
370
375
  focused review range. All narrowing mechanisms produce the ordinary
371
376
  queryable skipped outcome; Git failure is infrastructure and fails closed,
@@ -537,6 +542,17 @@ receive-pack-free network policy, so even a failed publication-policy restore
537
542
  fails closed before setup or plugin code runs. Normal VM sessions never receive
538
543
  Forge credentials.
539
544
 
545
+ **Forge readiness.** `ports/forge/readiness.ts` owns the portable check inventory,
546
+ classification, plugin fallback, and formatting; `github-readiness.ts` performs
547
+ read-only settings/policy inspection, keeping incomplete evidence unknown. Host
548
+ init validation invokes the configured registry forge outside guest probes.
549
+ Dispatch inspects after acquiring its repository lease and writes validated
550
+ `dispatcher.forge-readiness-failed` facts once per run/check for known hard
551
+ failures. `kernel/dispatch-status.ts` retains their typed collection across ticks
552
+ and reloads; the independent frontend and operator query project the same warnings.
553
+ `ab watch` follows these repository attention events for external orchestrators.
554
+ See [setup](setup.md#forge-readiness) for requirements and access guidance.
555
+
540
556
  **Forge credentials.** `packages/core/src/ports/forge/github-transport.ts` owns the
541
557
  REST transport seam and credential resolution for the builtin GitHub forge:
542
558
  `GITHUB_TOKEN`, then `GH_TOKEN`, then the gh CLI's stored login read through
@@ -550,6 +566,35 @@ dispatcher — requires an exported token before any side effect and never consu
550
566
  a checkout-less host has neither gh nor a keyring, and `vercel-sandbox` publication
551
567
  injects that same token.
552
568
 
569
+ **Stable build identity.** The forge landing seam accepts optional build identity at operation time. Both
570
+ built-in adapters preserve their squash message and normalize a final
571
+ `Autobuild-Build: <slug>` trailer through `packages/core/src/kernel/build-identity.ts`. The GitHub
572
+ adapter reads the viewer's squash headline/body and head in one GraphQL query;
573
+ it never reconstructs server defaults from repository settings. The janitor
574
+ maintains native request message freshness after acknowledgement. A matching
575
+ request costs one GraphQL freshness query and no extra consent or pipeline read;
576
+ full gate inspection and refreshed durable consent/engine eligibility precede
577
+ any repair. Body comparison tolerates provider trimming of trailing whitespace
578
+ while preserving the complete headline, body content, and squash method.
579
+
580
+ Optional `Forge.readCommitMessage` and `Forge.containsBuild` capabilities expose
581
+ actual landed messages and exact trailer presence in reachable branch history.
582
+ The janitor records optional `pr.merged.buildTrailerPresent` for normal and abort
583
+ cleanup observations. Unsupported or failed inspection leaves evidence unknown;
584
+ a read failure also records an observation without preventing completion. Old
585
+ logs need no migration and keep the same status and presentation.
586
+
587
+ GitHub merge queues ignore squash-message overrides. The message query also
588
+ reads `repository.mergeQueue(branch:)`, covering classic protection and rulesets.
589
+ Its branch hint is checked against the PR's actual base, with a bounded re-query
590
+ after a retarget rather than assuming the repository default is the base.
591
+ Kernel auto-merge therefore
592
+ returns an actionable `unproven-gate-state` deferral for queue-protected bases;
593
+ it never bypasses the queue. Human queue landings still settle normally with
594
+ inspected trailer evidence when available. Expected-head guards and recurring
595
+ polls bound native message freshness, but cannot prevent a push and automatic
596
+ landing from both completing between polls.
597
+
553
598
  **Agent runtimes.** `packages/core/src/ports/runner/`: `runtime.ts` (capability-carrying
554
599
  registry plus boundary validation), `routing.ts` (eager role resolver),
555
600
  `production.ts` (shipped Claude/Codex/Pi registrations), `codex.ts` (direct
@@ -697,13 +742,41 @@ queue. The supervised kernel child owns every slow
697
742
  adapter operation, so slug naming, provisioning, runners, and Harvest cannot
698
743
  block input.
699
744
 
745
+ `packages/core/src/cli/dashboard/refresh.ts` owns the shared presentation read
746
+ scheduler for both terminal paths: focused by default, independent of focus for
747
+ local stores, and 5-second polling when unfocused for network stores,
748
+ immediate on focus-in or keys, 500 ms with retained builds or during a 30-second
749
+ interaction hold, and 5 seconds when idle. The optional BuildStore.networkReads
750
+ capability identifies remote HTTP and Postgres adapters, including wrapped stores.
751
+ Session feeds and automatic recovery follow the same cadence; unchanged network
752
+ polls retain the change-position savings and bounded enrichment exception. Presentation store facades check
753
+ admission at every asynchronous read stage; the kernel uses its original store
754
+ and independent tick timers. Cached clock paints perform no reads. The mode
755
+ ledger owns focus reporting through teardown and catchable faults; job-control
756
+ suspension restores modes and input before stopping and reactivates with assumed
757
+ focus on resume. Plain, non-TTY, and once runs never enable focus reporting.
758
+
700
759
  `packages/core/src/cli/build-progress.ts` projects the exact last-event, heartbeat, and lease
701
760
  inputs shared by the diagnostic `ab builds` and `ab build status` surfaces. Its
702
761
  one-hour `diverged` predicate is presentation-only: reducer status, engine
703
762
  routing, and lease health remain independent. `packages/core/src/cli/dashboard/model.ts` is
704
763
  the event-derived build-row projection; `poll.ts` reprojects rows for event or
705
- effective-config changes and reuses them across heartbeat/lease-only renewals
706
- while retaining the cached log and reduction.
764
+ effective-config changes and bounded enrichment refreshes while retaining the
765
+ cached log and reduction. `repository-poll.ts` serializes the complete presentation
766
+ snapshot in both terminal paths. It samples `getRepoChangePosition` before reads,
767
+ acknowledges it only after complete admitted reads, and reuses unchanged snapshots
768
+ for up to ten seconds. Scoped discovery uses `listBuildsForRepo`; unchanged focused
769
+ frames make one counter request. Session feeds remain independent.
770
+
771
+ The memory adapter maintains independent bigint counters; SQLite and PostgreSQL
772
+ increment `repo_change_positions` transactionally through triggers on build,
773
+ build-event, repository-event insertion and null-safe repository lease holder
774
+ changes. Reads return decimal text (unknown repos: `"0"`) without journal creation.
775
+ The hosted counter route returns only that position; scoped build discovery has
776
+ its own repository-authorized route before the journal-existence gate. PostgreSQL
777
+ counter DDL is additive, outside the guarded core schema/checksum, and must be
778
+ explicitly migrated before the service rollout. Existing writers use the same
779
+ triggers; rerunning migration preserves positions without replaying old events.
707
780
  `detail.ts` projects chronological session history from the same retained log,
708
781
  including a distinct transcriptless `reclaimed` ending, and `transcript.ts`
709
782
  heuristically presents ordinary opaque transcript artifacts with a raw
@@ -988,13 +1061,13 @@ revisions rather than ignoring them.
988
1061
 
989
1062
  `ab ticket edit <id>` opens `$VISUAL`, falling back to `$EDITOR`, using TOML
990
1063
  frontmatter and a Markdown body. Only title, body and labels are editable;
991
- id, blockers, creation key and reference comments are read-only. It saves only
1064
+ kind, target, id, blockers, creation key and reference comments are read-only. It saves only
992
1065
  changed fields with the opening revision. Unchanged or formatting-only edits
993
1066
  write nothing. On conflict, invalid input or editor failure, the error names an
994
1067
  absolute file path containing the edited text. Read the current ticket and
995
1068
  reapply the intended changes before retrying; conflicts are never merged.
996
1069
 
997
- File and Linear revisions fingerprint title, body, canonical label/blocker sets
1070
+ File and Linear revisions fingerprint kind, target, title, body, canonical label/blocker sets
998
1071
  and state; reverting identical content restores its fingerprint. File checks
999
1072
  re-read immediately before writing, with the existing no-lock race window.
1000
1073
  Direct file edits and state-directory moves change revisions. File comments
@@ -1020,3 +1093,155 @@ Hosted ticket detail reads expose complete, oldest-first structured comments in
1020
1093
  HTTP clients opt in with `x-autobuild-ticket-comments: 1` so historical strict
1021
1094
  decoders retain compatible responses. File comments remain embedded in the body;
1022
1095
  Linear comment reads are unchanged.
1096
+
1097
+ Ticket integration metadata lives in `ports/tickets/tree.ts`: source compatibility
1098
+ normalization, capability refusal, graph validation and the pure tree projection.
1099
+ File/fake/Linear adapters validate metadata at write boundaries; `operations.ts`
1100
+ and CLI/operator source opening wrap injected or plugin sources with the same
1101
+ compatibility facade. Metadata is excluded from hosted persistence/protocols.
1102
+
1103
+
1104
+ ### Integration node dispatch
1105
+
1106
+ The product dispatcher owns the workspace-free node lifecycle:
1107
+ spec → node.opening → node.opened → collecting → complete → verify:* → consent → land.
1108
+ The ordinary work pipeline is unchanged. `build.created` freezes kind, target
1109
+ ticket/build identity and resolved parent in `baseBranch`. Integration facts
1110
+ are projected by the shared reducer and digests, including collecting/empty
1111
+ state. Admission resolves same-source targets through repository read facts;
1112
+ integration identities remain active for deduplication but consume no work slot.
1113
+
1114
+ Optional Forge node branch creation and comparison capabilities let GitHub
1115
+ operate without a checkout and local-git operate directly on its shared refs.
1116
+ Opening intent retains the sampled SHA across retries; adoption requires that
1117
+ commit in the existing branch's history. Comparison uses reachability, so an
1118
+ advanced parent never makes an empty node nonempty. The janitor opens PRs lazily
1119
+ and reuses terminal cleanup without leaf reconcile or auto-merge.
1120
+
1121
+ ### Leaf and reconcile restacking
1122
+
1123
+ The kernel prepares a detached replay of one net build change on the base frozen
1124
+ by `reconcile.started`. The contribution baseline is the initial branch-cut base
1125
+ or latest successfully published restack/reconcile base. The resolver continues that one replay;
1126
+ completion requires one parent at the frozen base and the build identity trailer.
1127
+ Historical merge completions retain their original shape and semantics.
1128
+
1129
+ The optional grouped Forge rewrite capability owns authoritative head snapshots,
1130
+ immutable `refs/autobuild/archive/<slug>/<sha>` publication and expected-head CAS.
1131
+ GitHub uses explicit Git transport leases; local-git uses shared-database
1132
+ `update-ref` CAS without network calls. Trusted remote publication archives before
1133
+ replacement after guest teardown; it never uses ordinary append-only publication
1134
+ for restacks. Prepared, replayed, intended and rewritten facts support recovery.
1135
+ A contended rewrite preserves the observed work and retries on the same base.
1136
+
1137
+ `kernel/leaf-restack-state.ts` projects target observations, frozen transactions
1138
+ and cycle gates into the log index and persisted build facts. The engine selects
1139
+ automatic kernel work before any verify action and after finalize post-steps when
1140
+ the target moves. `reconcile-restack.ts` shares collapse, detached replay,
1141
+ archive-before-replacement and expected-head publication mechanics. Automatic
1142
+ transactions emit `restack.*`; clean completion never starts a reconcile cycle.
1143
+ Pre-PR conflicts adopt the prepared replay through ordinary reconcile. Initial
1144
+ verification remains mandatory; waiting conflicts use post-reconcile policy.
1145
+
1146
+ The dispatcher observes targets without changing workspaces; execution ownership
1147
+ and session settlement fence mutation. Transaction targets stay frozen while
1148
+ later moves coalesce. `publication.requested` carries automatic transaction
1149
+ identity through trusted remote teardown and publication. The runner settles
1150
+ local resolver intent only after its session ends. Verification facts
1151
+ cite the cycle's base/head, and clean waiting rewrites preserve those results.
1152
+ Object packs retain newly introduced replay trees/blobs as well as commit bytes.
1153
+
1154
+ GitHub archive push/fresh-fetch and rewrite contracts are manual opt-in cases in
1155
+ `ports/forge/github.live.test.ts`, using `AB_RUN_LIVE_PORT_CONTRACTS=1` and an
1156
+ explicit disposable `AB_GITHUB_CONTRACT_REPO`. Offline transport tests are not
1157
+ live provider evidence.
1158
+
1159
+ ### Descendant node restacking
1160
+
1161
+ `kernel/node-restack.ts` inventories the contribution above the durable previous
1162
+ base, proves foreign merge safety against the sampled parent's full identity set,
1163
+ and replays individual changes. `kernel/node-restack-state.ts` reduces writer
1164
+ reservations, ordered receipts, conflicts, publication intent, confirmed effects,
1165
+ and inventory. `kernel/node-restack-transaction.ts` retains replay objects and
1166
+ archives before expected-head publication. The dispatcher polls all open nodes,
1167
+ including empty nodes, and advances clean cascades without agent calls. Only the
1168
+ active conflicted item attaches a reconcile runner, using source-build artifacts
1169
+ materialized by the dispatcher into the integration owner's store scope.
1170
+
1171
+ `kernel/node-parent.ts` coordinates lifecycle-aware target mutations for CLI
1172
+ and operator requests. It canonicalizes source aliases, checks the latest build
1173
+ generation and proposed/effective/pending ancestry, and reserves a durable
1174
+ `node.parent-requested` before provider mutation. Claimed work targets stay frozen;
1175
+ a changed target requires abort and re-dispatch before any mixed patch is written.
1176
+ The dispatcher reads node tickets independently of readiness and activates a
1177
+ confirmed, revalidated request with `node.parent-accepted`. Provider edits use
1178
+ the same validation; refusals are deduplicated by revision, target and reason.
1179
+ Uncertain writes recover by source readback rather than replaying a caller patch.
1180
+ Tracker observation errors are contained within that observation, preserving
1181
+ ordinary cascade and PR handling against durable ancestry. Already accepted moves
1182
+ complete their PR effects without another tracker read. Rejection comparisons use
1183
+ revision, target and reason fields so JSONB key ordering cannot defeat deduplication;
1184
+ `node.parent-rejection-cleared` removes a current refusal after correction while
1185
+ preserving its history.
1186
+
1187
+ Accepted parent facts update node target/base projections while creation facts
1188
+ remain provenance. Pending requests and moves fence verification, child landing
1189
+ and source landing, and count against both parents' completeness. Existing writer
1190
+ reservations settle before activation. The existing replay transaction freezes the
1191
+ new destination and retains the old contribution boundary until completion, even
1192
+ for distinct parents at the same SHA. Afterwards the dispatcher retargets the same
1193
+ PR through the optional `Forge.retargetPr` capability, inspects its acknowledged
1194
+ base/head, records a receipt and completes the parent operation. GitHub uses the
1195
+ [documented PR update endpoint](https://docs.github.com/en/rest/pulls/pulls#update-a-pull-request)
1196
+ with a branch-name `base`. Publication and PR acknowledgement retry separately;
1197
+ terminal human PR changes keep their ordinary handling. Children retain the moved
1198
+ node's identity and branch, so the usual target observations cascade the move.
1199
+
1200
+ In origin mode, node plumbing uses the forge's trusted `kernelExec` transport.
1201
+ The GitHub adapter supplies its token through subprocess-only Git configuration,
1202
+ scoped to the repository's HTTPS URL; credentials are absent from argv, saved
1203
+ remote URLs, repository configuration and agent environments. Parent snapshots,
1204
+ archives and expected-head writes use this same transport. The dispatcher checks
1205
+ parent and node heads through the forge API before acquiring a repository: an
1206
+ unchanged inventory needs no clone or Git commands. A required temporary clone
1207
+ completes before the node writer lease is acquired, so download time cannot
1208
+ expire writer authority. Build sandbox publication retains its separate trusted
1209
+ receive-pack path.
1210
+
1211
+ `kernel/node-landing.ts` shares the node writer lease and reservation with
1212
+ restacking. It cancels native auto-merge, refreshes actual PR refs, proves the
1213
+ exact destination ungated and fast-forwards the canonical child commit under
1214
+ CAS. The destination write proves landing; provider PR reconciliation is
1215
+ best-effort and never decides or retries that write. Root landing retains squash
1216
+ semantics. Store adapters expose node writer claim, renewal and holder-checked
1217
+ release separately from execution leases; Postgres schema version 15 adds their
1218
+ columns. Reservations live in the event stream and survive lease expiry.
1219
+
1220
+ The contribution boundary advances only on completed restacks. Reachable build
1221
+ identities include inherited parent changes; foreign counts include only the
1222
+ node's own contribution, preventing a parent rewrite from inflating descendants'
1223
+ foreign inventory. Status text and JSON expose both inventory and active items.
1224
+
1225
+
1226
+ Integration completion is sampled by `kernel/integration-completeness.ts` from
1227
+ exhaustive source listings, frozen claims and retained contribution identities.
1228
+ `integration.*` events retain observations, immutable cycle inputs, landing
1229
+ intents, provenance and tree audits. The build reducer projects these facts and
1230
+ `engine.ts` routes nodes directly through verification, without producer phases.
1231
+ Failed cycles park for repair children. The dispatcher temporarily provisions
1232
+ verification resources and rechecks head, parent, controls and completeness
1233
+ before publication. `integration-landing.ts` owns source-reserved root landing
1234
+ and immutable result audits; nested nodes use the destination writer transaction
1235
+ in `node-landing.ts`. GitHub uses guarded PR rebase; local-git uses an ancestry
1236
+ proof and exact-parent fast-forward. Shared status vocabulary exposes provenance
1237
+ and mismatch attention in both frontends. Human forge merges remain observable
1238
+ escape hatches independent of completeness and verification.
1239
+
1240
+ ### Landing authorization
1241
+
1242
+ The pure evaluator in `kernel/landing-policy.ts` chooses the first matching
1243
+ `[[landing]]` rule. `kernel/landing-state.ts` reduces immutable candidate
1244
+ decisions and persistent hold/land commands. The dispatcher owns readiness,
1245
+ ticket label sampling and native-state convergence. `kernel/landing-publication.ts`
1246
+ confirms native cancellation at local and trusted remote head-publication seams.
1247
+ Node landings retain the existing writer serialization and gate proof.
Binary file
@@ -1,5 +1,9 @@
1
1
  # Configuration reference
2
2
 
3
+ Install Autobuild in the target repository with `bun add -d --exact @defrex/autobuild`.
4
+ Here, `ab <command>` means the repository-installed CLI; run it as
5
+ `bun ab <command>`, for example `bun ab init`.
6
+
3
7
  Autobuild reads one declarative `autobuild.toml` from the repository root.
4
8
  Commands in the file are shell strings; the file itself is never evaluated as
5
9
  code. A running dispatcher owns an accepted snapshot from the main checkout,
@@ -214,6 +218,7 @@ These fields hot-reload:
214
218
  | `ticketScanIntervalSeconds` | Next tick; evaluates elapsed time against the new interval. |
215
219
  | `capacity` | Next dispatcher tick. |
216
220
  | `[pr]` | Next build creation. |
221
+ | `[landing]` (ordered `[[landing]]` rules) | Dispatcher-owned policy; next new readiness decision. Existing decisions retain their sampled rule. |
217
222
  | `[commands]` | Next setup, verify check, or finalize check selected for a build whose OWN branch carries it. Dispatcher readiness, resume, and recovery use the same pin. A base-branch reload does not retarget an in-flight build. |
218
223
  | `[verify]` and `[finalize]` | Next engine step selection for a build whose OWN branch carries it. Dispatcher readiness, resume, and recovery use the same pin. An approved plan's stored verify selection remains authoritative, and a base-branch reload does not retarget an in-flight build. |
219
224
  | `[workspace]` provider and config (including `provisioning`) | Next launch of a build whose OWN branch carries it. A base-branch reload never re-provisions an in-flight build. |
@@ -277,8 +282,8 @@ root whose config is being read. In a scoped phase process that root is the
277
282
  immutable build worktree. Bare npm package specifiers resolve first from the
278
283
  consuming repository's main checkout and therefore use its installed
279
284
  dependencies; a package the repository lacks then resolves from Autobuild's own
280
- installation, so an extension installed next to the CLI (`bun add -g
281
- @defrex/autobuild-<extension>`) loads without being added to the repository. A
285
+ installation as a fallback. Install extensions in the consuming repository with
286
+ `bun add -d --exact @defrex/autobuild-<extension>`. A
282
287
  repository copy always wins over an installed one. This package lookup remains
283
288
  stable when a relocated local store places a linked worktree outside the
284
289
  checkout. Dispatch and sessionless commands use the main checkout for both
@@ -445,6 +450,32 @@ runtime's optional one-shot capability serves slug naming and lazy upgrade
445
450
  conflict resolution; when absent, each caller retains its existing safe
446
451
  fallback.
447
452
 
453
+ ## `[[landing]]`
454
+
455
+ An ordered list of strict landing rules. Predicates within one rule are ANDed;
456
+ the first matching rule wins. Omitted predicates match everything. With no
457
+ matching rule, leaves default to `auto` and nodes to `consent`.
458
+
459
+ | Field | Meaning |
460
+ |---|---|
461
+ | `into` | Optional destination: `root`, any `node`, or an exact frozen destination node ticket id. |
462
+ | `from` | Optional source kind: `leaf` or `node`. |
463
+ | `label` | Optional exact, case-sensitive label on the source ticket. Blank labels are invalid. |
464
+ | `mode` | Required `auto` or `consent`. |
465
+
466
+ For example, put a rule with `into = "root"` and `mode = "consent"`
467
+ before a catch-all rule with `mode = "auto"` to request consent only at the
468
+ root. A catch-all placed first shadows every later rule. Specific-node rules
469
+ match the build's frozen destination, rather than the ticket's current parent.
470
+
471
+ A readiness decision retains the complete matched rule and index (or an explicit
472
+ default), source kind, destination and sampled labels. Later policy edits do not
473
+ rewrite this provenance. Landing policy belongs to the live dispatcher config;
474
+ it is excluded from pinned pipeline settings and integration verification inputs.
475
+ See [worked landing configurations and forge requirements](landing-policy.md),
476
+ [operating controls](#landing-policy), and
477
+ [migration from 0.x](migration-1.0.md).
478
+
448
479
  ## `[pr]`
449
480
 
450
481
  Optional. Omitting the table leaves attachment hosting off; attached artifacts
@@ -1243,6 +1274,25 @@ invariants, not additional configuration fields.
1243
1274
 
1244
1275
  ## `[tickets]`
1245
1276
 
1277
+ ### Ticket kind and target metadata
1278
+
1279
+ `kind` and `target` are fields on individual tickets, not `[tickets]` TOML keys.
1280
+ `kind` defaults to `work`; `node` creates a finite integration point. Omitted
1281
+ `target` means the configured `baseBranch` root. A target must be a same-source
1282
+ node ticket id. `ab ticket update <id> --target <node-id>` changes it;
1283
+ `--no-target` clears it and `--kind work` resets kind. Omitted update fields
1284
+ preserve values. Claimed work targets cannot change: abort and re-dispatch.
1285
+ Open nodes can reparent under the guarded protocol, revoking land consent.
1286
+
1287
+ File tickets persist the fields in frontmatter; hosted tickets store them with
1288
+ project-scoped transactional validation. Linear maps kind to the exact `node`
1289
+ label and target to a parent carrying that label. Ordinary grouping parents do
1290
+ not impose targets; explicit clear removes the parent relation. Node demotion
1291
+ with targeting children and cycles are refused regardless of child state.
1292
+ See [integration trees](integration-tree.md) for admission, lifecycle and commands.
1293
+
1294
+ ### Source configuration
1295
+
1246
1296
  To move an existing project between sources, follow the
1247
1297
  [ticket migration procedure](ticket-migration.md).
1248
1298
 
@@ -1647,8 +1697,10 @@ configuration. The setup prompt instead asks the agent to review and improve
1647
1697
  the existing config.
1648
1698
 
1649
1699
  Re-running init still maintains the `.autobuild/` ignore rule and skill
1650
- installation. `ab upgrade` does not migrate or rewrite `autobuild.toml`; by
1651
- default it first updates a recognized Bun installation — from the npm registry
1700
+ installation. `ab upgrade` migrates an absent landing policy from the target
1701
+ repository journal; explicit landing arrays are preserved. See
1702
+ [migration from 0.x](migration-1.0.md). By default it first updates a recognized
1703
+ Bun installation — from the npm registry
1652
1704
  for a registry install, or from GitHub Releases for a `github:` install — and
1653
1705
  then merges vendored skills from that distribution. For a local install, Bun may update the
1654
1706
  *owning* project's Autobuild dependency in `package.json` and `bun.lock`; this
@@ -1705,7 +1757,7 @@ either retirement.
1705
1757
 
1706
1758
  ## Durable settings outside TOML
1707
1759
 
1708
- Four repository-wide operator choices intentionally live as facts in the
1760
+ Three repository-wide operator choices intentionally live as facts in the
1709
1761
  BuildStore repository journal, not in `autobuild.toml`. They are latest-write
1710
1762
  wins, survive process restarts, and are sampled by every dispatcher on its
1711
1763
  poll. Editing TOML cannot change them.
@@ -1714,13 +1766,13 @@ poll. Editing TOML cannot change them.
1714
1766
  |---|---:|---|---|
1715
1767
  | Ticket intake | on | `ab dispatch --intake` / `--no-intake`; `i` on the dashboard's global row, and `p` (pause all) / `r` (resume all) on that row or their sessionless equivalents `ab pause --all` / `ab resume --all`, which turn intake off and on as part of quiescing the repository | When off, skip only new ticket list/claim/dispatch work. Janitor work, lease recovery, in-flight builds, and harvesting continue. Turning intake off does not hold builds the repository has already accepted — that is the repository pause below. |
1716
1768
  | Repository pause | off | `p` (pause all) / `r` (resume all) on the dashboard's global row, or `ab pause --all` / `ab resume --all` | While on, the dashboard controls line shows `repository PAUSED`, and each held queued row shows `(held)` while retaining its literal `QUEUED` status. No dispatcher tick attaches a runner to such a build — recovery, startup resume, and the lease sweep all skip them. Running builds are parked by the per-build pauses the same command writes; the janitor still settles aborts and discards. |
1717
- | Repository auto-merge default | off | `ab dispatch --auto-merge` / `--no-auto-merge`; `m` on the global row | Seeds durable auto-merge intent on builds claimed while the setting is enabled, and — on each change — also applies as a bulk action to every current non-terminal build: turning it on requests consent for each build (turning it off withdraws it), attributed to the operator who toggled it exactly as if they had pressed `m` on every row. A per-build toggle overrides its build's state until the global row is toggled again. |
1718
1769
  | Harvest gate | on | `h` on the dashboard's global row | Pauses or resumes repository observation harvesting. The header shows the kernel-acknowledged gate, not merely a pending keypress. |
1719
1770
 
1720
1771
  The opposite flag forms for each dispatch setting are mutually exclusive.
1721
1772
  Omitting both writes nothing and reuses the durable value. Per-build
1722
- pause/resume and auto-merge controls are separate facts and do not alter these
1723
- repository defaults. Pause all and resume all write two facts each — the
1773
+ pause/resume and landing controls are separate facts and do not alter these
1774
+ repository settings; landing authorization follows `[[landing]]`. Pause all and
1775
+ resume all write two facts each — the
1724
1776
  repository pause first, then intake — so a partial failure still leaves the
1725
1777
  repository at least as quiesced as asked; `ab pause --all` reports on stderr
1726
1778
  which of them landed when a walk stops partway. The current release has no TOML
@@ -1758,8 +1810,10 @@ set or copy them into `.env`; the runner stamps them for each session.
1758
1810
 
1759
1811
  Forge and agent credentials remain adapter-owned. The `local-git` forge uses no
1760
1812
  credentials or network access: it keeps durable PR records under private Git
1761
- refs, leaves each build at `refs/heads/ab/<slug>`, and squash-merges locally only
1762
- after auto-merge consent. The squash author and committer come from the
1813
+ refs, leaves each work build at `refs/heads/ab/<slug>`, and lands root leaves by
1814
+ squash under the recorded landing authorization. Node landings use guarded
1815
+ fast-forwards; see [landing methods](landing-policy.md#landing-methods).
1816
+ The squash author and committer come from the
1763
1817
  repository's ordinary Git identity, as resolved for a plain `git commit`; the
1764
1818
  landing is always unsigned even when `commit.gpgsign` is enabled. If Git cannot
1765
1819
  resolve that identity, the PR remains open and `ab build status <slug>` names
@@ -1891,21 +1945,24 @@ configuration still rejects unknown override keys.
1891
1945
 
1892
1946
  ## Hosted service client compatibility
1893
1947
 
1894
- A service accepts stable clients from its own `major.minor` release line and
1895
- the two preceding minor lines in the same major. A major starts a new family:
1948
+ A service accepts stable and prerelease clients from its own `major.minor`
1949
+ release line and the two preceding minor lines in the same major. A major starts a new family:
1896
1950
  X.0 accepts only X.0, X.1 accepts X.0/X.1, and X.2 onward accepts three lines.
1897
1951
  Patch versions are interchangeable in both directions and must never change
1898
1952
  the protocol. Upgrade the service first, then projects independently within
1899
1953
  its window. Supported release lines retain their wire handlers and known
1900
1954
  protocol identities; an unknown protocol is refused independently of version.
1901
- Malformed, missing, and prerelease identities are refused with HTTP 409.
1955
+ Stable and prerelease service and client identities share their numeric major/minor
1956
+ line. Malformed or missing identities, build metadata (`+…`), prefixes and
1957
+ whitespace are refused with HTTP 409.
1902
1958
  A newer client is told to upgrade the service; a client below the window is
1903
1959
  told to upgrade the project's Autobuild. Diagnostics name the service version
1904
1960
  and supported range.
1905
1961
 
1906
1962
  Unauthenticated `GET /health` publishes `ok`, `autobuildVersion`,
1907
1963
  `protocolVersion`, and `supportedClientRange: { minVersion, maxVersionExclusive }`.
1908
- The range is inclusive at the minimum and exclusive at the maximum; a 0.11.x
1964
+ Range endpoints remain stable versions. The range is inclusive at the minimum
1965
+ and exclusive at the maximum; a 0.11.x
1909
1966
  service publishes `>=0.9.0 <0.12.0`. Health needs no credentials, version
1910
1967
  headers, or available backend.
1911
1968
 
@@ -1916,3 +1973,50 @@ and is never supplied; factory environments also exclude `AB_TOKEN`. Launch
1916
1973
  credentials travel through the separate transient execution-auth argument, never
1917
1974
  through serialized execution identity. Existing plugins that forwarded
1918
1975
  `storeToken` must migrate to this callback and fail closed if it is unavailable.
1976
+
1977
+ ## Landing policy
1978
+
1979
+ The [`[[landing]]` table](#landing) defines ordered authorization rules and
1980
+ readiness provenance. See [landing policy](landing-policy.md) for examples,
1981
+ merge methods and forge capability requirements.
1982
+
1983
+ `ab hold <slug>` durably suppresses landing and revokes previous consent, even
1984
+ before readiness. `ab land <slug>` requires readiness, clears hold, and consents
1985
+ to this build/node landing into its effective destination. Consent survives head
1986
+ replacement, restacking, verification and re-finalization until another hold or
1987
+ completion. Accepted node reparenting revokes consent; holds survive.
1988
+ It is consent to the landing, not approval of an immutable diff.
1989
+ Commands and acknowledgements are sequence-correlated; hold acknowledgement
1990
+ requires confirmed native cancellation, while land acknowledgement accepts
1991
+ consent without claiming that merge gates passed. The same actions are available
1992
+ through the MCP/operator build-control tools. The terminal uses `l` for land and
1993
+ `o` for hold on the selected landing. The web has no consent controls.
1994
+
1995
+ The repository auto-merge default and its fan-out are retired. Historical events
1996
+ still replay; explicit old per-build commands map to consent/hold until a new
1997
+ landing command supersedes them, while old default seeds confer no consent.
1998
+ `ab upgrade` samples the target repository's configured journal and writes leaf
1999
+ auto for old ON, leaf consent for old OFF (including no fact), and node consent
2000
+ in either case. Explicit landing arrays remain byte-for-byte unchanged. Missing
2001
+ configuration or unavailable journals fail with recovery guidance. Fresh init
2002
+ uses the no-rules fallback.
2003
+
2004
+ Native auto-merge is reconciled on every janitor poll against durable desired
2005
+ landing state. It is disabled while held, unauthorized, unready, or replacement
2006
+ publication is pending or just completed; enabling binds to the current head
2007
+ through the forge's expected-head guard. Every replacement publication confirms
2008
+ cancellation first, and its first following poll re-reads and reconciles native
2009
+ state before other build actions. Native receipts bind to exact candidates;
2010
+ consent does not. A stale enable completing after cancellation is repaired by
2011
+ poll reconciliation. This is an explicitly bounded failure model: native merge
2012
+ is used only behind a merge-blocking gate, and checks on a replacement head must
2013
+ take far longer than one poll interval, allowing cancellation before they pass.
2014
+ There is no durable native-effect reservation protocol. An undesired forge
2015
+ landing is classified from the kernel's last durable native application state, without changing provider contracts. A confirmed disabled
2016
+ state with no enable in flight or indeterminate means a deliberate human forge
2017
+ landing, which supplies consent. Record whether it overrode a hold: an unheld
2018
+ human landing needs no operator attention; overriding a hold is informational.
2019
+ If native auto-merge was armed, or an enable was in flight or indeterminate,
2020
+ record a possible stale-enable landing as contrary to policy and raise operator
2021
+ attention. Autobuild never rewrites the target to undo either outcome. Merge
2022
+ gates and the serialized node-writer publication rules remain authoritative.
@@ -238,3 +238,21 @@ To retain earlier names configure `triageState = "Backlog"`,
238
238
  `claimedState = "Doing"`, `doneState = "Done"`, and the desired `readyState`.
239
239
  Existing ticket rows are never renamed. Older combined-service clients continue
240
240
  using the uploaded dispatcher configuration until independent policy is published.
241
+
242
+ ## Integration tree metadata
243
+
244
+ Hosted tickets store `kind` (`work` or `node`, default `work`) and optional
245
+ `target`, the canonical readable id of a node in the same project. Create accepts
246
+ both fields; update and guarded update preserve omitted fields and accept
247
+ `target: null` to clear an edge. Targets must exist and be nodes. Self-targets,
248
+ ancestor cycles, and demoting a node with targeting tickets (including completed
249
+ work) are rejected before any part of a mixed patch is written. Graph mutations
250
+ serialize per project in the same transaction as validation and revision checks.
251
+ Effective metadata changes increment the revision; equivalent aliases are no-ops.
252
+
253
+ Ticket responses include these fields only with `x-autobuild-ticket-tree: 1`.
254
+ This capability is independent of revision and comment capabilities and of the
255
+ client version. Without it, both fields are projected away, preserving historical
256
+ strict decoders. Current hosted clients send all three capability headers and
257
+ default absent kind to `work`. Unfiltered listing includes all ticket states and
258
+ empty nodes for `ab ticket tree`; dispatch and landing behavior are unchanged.