Skip to content

chore: back-merge main hotfixes into dev (option 2 — accept dev for conflicts) - #1703

Closed
namastex888 wants to merge 2 commits into
devfrom
chore/back-merge-main-hotfixes
Closed

namastex888 wants to merge 2 commits into
devfrom
chore/back-merge-main-hotfixes

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Why

Main and dev diverged from common ancestor `ca0a1d8100`:

  • main has 11 commits ahead (6 PRs by @felipehowit, all legitimate)
  • dev has 481 commits ahead (active integration)

Six main-only PRs never reached dev:

PR What
#1689 fix(agent): subagent team inheritance + builtin pinning + parent fallback
#1690 fix(agent): retire `--name` + distinguish `auto_resume_disabled`
#1690 (follow-up) fix(ci): extract npm pack tarball name
#1693 fix: address CI failures + CodeRabbit major
#1698 fix(tl-spawn): write `executors.claude_session_id` at team-lead spawn
#1699 feat(cli): `genie recover-orphans`

Strategy

Standard `git merge --no-ff` with `-X ours`:

  • Conflicts → resolved to dev's version (dev evolved past these files; main's edits are obsolete where dev moved on).
  • New files from main → kept (genuinely new content has no conflict).
  • Main's non-conflicting edits to evolved files → applied (they came in cleanly because dev didn't touch the same hunks).

This matches user intent: "accept dev for everything except genuinely new content from those 6 PRs."

What lands

20 files / +1479 / −73 — mostly the new content, plus modest edits to wire it in:

New files (725 LOC of genuinely new content):

