@defrex/autobuild 1.4.0 → 1.4.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.
package/README.md CHANGED
@@ -26,7 +26,7 @@ From the repository you want built, install Autobuild as a development dependenc
26
26
  <!-- release-install:start -->
27
27
 
28
28
  ```sh
29
- bun add -d --exact @defrex/autobuild@1.4.0
29
+ bun add -d --exact @defrex/autobuild@1.4.1
30
30
  ```
31
31
 
32
32
  <!-- release-install:end -->
package/SPEC.md CHANGED
@@ -2874,7 +2874,11 @@ Repository tick telemetry is bounded mutable operational metadata, like leases.
2874
2874
  `beginRepoTick` persists the open boundary before unsafe work; `finishRepoTick`
2875
2875
  atomically replaces it with actual completion time and outcome and appends any
2876
2876
  validated tick boundaries. Both are fenced by the unexpired repository lease,
2877
- and neither renews it. Quiet completions advance telemetry without advancing the
2877
+ and neither renews it. Unchanged standing ticket counts and diagnostics do not publish
2878
+ tick pairs. Changes to those counts or diagnostics, per-tick activity, recovery from a
2879
+ failed tick, and due attention retries still publish. The last published diagnostics
2880
+ remain visible while lease-fenced completion telemetry advances independently of the
2881
+ journal cursor. Quiet completions advance telemetry without advancing the
2878
2882
  journal. Readers refresh telemetry independently of event cursors, correlate it
2879
2883
  by run, and merge with historical completions by actual time; heartbeat never
2880
2884
  stands in for tick completion. Telemetry survives lease release. Safe shutdown
@@ -56,9 +56,10 @@ projection, plugin SDK, and reusable contract suites. The optional
56
56
  `packages/hosted-store-service` workspace composes the public remote-server
57
57
  surface with `packages/postgres-store`; the separate optional
58
58
  `packages/hosted-dispatcher` workspace owns the cron-driven hosted dispatcher
59
- (the `/api/dispatch` route driver, the deploy-time `pack-distribution` command,
60
- and the packed-distribution trace helper) and peers on both the core and the
61
- store service. The optional `packages/vercel-sandbox` workspace publishes the
59
+ (the `/api/dispatch` route driver, and the deploy-time `pack-distribution` and
60
+ `ship-deployment` commands that pack the guest archive and ship it, its
61
+ manifest and the selected provider plugins into the dispatch function) and
62
+ peers on both the core and the store service. The optional `packages/vercel-sandbox` workspace publishes the
62
63
  `@defrex/autobuild-vercel-sandbox` provider plugin (AUT-517): while the
63
64
  builtin hosts the implementation, its manifest re-registers the provider name
64
65
  over the shared capability object and the loader skips it with a notice.
@@ -80,7 +81,7 @@ remote-store protocol requires matching client and server versions.
80
81
  | `packages/core/src/store/` | BuildStore contract spanning builds, the repository journal, and operator sessions; interface-enforced build, operator-session, and local ambient-session scope wrappers; memory, SQLite/blob, and remote HTTP adapters | §7 |
81
82
  | `packages/core/src/store/streams/` | The stream primitive's shared core (§7.6): record/chunk types and the `ai-ui-message-stream/v1` constants, SDK-backed close-time `UIMessage[]` assembly, and the uniform bounded-wait read loop | §7.6 |
82
83
  | `packages/hosted-store-service/` | Environment-only hosted Fetch handler, lazy PostgreSQL/blob composition, offline token binary, the Next.js operator web app (`app/`, `server.ts`, `next.config.ts`, `vercel.json`), tests, and deployment guide | §7.2, §18 |
83
- | `packages/hosted-dispatcher/` | The optional cron-driven hosted dispatcher: endpoint driver, deploy-time `pack-distribution` binary, packed-distribution trace helper, tests, and operator guide | §7.2, §12, §18 |
84
+ | `packages/hosted-dispatcher/` | The optional cron-driven hosted dispatcher: endpoint driver, deploy-time `pack-distribution` and `ship-deployment` binary, packed-distribution trace helper, provider plugin shipper, tests, and operator guide | §7.2, §12, §18 |
84
85
  | `packages/vercel-sandbox/` | Published `@defrex/autobuild-vercel-sandbox` provider plugin: transitional manifest over the shared capability object with a guarded factory (implementation stays builtin-hosted until AUT-505) | §3.2.1 |
