Skip to content

fix(notes): pin pack programs with command-line flags on vault git calls - #25581

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/notes-pack-program-24845
Oct 29, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/notes-pack-program-24845

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a Notes vault's own .git/config can no longer pick the program git runs for upload-pack / receive-pack when Notes syncs.

Notes (md_notebook) pins remote.origin.uploadpack and remote.origin.receivepack through GIT_CONFIG_* and expects that to override the vault's config. For these two keys git keeps the FIRST value it reads, and .git/config is read before any -c / GIT_CONFIG_* entry. So a vault-set value wins, and on a local/file remote git executes it during sync.

Why it matters

A vault is an ordinary checkout an agent can write to. A remote.origin.uploadpack=<script> line in its .git/config runs that script with the gateway's privileges, outside any sandbox, the next time the background syncer fetches.

Not a goal

Intended? / Repro

Intended? No. The comment above the pins on main says they restore git's defaults "over anything in .git/config" (src/kiro_crew/apps/builtins/md_notebook/git_ops.py:306-311); git does not honour that order for these keys.

Repro (real git 2.50.1, local bare remote):

  • git config remote.origin.uploadpack <script that touches a marker> in the clone.
  • GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=remote.origin.uploadpack GIT_CONFIG_VALUE_0=git-upload-pack git fetch origin prints error: more than one uploadpack given, using the first and the marker file is created.
  • git fetch --upload-pack=git-upload-pack origin on the same clone: no marker.

The sync path uses exactly that env (run_git → _auth_env) for fetch origin (git_ops.py:1305) and push origin (git_ops.py:1371).

Papyrus (src/kiro_crew/apps/builtins/papyrus/backend/gitops.py:187-221) is not affected: it already passes --upload-pack / --receive-pack on every remote subcommand through _pack_program_args.

What changed (motivation → approach → change)

Symptom: a vault-set pack program runs during sync. Cause: a config pin cannot outrank a first-wins key already set in .git/config. Change: pin it with the command-line flag, which beats every config file for that call.

  • md_notebook/git_ops.py: _pack_program_args adds --upload-pack=git-upload-pack to fetch, pull, ls-remote, clone and --receive-pack=git-receive-pack to push, right after the subcommand. run_git applies it, so every call site is covered at one chokepoint. Same shape as Papyrus.
  • The GIT_CONFIG_* pins stay; their comment says they are not the guarantee.

Security

area: security code: it decides which program git may execute during an unsandboxed background sync. The change only adds argv flags that force git's own default programs; nothing that was refused becomes allowed.

Backwards compatibility

