@uchibeke/gallivant 0.2.1 → 0.3.0

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 (129) hide show
  1. package/README.md +38 -16
  2. package/SECURITY.md +9 -0
  3. package/bin/gallivant.mjs +33 -10
  4. package/bin/promote-bitbucket.mjs +40 -0
  5. package/bin/task-pr.mjs +9 -0
  6. package/bin/task-review.mjs +15 -0
  7. package/docs/README.md +2 -0
  8. package/docs/architecture.md +11 -3
  9. package/docs/bitbucket-promotion.md +69 -0
  10. package/docs/bitbucket-review.md +330 -0
  11. package/docs/chains.md +30 -1
  12. package/docs/codex-cloud.md +7 -0
  13. package/docs/codex-review.md +50 -0
  14. package/docs/commands.md +65 -5
  15. package/docs/config.md +35 -10
  16. package/docs/first-party-review.md +266 -0
  17. package/docs/git-hosts.md +294 -0
  18. package/docs/guardrails.md +56 -0
  19. package/docs/install.md +18 -8
  20. package/docs/network-recovery.md +9 -0
  21. package/docs/openai-agents.md +2 -1
  22. package/docs/prd.md +23 -2
  23. package/docs/preparation.md +1 -1
  24. package/docs/release-qualification.md +1 -1
  25. package/docs/releasing.md +17 -2
  26. package/docs/task-delivery.md +4 -4
  27. package/docs/task-profiles.md +537 -0
  28. package/docs/tasks.md +59 -197
  29. package/lib/attribution.mjs +7 -3
  30. package/lib/block.mjs +10 -1
  31. package/lib/chains.mjs +101 -30
  32. package/lib/codex_cloud.mjs +2 -1
  33. package/lib/codex_cloud_input.mjs +15 -6
  34. package/lib/codex_cloud_result.mjs +1 -1
  35. package/lib/commands/doctor.mjs +22 -462
  36. package/lib/commands/init.mjs +72 -30
  37. package/lib/commands/register.mjs +25 -11
  38. package/lib/commands/resume.mjs +5 -1
  39. package/lib/commands/review.mjs +66 -0
  40. package/lib/commands/serve.mjs +8 -0
  41. package/lib/commands/start.mjs +30 -11
  42. package/lib/commands/status.mjs +18 -2
  43. package/lib/commands/task.mjs +9 -1
  44. package/lib/commands/up.mjs +19 -11
  45. package/lib/commands/why.mjs +7 -3
  46. package/lib/config.mjs +42 -9
  47. package/lib/context.mjs +23 -18
  48. package/lib/control.mjs +21 -6
  49. package/lib/credential.mjs +20 -14
  50. package/lib/deliverable.mjs +2 -0
  51. package/lib/events.mjs +96 -53
  52. package/lib/execution.mjs +48 -3
  53. package/lib/execution_preparation.mjs +16 -1
  54. package/lib/execution_result.mjs +26 -5
  55. package/lib/first_party_review.mjs +618 -0
  56. package/lib/gh.mjs +144 -56
  57. package/lib/git.mjs +133 -32
  58. package/lib/git_diff.mjs +121 -0
  59. package/lib/harness.mjs +14 -10
  60. package/lib/host_contract.mjs +71 -0
  61. package/lib/host_definitions.mjs +22 -0
  62. package/lib/hosts/bitbucket.mjs +553 -0
  63. package/lib/hosts/bitbucket_contract.mjs +57 -0
  64. package/lib/hosts/bitbucket_credential.mjs +62 -0
  65. package/lib/hosts/bitbucket_review.mjs +44 -0
  66. package/lib/hosts/bitbucket_review_producer.mjs +50 -0
  67. package/lib/hosts/github.mjs +57 -0
  68. package/lib/hosts/github_contract.mjs +27 -0
  69. package/lib/hosts/github_doctor.mjs +482 -0
  70. package/lib/hosts/github_review_summary.mjs +38 -0
  71. package/lib/hosts/transport_doctor.mjs +35 -0
  72. package/lib/hosts.mjs +130 -0
  73. package/lib/learning_qualification.mjs +1 -1
  74. package/lib/notify.mjs +1 -1
  75. package/lib/openai_agents_input.mjs +7 -2
  76. package/lib/openai_agents_sources.mjs +16 -8
  77. package/lib/plugin_package.mjs +13 -1
  78. package/lib/pr_operation.mjs +41 -0
  79. package/lib/prd.mjs +18 -3
  80. package/lib/preparation_codex.mjs +6 -1
  81. package/lib/probe.mjs +6 -4
  82. package/lib/process.mjs +24 -0
  83. package/lib/promotion.mjs +132 -0
  84. package/lib/promotion_git.mjs +63 -0
  85. package/lib/prompt.mjs +16 -13
  86. package/lib/provider_health.mjs +14 -3
  87. package/lib/repository.mjs +68 -0
  88. package/lib/repository_preflight.mjs +11 -0
  89. package/lib/review_evaluation.mjs +25 -0
  90. package/lib/review_evidence.mjs +500 -0
  91. package/lib/review_history.mjs +73 -0
  92. package/lib/review_image.mjs +145 -0
  93. package/lib/review_link.mjs +12 -0
  94. package/lib/review_policy.mjs +132 -0
  95. package/lib/review_policy_contract.mjs +18 -0
  96. package/lib/review_state.mjs +13 -0
  97. package/lib/review_visual.mjs +94 -0
  98. package/lib/runtime-environment.mjs +6 -0
  99. package/lib/runtime_node.mjs +3 -2
  100. package/lib/runtime_state.mjs +39 -5
  101. package/lib/sources/prd.mjs +6 -3
  102. package/lib/state.mjs +137 -24
  103. package/lib/task_completion.mjs +7 -3
  104. package/lib/task_contract.mjs +201 -27
  105. package/lib/task_delivery.mjs +9 -2
  106. package/lib/task_delivery_contract.mjs +13 -9
  107. package/lib/task_delivery_view.mjs +18 -2
  108. package/lib/task_environment.mjs +13 -1
  109. package/lib/task_limits.mjs +13 -0
  110. package/lib/task_model_config.mjs +99 -0
  111. package/lib/task_model_route.mjs +243 -0
  112. package/lib/task_prepare.mjs +21 -8
  113. package/lib/task_profile.mjs +1875 -0
  114. package/lib/task_repository_context.mjs +65 -0
  115. package/lib/tasks.mjs +252 -51
  116. package/lib/tick.mjs +353 -97
  117. package/lib/time.mjs +1 -0
  118. package/lib/tracker/pages.mjs +19 -5
  119. package/lib/tracker/review.mjs +21 -0
  120. package/lib/tracker_process.mjs +8 -1
  121. package/lib/verification_sandbox.mjs +2 -1
  122. package/lib/work_artifacts.mjs +79 -0
  123. package/npm-shrinkwrap.json +12 -3
  124. package/package.json +9 -3
  125. package/templates/plugin/task-delivery.SKILL.md +17 -10
  126. package/templates/plugin/task-intake-contract.json +18 -0
  127. package/templates/plugin/task-profile-requests.mjs +1448 -0
  128. package/templates/tracker/tracker.css +3 -0
  129. package/templates/tracker/tracker.js +38 -0
