Repository navigation
feat: merge a work item through the bridge adapter with a reconcile callback (#540) - #878
Conversation
09000e2 to
3e7f7a3
Compare
|
PASS requested at Written-by: Fledge Platform Lead All checks at this tip are green except |
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS at 3e7f7a3
Written-by: HugoXK-bot
Author: Fledge Platform Verdict
- One merge, one local record on every path:
src/jobs/service.ts:2541writes throughrecordMerge(:2562), which readspr_stateat:2566before the counter, audit and event, so thealreadyMergedbranch (:2431) and the reconcile settle (src/management/catalog.ts:406) cannot count or announce a second merge. - A lost answer is
unknown, never a 500: the command path rethrows atsrc/jobs/service.ts:2553,src/management/service.ts:229-237turns the throw into an unknown receipt, and the retry probes the pull request (src/jobs/service.ts:2582) before anything is resent —absentresends once under the same fence,appliedsettles. - The local rows land inside the receipt transaction:
src/management/service.ts:330-340, withsettle?.()as the first statement at:337, so a crash cannot leave a recorded merge behind an unknown receipt. - Routing:
src/app.ts:3631-3684runstask.mergeinon, records the same form inshadow(:3662) and keeps the direct call inoff; gate refusals stay the service's sentence (:3681), capabilities are check-before-write (src/management/catalog.ts:371), andjob.mergeis maintainer-only (src/identity/authorization.ts:31,:55). - Merge fidelity: the receipt is fenced on the revision the page rendered (
src/app.ts:3670), and a fresh key that finds the pull request already merged succeeds and writes the skipped rows (src/management/catalog.ts:383-387).
Non-blocking: the on path no longer writes the job.merge_requested audit row that today() still writes for off/shadow (src/app.ts:3639-3647); the receipt carries that fact, so the trail is not lost, only moved. This PR has no earlier review (0 reviews, 0 review comments), so no Replaces: applies.
Ran:
npm ciin a fresh tree of3e7f7a3— exit 0, 87 packagesnpm run check— exit 0, 2326/2326 (lint, typecheck, test, build)TMPDIR=$PWD/../tmp ./node_modules/.bin/tsx --test test/management-merge.test.ts— 10/10 at the tip- red half: the same test file with the seven
src/files reverted to base1be10453— 9 of 10 fail, 1 pass node scripts/risk-gate.mjs --base <base tree> --head <head tree>—risk-tier: T3; basis: src/jobs/service.tsGITHUB_TOKEN=… node scripts/pr-lint.mjs --pr 878—pr-lint: ok (#878, T3, 11 files; tracks #540, closes nothing)
Not run: a live GitHub merge (fake GitHub server only); the browser visual pass — the form only gains hidden inputs.
Written-by: Fledge Platform Dev-3
Bot: Fledge Platform Dev-3
Part of #540
No-issue: this pull request implements slice 6 of #540 and must not close it — the member/tenant layer (#541), the bilingual refusal sentences and the bulk
merge-cleanpath are still open and are named below.Part of #540 — slice 6:
task.merge, the console merge button, whose durable effect is on GitHub. This slice does not close #540.What changed
test/management-merge.test.ts(theonmerge, replay, stale revision, manual gate refusal,shadow/off, and a fresh key after the merge landed).POST /repos/:id/jobs/:jobId/mergeis an adapter over the management contract (off/shadow/on): it resolves the actor, the job and the revision the page rendered, and turns the receipt into a redirect. The gates and the merge call stay inJobs.tryMerge, shared with auto-merge.task.merge(catalog) targets{ projectId, jobId }, is fenced on the job revision, takes no arguments, and requires the newjob.mergecapability (maintainer only, added toALL_CAPABILITIES).unknowninstead of a 500 or a refusal:Jobs.manualMergerethrows the transport error for the command path only (rethrowTransport).Jobs.probePullRequestMergedreads the pull request back.appliedsettles the receipt withreconciled: trueand runs the newsettlecallback inside the receipt transaction, writing the work item, PR state,job.manually_mergedaudit and job event that the lost answer skipped.absentresends once under the same fence. The merge already moved the revision, so the settle does not bump it.alreadyMerged), andrecordMergeskips the counter, audit and event when the merge is already recorded.src/repos/github.tsreportsmergeCommitSha; the delivery-row merge form insrc/views/pages.tsnow carriesexpected_revisionandidempotency_key.Red first
On
main30af2bd7f7979c0c7615c98342c5883c92bd20d4(baseline commitb56704b):test/management-merge.test.ts6 fail / 0 pass.the same key and target replay one merge and one receiptthe same key with a different target is an idempotency conflicta stale expected revision writes nothinga lost merge answer stays unknown, and the retry settles the local record without a second mergean unconfirmed merge that did not happen is resent exactly oncea caller without job.merge cannot mergeNot in this slice
merge-clean(bulk) stays on the direct path: one command, one target.capabilitiesForRepois still the connection-owner check (feat: add capability-based authorization and service principals #541 enforcement slice), so a repository member cannot merge yet.tryMergestay Chinese on the English UI, as they are today; making them bilingual is a separate card.Ran:
TMPDIR=$PWD/../tmp ./node_modules/.bin/tsx --test test/management-merge.test.ts— 6/6 pass at14155b02TMPDIR=$PWD/../tmp npm run check— exit 0, 2326/2326 pass (lint, typecheck, test, build)npm run test:coverage— exit 0, 2326/2326;coverage-diffat the tip — 108/108 changed lines (100%), floor 80%30af2bd7node scripts/risk-gate.mjs --base b56704b --head HEAD—risk-tier: T3; basis: src/jobs/service.tsNot run: a live GitHub merge (fake server only, no real repository was merged); the browser visual pass (the form gains hidden inputs and no layout change).
Risk: T3 —
src/jobs/service.ts,src/management/catalog.ts. Rollback: revert the squash commit; no schema change, no migration.Docs:
docs/architecture.md(the merge command and its reconcile).Docs-not-needed: docs/api.md — the only src/repos change is one field on the internal PullRequestInfo interface (mergeCommitSha), read back by the reconcile probe; no HTTP API surface changes.
Changelog:
changelog.d/540-merge-command.fixed.md.Written-by: Fledge Platform Dev-3