Compatible: a vault with no pack-program config runs the same programs as on main (git-upload-pack / git-receive-pack are git's defaults).

Removes nothing: no config key, field or error path is removed.

Tests

test/test_md_notebook_git_trust.py:

  • test_pack_program_flags_pin_every_remote_subcommand: the flag lands after fetch / push / clone; status and a -c-prefixed merge are unchanged.
  • test_pack_program_flags_beat_a_vault_set_uploadpack_and_receivepack: real git, a cloned vault whose .git/config sets both keys to a marker-writing script; run_git fetch and push leave no marker. On main the fetch creates the marker.

Proof: not provable -- other: this host runs no local tests; CI runs them

Manual verification

The real-git repro above was run on this host against a scratch bare remote. Static gates run locally: black, isort, flake8, scripts/check_file_line_cap.py, scripts/check_comment_history.py. Tests run in CI.

Screenshots

Why no screenshot: backend git argv only; nothing rendered changes.

Related Issues

Fixes #24845

Sibling sweep

Swept: git grep -ln "remote.origin.uploadpack|remote.origin.receivepack|upload-pack=|receive-pack=" -- src/
Sibling: src/kiro_crew/apps/builtins/md_notebook/git_ops.py -- changed here
Sibling: src/kiro_crew/apps/builtins/papyrus/backend/gitops.py -- not affected (already passes the flags via _pack_program_args)
Sibling: src/kiro_crew/cli_server_update.py -- not affected (already passes --upload-pack=git-upload-pack)
Sibling: src/kiro_crew/dashboard/handlers/updates_apply.py -- not affected (already passes --upload-pack=git-upload-pack)
Sibling: src/kiro_crew/platform/update_governance.py -- not affected (refuses repo-set pack programs)
Sibling: src/kiro_crew/apps/builtins/dev_fleet/repository.py -- not affected (mentions the flag only in option-injection comments; sets no pack-program pin)
Sibling: src/kiro_crew/apps/builtins/ops_mission_control/backend/ledger_sync.py -- not affected (option-injection comments only)
Sibling: src/kiro_crew/apps/builtins/design_critique/backend/routes.py -- not affected (option-injection comment only)

Pattern harvest

Rule candidate: for git keys that are first-value-wins (remote.<name>.uploadpack / .receivepack), a -c / GIT_CONFIG_* pin does not override repo config. Pin with the subcommand's own flag instead.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

A vault's own remote.origin.uploadpack/receivepack in .git/config won over the GIT_CONFIG_* pins, because git keeps the first value it reads for those keys. run_git now adds --upload-pack/--receive-pack to fetch, pull, push, ls-remote and clone, matching Papyrus.

Fixes #24845
@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 29, 2026 02:41
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 9d1d6c13360424eb2e251dacead83e1ad2a0437d touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 9d1d6c13360424eb2e251dacead83e1ad2a0437d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The pin goes on as a command-line flag at the single run_git chokepoint, which closes the first-wins override. It matches the shape Papyrus already uses and adds no new surface.

Notes

  • _pack_program_args only checks args[0]. A future run_git(["-c", ..., "fetch", ...]) would skip the pin with no error, because the code returns it unchanged. Today only commit and merge take a -c prefix. A one-line assertion against a -c-prefixed remote subcommand would turn that gap into a failure.

[DESIGN-REVIEWED] 9d1d6c1

Description read

[DESCRIPTION-READ] c6015febd484e51fdc7526d23bdb9cf1cf4f2d67c2a6a843b9f5cb8ea04fac33

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 9d1d6c13360424eb2e251dacead83e1ad2a0437d — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

This fixes the cause: a first-wins key that a config pin can't override. It is fixed with the command-line flag at the single run_git chokepoint. The one note is a copied helper.

Notes

  • Item 1 — duplicate of src/kiro_crew/apps/builtins/papyrus/backend/gitops.py:197-222: _PACK_PROGRAM_FLAGS and _pack_program_args are copied line for line, the same 5 entries and the same body (grepped _pack_program_args|upload-pack=git-upload-pack: 2 definitions). The PR says "Same shape as Papyrus." Two copies of one security pin will drift apart. This is a note, not a block, because the existing copy is private to another app. Subtraction: delete one of the two copies, and have both apps import the remaining one from a shared helper next to kiro_crew.git_config_hooks, which md_notebook/git_ops.py already imports.

What this change ships

Inventory (3 items) — 2 justified

Intent: stop a Notes vault's own .git/config from choosing which program git runs during background sync. This is a FIX (#24845, plus a real-git test that fails on base).

  1. Notes fetch/pull/ls-remote/clone always run git-upload-pack, whatever the vault config says — duplicate of papyrus/backend/gitops.py:_pack_program_args
  2. Notes push always runs git-receive-pack, whatever the vault config says — justified
  3. The comment on the GIT_CONFIG_* pins now says they are not the guarantee — justified

[FIRST-PRINCIPLES-REVIEWED] 9d1d6c1

Description read

[DESCRIPTION-READ] da5812d2c04ec9a16b7ae9249473da1a1116afbbac98976392e00bcc65bc7ab2

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 9d1d6c13360424eb2e251dacead83e1ad2a0437d — this comment is updated in place on each push.

Review details

No findings.

Notes:

  • Before this PR, a fetch or push that recursed into submodules already ran child git processes. Those children read each submodule's own remote.origin.uploadpack/.receivepack and never get the new command-line flags. The diff doesn't change that path, so it isn't counted against this PR. Pinning fetch.recurseSubmodules/push.recurseSubmodules in _GIT_NEUTRALIZERS would be a reasonable follow-up.

[OPUS-REVIEWED] 9d1d6c1

Verdict parsed from the review's SHA-scoped output markers for commit 9d1d6c13360424eb2e251dacead83e1ad2a0437d.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 9d1d6c13360424eb2e251dacead83e1ad2a0437d false-positive: <reason, 20 to 500 characters>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 9d1d6c13360424eb2e251dacead83e1ad2a0437d and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9d1d6c1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 9d1d6c13360424eb2e251dacead83e1ad2a0437d false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 29, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (policy-sensitive) at 9d1d6c1.

The fix looks right. run_git now inserts --upload-pack=git-upload-pack or --receive-pack=git-receive-pack right after each remote subcommand, and those flags outrank the vault's first-wins .git/config values (git_ops.py#L322, #L528). A real-git test proves it, and CI is green. The PR decides which program git runs during an unsandboxed sync, so it stays with a human reviewer.

One point for that reviewer: Opus notes that submodule children of a recursive fetch or push read their own pack-program config. Fetch recursion is already pinned off on every run_git call (git_config_hooks.py#L296). I found no push.recurseSubmodules=no pin for Notes, though, and a vault-set push.recurseSubmodules beats submodule.recurse=false. I have not verified that by running it. Either pin it (the auto_improvement git_safety module already does) or open an issue for it.

AI findings judged non-blocking: First Principles' duplicated helper (identical to Papyrus today) and Design's note that a future -c-prefixed remote call would skip the pin (no current call site does that).

What clears it: a human maintainer review, plus a decision on the push-recursion point.

— crew-pr-reviewer (r135)

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head (or skipped / author override), UX skipped or pass, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 1a561df into main Oct 29, 2026
115 of 138 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/notes-pack-program-24845 branch October 29, 2026 19:54
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
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.

md_notebook / papyrus git ops carry the first-value-wins remote.origin.uploadpack pin

3 participants