Skip to content

kaizen: Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました (#330) - #340

Open
s-hiraoku wants to merge 17 commits into
mainfrom
kaizen/issue-330-preserve-git-publication-credentials-across-isol
Open

kaizen: Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました (#330)#340
s-hiraoku wants to merge 17 commits into
mainfrom
kaizen/issue-330-preserve-git-publication-credentials-across-isol

Conversation

@s-hiraoku

@s-hiraoku s-hiraoku commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Closes #330

元Issue

#330: Preserve Git publication credentials across isolated builder execution

Summary

A manual recovery run for kaizen-loop#319 completed implementation and verification, then failed only at git push because the isolated builder subprocess could not read credentials for the HTTPS origin. The supervising Kaizen process had GitHub access and successfully published the unchanged generated commit afterward.

Evidence

  • Project: kaizen-agents-org-kaizen-loop
  • Run started: 2026-08-03T22:40:26.066Z
  • Generated commit: 97eeb3a
  • Failure: git push returned 128, could not read Username for https://github.com

Builder task understanding

Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。

Builder notes

回帰テストを追加し、builder に GH_TOKEN が渡らず supervisor が PR publication まで完了することを確認しました。認証付き push は pre-push hook を実行しません。指定検証は全て成功(587 passed、1 skipped)。dist を更新済みで、保護対象パスの変更はありません。

Provider evidence:

  • codex: exitCode=0, status=selected, failureClass=none, fallbackReason=none, payloadSource=last-message, truncatedOutput=none
    Selected backend: codex
    Final payload source: last-message

変更ファイル

  • dist/utils/command.d.ts — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • dist/utils/command.js — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • dist/utils/command.js.map — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • dist/workspace/git.js — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • dist/workspace/git.js.map — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • src/utils/command.ts — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • src/workspace/git.ts — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • test/command.test.ts — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • test/improve.test.ts — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • test/integration/dry-run.test.ts — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。
  • test/workspace.test.ts — Git publication 時のみ supervisor の GitHub 認証を安全な credential helper 経由で利用するよう修正しました。
    builder には認証情報を渡さず、force-with-lease と ready-for-review PR の既存保護を維持しています。

Changed files: 11 / Changed lines: 121

Verification

  • npm test — 成功
  • npm run typecheck — 成功
  • npm run check:dist — 成功
  • npm run build — 成功
  • test -f skills/gh-link-issue-pr/SKILL.md && test -f skills/kaizen-bug-router/SKILL.md && test -f skills/pr-guardian/SKILL.md — 成功

Verifier verdict

verifier: open_pr_with_warning
summary: Open PR with warning and 2 should_fix item(s); risk is medium.
evidence: reported (未実行の可能性あり)
should_fix: [verify_logs] Verification output contains a non-blocking risk signal. — evidence: Tests 587 passed | 1 skipped (588)
should_fix: [builder_report] Verification output contains a non-blocking risk signal. — evidence: 回帰テストを追加し、builder に GH_TOKEN が渡らず supervisor が PR publication まで完了することを確認しました。認証付き push は pre-push hook を実行しません。指定検証は全て成功(587 passed、1 skipped)。dist を更新済みで、保護対象パスの変更はありません。
confidence: 60/100
risk: medium
notes: evidence_grade=reported
warning: この判定は実行証拠ではなくテキスト報告に基づくため、未実行の可能性があります。

Evidence strength

  • reported: builder summary and builder notes come from the builder-agent self-report.
  • executed: Kaizen Loop ran the verification commands listed above.
  • reported: Kaizen Loop ran verifier, but verifier evidence is based on text reporting rather than execution proof.
  • static: changed file and line counts come from git diff metadata.

残存リスク / レビュー観点

Verifier cleared PR with warning: Open PR with warning and 2 should_fix item(s); risk is medium.
should_fix: [verify_logs] Verification output contains a non-blocking risk signal. — evidence: Tests 587 passed | 1 skipped (588)
should_fix: [builder_report] Verification output contains a non-blocking risk signal. — evidence: 回帰テストを追加し、builder に GH_TOKEN が渡らず supervisor が PR publication まで完了することを確認しました。認証付き push は pre-push hook を実行しません。指定検証は全て成功(587 passed、1 skipped)。dist を更新済みで、保護対象パスの変更はありません。
confidence: 60/100
risk: medium

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability for branch and pull request publishing across commits, checkpoints, and recovery flows.
    • Added repository validation to prevent publishing to an unintended destination.
    • Preserved remote-tracking state and improved force-with-lease updates.
  • Security

    • Isolated credentials to publication operations and protected unrelated processes.
    • Improved authenticated HTTPS and SSH publishing with safer executable selection.
    • Rejected unsupported Git LFS pointers during publication.
  • Documentation

    • Clarified required publication credentials and authentication behavior.
    • Added publication authentication checks to setup and diagnostic commands.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@s-hiraoku, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository: kaizen-agents-org/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5bbff90b-fbc2-480e-8e79-86dd61ede542

📥 Commits

Reviewing files that changed from the base of the PR and between 3803bf1 and c1a04c2.

⛔ Files ignored due to path filters (24)
  • dist/agents/builder.js is excluded by !**/dist/**
  • dist/agents/builder.js.map is excluded by !**/dist/**, !**/*.map
  • dist/agents/verifier.js is excluded by !**/dist/**
  • dist/agents/verifier.js.map is excluded by !**/dist/**, !**/*.map
  • dist/agents/verifierFreshness.js is excluded by !**/dist/**
  • dist/agents/verifierFreshness.js.map is excluded by !**/dist/**, !**/*.map
  • dist/goals/agent.js is excluded by !**/dist/**
  • dist/goals/agent.js.map is excluded by !**/dist/**, !**/*.map
  • dist/goals/runner.js is excluded by !**/dist/**
  • dist/goals/runner.js.map is excluded by !**/dist/**, !**/*.map
  • dist/init/init.js is excluded by !**/dist/**
  • dist/init/init.js.map is excluded by !**/dist/**, !**/*.map
  • dist/orchestrator/prGuardian.js is excluded by !**/dist/**
  • dist/orchestrator/prGuardian.js.map is excluded by !**/dist/**, !**/*.map
  • dist/scheduler/scheduler.d.ts is excluded by !**/dist/**
  • dist/scheduler/scheduler.js is excluded by !**/dist/**
  • dist/scheduler/scheduler.js.map is excluded by !**/dist/**, !**/*.map
  • dist/utils/command.d.ts is excluded by !**/dist/**
  • dist/utils/command.js is excluded by !**/dist/**
  • dist/utils/command.js.map is excluded by !**/dist/**, !**/*.map
  • dist/workspace/git.js is excluded by !**/dist/**
  • dist/workspace/git.js.map is excluded by !**/dist/**, !**/*.map
  • dist/workspace/manager.js is excluded by !**/dist/**
  • dist/workspace/manager.js.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (18)
  • README.md
  • src/agents/builder.ts
  • src/agents/verifier.ts
  • src/agents/verifierFreshness.ts
  • src/goals/agent.ts
  • src/goals/runner.ts
  • src/init/init.ts
  • src/orchestrator/prGuardian.ts
  • src/scheduler/scheduler.ts
  • src/utils/command.ts
  • src/workspace/git.ts
  • src/workspace/manager.ts
  • test/command.test.ts
  • test/doctor.test.ts
  • test/fleet.test.ts
  • test/init.test.ts
  • test/scheduler.test.ts
  • test/workspace.test.ts
📝 Walkthrough

Walkthrough

The change moves Git publication behind a credential-aware supervising boundary. It validates the target repository, isolates HTTPS and SSH credentials, resolves trusted Git executables, updates orchestration call sites, adds publication preflight checks, and expands regression coverage.

Changes

Credential-safe Git publication

Layer / File(s) Summary
Publication environment and trusted executable resolution
src/utils/command.ts, test/command.test.ts
Adds trusted executable resolution and isolated HTTPS and SSH publication environments.
Validated Git publication
src/workspace/git.ts, test/workspace.test.ts
Validates repository URLs, publishes through a temporary bare clone, supports force-with-lease, and rejects unsafe publication states.
Repository-aware orchestration
src/commands/actions.ts, src/orchestrator/run.ts
Passes repository identifiers through action, checkpoint, direct-commit, pull-request, and failure flows.
Publication authentication preflight
src/commands/doctor.ts, README.md, docs/01-architecture.md, docs/02-cli-spec.md, test/doctor.test.ts
Requires supervisor publication tokens and documents token and Git LFS publication rules.
Publication flow regression coverage
test/actions.test.ts, test/goal.test.ts, test/improve.test.ts, test/integration/dry-run.test.ts, test/report.test.ts, test/smoke.test.ts
Updates Git mocks and assertions for push URL lookup, credential isolation, URL-based pushes, and executable variants.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Orchestrator
  participant GitClient
  participant TemporaryBareClone
  participant GitHub
  Orchestrator->>GitClient: Push ref with expectedRepo
  GitClient->>GitClient: Validate origin push URL
  GitClient->>TemporaryBareClone: Create temporary bare clone
  TemporaryBareClone->>GitHub: Publish with isolated credentials
  GitHub-->>TemporaryBareClone: Return push result
  TemporaryBareClone-->>GitClient: Update local tracking state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the secure supervisor authentication change during Git publication.
Linked Issues check ✅ Passed The changes address #330 through supervisor publication, credential isolation, recovery handling, force-with-lease protection, and regression tests.
Out of Scope Changes check ✅ Passed The reviewed source, documentation, and test changes support the linked issue objectives and contain no unrelated changes.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kaizen/issue-330-preserve-git-publication-credentials-across-isol

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a82d9f3a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/command.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 167b023dd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/workspace/git.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 888f3c1d5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/workspace/git.ts Outdated
Comment thread src/workspace/git.ts Outdated
Comment thread src/workspace/git.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f70d78fdc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/command.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbdfcab5ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/workspace/git.ts Outdated
Comment thread src/utils/command.ts Outdated
Comment thread src/utils/command.ts Outdated
@s-hiraoku

s-hiraoku commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

PR Guardian final report — pass 1/5

The PR was not merged.

@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d057e246f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/command.ts Outdated
Comment thread src/utils/command.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c22737774b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/workspace/git.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 390669d621

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/command.ts
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdfe7c1231

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/command.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

PR Guardian final report — pass 2/5

  • Final state: mergeablemergeable=MERGEABLE, mergeStateStatus=CLEAN, head 68edc8096143f0add734121d43b81c9b4eb0a462; PR is ready for review and was not merged.
  • Required checks: verify passed on the final head. CodeRabbit status is successful. Branch protection requires conversation resolution but no approval; all conversations are resolved.
  • Stabilization: two complete passing snapshots at 2026-08-06T07:29:14Z and 2026-08-06T07:30:21Z had the same head, zero unresolved threads, zero check annotations, and no new review/comment activity.
  • Workflow runs watched with gh run watch --exit-status: 31079170124, 31079665544, 31080199451, 31080573706, and 31081022893; all completed successfully.
  • Fixes pushed without force after guarded remote-head checks:
    • 4d057e2 — pin trusted Git publication execution, capture supervisor auth before untrusted work, remove the mutable gh publication helper, and honor Windows PATHEXT.
    • c227377 — require a trusted startup gh executable and pin the SSH executable.
    • 390669d — isolate the local bare clone from global/system Git config and omit SSH credentials.
    • fdfe7c1 — isolate SSH publication from global/system Git config.
    • 68edc80 — force an empty SSH user config to block builder-controlled ProxyCommand.
  • Validation: npm test (594 passed, 1 skipped), npm run typecheck, npm run build, generated-dist CI, and final-head required CI all pass.
  • Feedback addressed: all 8 actionable P1 threads observed during this pass were individually replied to with commit/validation evidence and resolved (3 inherited threads plus 5 current-head follow-ups).
  • Full audit: paginated GraphQL review threads and REST reviews, review comments, PR comments, check runs, and annotations were exhausted; no unresolved actionable feedback or annotations remain.
  • Skipped/non-blocking feedback:
    • CodeRabbit summary was rate-limited on the final head and reports an optional docstring-coverage warning. It is non-required, unrelated to the focused publication-security fix, and no repository check requires it.
    • The fifth Codex review found the SSH user-config issue fixed in 68edc80; that thread was replied to and resolved. A sixth current-head Codex request was not made because the retry budget is exhausted.
  • Remaining blockers: none reported by GitHub. Required checks pass, merge state is clean, required conversations are resolved, and no approval is required.

The PR was not merged.

@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68edc80961

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/workspace/git.ts Outdated
Comment thread src/utils/command.ts
Comment thread src/utils/command.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab2dba97b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/workspace/git.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f310ed7bff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/workspace/git.ts Outdated
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/workspace.test.ts (1)

40-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover a populated --force-with-lease value.

The runner returns an empty stdout for rev-parse --verify refs/remotes/origin/<ref>, so the lease value at src/workspace/git.ts:254 is the empty string and line 57 asserts --force-with-lease=refs/heads/kaizen/issue-12-retry-branch:.

An empty lease value is the no-remote-branch case. The case that protects an existing remote branch carries the remote-tracking sha. The PR objectives require preserving the force-with-lease protection, and that path has no assertion. A regression that drops the sha would still pass this test.

Add a case where rev-parse --verify returns a sha and assert the lease contains it.

💚 Proposed test
+  it('leases against the recorded remote-tracking commit when one exists', async () => {
+    vi.stubEnv('GH_TOKEN', 'supervisor-token');
+    const runner = vi.fn<CommandRunner>(async (command, args) => ({
+      command,
+      args,
+      cwd: '/workspace',
+      exitCode: 0,
+      stdout: args.join(' ') === 'remote get-url --push --all origin'
+        ? 'https://github.com/o/r.git\n'
+        : args[0] === 'rev-parse' && args[1] === '--verify'
+          ? 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef\n'
+          : '',
+      stderr: '',
+      durationMs: 1
+    }));
+
+    await new GitClient(runner, '/workspace', '/trusted/git')
+      .push('kaizen/issue-12-retry-branch', { forceWithLease: true, expectedRepo: 'o/r' });
+
+    const push = runner.mock.calls.find(([, args]) => args[0] === 'push');
+    expect(push?.[1]).toContain(
+      '--force-with-lease=refs/heads/kaizen/issue-12-retry-branch:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
+    );
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/workspace.test.ts` around lines 40 - 60, Extend the workspace GitClient
tests around the existing forceWithLease push case to return a non-empty SHA for
the rev-parse --verify remote-tracking ref, then assert the generated push
arguments include that SHA in --force-with-lease. Keep the existing empty-lease
scenario and add a separate populated-lease case covering an existing remote
branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/02-cli-spec.md`:
- Line 72: Update initProject’s preflight validation to require GH_TOKEN or
GITHUB_TOKEN before any configuration, label, workspace, or registry mutation,
using the existing ConfigError path so failures exit with code 2; otherwise
remove the token requirement from the CLI specification.

In `@src/workspace/git.ts`:
- Around line 280-282: Update the finally cleanup around the publication flow in
git.ts so an fs.rm failure cannot replace the original publication, push, or
validation error. Catch cleanup failures from fs.rm and report them separately
while preserving propagation of the original error; retain recursive forced
cleanup behavior.
- Around line 246-251: Add coverage in the publication test around the existing
Git command mock in test/workspace.test.ts, making the git grep inspection
return exit code 2 while preserving normal behavior for other commands. Assert
that publication throws the “Could not inspect” error for the target ref and
verify the push command is never invoked, preserving the fail-closed branch in
the Git LFS inspection flow.

In `@test/command.test.ts`:
- Around line 113-116: Add coverage in the gitPublicationEnv tests for the
startup-captured fallback: call gitPublicationEnv with an empty source and a
non-empty initialToken, then assert KAIZEN_GIT_PASSWORD equals that token. Keep
the existing GITHUB_TOKEN source and missing-token cases unchanged.

In `@test/doctor.test.ts`:
- Around line 110-130: Extend the doctor tests with a GITHUB_TOKEN-only case:
after setupProject, clear GH_TOKEN, set a non-empty GITHUB_TOKEN, run
doctorProject with the existing runner configuration, and assert the publication
auth check succeeds. Ensure the assertion verifies the check named “publication
auth” has ok: true, preserving coverage for the either-variable authentication
contract.

In `@test/workspace.test.ts`:
- Around line 129-139: Update the workspace test’s GIT_SSH_COMMAND assertion to
expect the platform-specific value selected by process.platform, matching the
neighboring assertions. In the runner mock setup, return a realistic non-empty
SHA for the rev-parse command, then update the updateRef expectation to use that
SHA instead of an empty string.
- Line 89: Update the assertion on publicationPush arguments to join the
argument array into a single string before checking that it does not contain
“supervisor-token”, ensuring embedded occurrences within URLs or other arguments
are detected.

---

Outside diff comments:
In `@test/workspace.test.ts`:
- Around line 40-60: Extend the workspace GitClient tests around the existing
forceWithLease push case to return a non-empty SHA for the rev-parse --verify
remote-tracking ref, then assert the generated push arguments include that SHA
in --force-with-lease. Keep the existing empty-lease scenario and add a separate
populated-lease case covering an existing remote branch.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: kaizen-agents-org/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 424a5759-6cb0-4e0f-afe1-f3c582f74a11

📥 Commits

Reviewing files that changed from the base of the PR and between 4d057e2 and 3803bf1.

⛔ Files ignored due to path filters (7)
  • dist/commands/doctor.js is excluded by !**/dist/**
  • dist/commands/doctor.js.map is excluded by !**/dist/**, !**/*.map
  • dist/utils/command.d.ts is excluded by !**/dist/**
  • dist/utils/command.js is excluded by !**/dist/**
  • dist/utils/command.js.map is excluded by !**/dist/**, !**/*.map
  • dist/workspace/git.js is excluded by !**/dist/**
  • dist/workspace/git.js.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (9)
  • README.md
  • docs/01-architecture.md
  • docs/02-cli-spec.md
  • src/commands/doctor.ts
  • src/utils/command.ts
  • src/workspace/git.ts
  • test/command.test.ts
  • test/doctor.test.ts
  • test/workspace.test.ts

Comment thread docs/02-cli-spec.md
Comment thread src/workspace/git.ts
Comment thread src/workspace/git.ts
Comment thread test/command.test.ts
Comment thread test/doctor.test.ts
Comment thread test/workspace.test.ts Outdated
Comment thread test/workspace.test.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3803bf169c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/command.ts
Comment thread README.md
@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a12ee4d3a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/command.ts Outdated
Comment thread src/scheduler/scheduler.ts
@s-hiraoku

s-hiraoku commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

PR Guardian final report — pass 3/5

  • Final GitHub state: mergeable — mergeable=MERGEABLE, mergeStateStatus=CLEAN, head c1a04c2; the PR is open, ready for review, and was not merged.
  • Required checks: verify passed on the final head in run 31085160485. CodeRabbit is successful but rate-limited on the final head. Branch protection requires conversation resolution but no approval; all 30 conversations are resolved.
  • Workflow runs watched with gh run watch --exit-status: 31081022893, 31082423340, 31082902756, 31083478476, 31084162814, 31084495345, 31084639815, and 31085160485. All final-head-relevant runs pass; 31084495345 exposed two Linux fleet-fixture failures corrected in a12ee4d.
  • Fixes pushed without force after guarded remote-head checks:
    • ab2dba9 — isolate post-push hooks/auth, require exported supervisor publication auth, validate Windows executable writability, and add doctor/docs coverage.
    • f310ed7 — reject Git LFS pointer publication without a trusted LFS upload.
    • 3803bf1 — use pinned authentication-free Git for every publication validation/bookkeeping operation.
    • 440611b — preflight init auth, preserve publication errors across cleanup failures, and complete fail-closed/fallback regression coverage.
    • 6d7b8a5 — strip supervisor credentials from every configured untrusted child environment and add non-persistent cron token loading.
    • a12ee4d — make fleet cron fixtures explicit and CI-stable.
    • c1a04c2 — filter reserved credentials case-insensitively and require an immutable cron secret helper.
  • Validation: npm test (604 passed, 1 skipped), npm run typecheck, npm run build, npm run check:dist, and final-head required CI all pass.
  • Feedback addressed: 16 actionable findings in this pass were each fixed or dispositioned in-thread with commit and validation evidence, then resolved. The final paginated GraphQL/REST audit exhausted review threads, reviews, review comments, PR comments, check runs, and annotations; unresolved threads and annotations are both zero.
  • Skipped/non-blocking feedback: the final-head CodeRabbit review was rate-limited and reports no new actionable thread; its optional docstring warning is non-required and outside this focused security/publication fix.
  • Remaining GitHub blockers: none. GitHub reports clean mergeability, required checks pass, and required conversations are resolved.
  • Guardian evidence blocker: retry budget 5/5 is exhausted. The fifth Codex review is tied by REST commit_id to a12ee4d; its two P1 findings were fixed in c1a04c2, but no sixth current-head Codex review may be requested. Therefore the skill's current-head automated-review evidence and two-snapshot stabilization gate cannot be completed in this pass, despite GitHub reporting the PR mergeable.

The PR was not merged.

@s-hiraoku

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1a04c291a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/init/init.ts
Comment on lines +45 to +46
if (!process.env.GH_TOKEN && !process.env.GITHUB_TOKEN) {
throw new ConfigError('Set GH_TOKEN or GITHUB_TOKEN in the supervisor environment before initialization.');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pin gh before requiring the supervisor token

When a builder writes a replacement gh into a writable directory earlier in PATH (the documented setup prepends $KAIZEN_HOME/bin), the post-push PR flow reaches GitHubClient.gh at src/github/client.ts:503, resolves the bare command again, and passes this newly mandatory token through githubCliEnv(). The replacement can therefore capture the supervisor credential and fake privileged GitHub operations. Fresh evidence beyond the resolved publication-helper finding is this ordinary post-build GitHubClient path, which never uses a pinned executable; resolve a trusted immutable gh before untrusted work and use it for every privileged GitHub call.

AGENTS.md reference: AGENTS.md:L10-L10

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve Git publication credentials across isolated builder execution

1 participant