Skip to content

Write git notes on Artifacts publish - #509

Merged
kentcdodds merged 7 commits into
mainfrom
cursor/publish-git-notes-c3f3
May 28, 2026
Merged

kentcdodds merged 7 commits into
mainfrom
cursor/publish-git-notes-c3f3

Conversation

@kentcdodds

@kentcdodds kentcdodds commented May 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Writes structured Kody publish metadata as git notes on refs/notes/commits when repo sessions publish, bootstrap source repos, or reconcile external pushes. Adds repo_show_publish_note MCP capability to read those notes.

Review fixes

  • Propagate auth/network/git failures from note fetch/read (tight missing-note detection)
  • Fetch remote refs/notes/commits before addNote, then force: true push
  • Fix GitStat directory mode typo; respect explicit previousPublishedCommit: null
  • Best-effort git note setup after external publish (token + attach wrapped in try/catch)

Validation

  • ✅ Validate
  • 🔎 Preview deploy
  • Cursor Bugbot pass
  • CodeRabbit pass
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Publish operations now create, validate, store, and read structured publish metadata as git notes.
    • Added a repo capability to retrieve and display publish-note details for commits/sources.
    • Publish flows attach scoped publish-note records (bootstrap, session, external push) including provenance and checks.
  • Tests

    • New and expanded unit tests covering note building, parsing, read/write, fetch/error paths, and capability behavior.

Review Change Stack

Attach JSON harness notes to published commits via refs/notes/commits
when repo sessions publish, bootstrap source repos, or reconcile external
pushes. Notes capture publish provenance, session/conversation ids, and
check results without moving metadata out of D1.

Also teach package_get_git_remote setup commands to fetch notes refs so
local clones can read publish context.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds versioned publish git notes: core library to build/write/read notes, an MCP capability to query notes by source/package identity, tests for new behaviors, and integration that attaches notes during bootstrap, session publish, and external publish flows; also updates git-remote setup to fetch notes refs.

Changes

Publish Git Notes Recording and Querying

Layer / File(s) Summary
Publish Git Notes Infrastructure
packages/worker/src/repo/publish-git-notes.ts, packages/worker/src/repo/publish-git-notes.node.test.ts
Defines versioned KodyPublishGitNote schema with provenance and optional checks; implements buildPublishGitNote, writeAndPushPublishGitNote, attachPublishGitNoteBestEffort, ephemeral in-memory git workspace and isomorphic-git fs adapter, parsePublishGitNote, and readPublishGitNoteFromArtifactsRepo. Tests cover build/parse/write/read and error cases.
MCP Capability for Reading Publish Notes
packages/worker/src/mcp/capabilities/repo/repo-show-publish-note.ts, packages/worker/src/mcp/capabilities/repo/repo-show-publish-note.node.test.ts, packages/worker/src/mcp/capabilities/repo/domain.ts, packages/worker/src/mcp/capabilities/repo/index.ts
Adds repo_show_publish_note capability with input/output Zod schemas, caller auth, source resolution/ownership checks, commit selection, and reading notes via readPublishGitNoteFromArtifactsRepo. Includes tests for successful read, explicit commit with missing note, and ownership rejection; wired into repo domain exports.
Publish Notes Integration in Session Flows
packages/worker/src/repo/repo-session-do.ts, packages/worker/src/mcp/capabilities/packages/get-git-remote.ts
Attaches publish git notes at bootstrapSource (source_bootstrap), publishSession (repo_session with derived checks), and publishFromExternalRef (external_push with runId and checks). publishFromExternalRef now acquires a write-capable artifact remote. get-git-remote.ts setup now configures and fetches refs/notes/* alongside branch refs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • kentcdodds/kody#253: Also modifies publishSession flows and workspace/persistence interactions touching the same publish paths.
  • kentcdodds/kody#194: Related bootstrap/publish flow changes that intersect bootstrapSource and publish behavior.
  • kentcdodds/kody#427: Changes to external publish paths that relate to publishFromExternalRef wiring and retries.

Poem

🐰 I stitched a note upon each commit,
A whisper of who made that bit.
With runs and checks and session ties,
The provenance hops into the skies.
Happy patches, tidy wits!

🚥 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
Title check ✅ Passed The title 'Write git notes on Artifacts publish' directly describes the main feature added: writing git notes during artifact/repo publishing workflows.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/publish-git-notes-c3f3

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 and usage tips.

Expose read path for Kody publish harness git notes on Artifacts
commits. Supports source_id or package identity lookup, parses v1 JSON
notes, and returns raw note text plus structured fields.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@cursor
cursor Bot marked this pull request as ready for review May 28, 2026 18:02
@github-actions

github-actions Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-509.kentcdodds.workers.dev

Worker: kody-pr-509
D1: kody-pr-509-db
KV: kody-pr-509-oauth-kv

Mocks:

@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: 1

🤖 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 `@packages/worker/src/repo/publish-git-notes.ts`:
- Around line 493-500: The current catch-all converts any exception into a "note
not found" result (returning found: false), hiding auth/network/git failures;
change the catch to catch the error (e.g., catch (err)) and only return
{found:false, commit: input.commitOid, rawNote: null, note: null} for the
specific case that the note truly does not exist (detectable by a specific error
code/message from the git library or by checking the absence of the note
response), but rethrow or propagate all other errors (auth/token/network/git) so
callers can observe operational failures; locate the try/catch around the
read/fetch call that uses input.commitOid and adjust to inspect the thrown error
before deciding to return versus throw.
🪄 Autofix (Beta)

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e991387-1702-4300-9847-e5f71164e104

📥 Commits

Reviewing files that changed from the base of the PR and between ded96cf and b2099c2.

📒 Files selected for processing (8)
  • packages/worker/src/mcp/capabilities/packages/get-git-remote.ts
  • packages/worker/src/mcp/capabilities/repo/domain.ts
  • packages/worker/src/mcp/capabilities/repo/index.ts
  • packages/worker/src/mcp/capabilities/repo/repo-show-publish-note.node.test.ts
  • packages/worker/src/mcp/capabilities/repo/repo-show-publish-note.ts
  • packages/worker/src/repo/publish-git-notes.node.test.ts
  • packages/worker/src/repo/publish-git-notes.ts
  • packages/worker/src/repo/repo-session-do.ts

Comment thread packages/worker/src/repo/publish-git-notes.ts Outdated
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Comment thread packages/worker/src/repo/publish-git-notes.ts Outdated
Only treat missing notes ref / note as found:false. Propagate auth,
network, and other git failures to callers instead of hiding them as
false negatives.

Also fix GitStat directory fallback mode typo (16_384 / 0o40000).

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

Comment thread packages/worker/src/repo/publish-git-notes.ts
Comment thread packages/worker/src/repo/repo-session-do.ts Outdated
Subsequent publishes were silently failing when the local workspace
lacked the remote notes history. Fetch refs/notes/commits best-effort,
then push with force so note writes succeed after the first publish.

Also defer source write token creation until external publish succeeds.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Comment thread packages/worker/src/repo/publish-git-notes.ts
Comment thread packages/worker/src/repo/publish-git-notes.ts Outdated
Only treat NotFoundError or notes-ref-specific messages as missing-note
cases so errors like Repository not found propagate. Preserve explicit
previousPublishedCommit: null for bootstrap notes.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1ef923c. Configure here.

Comment thread packages/worker/src/repo/repo-session-do.ts
Wrap write-token creation and note attachment in try/catch so a token
failure after finalizePublishedEntitySource does not fail the publish
response.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

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.

2 participants