Skip to content

Make workspace sync non-destructive#1864

Merged
Wirasm merged 4 commits into
devfrom
archon/task-bench-1516-codex
Jun 8, 2026
Merged

Make workspace sync non-destructive#1864
Wirasm merged 4 commits into
devfrom
archon/task-bench-1516-codex

Conversation

@Wirasm

@Wirasm Wirasm commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Describe this PR in 2-5 bullets:

  • Problem: chat workflow discovery was hard-resetting managed source/ clones to origin/<default_branch> on ordinary messages, which could discard tracked edits or orphan local branch tips.
  • Why it matters: managed clones are writable by users and agents, so destructive sync during chat can cause data loss without an explicit reset action.
  • What changed: syncWorkspace is now mode-based and non-destructive by default, chat sync uses safe branch-aware sync, worktree creation explicitly opts into reset where a clean managed base is required, and codebase branch persistence now stores nullable detected default branches.
  • What did not change (scope boundary): this does not remove explicit reset behavior from worktree creation, does not alter unrelated AI message handling, and does not change external GitHub or provider APIs.

UX Journey

Before

User                   Archon orchestrator        packages/git              Managed source clone
----                   -------------------        ------------              --------------------
sends message -------> loads conversation
                       discovers workflows -----> syncWorkspace
                                                  fetch origin
                                                  reset --hard origin/<branch> -------------> tracked local state discarded
                       loads workflows/config
sees reply <--------- continues chat

After

User                   Archon orchestrator        packages/git              Managed source clone
----                   -------------------        ------------              --------------------
sends message -------> loads conversation
                       discovers workflows -----> [syncWorkspace fast-forward mode]
                                                  fetch origin
                                                  classify dirty/ahead/behind/diverged
                                                  [ff-only only when safe] -----------------> local tracked work preserved
                       loads workflows/config
sees reply <--------- continues chat

Architecture Diagram

Before

core/orchestrator-agent
  | discovers workflows and syncs codebase
  v
git/syncWorkspace
  | default/resetAfterFetch behavior
  v
git reset --hard origin/<branch>

isolation/worktree provider
  | creates worktrees from source
  v
git/syncWorkspace

core/clone handler
  | registers codebase
  v
core/db/codebases

After

[~] core/orchestrator-agent
  === safe chat sync with stored branch ===>
[~] git/syncWorkspace
  === fetch + classify + ff-only when safe ===>
managed source clone

[~] isolation/worktree provider
  === explicit reset mode for managed worktree bases ===>
[~] git/syncWorkspace

[~] core/clone handler
  === detected default_branch ===>
[~] core/db/codebases
  === nullable default_branch schema ===>
[+] migrations/023_add_default_branch_to_codebases.sql

Connection inventory (list every module-to-module edge, mark changes):

From To Status Notes
packages/core/src/orchestrator/orchestrator-agent.ts packages/git/src/repo.ts modified Chat workflow discovery now relies on default non-destructive sync and passes stored branch context.
packages/git/src/repo.ts Git CLI modified Fetch still runs, but hard reset only runs in explicit reset mode; default mode classifies state and fast-forwards only when safe.
packages/isolation/src/providers/worktree.ts packages/git/src/repo.ts modified Managed worktree creation explicitly requests reset mode; non-managed repositories use safe sync.
packages/core/src/handlers/clone.ts packages/core/src/db/codebases.ts modified Clone registration persists detected nullable default branch.
packages/core/src/db/codebases.ts database schema/migrations modified Codebase records include nullable default_branch.
packages/core/src/schemas/codebase.ts API schema consumers modified Codebase schema exposes nullable default_branch.

Label Snapshot

  • Risk: risk: medium
  • Size: size: M
  • Scope: core|isolation|git|server|tests
  • Module: core:orchestrator, git:sync, isolation:worktree, core:codebases

Change Metadata

  • Change type: bug
  • Primary scope: multi

Linked Issue

Validation Evidence (required)

Commands and result summary:

