fix(security): make product publisher branch creation atomic - #80
fix(security): make product publisher branch creation atomic#80seonghobae wants to merge 46 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
|
|
@coderabbitai review Please perform a substantive security review of exact head |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
head='ab0819a0f504a00dccaa3e0e3d6c41de4c38a5fd'
base='e0106ce16b7b8b493f46bf075ec5baf58762bd95'
echo '== exact head =='
git show -s --format='commit=%H%nparents=%P%nsubject=%s' "$head"
echo
echo '== changed files at exact head relative to first parent =='
git diff-tree --no-commit-id --name-status -r "$head"
echo
echo '== diff =='
git diff --find-renames --find-copies "${head}^" "$head" -- .github docs test tests 2>/dev/null || true
echo
echo '== workflow and relevant test/document candidates =='
fd -t f . | rg '(^|/)(.*product.*publisher.*|.*hourly.*product.*|.*atomic.*lease.*|.*publisher.*\.(test|spec)\.[^/]+|.*doctoring.*)$' || true
echo
echo '== outlines for changed source-like files =='
git diff-tree --no-commit-id --name-only -r "$head" | while IFS= read -r f; do
case "$f" in
*.js|*.mjs|*.cjs|*.ts|*.mts|*.cts|*.yml|*.yaml|*.md)
echo "--- $f"
ast-grep outline "$f" --items all 2>/dev/null || true
;;
esac
done
echo
echo '== requested and live remote refs =='
git ls-remote origin \
'refs/heads/*' \
| rg 'ab0819a0f504a00dccaa3e0e3d6c41de4c38a5fd|e0106ce16b7b8b493f46bf075ec5baf58762bd95' || true
echo
echo '== PR metadata and current refs =='
gh pr view 80 --repo ContextualWisdomLab/noema \
--json number,state,isDraft,headRefName,headRefOid,baseRefName,baseRefOid,urlLength of output: 5619 🏁 Script executed: #!/bin/bash
set -euo pipefail
head='ab0819a0f504a00dccaa3e0e3d6c41de4c38a5fd'
base_ref='origin/fix/nanoid-cve-2026-67213'
merge_base="$(git merge-base "$head" "$base_ref")"
echo "== merge base =="
printf '%s\n' "$merge_base"
git show -s --format='subject=%s' "$merge_base"
echo
echo "== cumulative PR changes =="
git diff --name-status "$merge_base" "$head"
echo
echo "== workflow sections: permissions, publisher stage, Git operations, traps =="
workflow='.github/workflows/hourly-product-development.yml'
git show "$head:$workflow" | nl -ba | rg -n -C 12 \
'(^|\s)(permissions:|publish_product_increment:|trap |force-with-lease|git push|git update-ref|git ls-remote|git fetch|git branch|contents:|pull-requests:|id-token:|actions:|security-events:|proposal|final_candidate|cleanup)' || true
echo
echo "== relevant workflow full file =="
git show "$head:$workflow" | nl -ba
echo
echo "== lease regression test =="
git show "$head:test/hourly-product-development-publisher-lease.test.ts" | nl -ba
echo
echo "== workflow-order and cleanup tests =="
for f in \
test/hourly-product-development-workflow.test.ts \
test/hourly-product-development-final-candidate-cleanup.test.ts \
test/hourly-product-development-git-mode-boundary.test.ts \
test/hourly-product-development-publication-prerequisite.test.ts \
test/hourly-product-development-runner-isolation.test.ts; do
echo "--- $f"
git show "$head:$f" | nl -ba | rg -n -C 8 \
'(force-with-lease|proposal|cleanup|trap|push|delete|permission|contents|publisher|git mode|ls-remote)' || true
done
echo
echo "== doctoring record =="
git show "$head:docs/doctoring/atomic-product-publisher-lease.md" | nl -ba
echo
echo "== workflow references and invocation paths =="
rg -n -C 5 \
'(hourly-product-development|publish_product_increment|workflow_call|workflow_dispatch|schedule)' \
.github README.md docs 2>/dev/null || trueLength of output: 2263 🏁 Script executed: #!/bin/bash
set -euo pipefail
head='ab0819a0f504a00dccaa3e0e3d6c41de4c38a5fd'
first='1a7a6eea0e4345f45d743efee9070d2265c779df'
impl='f60c4d93fe54cff211675b47c0f6a0950aadf8bd'
compat='16941a9139bc154403410bd22ee6c6e19c96e3ed'
workflow='.github/workflows/hourly-product-development.yml'
echo '== stated lineage and parents =='
for c in "$first" "$impl" "$compat" "$head"; do
git show -s --format='commit=%H%nparent=%P%nsubject=%s%n' "$c"
done
lineage_base="$(git rev-parse "${first}^")"
echo "== cumulative changes from lineage base $lineage_base =="
git diff --name-status "$lineage_base" "$head"
echo
echo '== workflow: complete exact-head content =='
git show "$head:$workflow" | nl -ba
echo
echo '== workflow: mutation and privilege context =='
git show "$head:$workflow" | nl -ba | rg -n -C 15 \
'(permissions:|publish_product_increment:|trap |force-with-lease|git push|git fetch|git ls-remote|git config|proposal|final_candidate|cleanup|contents:|pull-requests:|id-token:|environment:)' || true
echo
echo '== exact-head executable contracts =='
for f in \
test/hourly-product-development-publisher-lease.test.ts \
test/hourly-product-development-workflow.test.ts \
test/hourly-product-development-final-candidate-cleanup.test.ts \
test/hourly-product-development-git-mode-boundary.test.ts \
test/hourly-product-development-publication-prerequisite.test.ts \
test/hourly-product-development-runner-isolation.test.ts \
docs/doctoring/atomic-product-publisher-lease.md; do
echo "--- $f"
git show "$head:$f" | nl -ba
done
echo
echo '== local references to workflow or publisher stage =='
rg -n -C 5 \
'(hourly-product-development|publish_product_increment|workflow_call|workflow_dispatch|schedule)' \
.github README.md docs 2>/dev/null || true
echo
echo '== GitHub PR file list and current branch refs =='
gh api 'repos/ContextualWisdomLab/noema/pulls/80/files?per_page=100' \
--jq '.[] | [.filename, .status, .sha] | `@tsv`'
gh api 'repos/ContextualWisdomLab/noema/git/ref/heads/fix%2Fatomic-product-publisher-lease' --jq '.object.sha'
gh api 'repos/ContextualWisdomLab/noema/git/ref/heads/fix%2Fnanoid-cve-2026-67213' --jq '.object.sha'Length of output: 3527 🏁 Script executed: #!/bin/bash
set -euo pipefail
head='ab0819a0f504a00dccaa3e0e3d6c41de4c38a5fd'
workflow='.github/workflows/hourly-product-development.yml'
number() { awk '{printf "%6d %s\n", NR, $0}'; }
echo '== workflow: complete exact-head content =='
git show "$head:$workflow" | number
echo
echo '== workflow: mutation and privilege context =='
git show "$head:$workflow" | number | rg -n -C 18 \
'(permissions:|publish_product_increment:|trap |force-with-lease|git push|git fetch|git ls-remote|git config|proposal|final_candidate|cleanup|contents:|pull-requests:|id-token:|environment:)' || true
echo
echo '== exact-head regression and doctoring files =='
for f in \
test/hourly-product-development-publisher-lease.test.ts \
test/hourly-product-development-workflow.test.ts \
docs/doctoring/atomic-product-publisher-lease.md; do
echo "--- $f"
git show "$head:$f" | number
done
echo
echo '== exact-head diffs for implementation and tests =='
for c in \
f60c4d93fe54cff211675b47c0f6a0950aadf8bd \
16941a9139bc154403410bd22ee6c6e19c96e3ed \
ab0819a0f504a00dccaa3e0e3d6c41de4c38a5fd; do
echo "--- $c"
git show --format= --find-renames "$c" -- \
.github/workflows/hourly-product-development.yml \
test/hourly-product-development-publisher-lease.test.ts \
test/hourly-product-development-workflow.test.ts \
docs/doctoring/atomic-product-publisher-lease.md
done
echo
echo '== all workflow invocation and permission context =='
rg -n -C 8 \
'(hourly-product-development|publish_product_increment|workflow_call|workflow_dispatch|schedule|permissions:|contents:|pull-requests:)' \
.github README.md docs 2>/dev/null || true
echo
echo '== GitHub PR files and current refs =='
gh api 'repos/ContextualWisdomLab/noema/pulls/80/files?per_page=100' \
--jq '.[] | [.filename, .status, .sha] | `@tsv`' || true
printf 'head: '; gh api 'repos/ContextualWisdomLab/noema/git/ref/heads/fix%2Fatomic-product-publisher-lease' --jq '.object.sha' || true
printf 'base: '; gh api 'repos/ContextualWisdomLab/noema/git/ref/heads/fix%2Fnanoid-cve-2026-67213' --jq '.object.sha' || trueLength of output: 197010 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/noema'
head='ab0819a0f504a00dccaa3e0e3d6c41de4c38a5fd'
echo '== exact-head combined status =='
gh api "repos/$repo/commits/$head/status" \
--jq '{state, sha, statuses: [.statuses[] | {context, state, creator: .creator.login, target_url}]}'
echo
echo '== exact-head check runs =='
gh api "repos/$repo/commits/$head/check-runs?per_page=100" \
--jq '.check_runs[] | {name, status, conclusion, app: .app.slug, started_at, completed_at, details_url}'
echo
echo '== workflow runs directly associated with exact head =='
gh api "repos/$repo/actions/runs?head_sha=$head&per_page=100" \
--jq '.workflow_runs[] | {name, event, status, conclusion, head_sha, head_branch, run_number, html_url, created_at, updated_at}'
echo
echo '== PR review and merge metadata =='
gh pr view 80 --repo "$repo" \
--json isDraft,mergeStateStatus,mergeable,reviewDecision,statusCheckRollup,reviews \
--jq '{isDraft, mergeStateStatus, mergeable, reviewDecision, reviews: [.reviews[] | {author: .author.login, state, submittedAt, commit: .commit.oid}], checks: [.statusCheckRollup[] | {name, status, conclusion, workflowName}]}'
echo
echo '== repository rulesets and main branch protection metadata =='
gh api "repos/$repo/rulesets?includes_parents=true" \
--jq '.[] | {name, target, enforcement, conditions, rules}' || true
gh api "repos/$repo/branches/main/protection" \
--jq '{required_status_checks, required_pull_request_reviews, enforce_admins, restrictions, required_linear_history, required_signatures}' || true
echo
echo '== current PR branch and base refs =='
gh pr view 80 --repo "$repo" \
--json headRefOid,baseRefOid,headRefName,baseRefName,isDraft,updatedAt,urlLength of output: 4533
I found no actionable security defect in the reviewed change.
The live The PR remains Draft. It has no recorded reviews. The branch-protection API was unavailable to this integration with HTTP 403. This review is not approval or merge authority. Current-base exact-head CI, security, coverage, governance, and an eligible independent approval remain required. You are interacting with an AI system. |
|
Exact-head security review for After the leased branch creation succeeds, Required test-first follow-up in this same PR:
Do not add a pre-create |
|
@coderabbitai review Please perform a substantive security review of exact head |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/noema'
head='d144f016a18d164de0363246a9b9f575d1d27dd5'
base='e0106ce16b7b8b493f46bf075ec5baf58762bd95'
workflow='.github/workflows/hourly-product-development.yml'
echo '== exact head and merge-base relationship =='
git show -s --format='head=%H%nparents=%P%nsubject=%s' "$head"
git cat-file -e "${base}^{commit}"
printf 'merge_base='
git merge-base "$head" "$base"
git merge-base --is-ancestor "$base" "$head" && echo 'base_is_ancestor=true' || echo 'base_is_ancestor=false'
echo
echo '== cumulative changes from specified base =='
git diff --name-status "$base" "$head"
echo
echo '== workflow mutation, cleanup, PR creation, and token contexts =='
git show "$head:$workflow" | nl -ba | rg -n -C 18 \
'(permissions:|publish_product_increment:|trap |force-with-lease|git push|gh pr create|gh pr view|gh pr close|proposal_head|proposal_base|head\.sha|base\.sha|cleanup|Maintainer|contents:|pull-requests:|GITHUB_TOKEN|token)' || true
echo
echo '== focused workflow slice around all relevant lines =='
git show "$head:$workflow" | nl -ba | sed -n '800,980p'
echo
echo '== exact-head contract and doctoring files =='
for f in \
test/hourly-product-development-publisher-lease.test.ts \
test/hourly-product-development-workflow.test.ts \
test/hourly-product-development-final-candidate-cleanup.test.ts \
test/hourly-product-development-git-mode-boundary.test.ts \
docs/doctoring/atomic-product-publisher-lease.md; do
echo "--- $f"
git show "$head:$f" | nl -ba | rg -n -C 8 \
'(force-with-lease|proposal_head|proposal_base|gh pr create|gh pr view|gh pr close|head\.sha|base\.sha|trap|cleanup|malformed|missing|mismatch|identity|permission|ls-remote)' \
|| true
done
echo
echo '== changed test and doctoring files relative to base =='
git diff --find-renames --unified=35 "$base" "$head" -- \
"$workflow" \
test/hourly-product-development-publisher-lease.test.ts \
test/hourly-product-development-workflow.test.ts \
docs/doctoring/atomic-product-publisher-lease.md
echo
echo '== current PR, refs, checks, and review state =='
gh pr view 80 --repo "$repo" \
--json state,isDraft,headRefName,headRefOid,baseRefName,baseRefOid,mergeable,mergeStateStatus,reviewDecision,reviews,url
printf 'live_base_ref='
gh api "repos/$repo/git/ref/heads/fix%2Fnanoid-cve-2026-67213" --jq '.object.sha'
printf 'pr_head_ref='
gh api "repos/$repo/git/ref/heads/fix%2Fatomic-product-publisher-lease" --jq '.object.sha'
gh api "repos/$repo/commits/$head/check-runs?per_page=100" \
--jq '.check_runs[] | [.name,.status,.conclusion,.app.slug] | `@tsv`'Length of output: 3705 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/noema'
head='d144f016a18d164de0363246a9b9f575d1d27dd5'
base='e0106ce16b7b8b493f46bf075ec5baf58762bd95'
workflow='.github/workflows/hourly-product-development.yml'
number() { awk '{printf "%6d %s\n", NR, $0}'; }
echo '== workflow permissions and publisher job context =='
git show "$head:$workflow" | number | grep -n -E -C 15 \
'permissions:|publish_product_increment:|Maintainer|GITHUB_TOKEN|contents:|pull-requests:|actions:|id-token:' || true
echo
echo '== workflow publication and cleanup sequence =='
git show "$head:$workflow" | number | sed -n '800,980p'
echo
echo '== all workflow mutation and PR identity operations =='
git show "$head:$workflow" | number | grep -n -E -C 12 \
'trap |force-with-lease|git push|gh pr create|gh pr view|gh pr close|proposal_head|proposal_base|head\.sha|base\.sha|cleanup|ls-remote' || true
echo
echo '== full publisher lease regression =='
git show "$head:test/hourly-product-development-publisher-lease.test.ts" | number
echo
echo '== matching sections from workflow regression =='
git show "$head:test/hourly-product-development-workflow.test.ts" | number | grep -n -E -C 15 \
'force-with-lease|proposal_head|proposal_base|gh pr create|gh pr view|gh pr close|head\.sha|base\.sha|trap|cleanup|ls-remote|identity' || true
echo
echo '== full atomic publisher lease doctoring =='
git show "$head:docs/doctoring/atomic-product-publisher-lease.md" | number
echo
echo '== exact-head changes from requested base =='
git diff --find-renames --unified=20 "$base" "$head" -- \
"$workflow" \
test/hourly-product-development-publisher-lease.test.ts \
test/hourly-product-development-workflow.test.ts \
docs/doctoring/atomic-product-publisher-lease.md
echo
echo '== PR, live refs, check state, and reviews =='
gh pr view 80 --repo "$repo" \
--json state,isDraft,headRefName,headRefOid,baseRefName,baseRefOid,mergeable,mergeStateStatus,reviewDecision,reviews,url
printf 'live_base_ref='
gh api "repos/$repo/git/ref/heads/fix%2Fnanoid-cve-2026-67213" --jq '.object.sha'
printf 'pr_head_ref='
gh api "repos/$repo/git/ref/heads/fix%2Fatomic-product-publisher-lease" --jq '.object.sha'
gh api "repos/$repo/commits/$head/check-runs?per_page=100" \
--jq '.check_runs[] | [.name,.status,.conclusion,.app.slug] | `@tsv`'Length of output: 22883 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/noema'
head='d144f016a18d164de0363246a9b9f575d1d27dd5'
number() { awk '{printf "%6d %s\n", NR, $0}'; }
echo '== complete publisher lease regression =='
git show "$head:test/hourly-product-development-publisher-lease.test.ts" | number
echo
echo '== complete workflow regression =='
git show "$head:test/hourly-product-development-workflow.test.ts" | number
echo
echo '== complete atomic publisher lease doctoring =='
git show "$head:docs/doctoring/atomic-product-publisher-lease.md" | number
echo
echo '== workflow lines 638 through 930 =='
git show "$head:.github/workflows/hourly-product-development.yml" | number | sed -n '638,930p'
echo
echo '== current PR metadata =='
gh pr view 80 --repo "$repo" \
--json state,isDraft,headRefName,headRefOid,baseRefName,baseRefOid,mergeable,mergeStateStatus,reviewDecision,reviews,url
echo
echo '== current PR branch and requested live base ref =='
printf 'live_base_ref='
gh api "repos/$repo/git/ref/heads/fix%2Fnanoid-cve-2026-67213" --jq '.object.sha'
printf 'pr_head_ref='
gh api "repos/$repo/git/ref/heads/fix%2Fatomic-product-publisher-lease" --jq '.object.sha'
echo
echo '== exact-head check runs =='
gh api "repos/$repo/commits/$head/check-runs?per_page=100" \
--jq '.check_runs[] | [.name,.status,.conclusion,.app.slug] | `@tsv`'Length of output: 52795
I found one actionable fail-closed cleanup defect. Finding — Malformed In If Capture a usable created-PR identifier in a machine-readable response from the creation operation. Install the created-PR cleanup trap after that identifier is available. On malformed or missing identity evidence, close only that identifier and then retain the existing exact-proposal-head branch deletion lease. Add a regression case that requires this cleanup path. The remaining requested controls are correctly implemented at exact head:
The requested commit has merge base At inspection time, PR
|
Summary
Hardens the trusted
hourly-product-developmentscheduler and its credential-bearing proposal publisher without adding repair automation, synthetic approval, merge authority, release authority, or deployment authority.This PR owns the focused scheduler/publisher implementation. Repository-wide PRD/TRD/Architecture/ADR/UML/ERD/Test/Operability/Traceability remains canonical on PR #71; #71 records this work as
Proposeduntil protected integration and operational proof.Exact source identity
fix/atomic-product-publisher-leasea937c59f14098de03a0b83e99359c8ac3579df69fix/nanoid-cve-2026-67213e0106ce16b7b8b493f46bf075ec5baf58762bd95base_shafield is not treated as the current live feature-branch authority.Scheduler RCA, feasibility, and continuation contract
The product-development workflow begins by reading
AGENTS.md. That repository-consumed preflight requires:Each candidate is classified
execute_now,defer_until_trigger,read_only_dependency,external_only, orreject. Authority, capability, exact target, policy, dependency order, writer lease, reversibility, remaining budget, blast radius and a test oracle must be proved before mutation. Failed/no-op remedies become new evidence; three materially distinct failed hypotheses require architecture/contract reassessment rather than another symptom patch.Work-conserving deliverable handoff
The scheduler now explicitly refuses to treat an intermediate artifact as invocation completion:
A blocked handoff defers only that lane and rotates to another non-conflicting action. Documentation repair must be followed by the highest-value safe non-documentation work when practical budget and the writer lease permit it. Termination requires a mandatory double fresh exit sweep or genuine practical invocation-budget exhaustion. A user-visible report is never completion.
CHANGELOG.mdnow records this contract explicitly rather than leaving it only in scheduler policy and tests.Stacked Security Scan trigger boundary
The central
.githubSecurity Scan currently selects supported pull-request base branches. Because #80 is stacked on the feature branch owned by #76, absence of a central Security Scan on this exact head is an event-selection boundary, not scanner success.Required treatment:
defer_until_trigger, never passing evidence;Atomic publisher boundary
The publisher protects both mutable GitHub objects it creates:
--force-with-lease;proposal_head;head.sha/base.shamust match verified identities;Test-first lineage
Historical publisher/RCA lineage remains audit evidence, not current-head acceptance:
97b9a2f5f604f9885c0c32e5204f6b2f9ccfed13: RED realistic-remediation contract.8649f6fe134f210b1e606b36cc60c8afaeb92624: remediation guidance GREEN.a2da363eb40dfe4723475605a67a84c93bb16bcb: RED recoverable PR identity/full-queue contracts.f60f4bb001e6219b2588312e1665f1e5dc806d01: publisher identity/cleanup contracts GREEN.8ae32bbaa20d8da83b3d6ceff3300715ebd28667: RED RCA/feasibility contract.13ea7eeb0dab8b33d70cb4bb6823e22484458ff9: RCA-to-action contract GREEN.abd973a299ceec76148041a7cebe8a3ead32c20b: RED stacked-Security-Scan trigger contract.9103c46b72485fe83b63ac84c2d2bf51d85a5ce3: corrected event-selection contract.73bdcb646e9e14e811f5fa5b1b465f28a52ca161: removes competing repository-wide documentation ownership; fix(security): bind workflow source and document MSA boundaries #71 remains canonical.6e73aa73d06ecbabf335388d3dacc58f66791a76: RED contract requiring deliverable handoff, post-documentation continuation, double exit sweep and report-not-completion semantics.9a19f216ec133c45671e906f01672150afa3e2ab: repository-consumedAGENTS.mdimplementation.01f25c5f0a2d92488aaf301805004667a102b675: RED contract requiring the same continuation semantics to be recorded inCHANGELOG.md.a937c59f14098de03a0b83e99359c8ac3579df69: current exact head;CHANGELOG.mdimplements the required handoff/double-sweep/intermediate-state record. The exact one-commit comparison from RED to GREEN changes onlyCHANGELOG.mdwith the intended insertion.Exact-head evidence state
Freshly revalidated for exact head
a937c59f14098de03a0b83e99359c8ac3579df69:cirun31314266572: terminal success;reviewer-cirun31314266576: terminal success;Security Scan: absent because the current base is a feature branch; this remainsdefer_until_trigger, not passing evidence;APPROVED: none.The PR remains Draft because terminal application/reviewer CI cannot substitute for the absent stack-ineligible Security Scan, unintegrated predecessor, enforceable governance, or qualifying approval. No predecessor-head CI/review evidence transfers to a future refreshed exact head.
Dependency and governance boundary
Do not merge #80 until:
Issue #27 owns enforceable
maingovernance. Issue #29 owns Reviewer/Maintainer App provisioning. Previously disprovenopencode-agentandcwl-noema-reviewreviewer routes are not spammed or treated as approval paths.No
.github/workflows/repair-*, self-modifying Action, branch-patchingcontents:write, protection bypass, synthetic approval, merge, release, or deployment authority is introduced.Related: #71, #76, #78, #27, #29