85
86
  | `packages/hosted-store-service/server.ts`, `packages/hosted-store-service/vercel.json` | One host-neutral Bun listener used locally and by Vercel's Bun preset | §7.2 |
86
87
  | `packages/core/src/kernel/` | Phase table, build reducer, engine; pure harvest, dispatcher-settings, dispatcher-status, and PR-attachment selectors; converge, stall detection, verify gating | §5, §7.5, §10, §12, §14, §15.4–15.5 |
@@ -558,8 +559,12 @@ kernel child is reaped, after which a non-SIGINT terminating signal is replayed
558
559
  in the frontend. A parent-liveness watch remains the detached-kernel fallback.
559
560
  The repository record carries constant-size, lease-holder-fenced tick telemetry:
560
561
  `beginRepoTick` opens the unsafe boundary, and `finishRepoTick` atomically closes
561
- it and appends selected tick facts. Successful unchanged ticks append nothing;
562
- queue transitions, counters, diagnostics, attention resets/retries, and failures
562
+ it and appends selected tick facts. Unchanged standing ticket counts and diagnostics do
563
+ not publish tick pairs. Changes to those counts or diagnostics, per-tick activity,
564
+ recovery from a failed tick, and due attention retries still publish. The last published
565
+ diagnostics remain visible while lease-fenced completion telemetry advances
566
+ independently of the journal cursor. Successful unchanged ticks append nothing;
567
+ queue transitions, activity counters, changed diagnostics, attention resets/retries, and failures
563
568
  retain their journal evidence. Buffered starts preserve actual `startedAt` for
564
569
  attention cooldowns; old starts use their envelope time. Liveness reads refresh
565
570
  the repository record even with an unchanged event cursor, merging matching-run
@@ -1556,6 +1556,10 @@ is `{outcome:"completed", counters}` or `{outcome:"failed", error}`; events is
1556
1556
  empty for a quiet success or a matching dispatcher start/terminal pair for that
1557
1557
  holder. The validated batch and finished telemetry commit atomically. The reply
1558
1558
  is `{observation, events}` with assigned envelopes, or null on fencing failure.
1559
+ Unchanged standing ticket counts and diagnostics do not publish tick pairs. Changes to
1560
+ those counts or diagnostics, per-tick activity, recovery from a failed tick, and due
1561
+ attention retries still publish. The last published diagnostics remain visible while
1562
+ lease-fenced completion telemetry advances independently of the journal cursor.
1559
1563
  These operations never renew the lease. Repository records optionally expose
1560
1564
  `tick: {run, open?: {startedAt}, finished?: {run, startedAt, completedAt, ...completion}}`.
1561
1565
  They retain the previous completion while a new tick is open and after lease
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defrex/autobuild",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Agent-driven software delivery from groomed ticket to merged PR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -156,8 +156,8 @@
156
156
  },