bun install
bun run check:bundled-schema
bun run type-check
bun run lint
bun run format:check
bun test packages/git/src/git.test.ts
bun test packages/core/src/orchestrator/orchestrator-agent.test.ts
bun test packages/isolation/src/providers/worktree.test.ts
bun run test
bun run build
  • Evidence provided (test/log/trace/screenshot): artifact validation reports bun run type-check, bun run lint, bun run format:check, full bun run test with 4,376 passed, 0 failed, 1 skipped, and successful build. Targeted tests passed with 148 git tests, 123 orchestrator-agent tests, and 142 worktree provider tests.
  • If any command is intentionally skipped, explain why: None.

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • New external network calls? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • File system access scope changed? (Yes/No): No
  • If any Yes, describe risk and mitigation: No security-impacting capability changes were introduced.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Database migration needed? (Yes/No): Yes
  • If yes, exact upgrade steps: apply migrations/023_add_default_branch_to_codebases.sql; SQLite bundled schema and adapter migration behavior were updated so remote_agent_codebases.default_branch is nullable.

Human Verification (required)

What was personally validated beyond CI:

  • Verified scenarios: safe default sync behavior, explicit managed worktree reset mode, chat workflow discovery call site, branch persistence on clone/register paths, schema bundling, and stale /register-project test expectation.
  • Edge cases checked: dirty tracked work, ahead branches, behind branches, diverged branches, non-default branch sync, managed clone worktree reset behavior, and nullable default_branch.
  • What was not verified: manual end-to-end browser interaction with a live chat session was not separately performed; validation relied on targeted and full automated test suites plus build.

Side Effects / Blast Radius (required)

  • Affected subsystems/workflows: Git workspace sync, orchestrator workflow discovery, codebase registration/storage, managed clone worktree creation, bundled schema/migrations, and related test coverage.
  • Potential unintended effects: repositories that previously reset on chat messages may now remain dirty/ahead/diverged and avoid automatic correction; worktree creation still has explicit reset behavior for managed clones.
  • Guardrails/monitoring for early detection: sync state result typing, regression tests for mode selection and state classification, full test suite, lint, type check, format check, and build validation.

Rollback Plan (required)

  • Fast rollback command/path: revert the PR commit(s) and re-apply previous migration/schema state if needed.
  • Feature flags or config toggles (if any): None.
  • Observable failure symptoms: workflow discovery fails to refresh codebase refs, managed worktree creation uses an unexpected base, or codebase records fail to load due to schema mismatch.

Risks and Mitigations

List real risks in this PR (or write None).

  • Risk: changing default sync from reset to fast-forward may leave some managed clones out of sync when they are dirty, ahead, or diverged.
    • Mitigation: sync state classification reports the condition and hard reset remains available only in explicit reset mode for worktree creation.
  • Risk: nullable default_branch schema changes may expose drift between Postgres and SQLite behavior.
    • Mitigation: migrations, bundled schema, adapter behavior, schema checks, and codebase database tests were updated together.

Closes #1273 (same data-loss class — destructive sync now fast-forward-only and respects the configured default_branch).

Summary by CodeRabbit

  • New Features

    • Automatic detection and storage of repository default branches during project registration
    • Enhanced workspace synchronization with explicit modes (fast-forward, fetch-only, reset) and detailed state reporting (in_sync, behind, ahead, diverged, dirty)
    • Non-destructive workspace sync by default
  • Documentation

    • Updated architecture and database schema documentation to reflect branch tracking capabilities

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 931ac407-a6a1-4a01-8b15-1c845aa8773a

📥 Commits

Reviewing files that changed from the base of the PR and between 282e9ff and c4af65e.