@@ -0,0 +1,330 @@
1
+ # Bitbucket Cloud review setup and qualification
2
+
3
+ Bitbucket Cloud dispatch and complete first-party evidence capture are implemented.
4
+ The independent local review route is still **live-unqualified** until the public
5
+ and private disposable repository matrix records a genuine blocking verdict,
6
+ same-session correction and fresh exact-head clearance. Earlier disposable runs
7
+ proved regular PR publication and receipt acceptance with **no reviewer
8
+ configured**; they are not review evidence. The private coding session could also
9
+ read the coordinator's merge-capable API-token file by path, so that historical
10
+ coding-credential hold remains separate from reviewer credential isolation. Do
11
+ not migrate an existing legacy run or start unattended work on the strength of
12
+ offline fixtures. See the [qualification record](audit/bitbucket-review-qualification.md).
13
+
14
+ ## First setup, including a checkout with no existing configuration
15
+
16
+ Use Node 22 or later, Git, and an explicitly selected installed local Codex or
17
+ Claude executable. Bitbucket setup does not require `gh` or GitHub sign-in.
18
+ Version/sign-in diagnostics do not prove model access. Existing GitHub defaults
19
+ and runs retain their previous review semantics.
20
+
21
+ 1. Obtain an Atlassian **account API token** scoped to the intended workspace,
22
+ with `read:repository:bitbucket`, `write:repository:bitbucket`,
23
+ `read:pullrequest:bitbucket`, and `write:pullrequest:bitbucket`. Save it in a
24
+ private file (`chmod 600`). Supply the account email separately. An account
25
+ API token can be used with a free-plan repository; this does not require a
26
+ workspace/repository access-token subscription or Agentic Pipelines.
27
+ 2. For HTTPS Git, the coordinator uses the selected token as
28
+ `x-bitbucket-api-token-auth`; the API uses account email/token Basic auth.
29
+ For SSH Git, keep the API token and select the explicit SSH key/verified
30
+ known-hosts file described in [Git host setup](git-hosts.md). SSH authentication
31
+ alone cannot read or write PRs. The coding session receives neither token nor
32
+ SSH key through environment variables: its bounded PR mailbox asks the
33
+ coordinator to push and publish. A same-user coding process can still read
34
+ the configured private files unless a separate boundary denies those reads.
35
+ HTTPS and Cloud SSH checkout origins identify
36
+ the same repository; self-hosted servers and SSH aliases remain unsupported.
37
+ 3. Write a host settings file outside the coding checkout. Example:
38
+
39
+ ```json
40
+ {
41
+ "api": {
42
+ "email": "operator@example.com",
43
+ "token_file": "~/.config/repository-access/bitbucket-api-token"
44
+ },
45
+ "git": { "transport": "https" },
46
+ "trusted_authors": ["{11111111-1111-1111-1111-111111111111}"],
47
+ "reviewer": null,
48
+ "required_checks": ["Tests"]
49
+ }
50
+ ```
51
+
52
+ Replace the example UUID with the operator's stable Bitbucket UUID, not a nickname.
53
+ Select `reviewer: null` deliberately; the local first-party path needs no separate
54
+ Bitbucket reviewer account. After `init`, configure the repository entry for a
55
+ new reviewed run:
56
+
57
+ ```json
58
+ {
59
+ "repo": "bitbucket.org/workspace/repository",
60
+ "reviewer": null,
61
+ "review": {
62
+ "mode": "first-party-required",
63
+ "route": "codex",
64
+ "max_input_bytes": 100000,
65
+ "max_jobs": 2048,
66
+ "budget_usd": 100,
67
+ "zero_checks": false
68
+ }
69
+ }
70
+ ```
71
+
72
+ Keep `review.legacy_no_review: true` only for a deliberately unreviewed legacy
73
+ run while live qualification is unavailable. That mode still enforces configured
74
+ CI, trusted commands, unresolved required feedback and the completion receipt,
75
+ but its readiness record says `none`; it is never independently reviewed. The
76
+ example check name must exactly match the repository's build status name. An
77
+ empty `required_checks` list does not waive CI for a version-1 policy: a repository
78
+ with no checks must explicitly set `review.zero_checks: true`. Missing/partial
79
+ responses, rate limits, outages and pending checks never pass.
80
+
81
+ From the intended checkout:
82
+
83
+ ```sh
84
+ gallivant init --harness codex --host-config /absolute/path/bitbucket-host.json --base release/v2
85
+ gallivant doctor
86
+ ```
87
+
88
+ `--host-config` imports settings for the verified checkout's host. It creates a
89
+ new config, or accepts unchanged settings while preserving UUID bindings added
90
+ by setup. JSON member order does not matter; changed or omitted policy and
91
+ conflicting identity bindings are refused. `--base` is validated and saved on the repository entry.
92
+ `init` binds repository/workspace UUIDs, reads the selected base and account push
93
+ role, and verifies Git's base SHA against the API. `doctor` distinguishes unknown
94
+ write scopes from observed read access. Only an actual write can prove Git push,
95
+ PR creation and comment write permission. Setup never installs a pipeline,
96
+ creates a credential, changes repository protection, or makes a paid model call.
97
+ It reports dispatch availability separately from transport access.
98
+
99
+ Host settings live under `git_hosts["bitbucket.org"]`. `repositories["workspace/repo"]`
100
+ may override `api`, `git`, `reviewer`, `trusted_authors`, and `required_checks`,
101
+ alongside the UUID binding. Each override replaces that setting, not another
102
+ host's credentials. A `repos` object may override reviewer/trust/check policy;
103
+ precedence is repository entry, host repository binding, host settings. Historical
104
+ top-level reviewer/trust defaults apply only to GitHub. Reviewer objects for
105
+ Bitbucket must supply every required field; the GitHub mention is rejected.
106
+
107
+ ## Independent local Codex reviewer
108
+
109
+ The host adapter binds the repository UUID, PR number, full head and base object
110
+ IDs, and merge base. It paginates `diffstat/<head>..<base>?topic=true`, compares
111
+ that changed-path inventory to the complete raw comparison, and reads regular
112
+ UTF-8 source at the merge base and head through `src/{commit}/{path}`. Added,
113
+ modified, removed and renamed files all carry before/after text as applicable.
114
+ Unsupported binary, subrepository, missing-patch, duplicate, truncated, stale,
115
+ rate-limited, redirected and oversized evidence is refused. The coordinator
116
+ captures bounded symlink target data as untrusted Git objects without following
117
+ the link. Unsupported targets or ambiguous type transitions block review.
118
+ The PR binding is read again after capture. The API token stays behind the host boundary and is not
119
+ part of the reviewer prompt or environment.
120
+
121
+ The coordinator requests bounded PNG and JPEG sides at the exact revisions and
122
+ requires a separate image-capability qualification before launching visual jobs.
123
+ It combines their validated reports with text review and whole-PR synthesis.
124
+ The image qualification does not itself qualify the host or complete a PR review;
125
+ the [disposable live screenshot review](audit/bitbucket-review-qualification.md#live-image-qualification-and-disposable-review-2026-11-03)
126
+ reached a clear verdict after its owned outputs were recovered; the resend PR
127
+ has not been rechecked. Preserve the original files and incomplete state when any
128
+ capability or evidence is unavailable.
129
+
130
+ Qualify the exact configured executable/provider route only after authorizing its
131
+ separate paid challenge:
132
+
133
+ ```sh
134
+ gallivant review qualify --repo bitbucket.org/workspace/repository
135
+ gallivant review qualify --repo bitbucket.org/workspace/repository --run --wait
136
+ gallivant review qualify --repo bitbucket.org/workspace/repository
137
+ ```
138
+
139
+ The first and last commands are read-only. `--run` starts at most the one durable
140
+ qualification job for that fingerprint; CLI version and sign-in checks alone do
141
+ not prove selected-model access. Start refuses before author dispatch if the route
142
+ cannot qualify.
143
+
144
+ Qualification fingerprints use the adapter's selected provider environment,
145
+ configuration, credentials and executable. Parent-agent session and tool-call
146
+ IDs do not invalidate an existing qualification. The private Codex profile drops
147
+ the desktop-only `daybreak` flag for CLI compatibility; strict inspection of
148
+ effective permissions and managed policy remains required.
149
+
150
+ For a settled existing run that still has the explicit legacy snapshot, use the
151
+ audited transition and then recheck the same PR:
152
+
153
+ ```sh
154
+ gallivant review policy HANDLE --mode first-party-required \
155
+ --reason "Enable the qualified independent local reviewer"
156
+ gallivant recheck HANDLE
157
+ ```
158
+
159
+ This is the only path that removes the saved legacy policy. It retains the task
160
+ identity, original PRD snapshot, PR, checkout and implementation session. A
161
+ failed route preflight changes nothing and launches no review. Do not edit an
162
+ active WebBabyShower brief or local policy as an implementation test.
163
+
164
+ Each reviewer job is a fresh restricted Codex execution with no implementation
165
+ session, context mounts, tools, network, host/Git credential or publication
166
+ authority. The 100,000-byte input cap applies to every job. Large evidence is
167
+ split into immutable source/patch slices, including a single large lockfile or
168
+ line; every slice repeats the aggregate identities and all acceptance criteria.
169
+ Clearance requires every piece to complete and match. `max_jobs`, `budget_usd`
170
+ and per-job timeout bound the aggregate. If the full change does not fit those
171
+ bounds, the run stops with `review-incomplete`; no path or suffix is omitted.
172
+
173
+ ## External Bitbucket reviewer account
174
+
175
+ This is an alternative external-review setup, not required by the local path.
176
+ Use a separate Bitbucket account for the automated reviewer. Configure its stable
177
+ UUID, never its display name, nickname, the coding account, or a Pipeline label:
178
+
179
+ ```json
180
+ {
181
+ "reviewer": {
182
+ "actor_id": "{22222222-2222-2222-2222-222222222222}",
183
+ "rereview_comment": "Review the current commit and post a work-review verdict.",
184
+ "blocking_pattern": "\\bP[01]\\b"
185
+ }
186
+ }
187
+ ```
188
+
189
+ This fragment belongs in the coding coordinator's host/repository policy. The
190
+ reviewer token does **not** belong there. On a separate operator-controlled
191
+ reviewer machine, OS account, or isolated container, store another private config
192
+ with the same policy and the **reviewer** account email/token in `api`. Its token
193
+ needs repository read and PR read/write. The coding agent must have no filesystem,
194
+ environment, secret-store or container access to that credential. A private file
195
+ in a directory readable by the coding identity is not isolation. The review model
196
+ needs only the prepared input and a read-only checkout, never publication secrets.
197
+ Codex requires its own supported sign-in or provider credentials and actual model
198
+ access; CLI installation/sign-in alone cannot qualify it.
199
+
200
+ The installed `task-review` tool separates preparation and publication from
201
+ inference. It never invokes a model, changes model/provider settings, or posts a
202
+ review request. These review transport steps are covered by offline tests; the
203
+ intervening Codex execution and end-to-end publication are still unqualified:
204
+
205
+ ```sh
206
+ task-review prepare --config /private/reviewer-config.json \
207
+ --url https://bitbucket.org/workspace/repo/pull-requests/7 > review-input.json
208
+ ```
209
+
210
+ In the isolated reviewer checkout, use the operator-selected Codex executable
211
+ under the existing read-only review permissions to inspect the input's exact
212
+ head and diff. Follow `review-input.json.instructions`. Save its actual response
213
+ as `review-result.json`, containing only this JSON shape:
214
+
215
+ ```json
216
+ {
217
+ "head_sha": "0123456789012345678901234567890123456789",
218
+ "verdict": "blocking",
219
+ "summary": "Concrete findings from reviewing this exact commit."
220
+ }
221
+ ```
222
+
223
+ A successful model execution is not a verdict. Outside the model process, publish
224
+ its response with the separate reviewer credential:
225
+
226
+ ```sh
227
+ task-review publish --config /private/reviewer-config.json \
228
+ --url https://bitbucket.org/workspace/repo/pull-requests/7 \
229
+ --input review-input.json --result review-result.json
230
+ ```
231
+
232
+ Publication verifies the authenticated actor differs from the coding author and
233
+ matches `reviewer.actor_id`. It rechecks repository UUIDs, PR number, branches,
234
+ base, full head SHA and diff hash against the prepared input. An explicit retry
235
+ reuses an identical verdict only while it remains the reviewer's latest decision.
236
+ A superseded match causes a new publication, so blocking/clear/blocking decisions
237
+ take effect even on the same head. Uncertain comment writes are not silently
238
+ retried. Keep the real model transcript/run ID with qualification
239
+ artifacts: a manually authored fixture result cannot prove a Codex review.
240
+ An ordinary Pipeline can orchestrate these steps when an operator explicitly
241
+ installs it, enables Pipelines, and configures provider and reviewer secrets in an
242
+ isolated trusted job. Do not expose those secrets to arbitrary PR code or the
243
+ coding step. No paid Agentic Pipelines capability is assumed or installed.
244
+
245
+ The posted comment contains a `work-review` fenced JSON block. Only the configured
246
+ actor and a complete exact current SHA can clear readiness. Abbreviations, old-head
247
+ approvals, prose claiming a successful Pipeline, or a run with no posted verdict
248
+ are silence. Native Bitbucket approvals do not identify a reviewed commit and
249
+ cannot clear an automated-review gate. Native change requests and unresolved tasks
250
+ remain blockers until their authors remove/resolve them, including after one fix
251
+ round has consumed their events.
252
+
253
+ Trusted humans can post `/fix ...`. Inline findings use a verified code link to
254
+ the full source SHA or a standalone `Reviewed commit: <40-character-sha>` line.
255
+ Unknown inline heads stop readiness with the source link rather than silently
256
+ approving or dispatching a guessed head. A command explicitly naming an older head
257
+ is ignored. Replies authored by the coding account do not become new fix requests.
258
+
259
+ ## Session PR operations and recovery
260
+
261
+ `task-pr` is the bounded PR CLI used by Bitbucket start/fix/resume prompts. In a
262
+ task session it writes a bounded request to the checkout's mailbox; the daemon
263
+ verifies the saved repository, branch, base and PR identity, then uses its own
264
+ Git and API credentials. `push`, `create`, `edit` and `comment` push committed
265
+ HEAD through the coordinator before publication. `view` and `diff` are read
266
+ operations. The agent receives no Git or PR token and no SSH key in its
267
+ environment. Its observed ability to read the token file remains a dispatch
268
+ blocker. The
269
+ coordinator disables checkout hooks when running Git, so an agent-written
270
+ pre-push hook cannot run with coordinator authority. The mailbox has no merge,
271
+ deployment or repository-settings operation. Direct `task-pr` use outside an
272
+ agent session still requires an explicitly bound API credential.
273
+ The PR CLI created and reconciled a disposable private PR, read its exact head,
274
+ posted a comment and updated its body. A separate live public task also used it
275
+ to open and update a regular PR. See the [qualification record](audit/bitbucket-review-qualification.md).
276
+
277
+ After the credential boundary is qualified, local PRD commands use the verified
278
+ checkout, and `register` uses the exact PR
279
+ URL. Host-qualified state/worktree keys
280
+ prevent a same-named GitHub repository controlling a Bitbucket PR. Base overrides
281
+ flow through clone, PR publication and later base updates. Use `gallivant doctor`
282
+ to confirm access and policy before `gallivant start <prd> --base <branch>`.
283
+ Hosted providers with a GitHub-bound environment are incompatible. A snapshot
284
+ provider must pass the same publication and qualification checks as a local one.
285
+
286
+ Bitbucket snapshots supply one coherent set of paginated comments, participants,
287
+ required tasks and statuses for the head. The shared event cursor, bounded fix
288
+ round, session continuation, completion gate and chain engine consume those
289
+ records. Unreadable snapshots preserve cursors. A changed PR branch/base or a
290
+ replacement repository stops with `pr-identity`. Declined/superseded PRs cannot
291
+ become done. A merged PR must match the recorded head and its merge commit must
292
+ be an ancestor of the intended base before completion or chain advancement.
293
+ No command merges the PR, force-pushes, deploys or alters protections.
294
+
295
+ ## Troubleshooting
296
+
297
+ - `NO_CREDENTIAL`: select the account email and private API-token file under the
298
+ correct host/repository. An SSH key, GitHub token or token file without an email
299
+ is insufficient. Restore scopes before retrying; do not broaden another host.
300
+ - `reviewer.actor_id` / explicit reviewer errors: use the actual UUID and producer
301
+ configuration, or explicitly choose no-reviewer mode. Do not use `@codex review`.
302
+ - `BB_INCOMPLETE`, `BB_STALE`, HTTP 429/5xx: restore API access or wait for the read
303
+ retry. Never clear a cursor or turn missing evidence into an empty collection.
304
+ - `REVIEW_UNQUALIFIED`: confirm the exact `harness.codex.bin`, selected model and
305
+ provider access, then explicitly run `review qualify --repo ... --run`. Do not
306
+ substitute `--version`, sign-in status or an offline fixture.
307
+ - `review-incomplete` / `REVIEW_INCOMPLETE`: inspect the named missing identity,
308
+ path, patch or required job count. For a large complete text change, raise
309
+ `max_jobs` and `budget_usd` only within an operator-approved bound, then select
310
+ the new policy explicitly. Unsupported binary, subrepository, malformed link, rate-limited,
311
+ redirected or stale evidence must be corrected; increasing a byte cap is not a
312
+ workaround.
313
+ - Screenshot evidence: check `review qualify --repo ... --capability image` for
314
+ the exact route. Repair the reported native or provider issue before a separately
315
+ authorized `--run`; do not repeat an unchanged failed launch. PNG/JPEG limits
316
+ and all image sides still apply. Unsupported formats remain incomplete.
317
+ - `pr-identity`: inspect source/base/repository/head and restore the recorded
318
+ identity. A decline or unproven merge needs operator reconciliation, not a new
319
+ paid run or an automatic chain advance.
320
+ - Access probe fails: check the selected coordinator SSH key or HTTPS token and
321
+ the account API token for PR operations. The coding session receives neither.
322
+ Re-run `doctor`, then resume the existing task rather than starting a duplicate.
323
+ - PR mailbox timeout: confirm the daemon is running and can read the selected
324
+ repository; retry the same `task-pr` operation. Do not give the coding session
325
+ a token to work around the mailbox.
326
+
327
+ API semantics are based on Atlassian's [PR APIs](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/),
328
+ [commit ancestry API](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/),
329
+ [source metadata](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/),
330
+ and [account API-token guidance](https://support.atlassian.com/bitbucket-cloud/docs/using-api-tokens/).
package/docs/chains.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # PRD chains
2
2
 
3
- **Gallivant automates delivery; humans approve integration.** A chain starts its next PRD only after GitHub confirms
3
+ **Gallivant automates delivery; humans approve integration.** A chain starts its next PRD only after the Git host confirms
4
4
  that the preceding PR was merged into the planned base branch. Gallivant never merges PRs. Passing tests, an accepted
5
5
  receipt, `ready-for-human`, and a finished agent session are progress toward that decision; none starts the next task.
6
6
 
@@ -38,6 +38,29 @@ the chain; closing any milestone's PR without merging stops it.
38
38
  The scope is deliberately linear: one repository, one base, one active milestone per chain. There is no dependency
39
39
  graph, stacked-PR mode or automatic merge. Unrelated tasks and other chains can run independently.
40
40
 
41
+ ## Continue after an existing PR
42
+
43
+ If the first task already has a registered PR, keep its current run and queue only the new work:
44
+
45
+ ```sh
46
+ gallivant chain launch --after https://github.com/your-org/your-repo/pull/123 docs/prds/launch.md
47
+ # A registered handle also works:
48
+ gallivant chain integration --after your-org/your-repo#123 docs/prds/integration.md docs/prds/next.md
49
+ ```
50
+
51
+ `--after` accepts a PR URL from a supported Git host or a registered run handle. Register the PR first if it is not
52
+ already tracked. At least one **new** ready PRD is required, in the same repository and approved base as the PR.
53
+ The predecessor is a dependency, not a newly started milestone: its session, review policy, counters and any existing
54
+ chain ownership stay unchanged. The usual `say`, `recheck` and `resume` commands still manage that run.
55
+
56
+ The chain records the exact registered PR, repository, branch and base. It waits for the author process to finish
57
+ and the host to confirm a merge, then checks that merge commit in both the remote base and the successor's clone.
58
+ An open PR marked ready does not release the dependency. A removed or retargeted registration, a closed unmerged PR,
59
+ or missing merge ancestry stops dispatch. Retry and resnapshot cannot replace the predecessor; cancel and create a
60
+ new chain to change it. Progress counts only the newly queued milestones and displays the predecessor separately.
61
+ Keep the predecessor registered until the chain finishes. Run a version supporting `--after` on every coordinator
62
+ using this home; do not downgrade while these chains remain active.
63
+
41
64
  ## Inspect progress
42
65
 
43
66
  ```sh
@@ -100,3 +123,9 @@ the ordinary review loop. It does not cancel or undo work that has already start
100
123
 
101
124
  Chain approval and unstarted milestones live in local `state.json`; unlike an open PR's identity, they cannot be
102
125
  reconstructed from GitHub. Preserve your Gallivant home when moving the daemon to another machine.
126
+
127
+ Repository identity, credential transport and PR evidence are defined by the
128
+ [Git host contract](git-hosts.md). GitHub and Bitbucket Cloud can dispatch;
129
+ Bitbucket's live no-reviewer path has been qualified on a disposable public
130
+ repository. Independent Bitbucket review remains unvalidated. Existing IDs and
131
+ chain ownership are retained without a state migration.
@@ -17,6 +17,13 @@ tasks remain available. Its implementation is offline tested; live qualification
17
17
  is **unverified**. Local Codex and `openai-agents` retain their existing defaults
18
18
  and continuation behavior.
19
19
 
20
+ The Git-based Cloud input transport cannot privately deliver new or changed carried
21
+ source files. It refuses before committing or pushing them; use a local harness or
22
+ `openai-agents` for those tasks. Existing repository files with unchanged bytes are
23
+ usable inputs. `publish_files` is only for output documents the operator explicitly
24
+ wants in the PR, never a workaround for publishing private task context. This remains
25
+ a separate limitation from the repository-binding requirement that currently disables dispatch.
26
+
20
27
  ## Trusted worker setup
21
28
 
22
29
  Use a trusted operator or self-hosted Node 22+ worker with persistent private
@@ -0,0 +1,50 @@
1
+ # Requesting and verifying Codex reviews
2
+
3
+ A Git push updates the pull-request head and can start CI. It does **not** by
4
+ itself request a new Codex review. In this repository's observed setup, automatic
5
+ review covers a newly opened pull request; a later head needs an explicit
6
+ `@codex review` comment. Security review is a separate request using
7
+ `@codex security review`. A quiet thread after a push is therefore not a clean
8
+ review result.
9
+
10
+ Gallivant's background review loop posts the configured
11
+ `reviewer.rereview_comment` after a fix run it dispatched. A manual push, a PR
12
+ outside that loop, or a branch reset does not inherit that behavior. Do not infer
13
+ that the daemon requested a review unless its comment is present on the PR.
14
+
15
+ ## Verify a review against the exact head
16
+
17
+ For every final push:
18
+
19
+ 1. Read the current PR head SHA from GitHub after the push.
20
+ 2. Post `@codex review`; also post `@codex security review` when the change
21
+ affects authorization, parsing, credentials, execution, or other security
22
+ boundaries.
23
+ 3. Wait for a Codex review receipt created after the request. Compare its
24
+ `commit_id` (and any `Reviewed commit` in the body) with the current GitHub
25
+ head SHA. For inline findings, compare each comment's `commit_id` too.
26
+ 4. Fix each finding or reply with a reproducible test showing why it does not
27
+ apply. After another push, request and verify both reviews again.
28
+
29
+ Example read-only checks:
30
+
31
+ ```bash
32
+ git rev-parse HEAD
33
+ gh pr view NUMBER --json headRefOid
34
+ gh api repos/OWNER/REPO/pulls/NUMBER/reviews \
35
+ --jq '.[] | {commit_id, submitted_at, state, body}'
36
+ gh api repos/OWNER/REPO/pulls/NUMBER/comments \
37
+ --jq '.[] | {commit_id, created_at, path, line, body}'
38
+ ```
39
+
40
+ An old inline thread can stay visible after later commits, and GitHub can retain
41
+ review records when a branch is reset to a previously seen SHA. Treat a record
42
+ as current only when its commit matches the live head and its timestamp follows
43
+ the current review request. A clean `reviewDecision`, an empty inline-comment
44
+ list, or a successful push is not a substitute for that receipt. A review with
45
+ no findings may have a summary and no inline threads, so verify the review record
46
+ as well as comments.
47
+
48
+ This procedure reflects the repository's observed Codex integration, not a
49
+ general guarantee about future GitHub or Codex behavior. If the trigger changes,
50
+ update this guide after verifying it with a new exact-head review.
package/docs/commands.md CHANGED
@@ -25,6 +25,7 @@ Use `gallivant --help` (or `gallivant help`) for the installed CLI's syntax and
25
25
  | Diagnose a stop | `gallivant why HANDLE` | Shows state, failure and pending controls. |
26
26
  | Continue stopped execution | `gallivant resume HANDLE` | Preserves the session; explicit changed-brief acceptance uses `--resnapshot`. |
27
27
  | Re-evaluate PR gates | `gallivant recheck HANDLE` | No budget reset, no CI rerun, no replacement for execution recovery. |
28
+ | Qualify or change review policy | `gallivant review qualify|status|policy|dispute` | Qualification is separate and may be paid only with `--run`; policy changes preserve the task and session. |
28
29
  | Send a correction | `gallivant say HANDLE --note "..."` | Queues same-session delivery; supported local runs can use `--interrupt`. |
29
30
  | Stop future dispatch | `gallivant cancel HANDLE` | Requests cancellation; inspect confirmation before assuming the process stopped. |
30
31
  | Forget tracking | `gallivant remove HANDLE` | Leaves the PR, branch, labels and checkout in place. |
@@ -115,6 +116,11 @@ Requests can produce code, documentation, research or other repository artifacts
115
116
  A natural-language task still becomes an explicit, validated delivery contract;
116
117
  it does not require the user to write a PRD first.
117
118
  See [task operations](tasks.md) for examples, source delivery and stopping rules.
119
+ `--delivery pull_request` selects the typed delivery profile that alone authorizes
120
+ external actions for new tasks, `--completion-target` sets its completion
121
+ condition, and `--route harness|model` chooses the planner route. The result's
122
+ `review` object is the revision-pinned view an owner approves with `task start
123
+ --run`. See [typed delivery profiles](task-profiles.md).
118
124
 
119
125
 
120
126
  ### Task operations
@@ -142,8 +148,9 @@ Preparation accepts `--repo`, `--base`, repeated `--context` files and `--verify
142
148
  commands, and a retry-safe `--request-id`. Answers may also add explicit context
143
149
  and verification commands. `--completion-target delivery_ready|integrated` selects
144
150
  whether the task tracks readiness or confirmed integration; neither grants merge
145
- permission. `--run` on initial preparation authorizes dispatch after readiness and
146
- any required answers. `--no-daemon` leaves monitoring startup to an existing host
151
+ permission. Initial preparation returns the draft or questions for review even
152
+ when `--run` is present; approve the visible revision separately with `task start
153
+ --revision N --run`. `--no-daemon` leaves monitoring startup to an existing host
147
154
  or explicit coordinator. See [task operations](tasks.md) for revision conflicts,
148
155
  uncertain dispatch, evidence and authorization rules.
149
156
 
@@ -188,7 +195,30 @@ Local task submission:
188
195
  8. Copies those snapshots into the checkout at their original repository paths, creating directories as needed. The PRD is usually only in your own checkout; this copy lets the session commit it with the implementation. Copies in the session's checkout are writable and are never read back for a decision.
189
196
  9. Starts the session detached with the PRD as its prompt, records the session id, and remembers the repo for recovery.
190
197
 
191
- The entry is `running` until the daemon sees the run end. Then either a PR exists on the branch and the entry enters `pr-open`, or it stops with `no-pr`.
198
+ The entry is `running` until the daemon sees the run end. Then either a PR exists on the branch and the entry enters `pr-open`, or a successful worker that did not open one stops with `no-pr`. A failed or incomplete worker without a PR stops with `harness-error`; inspect its run log. Recognized terminal connection failures use the bounded [network recovery](network-recovery.md) path instead.
199
+
200
+ Workers must collect verification results before returning. Claude launches disable
201
+ native background shell/subagent execution and disallow `Monitor`, which otherwise
202
+ remains available despite that setting. This applies to both new and resumed
203
+ implementation/review runs, without changing the operator's global settings,
204
+ sandbox, APort hooks or task allowances. Temporary development servers may still
205
+ be used within a run, with their tests collected and processes cleaned up before
206
+ returning. Shell checks need explicit timeouts sufficient for the check and within
207
+ the approved limits; a timed-out check is not a pass. Tool-free preparation keeps
208
+ its existing deny-all boundary. These native controls are described in Claude's
209
+ [environment reference](https://code.claude.com/docs/en/env-vars) and
210
+ [Monitor documentation](https://code.claude.com/docs/en/tools-reference#monitor-tool).
211
+
212
+ A background-task notification's result cannot settle the main task or hide its
213
+ failure. Gallivant owns durable wakeups and review polling. It does not blindly
214
+ restart every `no-pr` or missing-result failure, which could repeat external
215
+ effects or run unchanged blocked work indefinitely. After upgrading, explicitly
216
+ resume an already stopped run once; future launches receive the lifecycle policy.
217
+ An interrupted pre-PR session becomes resumable only after its owned process tree
218
+ has stopped. Late results stay quarantined; the coordinator still discovers any
219
+ PR already opened before delivering the queued correction to the same session.
220
+ An older failed interrupt is repaired to a stopped state, preserving its message
221
+ for an explicit retry instead of replaying that failed request automatically.
192
222
 
193
223
  It also brings the daemon up in the background if one is not already running, and waits until the daemon reports
194
224
  itself before returning. That is not a convenience: `start` opens a session that will open a pull request, and the
@@ -212,11 +242,13 @@ with exit code 1. Retry `gallivant start` without a PRD, not the original submis
212
242
  processes continue; restart monitoring with `gallivant start`. Embedded trackers
213
243
  are owned by their host and are not stopped by this command.
214
244
 
215
- ## `gallivant chain [<name> [<first.md> <next.md> ...]] [--base <branch>]`
245
+ ## `gallivant chain [<name> [<first.md> <next.md> ...]] [--base <branch>] [--after <pr-url|handle>]`
216
246
 
217
247
  Queue at least two ready PRDs in order. All must be new tasks in one checkout of the same repository and on the same
218
248
  resolved base. `--base` selects the base for a new chain; otherwise the repository config or default branch applies.
219
- The daemon starts the first task and starts each successor only after GitHub confirms the preceding PR was merged
249
+ With `--after`, queue one or more new PRDs behind an already registered PR in that same repository and base.
250
+ The existing run is preserved; its exact PR, branch and base are pinned, and its merge must precede all queued tasks.
251
+ The daemon starts the first task and starts each successor only after the Git host confirms the preceding PR was merged
220
252
  into that base. The final merge completes the chain. `ready-for-human`, a completed agent process and a local `done`
221
253
  entry never satisfy the dependency; closing without merging stops the chain. Gallivant never merges for you.
222
254
 
@@ -226,6 +258,7 @@ brings the existing daemon up if needed. Independent runs continue alongside it.
226
258
  | Command | Effect |
227
259
  |---|---|
228
260
  | `gallivant chain launch first.md next.md` | Approve the order and current brief/source fingerprints, then queue dispatch. |
261
+ | `gallivant chain launch --after your-org/repo#123 next.md` | Wait for the registered predecessor's verified merge, then start the new task. |
229
262
  | `gallivant chain launch --retry` | Recheck a stopped chain after its cause is resolved. |
230
263
  | `gallivant chain launch --retry --resnapshot` | Explicitly accept updated briefs and carried sources for unstarted tasks. |
231
264
  | `gallivant chain launch --cancel` | Stop future dispatch; preserve already started work and its review loop. |
@@ -647,3 +680,30 @@ Harnesses still invoke their own GitHub tools directly. A prompt and a later dae
647
680
  incorrect draft or branded phrase never appears briefly before correction. This implementation enforces daemon
648
681
  writes and readiness, not an exclusive network publication boundary. The encoded recovery record is also not secret:
649
682
  it can be decoded to inspect the precise existing branch/session identity.
683
+
684
+ ## Bitbucket setup and PR commands
685
+
686
+ For an explicitly mapped GitHub review mirror, `npm run promote:bitbucket -- --github-pr URL --bitbucket-repo bitbucket.org/WORKSPACE/REPO --bitbucket-pr N` previews a commit-preserving handoff from a source checkout. It requires exact accepted source readiness, then refreshes the shared review/check policy. Apply requires the inspected plan digest. See [GitHub-to-Bitbucket promotion](bitbucket-promotion.md) for retained post-merge plans, idempotent PR updates and race handling. It never merges or deploys.
687
+
688
+ Bitbucket Cloud dispatch is available with explicit repository credentials and review policy. Its complete first-party evidence adapter and the shared bounded review service are implemented; the private/public live reviewer matrix and clean Linux installation remain separate qualifications. A prior public disposable run proved PR publication and receipt acceptance in legacy no-reviewer mode only. See the [setup, review and troubleshooting guide](bitbucket-review.md) for prerequisites and limits. Bitbucket-only setup needs no GitHub sign-in; it does not install a pipeline or alter repository settings.
689
+
690
+ `init` accepts `--host-config <json>` and `--base <branch>`. The installed `task-pr` command supports bound PR create/view/diff/edit/comment operations; `task-review` prepares and publishes independent reviewer results. These commands do not qualify a harness or authorize a model invocation.
691
+
692
+ For the independent local reviewer, configure `review.mode: "first-party-required"` and `review.route: "codex"`, then run `gallivant review qualify --repo bitbucket.org/workspace/repository --run`. Run the same command without `--run` to inspect its durable result. A new task preflight refuses before author dispatch unless this exact executable/provider fingerprint qualified. To migrate a settled existing task, use `gallivant review policy HANDLE --mode first-party-required --reason "Enable the qualified independent local reviewer"`, then `gallivant recheck HANDLE`. That audited command preserves the task, PRD snapshot, PR and implementation session; editing config alone cannot remove its legacy policy.
693
+
694
+ Review prompts remain at or below 100,000 bytes. Large changes are divided across at most `review.max_jobs` fresh restricted jobs and the reserved `review.budget_usd`; every path and criterion must be covered. A single large file is sliced or the aggregate stops explicitly as incomplete. Zero CI checks still require `review.zero_checks: true` and are never inferred from reviewer clearance.
695
+
696
+ The default review allowance is 2,048 jobs and $100 in accounting reservations,
697
+ with 60 minutes per job. Split inspections provide source-grounded reports;
698
+ a separate whole-PR synthesis must clear before readiness. Coding fix rounds
699
+ default to 60 with a $50 per-run allowance. Reviewer jobs and Git commits are
700
+ not coding rounds: the displayed round advances when a corrective coding run
701
+ settles, including a changed completion receipt. Existing task review limits
702
+ remain pinned until an explicit `review policy` command and recheck.
703
+
704
+ Reviewer qualification can use `review qualify --repo OWNER/REPO --run --wait`
705
+ to keep the launch process alive until settlement. An explicitly inspected,
706
+ owned stopped timeout/provider failure can be retried with `--retry --reason
707
+ "explanation"` on that same command. This preserves its history and reserves a
708
+ new bounded allowance; it never accepts a failed result or bypasses review.
709
+ See [first-party review](first-party-review.md#waiting-for-qualification-and-explicitly-retrying-a-stopped-probe).