Repository navigation
feat(memory): support inline-with-candidate apply and converge auto-sync - #41
Conversation
Signed-off-by: thxCode <thxcode0824@gmail.com>
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
📄
|
| const expectedReceiptBranch = isInlineMode | ||
| ? (candidatePublication?.branchName ?? existingReceipt.branchName) | ||
| : memoryBranch; |
There was a problem hiding this comment.
Receipt replay can accept a stale receipt written by a different memory apply mode. In inline mode with candidatePublication === null, expectedReceiptBranch falls back to existingReceipt.branchName, so validateReceiptBindings is fed the receipt's own branch and trivially matches — e.g. a receipt from a prior separate-pull-request run on the default loopwright/memory/<taskpack>/<targetBranch> branch would be replayed as published even though inline mode never writes that branch. Suggestion: when isInlineMode && candidatePublication === null, treat any existing receipt as a binding mismatch (or reconcile_required) instead of falling back to the receipt's own branch.
Suggestion:
| const expectedReceiptBranch = isInlineMode | |
| ? (candidatePublication?.branchName ?? existingReceipt.branchName) | |
| : memoryBranch; | |
| const expectedReceiptBranch = isInlineMode | |
| ? (candidatePublication?.branchName ?? null) | |
| : memoryBranch; | |
| if (expectedReceiptBranch === null) { | |
| return Object.freeze({ | |
| status: 'refused', | |
| /* ... reuse mismatch payload ... */ | |
| }); | |
| } |
| branchName: memoryBranch, | ||
| pullRequestUrl: null, | ||
| pullRequestNumber: null, | ||
| reason: 'GitHub credentials, API URL, or git remote unavailable for separate memory PR publication', | ||
| pullRequestUrl: candidatePublication?.pullRequestUrl ?? null, | ||
| pullRequestNumber: candidatePublication?.pullRequestNumber ?? null, | ||
| reason: isInlineMode | ||
| ? 'GitHub credentials or git remote unavailable for inline memory commit' |
There was a problem hiding this comment.
Misleading summary on the local_only fallback: when inline mode lacks credentials/remote, nothing is appended to the candidate PR, yet the summary reports branchName: memoryBranch (the candidate branch) and the candidate's pullRequestUrl/pullRequestNumber. Downstream consumers (action.ts / CLI reporting) will present this as if the memory commit landed on the open PR. Suggestion: in inline mode return branchName: null (or the default memory branch) and null PR fields on this fallback, keeping the URL only for statuses where the push actually happened.
Signed-off-by: thxCode <thxcode0824@gmail.com>
| ?? validateReceiptBindings(existingReceipt, { | ||
| repositoryFullName: options.repositoryFullName, | ||
| taskpack, | ||
| targetBranch, | ||
| memoryDirectory, | ||
| memoryBranch: expectedReceiptBranch!, | ||
| }) |
There was a problem hiding this comment.
The non-null assertion expectedReceiptBranch! is only safe because of the subtle short-circuit ordering: when inline mode has no candidate publication, inlineReceiptBranchInvalid is true so the ?? chain returns before validateReceiptBindings runs. This invariant is fragile — any future reordering of the nullish chain or the invalid check would silently pass null into receipt binding validation, which is security-sensitive trust-boundary logic. Prefer making the nullability explicit, e.g. branch the inline-null case into its own early return, or pass expectedReceiptBranch ?? memoryBranch with a comment.
Suggestion:
| ?? validateReceiptBindings(existingReceipt, { | |
| repositoryFullName: options.repositoryFullName, | |
| taskpack, | |
| targetBranch, | |
| memoryDirectory, | |
| memoryBranch: expectedReceiptBranch!, | |
| }) | |
| if (isInlineMode && expectedReceiptBranch === null) { | |
| return Object.freeze({ | |
| status: 'refused', | |
| /* ...existing fields... */ | |
| reason: scrubTurnkeyReason('inline memory receipt cannot be replayed without matching candidate pull request publication', scrubber), | |
| }); | |
| } | |
| const bindingMismatchReason = (inlineReceiptBranchInvalid | |
| ? `inline memory receipt branch "${expectedReceiptBranch}" is invalid or targets "${targetBranch}"` | |
| : null) | |
| ?? validateReceiptBindings(existingReceipt, { | |
| memoryBranch: expectedReceiptBranch, | |
| }) | |
| ?? retainedRunMismatch; |
Signed-off-by: thxCode <thxcode0824@gmail.com>
Summary
spec.memory.apply: 'inline-with-candidate'across@loopwright/taskpack,@loopwright/cli, and@loopwright/github-app:memory.directoryremains strictly non-writable during untrusted agent turns and verification.PublishedCandidatePullRequestmetadata fromNativePullRequestPublisherServerand forwards it tofinalizeAndPublishTurnkeyMemory.no_candidate_pull_request) whenever no candidate PR was published (no_change, failed, blocked, orpublication.mode: disabled), eliminating standalone shadow memory PRs.skipCidefaults tofalseso branch-protected PR checks still execute, with DCOSigned-off-by), and pushes with--force-with-leaseonto the same PR branch.TASKPACK_HOST_BINDING_INVALID) infinalizeLocalTurnkeyMemoryandloopwright run --taskpackwhen no GitHub PR publisher is bound..auto-sync/taskpack.yaml,.auto-sync/instructions.md,.auto-sync/digests.lock.json, and.github/workflows/auto-sync.yml:metadata.name: auto-sync,auto-sync-verify,memory.directory: .auto-sync/memory/auto-sync,apply: inline-with-candidate,titleTemplate: "chore(deps): auto-sync runtime dependencies"), remove stale.auto-sync/memory/self-upgrade/entries, and drop the legacyvars.SELF_UPGRADE_RUNNERfallback.docs/configuration/taskpack.md,docs/operations/github-action.md,docs/operations/cli.md,docs/contribute/memory.md,docs/contribute/github-app-internals.md,docs/references/bootstrap-interview.md)./kind feature
/area memory
/area github-app
/area cli
/area docs
Verification
npm run buildnpm run typechecknpm run lintnpm run lint:docsnode scripts/prepare-self-upgrade.mjs --offline-checkanddigest sync --checkturnkey-memory.test.js,schema.test.js,turnkey.test.js,step-cli.test.js,docs-and-site.test.js,self-upgrade-taskpack.test.js,self-upgrade-verifier.test.js)Signed-off-byDCO trailer present on all commits