📒 Files selected for processing (24)
  • CLAUDE.md
  • migrations/000_combined.sql
  • migrations/023_add_default_branch_to_codebases.sql
  • packages/core/src/db/adapters/sqlite.test.ts
  • packages/core/src/db/adapters/sqlite.ts
  • packages/core/src/db/bundled-schema.generated.ts
  • packages/core/src/db/codebases.test.ts
  • packages/core/src/db/codebases.ts
  • packages/core/src/handlers/clone.test.ts
  • packages/core/src/handlers/clone.ts
  • packages/core/src/orchestrator/orchestrator-agent.test.ts
  • packages/core/src/orchestrator/orchestrator-agent.ts
  • packages/core/src/orchestrator/orchestrator.test.ts
  • packages/core/src/schemas/codebase.ts
  • packages/core/src/schemas/index.test.ts
  • packages/core/src/utils/path-validation.test.ts
  • packages/docs-web/src/content/docs/reference/architecture.md
  • packages/docs-web/src/content/docs/reference/database.md
  • packages/git/src/git.test.ts
  • packages/git/src/index.ts
  • packages/git/src/repo.ts
  • packages/git/src/types.ts
  • packages/isolation/src/providers/worktree.test.ts
  • packages/isolation/src/providers/worktree.ts

📝 Walkthrough

Walkthrough

This PR implements default branch detection and non-destructive workspace synchronization to prevent silent destruction of local work in managed clones. It adds a default_branch column to track the actual branch a codebase syncs to, detects and stores the current branch during registration, refactors syncWorkspace() from a boolean reset flag to a mode-based system with comprehensive state classification, and integrates this into orchestrator workflows.

Changes

Default Branch Tracking and Non-Destructive Sync

Layer / File(s) Summary
Schema and database layer for default_branch column
migrations/000_combined.sql, migrations/023_add_default_branch_to_codebases.sql, packages/core/src/db/adapters/sqlite.ts, packages/core/src/db/adapters/sqlite.test.ts, packages/core/src/db/bundled-schema.generated.ts, packages/core/src/schemas/codebase.ts, packages/core/src/db/codebases.ts, packages/core/src/db/codebases.test.ts, packages/core/src/schemas/index.test.ts
Add nullable default_branch column to remote_agent_codebases in fresh-install and migration paths with idempotent backfill; update Zod schema and extend createCodebase/updateCodebase to persist and retrieve the field.
Git workspace sync refactoring—mode-based dispatch and state classification
packages/git/src/types.ts, packages/git/src/index.ts, packages/git/src/repo.ts, packages/git/src/git.test.ts
Introduce WorkspaceSyncMode (fast-forward, fetch-only, reset) and WorkspaceSyncState (in_sync, behind, ahead, diverged, dirty); refactor syncWorkspace() to default to non-destructive fast-forward, classify workspace state, and only hard-reset when explicitly requested; add internal helpers for SHA reading, tracked file detection, and ancestry checking with error-tolerant logging.
Repository registration with git branch detection
packages/core/src/handlers/clone.ts, packages/core/src/handlers/clone.test.ts
Detect current git branch during clone/registration via git rev-parse --abbrev-ref HEAD; store in default_branch; conditionally update existing codebases with detected branch; return branch info in RegisterResult with fallback to null for detached HEAD.
Orchestrator integration—non-destructive sync during workflow discovery and project registration
packages/core/src/orchestrator/orchestrator-agent.ts, packages/core/src/orchestrator/orchestrator-agent.test.ts, packages/core/src/orchestrator/orchestrator.test.ts
Pass codebase.default_branch to syncWorkspace() during workflow discovery for non-destructive mode selection; enhance sync status events to report failures, divergence requiring manual merge, and fast-forward success with head SHAs; detect and store branch during /register-project before codebase creation.
Worktree provider—mode-based sync for isolation
packages/isolation/src/providers/worktree.ts, packages/isolation/src/providers/worktree.test.ts
Update syncWorkspaceBeforeCreate() to use mode-based control: reset for Archon-managed clones, fast-forward for user clones, replacing boolean resetAfterFetch.
Documentation and environment setup
CLAUDE.md, packages/docs-web/src/content/docs/reference/architecture.md, packages/docs-web/src/content/docs/reference/database.md, packages/core/src/utils/path-validation.test.ts
Update workspace sync guidance to describe non-destructive behavior and reset semantics; expand architecture and database docs to include default_branch schema; add HOME environment variable management to path validation tests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A branch once lost is lost for good,
But now we track what branch we should!
With modes of sync both safe and true,
We fetch and fast-forward, not break through.
No more resets in the dead of night—
Your local work will stay just right! 🌿