157
157
  "devDependencies": {
158
158
  "@biomejs/biome": "2.5.5",
159
- "@defrex/autobuild-postgres-store": "1.4.0",
160
- "@defrex/autobuild-vercel-sandbox": "1.4.0",
159
+ "@defrex/autobuild-postgres-store": "1.4.1",
160
+ "@defrex/autobuild-vercel-sandbox": "1.4.1",
161
161
  "@resvg/resvg-js": "2.6.2",
162
162
  "@types/bun": "^1.3.14",
163
163
  "@types/node": "^24.0.0",
@@ -163,6 +163,8 @@ export class DispatchFrontend {
163
163
  private accepting = false
164
164
  private cleanupInput: (() => void) | undefined
165
165
  private refresh: DashboardRefresh | undefined
166
+ /** Set once a failure streak is journaled; cleared by the next good frame. */
167
+ private renderFailureReported = false
166
168
  private suspension: ReturnType<typeof installPresentationSuspension> | undefined
167
169
  private readonly reader: BuildStore
168
170
  private paintTimer: ReturnType<typeof setInterval> | undefined
@@ -1078,12 +1080,18 @@ export class DispatchFrontend {
1078
1080
  async () => {
1079
1081
  try {
1080
1082
  await this.readFrame()
1083
+ this.renderFailureReported = false
1081
1084
  } catch (error) {
1082
- if (this.refresh?.admitted)
1085
+ // One durable warning per failure streak, not per poll: a poll that
1086
+ // fails on every tick would otherwise grow the journal it reads.
1087
+ // Messages carry moving cursors, so they cannot serve as the dedup key.
1088
+ if (this.refresh?.admitted && !this.renderFailureReported) {
1089
+ this.renderFailureReported = true
1083
1090
  await this.report(
1084
1091
  `dashboard render failed: ${error instanceof Error ? error.message : String(error)}`,
1085
1092
  'warning',
1086
1093
  )
1094
+ }
1087
1095
  throw error
1088
1096
  }
1089
1097
  },
@@ -40,7 +40,7 @@ import { cachedRuntime, resolveCachedGuestArchive } from '../../cli/dispatch-run
40
40
  * bytes installed and resolution never adds a second pack per tick.
41
41
  */
42
42
  import { createHash } from 'node:crypto'
43
- import { access, mkdir, readdir, readFile, writeFile } from 'node:fs/promises'
43
+ import { access, mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises'
44
44
  import { join, resolve } from 'node:path'
45
45
  import { distributionRoot, distributionPath } from '../../distribution'
46
46
  import { REMOTE_STORE_PROTOCOL_VERSION } from '../../store/remote/version'
@@ -247,16 +247,26 @@ export async function packageAutobuildDistribution(): Promise<Uint8Array> {
247
247
 
248
248
  /** Pack the running distribution into `<root>/.autobuild-dist/autobuild-<version>.tgz`
249
249
  * (the same bytes `bun pm pack` produces) and return the archive path. Meant
250
- * for a deployment's build step, where `bun` and the source tree exist. */
250
+ * for a deployment's build step, where `bun` and the source tree exist. Any
251
+ * other `autobuild-*.tgz` there is removed: a cached build folder from an
252
+ * earlier version would otherwise hold two archives, which the deployment
253
+ * refuses to ship. */
251
254
  export async function writePrebuiltDistributionArchive(
252
255
  root: string = distributionRoot(),
256
+ pack: () => Promise<Uint8Array> = packageAutobuildDistribution,
253
257
  ): Promise<string> {
254
258
  const version = await readDistributionIdentity()
255
- const archive = await packageAutobuildDistribution()
259
+ const archive = await pack()
256
260
  const dir = join(root, PREBUILT_DISTRIBUTION_DIR)
257
261
  await mkdir(dir, { recursive: true })
258
- const path = join(dir, distributionAssetName(version))
262
+ const name = distributionAssetName(version)
263
+ const path = join(dir, name)
259
264
  await writeFile(path, archive)
265
+ for (const entry of await readdir(dir)) {
266
+ if (entry !== name && entry.startsWith('autobuild-') && entry.endsWith('.tgz')) {
267
+ await rm(join(dir, entry), { force: true })
268
+ }
269
+ }
260
270
  return path
261
271
  }
262
272
 
@@ -1,40 +1,49 @@
1
1
  import type { RepositoryEvent } from '../events/repository'
2
2
  import type { TickReport } from './dispatcher'
3
3
 
4
- /** Every counter and diagnostic is significant, including standing counts.
5
- * Queue depth alone may be unchanged and nonzero. */
4
+ const standingCounters = ['invalidTickets', 'dependencyBlocked', 'creationWithheld'] as const
5
+ const diagnostics = [
6
+ 'blockedDiagnostics',
7
+ 'janitorDiagnostics',
8
+ 'ticketDiagnostics',
9
+ 'creationDiagnostics',
10
+ 'dependencyDiagnostics',
11
+ ] as const
12
+
13
+ /** Standing state changes publish; activity publishes on every occurrence. */
14
+ function reportRequiresPublication(
15
+ report: TickReport,
16
+ previous: RepositoryEvent | undefined,
17
+ ): boolean {
18
+ if (previous?.type !== 'dispatcher.tick-completed' || previous.payload.queued !== report.queued)
19
+ return true
20
+ for (const key of standingCounters)
21
+ if (report[key] !== (previous.payload.counters[key] ?? 0)) return true
22
+ for (const key of diagnostics) {
23
+ const before = previous.payload[key] ?? []
24
+ if (report[key].length !== before.length || report[key].some((value, i) => value !== before[i]))
25
+ return true
26
+ }
27
+ return Object.entries(report).some(
28
+ ([key, value]) =>
29
+ key !== 'queued' &&
30
+ key !== 'forgeRequests' &&
31
+ !standingCounters.some((standing) => standing === key) &&
32
+ typeof value === 'number' &&
33
+ value !== 0,
34
+ )
35
+ }
36
+
6
37
  export function shouldPublishTick(
7
38
  report: TickReport,
8
39
  events: readonly RepositoryEvent[],
9
40
  run: string,
10
41
  startedAt: string,
11
42
  ): boolean {
12
- if (
13
- Object.entries(report).some(
14
- ([key, value]) =>
15
- key !== 'queued' &&
16
- key !== 'forgeRequests' &&
17
- (typeof value === 'number' ? value !== 0 : value.length > 0),
18
- )
19
- )
20
- return true
21
- // Queue and diagnostic readers reduce per run, so each run must publish
22
- // its own baseline before quiet ticks can be suppressed.
23
43
  const previous = events.findLast(
24
44
  (e) => e.type === 'dispatcher.tick-completed' && e.payload.run === run,
25
45
  )
26
- if (previous?.type !== 'dispatcher.tick-completed' || previous.payload.queued !== report.queued)
27
- return true
28
- if (
29
- [
30
- previous.payload.blockedDiagnostics ?? [],
31
- previous.payload.janitorDiagnostics,
32
- previous.payload.ticketDiagnostics,
33
- previous.payload.creationDiagnostics ?? [],
34
- previous.payload.dependencyDiagnostics,
35
- ].some((list) => list.length > 0)
36
- )
37
- return true
46
+ if (reportRequiresPublication(report, previous)) return true
38
47
  const boundary = events.findLast(
39
48
  (e) =>
40
49
  (e.type === 'dispatcher.tick-completed' || e.type === 'dispatcher.tick-failed') &&
@@ -84,28 +93,7 @@ export function shouldPublishTickFromFacts(
84
93
  run: import('../kernel/read-facts').DispatcherRunFacts,
85
94
  startedAt: string,
86
95
  ): boolean {
87
- if (
88
- Object.entries(report).some(
89
- ([key, value]) =>
90
- key !== 'queued' &&
91
- key !== 'forgeRequests' &&
92
- (typeof value === 'number' ? value !== 0 : value.length > 0),
93
- )
94
- )
95
- return true
96
- const previous = run.completed
97
- if (previous?.type !== 'dispatcher.tick-completed' || previous.payload.queued !== report.queued)
98
- return true
99
- if (
100
- [
101
- previous.payload.blockedDiagnostics ?? [],
102
- previous.payload.janitorDiagnostics,
103
- previous.payload.ticketDiagnostics,
104
- previous.payload.creationDiagnostics ?? [],
105
- previous.payload.dependencyDiagnostics,
106
- ].some((list) => list.length > 0)
107
- )
108
- return true
96
+ if (reportRequiresPublication(report, run.completed)) return true
109
97
  if (run.tick?.type === 'dispatcher.tick-failed') return true
110
98
  return facts.attention.sources.some(
111
99
  ([, source]) =>
@@ -33,5 +33,16 @@
33
33
  "provenance": {
34
34
  "tag": "v1.4.0"
35
35
  }
36
+ },
37
+ {
38
+ "version": "1.4.1",
39
+ "publishedAt": "2026-11-03T00:07:39.172Z",
40
+ "protocol": "7",
41
+ "contract": "1.4.0.json",
42
+ "projects": true,
43
+ "catalogIdentity": "f9289449e0df64c1de972d7456cd4d50f179f06b36a20bed05ba91411573b194",
44
+ "provenance": {
45
+ "tag": "v1.4.1"
46
+ }
36
47
  }
37
48
  ]
@@ -1384,7 +1384,7 @@ commit, and the PR; a refused or failed attempt is journaled too.
1384
1384
  `[upgrade] automatic` is a strict boolean, defaults to `true`, and hot-reloads.
1385
1385
  Resident checkout dispatchers check every 60 seconds, independently of tick cadence.
1386
1386
  Exact changed targets can include downgrades. Missing or inconsistent declared-pin
1387
- metadata never falls back to installed mode. Self-hosting source launches follow
1387
+ metadata never falls back to installed mode. Source-mode launches follow
1388
1388
  the authoritative base commit using packaged-content and production-lock equality,
1389
1389
  without modifying operator or build worktrees. Equal-content advances still record
1390
1390
  the latest resolved target SHA. Compatible generations overlap through the durable draining handoff described above. `--once`, origin-mode and direct hot
@@ -1671,6 +1671,18 @@ saved credential for CI and other non-interactive hosts. A service override
1671
1671
  never borrows another service's credential. Build and harvest sessions keep
1672
1672
  their explicit scoped authority.
1673
1673
 
1674
+ ## Self-hosting the service
1675
+
1676
+ Connecting a project to an existing Autobuild service, as above, is the
1677
+ supported path. Running your own service instance, store-only or with its
1678
+ hosted dispatcher, is an unsupported, buyer-beware path: it is not fully
1679
+ production-ready, and its packaging, variables and procedure may change without
1680
+ notice. The deployment guide installs with the service package at
1681
+ `node_modules/@defrex/autobuild-hosted-store-service/SELF-HOSTING.md` inside the
1682
+ deployment folder; before that folder exists, read it at
1683
+ https://github.com/defrex/autobuild/blob/main/packages/hosted-store-service/SELF-HOSTING.md.
1684
+ Do not present self-hosting to users as a supported product feature.
1685
+
1674
1686
  ## Source-agnostic ticket operations
1675
1687
 
1676
1688
  The sessionless `ab ticket` namespace constructs whichever TicketSource the
@@ -2475,7 +2487,11 @@ Dispatcher liveness is also visible through `ab repository status --json`:
2475
2487
  `dispatcher.holder` identifies the unexpired repository lease owner, independently
2476
2488
  of `latestRun`. Each run includes its recorded `runtime` (version, commit, and
2477
2489
  source kind/location), or null for unrecorded historical starts. Heartbeat age measures attributable renewals; tick age measures
2478
- actual tick completion. Successful unchanged ticks leave no journal pair; bounded,
2490
+ actual tick completion. Unchanged standing ticket counts and diagnostics do not publish
2491
+ tick pairs. Changes to those counts or diagnostics, per-tick activity, recovery from a
2492
+ failed tick, and due attention retries still publish. The last published diagnostics
2493
+ remain visible while lease-fenced completion telemetry advances independently of the
2494
+ journal cursor. Successful unchanged ticks leave no journal pair; bounded,
2479
2495
  lease-fenced repository telemetry still records each actual completion and its
2480
2496
  outcome. Last-tick age refreshes independently of the event cursor and never uses
2481
2497
  heartbeat as completion evidence. Open telemetry protects unsafe work during
@@ -2611,6 +2627,12 @@ ab wait --for blocked --json my-build # exit 0: record says why; 2: it ended;
2611
2627
  Second, a plain blocking call — Codex, Pi, and the shell only expose "run a
2612
2628
  command and wait": run it in the turn and read the record when it returns.
2613
2629
 
2630
+ The same split governs `ab watch`, which streams and does not exit when it
2631
+ emits a record. Run an unbounded watch only under a monitor that wakes the
2632
+ agent on each output line. Under exit-only notification, bound it with
2633
+ `--count 1` so the first record ends the command, then re-arm from its
2634
+ trailing cursor.
2635
+
2614
2636
  The loop pattern ties the two together: wait, act on the record (answer the
2615
2637
  escalation, inspect the build, merge the PR), then wait again, passing the
2616
2638
  record's `cursor` back through `--since` so no event is ever examined twice:
@@ -1556,6 +1556,10 @@ is `{outcome:"completed", counters}` or `{outcome:"failed", error}`; events is
1556
1556
  empty for a quiet success or a matching dispatcher start/terminal pair for that
1557
1557
  holder. The validated batch and finished telemetry commit atomically. The reply
1558
1558
  is `{observation, events}` with assigned envelopes, or null on fencing failure.
1559
+ Unchanged standing ticket counts and diagnostics do not publish tick pairs. Changes to
1560
+ those counts or diagnostics, per-tick activity, recovery from a failed tick, and due
1561
+ attention retries still publish. The last published diagnostics remain visible while
1562
+ lease-fenced completion telemetry advances independently of the journal cursor.
1559
1563
  These operations never renew the lease. Repository records optionally expose
1560
1564
  `tick: {run, open?: {startedAt}, finished?: {run, startedAt, completedAt, ...completion}}`.
1561
1565
  They retain the previous completion while a new tick is open and after lease
@@ -162,12 +162,26 @@ satisfied only by new events. Conditions include `attention`,
162
162
  condition, 3 timeout, 4 interrupted. On 3 and 4 with `--json`, the output is a
163
163
  bare `{"cursor": …}` to resume from.
164
164
 
165
- Run long watches and waits in whatever background or monitor facility your
166
- harness provides, so the session stays responsive and you are woken when they
167
- emit. Use precisely the same resolved invocation and working directory as
168
- foreground commands, including inside background shells and harness monitors.
169
- Do not rely on a shell alias or function that those facilities may lose.
170
- Never block a foreground command for their whole duration.
165
+ An unbounded watch streams: it prints each record and keeps running, so it
166
+ does not exit when a build blocks. Match how you run it to how your harness
167
+ wakes you:
168
+
169
+ - **Woken on each new output line** (a monitor that streams stdout, such as
170
+ Claude Code's Monitor tool): run the standing watch unbounded there and act
171
+ on every line as it arrives.
172
+ - **Woken only when a command exits** (a background shell such as Claude
173
+ Code's background Bash, or a plain blocking call): never run an unbounded
174
+ watch this way, because its records sit unread until it exits. Add
175
+ `--count 1` so the watch exits on its first record:
176
+ `ab watch --operator --json --count 1 [--since <watch-cursor>]`. Act on the
177
+ record, then re-arm at once from the trailing cursor line. Presence survives
178
+ the re-arm gap.
179
+
180
+ `ab wait` exits on its first match, so it suits either kind. Use precisely the
181
+ same resolved invocation and working directory as foreground commands,
182
+ including inside background shells and harness monitors. Do not rely on a
183
+ shell alias or function that those facilities may lose. Never block a
184
+ foreground command for their whole duration.
171
185
 
172
186
  Ticket-source degradation records mean dispatch intake cannot evaluate the source;
173
187
  existing builds may still advance. Inspect `ab repository status --json` for the
@@ -215,8 +229,9 @@ Neither a loss observation nor a later retry authorizes dispatcher intervention.
215
229
  Operate the builds the repository's dispatcher dispatches, including new builds
216
230
  that appear after you arm. Finishing the initially queued set is no reason to stop.
217
231
 
218
- 1. Check presence as above, then arm `ab watch --operator --json` with no slugs.
219
- Retain its own cursor and re-arm with
232
+ 1. Check presence as above, then arm `ab watch --operator --json` with no slugs,
233
+ adding `--count 1` if your harness wakes you only on exit. Retain its own
234
+ cursor and re-arm with
220
235
  `ab watch --operator --json --since <watch-cursor>`. If it reports
221
236
  `cursor-too-old`, re-arm without `--since`, reconcile status and acknowledge
222
237
  the unavailable historical gap.
@@ -4,8 +4,8 @@
4
4
  "build": "ab-hosted-service-build"
5
5
  },
6
6
  "dependencies": {
7
- "@defrex/autobuild-hosted-store-service": "1.4.0",
8
- "@defrex/autobuild": "1.4.0",
7
+ "@defrex/autobuild-hosted-store-service": "1.4.1",
8
+ "@defrex/autobuild": "1.4.1",
9
9
  "next": "16.1.6",
10
10
  "react": "19.2.4",
11
11
  "react-dom": "19.2.4"