Modified files (main edits wiring in the new functionality):

  • `src/genie.ts` — register `recover-orphans` command + import
  • `src/genie-commands/session.ts` — write `claude_session_id` at team-lead spawn (fix(tl-spawn): write executors.claude_session_id at team-lead spawn (closes orphan-JSONL leak) #1698)
  • `src/lib/agent-directory.ts`, `src/lib/builtin-agents.ts`, `src/lib/executor-registry.ts`, `src/lib/protocol-router.ts`, `src/lib/provider-adapters.ts`, `src/lib/team-lead-command.ts`, `src/term-commands/agents.ts`, `src/db/migrations/044_phase_b_flip_defaults.test.ts`, `.github/workflows/release.yml`
  • `src/lib/team-lead-command.test.ts`

Notes

One follow-up commit (`fix(merge): restore recoverOrphansCommand import`) was needed: the `-X ours` resolution of the imports block in `genie.ts` kept dev's version, which dropped main's import line — but the command registration line survived, breaking the build (`TS2304: Cannot find name recoverOrphansCommand`). Re-added the import + biome organize-imports.

Test plan

  • `bun test src/term-commands/done.test.ts` — 14 pass (verifies the recently-merged --report mandatory feature still works after the back-merge)
  • `bun run build` — clean
  • `bun dist/genie.js --help` — both `done` (with `--report`) and `recover-orphans` registered
  • `bun test` (full DB-integration suite) — needs pgserve booted; deferred to CI runner
  • Reviewer: confirm `recover-orphans`, migrations 054 + 055, and team-lead session-id writer all work end-to-end on dev

What this is NOT

This is not a wholesale main → dev merge. With plain `git merge`, dev would resurrect 7 stale files and lose conflicts in 219 modified files to main's older versions. `-X ours` prevents that.

Brings 6 main-only PRs (#1689, #1690, #1693, #1698, #1699) into dev.

Strategy: -X ours — for files modified on both branches, keep dev's
version (dev is 481 commits past the merge-base ca0a1d8 and
those evolved files supersede main's older edits). New files from
main come in cleanly.

Files from main expected to land:
- src/genie-commands/recover-orphans.ts (new, from #1699)
- src/genie-commands/__tests__/recover-orphans.test.ts (new)
- src/db/migrations/054_fix_subagent_team_inheritance.sql (new, from #1689)
- src/db/migrations/055_default_auto_resume_true.sql (new, from #1690)
- src/__tests__/agent-team-inheritance.test.ts (new, from #1689)
- src/lib/protocol-router.test.ts (new, from #1689/#1690)
- src/lib/provider-adapters.test.ts (new, from #1690)
…d it

The -X ours strategy resolved the imports-block conflict in genie.ts
to dev's version, which dropped main's import line for
recoverOrphansCommand (added by PR #1699). The command registration
at line 213 survived intact, so the build broke with TS2304 'Cannot
find name recoverOrphansCommand'. Restoring the import + its
RecoverOrphansOptions type, biome organize-imports applied.
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 04b64571-6a6b-4fe3-8ece-c888c6ecaa7a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/back-merge-main-hotfixes

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.

@namastex888

Copy link
Copy Markdown
Contributor Author

Superseded — dev now has 58228e35d chore(merge): main into dev — sync hotfixes #1698 + #1699 forward. The hotfixes are already on dev via @felipehowit's direct merge. My branch's remaining diff is just version-bump deltas (dev advanced to 4.260507.7) and small file-resolution differences. Closing.

@namastex888 namastex888 closed this May 8, 2026
@namastex888
namastex888 deleted the chore/back-merge-main-hotfixes branch May 8, 2026 00:07

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

ℹ️ 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 on lines +34 to +35
WHERE child.id LIKE parent.id || '/%'
AND parent.id NOT LIKE '%/%'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P0 Badge Rewrite migration to target name instead of UUID id

This migration assumes agent_templates.id is a text name (child.id LIKE parent.id || '/%' and the built-in DELETE ... WHERE id IN (...)), but this repo already has migration 061 that retypes agent_templates.id to UUID and introduces name as the human key. On any environment that already applied 061, this pending migration will fail during runMigrations with UUID/text operator or cast errors, blocking subsequent migrations and startup; the backfill/delete logic needs to use name (or explicit safe casts) instead of id.

Useful? React with 👍 / 👎.

Comment on lines +1065 to +1066
if (!isBuiltinAgent(templateId)) {
// Hierarchical names (`parent/child`) inherit the parent's team. Without

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 Keep built-in templates persisted for auto-respawn

Skipping saveTemplate for built-ins removes the only spawn template source that ensureWorkerAlive/findSpawnTemplate uses when a worker is dead or suspended, so built-in agents can no longer be auto-respawned after pane loss and message delivery falls through to failure. This is especially impactful here because the same commit's migration deletes existing built-in template rows, making the regression immediate on upgraded installs unless there is an alternate template source.

Useful? React with 👍 / 👎.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a series of improvements to agent session management and team inheritance, most notably a new recover-orphans command for re-linking orphaned session files and a migration to enable auto_resume by default. It also addresses issues where built-in agents could inherit incorrect team pins and retires the --name flag to ensure reliable session resumption. Review feedback highlighted a recurring date typo in documentation comments and recommended renaming a misleading variable in the orphan recovery implementation.

test('fresh DB: agents.auto_resume column default is false after migration 044', async () => {
test('fresh DB: agents.auto_resume column default is true after migration 055', async () => {
// Migration 055 (PR #1693) flipped the column default from `false` to `true`.
// Felipe directive 2026-05-07: default-off was a bug shape — 52/53 agents

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.

medium

The date 2026-05-07 appears to be a typo as it is in the future. It should likely be 2024-05-07. This typo is present in several other files in this PR as well (e.g., 055_default_auto_resume_true.sql, agent-directory.ts, executor-registry.ts, provider-adapters.ts, etc.). It would be good to correct it everywhere for consistency and to avoid confusion.

    // Felipe directive 2024-05-07: default-off was a bug shape — 52/53 agents

Comment on lines +94 to +95
const fd = readFileSync(jsonlPath, { encoding: 'utf-8', flag: 'r' });
head = fd.slice(0, 16384);

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.

medium

The variable name fd is a bit misleading here. Typically, fd stands for 'file descriptor', which is an integer. However, in this context, it holds the entire file content as a string. Renaming it to something like fileContent or content would improve clarity and maintainability.

    const fileContent = readFileSync(jsonlPath, { encoding: 'utf-8', flag: 'r' });
    head = fileContent.slice(0, 16384);

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