✨ 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 archon/task-bench-1516-codex

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.

Wirasm commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator Author

🔍 Comprehensive PR Review

PR: #1864
Reviewed by: 5 specialized agents
Date: 2026-06-04T14:48:31+03:00


Summary

PR #1864 makes the important data-loss fix: normal chat-time workspace sync is now non-destructive, while hard reset remains explicit for managed worktree creation. The implementation is directionally sound and has strong regression coverage for the destructive Git behavior, but several merge-blocking risks remain around upgrade safety, Git error classification, missing tests, and stale docs/schema references. The highest-priority issue is the missing SQLite additive migration for remote_agent_codebases.default_branch, which can break upgraded default installs at runtime. The branch-persistence behavior also needs tighter handling and direct tests so local repo registration does not sync against stale branch metadata.

Verdict: REQUEST_CHANGES

Severity Count
🔴 CRITICAL 0
🟠 HIGH 5
🟡 MEDIUM 5
🟢 LOW 1

🔴 Critical Issues (Auto-fixing)

No critical issues were reported.


🟠 High Issues (Auto-fixing)

Existing SQLite Databases Never Receive default_branch

📍 packages/core/src/db/adapters/sqlite.ts:164

The SQLite adapter adds default_branch only in the CREATE TABLE IF NOT EXISTS remote_agent_codebases statement. Existing SQLite databases skip that path, and migrateColumns() does not add the new column. Since createCodebase() now inserts into default_branch, upgraded default SQLite installs can fail with no column named default_branch.

View fix
try {
  const codebaseCols = this.db.prepare("PRAGMA table_info('remote_agent_codebases')").all() as {
    name: string;
  }[];
  const codebaseColNames = new Set(codebaseCols.map(c => c.name));
  if (!codebaseColNames.has('default_branch')) {
    this.db.run('ALTER TABLE remote_agent_codebases ADD COLUMN default_branch TEXT');
  }
} catch (e: unknown) {
  getLog().warn({ err: e as Error }, 'db.sqlite_migration_codebases_columns_failed');
}

merge-base Failures Are Treated As Normal Non-Ancestor Results

📍 packages/git/src/repo.ts:255

isAncestor() catches every error from git merge-base --is-ancestor and returns false. Exit code 1 is expected for "not an ancestor", but permission errors, corrupt refs, missing objects, and command failures should be surfaced instead of becoming normal sync state.

View fix
async function isAncestor(
  workspacePath: RepoPath,
  ancestor: string,
  descendant: string
): Promise<boolean> {
  try {
    await execFileAsync(
      'git',
      ['-C', workspacePath, 'merge-base', '--is-ancestor', ancestor, descendant],
      { timeout: 10000 }
    );
    return true;
  } catch (error) {
    const err = error as Error & { code?: number | string; exitCode?: number; stderr?: string };
    const exitCode = err.exitCode ?? err.code;
    if (exitCode === 1 || exitCode === '1') {
      return false;
    }
    getLog().error(
      { err, workspacePath, ancestor, descendant, stderr: err.stderr },
      'workspace.merge_base_check_failed'
    );
    throw new Error(`Failed to compare git ancestry in ${workspacePath}: ${err.message}`);
  }
}

Clone/Register Default Branch Persistence Is Not Directly Tested

📍 packages/core/src/handlers/clone.ts:135 / packages/core/src/handlers/clone.test.ts

clone.ts now detects and persists the current branch for new codebases, but clone/register tests do not directly assert this behavior. Tests should distinguish rev-parse --abbrev-ref HEAD from rev-parse --git-dir and cover detached-HEAD fallback.

View suggested test
test('registerRepository persists detected current branch on new codebase', async () => {
  spyExecFileAsync.mockImplementation((_cmd: string, args: string[]) => {
    if (args.includes('--git-dir')) return Promise.resolve({ stdout: '.git\n', stderr: '' });
    if (args.includes('--abbrev-ref')) return Promise.resolve({ stdout: 'develop\n', stderr: '' });
    if (args.includes('get-url')) {
      return Promise.resolve({ stdout: 'https://github.com/owner/repo\n', stderr: '' });
    }
    return Promise.resolve({ stdout: '', stderr: '' });
  });

  await registerRepository('/home/user/repo');

  expect(mockCreateCodebase).toHaveBeenCalledWith(
    expect.objectContaining({ default_branch: 'develop' })
  );
});

Database Reference Omits Codebase default_branch

📍 packages/docs-web/src/content/docs/reference/database.md

The database reference still describes remote_agent_codebases without nullable default_branch, and the migration list stops at 022_workflow_node_sessions.sql.

View docs update
1. **`remote_agent_codebases`** - Repository metadata
   - Commands stored as JSONB: `{command_name: {path, description}}`
   - AI assistant type per codebase
   - Default working directory
   - Nullable detected default branch, used as branch context for workspace sync when available

| `023_add_default_branch_to_codebases.sql` | Detected default branch on codebases |

Architecture Database Schema Is Stale

📍 packages/docs-web/src/content/docs/reference/architecture.md

The architecture guide still says the database has 10 tables and the remote_agent_codebases schema block omits default_branch.

View docs update
│    SQLite (default) / PostgreSQL (16 Tables) │

remote_agent_codebases
├── id (UUID)
├── name (VARCHAR)
├── repository_url (VARCHAR)
├── default_cwd (VARCHAR)
├── default_branch (VARCHAR, nullable) -- detected branch used as sync context when available
├── ai_assistant_type (VARCHAR) -- registered provider identifier (e.g. 'claude', 'codex')
└── commands (JSONB) -- {command_name: {path, description}}

🟡 Medium Issues (Needs Decision)

Re-registering an Existing Codebase Keeps Stale Branch Metadata

📍 packages/core/src/handlers/clone.ts:168

registerRepoAtPath() detects the current branch before deduping by codebase name, but the existing-codebase path only updates default_cwd and repository_url. Re-registering a local checkout can leave an old default_branch attached to the new path.

Options: Fix now | Create issue | Skip

View details
Option Approach Effort Risk if Skipped
Fix Now Extend updateCodebase() to accept default_branch and update it when default_cwd changes or the existing branch is missing. LOW Chat sync can target stale branch metadata.
Create Issue Defer stale-branch metadata handling to a separate PR. LOW Users replacing managed clones with local checkouts may see sync failures or wrong-branch state.
Skip Accept existing branch metadata as authoritative. NONE Branch persistence can become inconsistent with the registered path.

Recommendation: Fix Now.


Short-SHA Read Failures Are Silently Converted To Empty Strings

📍 packages/git/src/repo.ts:207

readShortSha() catches all git rev-parse --short=8 failures and returns '' without logging. This can suppress sync update telemetry and hide invalid refs or repository access failures.

Options: Fix now | Create issue | Skip

View details
Option Approach Effort Risk if Skipped
Fix Now Log a warning with workspacePath and ref, then return ''. LOW Repository mutations may become less visible and harder to debug.
Create Issue Track telemetry hardening separately. LOW Silent telemetry failure remains in the sync path.
Skip Keep SHA reads best-effort and silent. NONE Future sync debugging loses useful failure context.

Recommendation: Fix Now.


Orchestrator Registration Branch Detection Is Only Tested As Null

📍 packages/core/src/orchestrator/orchestrator-agent.ts:1716 / packages/core/src/orchestrator/orchestrator-agent.test.ts

The /register-project flow now detects the current branch before creating a codebase, but tests only cover the null branch path.

Options: Fix now | Create issue | Skip

View details
Option Approach Effort Risk if Skipped
Fix Now Add one /register-project test where the Git mock returns develop. LOW Chat registration can regress to always storing null.
Create Issue Add command-path branch coverage later. LOW Branch-aware sync remains less protected for chat registration.
Skip Rely on clone-handler tests only. NONE A distinct registration path remains under-tested.

Recommendation: Fix Now.


Sync Result SHA Comments Still Say Reset

📍 packages/git/src/types.ts:51

WorkspaceSyncResult.previousHead and newHead comments still say they are before and after "the reset", but sync is now mode-based and usually non-destructive.

Options: Fix now | Create issue | Skip

View details
Option Approach Effort Risk if Skipped
Fix Now Replace "reset" with "sync operation". LOW Future callers may misread non-reset sync results.
Create Issue Defer comment cleanup. LOW Comment rot remains near the public return type.
Skip Leave comments as-is. NONE Type documentation contradicts behavior introduced by this PR.

Recommendation: Fix Now.


CLAUDE.md Sync Guidance Needs New Mode Semantics

📍 CLAUDE.md

Contributor guidance says workspaces automatically sync with origin before worktree creation, but it does not explain that default sync is non-destructive or that hard reset must be explicitly requested by callers that own the checkout.

Options: Fix now | Create issue | Skip

View details
Option Approach Effort Risk if Skipped
Fix Now Add short bullets describing default non-destructive sync and explicit mode: 'reset'. LOW Future contributors may reintroduce destructive sync assumptions.
Create Issue Defer contributor-doc update. LOW Guidance remains stale after a data-loss fix.
Skip Rely on inline code comments. NONE Project-level guidance does not capture the new safety rule.

Recommendation: Fix Now.


🟢 Low Issues

View 1 low-priority suggestion
Issue Location Suggestion
Codebase table comment omits default branch metadata migrations/000_combined.sql:44 Add "default branch" to the remote_agent_codebases table comment and refresh generated bundled schema if needed.

✅ What's Good

  • The PR addresses the main destructive behavior: chat workflow discovery no longer passes reset mode, while managed worktree creation still opts into reset explicitly.
  • syncWorkspace now returns mode and state, making callers and tests more precise than the previous reset boolean.
  • Regression tests cover dirty, behind, ahead, diverged, non-target branch, managed reset, and stored branch call-site behavior.
  • The orchestrator logs sync failures with codebase context and surfaces a structured "Sync failed - using local state" event where supported.
  • Inline comments in packages/git/src/repo.ts and packages/isolation/src/providers/worktree.ts clearly describe fast-forward, fetch-only, and reset modes.

📋 Suggested Follow-up Issues

Issue Title Priority Related Finding
"Keep codebase default_branch in sync when re-registering local paths" P1 MEDIUM issue #1
"Add observability for short SHA telemetry failures during workspace sync" P2 MEDIUM issue #2
"Document non-destructive workspace sync mode semantics in contributor guidance" P2 MEDIUM issue #5
"Refresh codebase metadata comments after default_branch schema change" P3 LOW issue #1

Next Steps

  1. ⚡ Auto-fix step will address CRITICAL + HIGH issues
  2. 📝 Review MEDIUM issues above
  3. 🎯 Merge when ready

Reviewed by Archon comprehensive-pr-review workflow
Artifacts: /Users/rasmus/.archon/workspaces/coleam00/Archon/artifacts/runs/414edc17b9979f10d79af28a4b193c43/review/

@Wirasm

Wirasm commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator Author

⚡ Self-Fix Report (Aggressive)

Status: COMPLETE
Pushed: ✅ Changes pushed to archon/task-bench-1516-codex
Commit: dc3de26bcb122ea58dfb8ba73321eaa4e282d5ac
Philosophy: Fix everything unless clearly a new concern


Fixes Applied (11 total)

Severity Count
🔴 CRITICAL 0
🟠 HIGH 5
🟡 MEDIUM 5
🟢 LOW 1
View all fixes
  • Existing SQLite databases never receive default_branch (packages/core/src/db/adapters/sqlite.ts) — Added additive SQLite migration and regression coverage.
  • merge-base failures are treated as normal non-ancestor results (packages/git/src/repo.ts) — Only exit code 1 is treated as expected non-ancestor; unexpected failures log and throw.
  • Clone/register default branch persistence is not directly tested (packages/core/src/handlers/clone.test.ts) — Added branch detection, detached HEAD, and existing-codebase branch update coverage.
  • Database reference omits codebase default_branch (packages/docs-web/src/content/docs/reference/database.md) — Documented field and migration 023.
  • Architecture database schema is stale (packages/docs-web/src/content/docs/reference/architecture.md) — Updated table count and codebase schema block.
  • Re-registering an existing codebase keeps stale branch metadata (packages/core/src/handlers/clone.ts) — Persist detected branch when replacing managed paths or filling missing branch metadata.
  • Short-SHA read failures are silently converted to empty strings (packages/git/src/repo.ts) — Added warning logs with workspace/ref context.
  • Orchestrator registration branch detection is only tested as null (packages/core/src/orchestrator/orchestrator.test.ts) — Added /register-project detected branch coverage.
  • Sync result SHA comments still say reset (packages/git/src/types.ts) — Updated comments to sync-operation wording.
  • CLAUDE.md sync guidance needs new mode semantics (CLAUDE.md) — Documented non-destructive default sync and explicit reset semantics.
  • Codebase table comment omits default branch metadata (migrations/000_combined.sql) — Updated SQL comment and regenerated bundled schema.

Tests Added

  • packages/core/src/handlers/clone.test.ts — branch persistence, detached HEAD, branch updates for existing codebases.
  • packages/core/src/orchestrator/orchestrator.test.ts/register-project branch detection.
  • packages/git/src/git.test.ts — short SHA logging and merge-base error classification.
  • packages/core/src/db/adapters/sqlite.test.ts / packages/core/src/db/codebases.test.ts — default_branch migration/update coverage.

Skipped (0)

(none — all findings addressed)


Suggested Follow-up Issues

(none)


Validation

✅ Type check (bun run type-check) | ✅ Lint (bun run lint) | ✅ Tests (bun run test, 4382 passed)


Self-fix by Archon · aggressive mode · fixes pushed to archon/task-bench-1516-codex

Wirasm added 4 commits June 8, 2026 19:09
Chat sync for managed source clones could hard-reset to origin on ordinary messages, discarding tracked local edits or branch tips. Make sync non-destructive by default and keep destructive reset explicit for worktree creation.

Changes:
- Added mode-based workspace sync with local/remote state classification
- Updated chat sync to use safe fast-forward behavior and clearer sync events
- Kept managed worktree creation on explicit reset mode
- Persisted detected codebase default branches
- Added regression coverage for dirty, ahead, diverged, and fast-forward cases

Fixes #1516
Fixed:
- Add SQLite default_branch migration for existing databases
- Keep codebase branch metadata in sync when re-registering paths
- Surface unexpected merge-base failures and log short SHA telemetry failures
- Update stale sync/schema docs and comments

Tests added:
- Branch persistence and detached HEAD coverage for clone/register flows
- Orchestrator register-project branch detection coverage
- Git sync error handling coverage
- SQLite/codebase/schema coverage for default_branch

Skipped:
- none
@Wirasm Wirasm force-pushed the archon/task-bench-1516-codex branch from 5123048 to c4af65e Compare June 8, 2026 16:10
@Wirasm Wirasm marked this pull request as ready for review June 8, 2026 16:14
@Wirasm Wirasm merged commit a0f418b into dev Jun 8, 2026
3 of 4 checks passed
@Wirasm Wirasm deleted the archon/task-bench-1516-codex branch June 8, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant