From c2e2b3a430d0bd865a3d0bc159e9d8543bc1b02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Thu, 27 Aug 2026 13:13:28 +0000 Subject: [PATCH] fix: reconcile prepared workspace origins (#3077) --- .../orchestrator/executor/executor_execute.go | 9 +- .../executor_resume_clone_transport_test.go | 169 ++++++++++++++++++ .../plan.md | 132 ++++++++++++++ ...01-reconcile-prepared-workspace-origins.md | 109 +++++++++++ .../requirements/github-authentication.md | 2 + .../system-design/github-authentication-01.md | 6 + .../system-design/github-authentication-02.md | 3 + .../system-design/github-authentication-03.md | 2 + 8 files changed, 428 insertions(+), 4 deletions(-) create mode 100644 docs/plans/prepared-workspace-origin-reconciliation/plan.md create mode 100644 docs/plans/prepared-workspace-origin-reconciliation/task-01-reconcile-prepared-workspace-origins.md diff --git a/apps/backend/internal/orchestrator/executor/executor_execute.go b/apps/backend/internal/orchestrator/executor/executor_execute.go index 5f1a0dfd21..9fd14b19ea 100644 --- a/apps/backend/internal/orchestrator/executor/executor_execute.go +++ b/apps/backend/internal/orchestrator/executor/executor_execute.go @@ -1133,6 +1133,11 @@ func (e *Executor) LaunchPreparedSession(ctx context.Context, task *v1.Task, ses // Inject session handover context if there are previous sessions for this task. prompt = e.injectHandoverIfNeeded(ctx, task.ID, sessionID, prompt) + allRepos, err := e.resolveAllRepoInfoForSession(ctx, task.ID, sessionID) + if err != nil { + return nil, err + } + // Fast path: workspace already launched (executors_running row exists). // Only start the agent subprocess if requested; otherwise return early. // If startAgentOnExistingWorkspace returns ErrStaleExecution, the in-memory @@ -1151,10 +1156,6 @@ func (e *Executor) LaunchPreparedSession(ctx context.Context, task *v1.Task, ses zap.Error(err)) } - allRepos, err := e.resolveAllRepoInfoForSession(ctx, task.ID, sessionID) - if err != nil { - return nil, err - } // Primary = first by Position. For repo-less tasks (e.g. quick chat), allRepos // is empty and primary is a zero-value placeholder; downstream code already // handles the missing-repo path. diff --git a/apps/backend/internal/orchestrator/executor/executor_resume_clone_transport_test.go b/apps/backend/internal/orchestrator/executor/executor_resume_clone_transport_test.go index ac4deeee25..3b07848e99 100644 --- a/apps/backend/internal/orchestrator/executor/executor_resume_clone_transport_test.go +++ b/apps/backend/internal/orchestrator/executor/executor_resume_clone_transport_test.go @@ -3,11 +3,15 @@ package executor import ( "context" "fmt" + "os" "os/exec" "path/filepath" "strings" + "sync" "testing" + "time" + "github.com/kandev/kandev/internal/common/logger" "github.com/kandev/kandev/internal/repoclone" "github.com/kandev/kandev/internal/task/models" v1 "github.com/kandev/kandev/pkg/api/v1" @@ -105,6 +109,143 @@ func TestEnsureRepoLocalPathReevaluatesGitHubProtocol(t *testing.T) { } } +// @covers AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.11 +// @covers AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.12 +func TestLaunchPreparedSession_ExistingWorkspace_ReconcilesGitHubOriginsBeforeAgentStart(t *testing.T) { + fixture := newPreparedWorkspaceOriginFixture(t) + executor := newTestExecutor(t, fixture.agentManager, fixture.repo) + executor.SetTaskGitCredentialPolicyResolver(fakeTaskGitCredentialPolicyResolver{ + policy: TaskGitCredentialPolicy{Mode: taskGitCredentialsModeExecutor}, + }) + executor.SetRepoCloner(fixture.cloner, nil) + + _, err := executor.LaunchPreparedSession(context.Background(), fixture.task, fixture.sessionID, LaunchOptions{ + AgentProfileID: "profile-prepared-origins", + StartAgent: true, + }) + if err != nil { + t.Fatalf("LaunchPreparedSession() error = %v", err) + } + + select { + case err := <-fixture.startDone: + if err != nil { + t.Fatalf("agent started before origin reconciliation: %v", err) + } + case <-time.After(5 * time.Second): + t.Fatal("timed out waiting for StartAgentProcess") + } + for _, path := range fixture.originPaths { + if got := fixture.cloner.originCallCount(path); got != 1 { + t.Errorf("SetOriginURL calls for %q = %d, want 1", path, got) + } + } +} + +type preparedWorkspaceOriginFixture struct { + repo *mockRepository + task *v1.Task + sessionID string + agentManager *mockAgentManager + cloner *countingRepoCloner + startDone chan error + originPaths []string +} + +func newPreparedWorkspaceOriginFixture(t *testing.T) *preparedWorkspaceOriginFixture { + t.Helper() + const ( + taskID = "task-prepared-origins" + sessionID = "session-prepared-origins" + workspaceID = "workspace-prepared-origins" + ) + firstPath := initGitRepoWithOrigin(t, "https://github.com/acme/first.git") + secondPath := initGitRepoWithOrigin(t, "git@github.com:acme/second.git") + configLock := filepath.Join(secondPath, ".git", "config.lock") + if err := os.WriteFile(configLock, nil, 0o600); err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = os.Remove(configLock) }) + + fixture := &preparedWorkspaceOriginFixture{ + repo: newPreparedWorkspaceOriginRepository(taskID, sessionID, workspaceID, firstPath, secondPath), + task: &v1.Task{ID: taskID, WorkspaceID: workspaceID, Title: "prepared origin reconciliation"}, + sessionID: sessionID, + cloner: &countingRepoCloner{ + Cloner: repoclone.NewCloner(repoclone.Config{}, repoclone.ProtocolSSH, "", logger.Default()), + setOriginCalls: make(map[string]int), + }, + startDone: make(chan error, 1), + originPaths: []string{firstPath, secondPath}, + } + fixture.agentManager = newPreparedWorkspaceOriginAgentManager(fixture) + return fixture +} + +func newPreparedWorkspaceOriginRepository(taskID, sessionID, workspaceID, firstPath, secondPath string) *mockRepository { + repo := newMockRepository() + repo.sessions[sessionID] = &models.TaskSession{ + ID: sessionID, TaskID: taskID, AgentProfileID: "profile-prepared-origins", + State: models.TaskSessionStateCreated, StartedAt: time.Now(), UpdatedAt: time.Now(), + } + repo.executorsRunning[sessionID] = &models.ExecutorRunning{ + ID: sessionID, SessionID: sessionID, TaskID: taskID, + AgentExecutionID: "exec-prepared-origins", Status: models.ExecutorRunningStatusReady, + } + repo.taskRepositories["task-repo-first"] = &models.TaskRepository{ + ID: "task-repo-first", TaskID: taskID, RepositoryID: "repo-first", Position: 0, + } + repo.taskRepositories["task-repo-second"] = &models.TaskRepository{ + ID: "task-repo-second", TaskID: taskID, RepositoryID: "repo-second", Position: 1, + } + repo.repositories["repo-first"] = preparedWorkspaceOriginRepository( + "repo-first", workspaceID, "first", firstPath, + ) + repo.repositories["repo-second"] = preparedWorkspaceOriginRepository( + "repo-second", workspaceID, "second", secondPath, + ) + return repo +} + +func preparedWorkspaceOriginRepository(id, workspaceID, name, localPath string) *models.Repository { + return &models.Repository{ + ID: id, WorkspaceID: workspaceID, SourceType: "provider", Provider: "github", + ProviderOwner: "acme", ProviderName: name, LocalPath: localPath, + } +} + +func newPreparedWorkspaceOriginAgentManager(fixture *preparedWorkspaceOriginFixture) *mockAgentManager { + return &mockAgentManager{ + getExecutionIDForSessionFunc: func(context.Context, string) (string, error) { + return "exec-prepared-origins", nil + }, + startAgentProcessFunc: func(ctx context.Context, _ string) error { + err := fixture.verifyOriginsAtAgentStart(ctx) + fixture.startDone <- err + return err + }, + } +} + +func (fixture *preparedWorkspaceOriginFixture) verifyOriginsAtAgentStart(ctx context.Context) error { + for _, check := range []struct { + path string + want string + }{ + {path: fixture.originPaths[0], want: "git@github.com:acme/first.git"}, + {path: fixture.originPaths[1], want: "git@github.com:acme/second.git"}, + } { + got, err := readGitOriginURL(ctx, check.path) + if err != nil { + return err + } + if got != check.want { + return fmt.Errorf("origin for %s = %q, want %q", check.path, got, check.want) + } + } + return nil +} + func TestEnsureRepoLocalPath_DoesNotRewriteUserManagedOrigin(t *testing.T) { if _, err := exec.LookPath("git"); err != nil { t.Skip("git not available") @@ -555,6 +696,25 @@ func (r *mutableExecutorGitProtocolResolver) ResolveGitProtocol(context.Context, return r.protocol } +type countingRepoCloner struct { + *repoclone.Cloner + mu sync.Mutex + setOriginCalls map[string]int +} + +func (c *countingRepoCloner) SetOriginURL(ctx context.Context, repositoryPath, originURL string) error { + c.mu.Lock() + c.setOriginCalls[repositoryPath]++ + c.mu.Unlock() + return c.Cloner.SetOriginURL(ctx, repositoryPath, originURL) +} + +func (c *countingRepoCloner) originCallCount(repositoryPath string) int { + c.mu.Lock() + defer c.mu.Unlock() + return c.setOriginCalls[repositoryPath] +} + var _ authenticatedRepoCloner = (*cloneTransportTestCloner)(nil) func (c *cloneTransportTestCloner) EnsureWorkspaceClonedWithCredentialRequest( @@ -626,3 +786,12 @@ func gitOriginURL(t *testing.T, repoPath string) string { } return string(out[:len(out)-1]) } + +func readGitOriginURL(ctx context.Context, repoPath string) (string, error) { + cmd := exec.CommandContext(ctx, "git", "-C", repoPath, "remote", "get-url", "origin") + out, err := cmd.Output() + if err != nil { + return "", fmt.Errorf("git remote get-url origin: %w", err) + } + return strings.TrimSpace(string(out)), nil +} diff --git a/docs/plans/prepared-workspace-origin-reconciliation/plan.md b/docs/plans/prepared-workspace-origin-reconciliation/plan.md new file mode 100644 index 0000000000..7e9054d1ef --- /dev/null +++ b/docs/plans/prepared-workspace-origin-reconciliation/plan.md @@ -0,0 +1,132 @@ +--- +created: 2026-08-27 +status: done +requirements: + - REQ-INTEGRATIONS-GITHUB-AUTHENTICATION-001 +system_design: + - ../../specs/integrations/system-design/github-authentication-01.md + - ../../specs/integrations/system-design/github-authentication-02.md + - ../../specs/integrations/system-design/github-authentication-03.md +legacy_specs: [] +--- + +# Fix Plan: Reconcile Origins for Prepared Workspaces + +Issue: [#3070](https://github.com/kdlbs/kandev/issues/3070) + +## Overview + +Every launch or resume must prepare each attached repository before an agent starts. The repair +moves the existing repository-resolution pass before the prepared-workspace branch. The full +launch path then reuses the same result. + +This order closes the fast-path gap without another repository pass. The launch-order work is +implemented on top of #3069's dynamic, host-aware Git protocol resolution from PR #3078. + +## Confirmed root cause + +`LaunchPreparedSession` checks `HasExecutorRunningRow` before it calls +`resolveAllRepoInfoForSession`. A running row can route the request through +`startAgentOnExistingWorkspace`, which returns before repository resolution. + +`resolveAllRepoInfoForSession` reaches `ensureRepoLocalPathForSession` and +`reconcileGitHubCheckoutOrigin`. Therefore, the prepared-workspace branch skips origin convergence +after the workspace policy or detected protocol changes. + +The smallest reproduction seeds a prepared session with an `executors_running` row and an +in-memory execution. An attached managed checkout has a noncanonical origin. A call to +`LaunchPreparedSession` starts the agent without changing that origin. + +## Scope + +### In scope + +- Run the existing repository-resolution pass before the prepared-workspace branch. +- Reuse that result if the request falls through to the full launch path. +- Reconcile every attached managed GitHub checkout once for each launch operation. +- Fail the launch before agent start when repository preparation fails. +- Add regression coverage at the real `LaunchPreparedSession` fast-path boundary. + +### Out of scope + +- Dynamic host-aware Git protocol detection, which belongs to #3069. +- Host `gh` credential bridging for HTTPS origins, which belongs to #3072. +- Changes to GitHub credential precedence, checkout ownership, or user-managed local repositories. +- Frontend, persistence, API, migration, and public documentation changes. + +## Technical approach + +### Prepared launch ordering + +In `apps/backend/internal/orchestrator/executor/executor_execute.go`, move the single +`resolveAllRepoInfoForSession` call above the `HasExecutorRunningRow` decision in +`LaunchPreparedSession`. + +The existing-workspace path needs the preparation side effects before it returns or starts the +agent. If that path falls through with `ErrStaleExecution` or `ErrAgentCommandMissing`, the full +path must reuse the resolved slice. It must not resolve the repositories again. + +The resolver remains the only origin-reconciliation entry point. Do not add another origin update +to `configureExistingWorkspace` or duplicate policy resolution. + +### Coordination with #3069 + +PR #3078, originally headed by commit `b976260e69b5abf421cfa9742dfc5c37d533ac0f`, is now +integrated into `main` as `e4d17b3925`. It provides the dynamic, host-aware protocol resolver and +context-aware `RepoCloner` contract. Executor-mode origin selection uses that seam. This work adds +no second protocol cache, detector, or host lookup. + +## Tests + +- `AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.11`: add + `TestLaunchPreparedSession_ExistingWorkspace_ReconcilesGitHubOriginsBeforeAgentStart` in + `apps/backend/internal/orchestrator/executor/executor_resume_clone_transport_test.go`. +- Exercise `LaunchPreparedSession` with a running row and an in-memory execution. Do not call the + repository helper directly. +- Attach two managed GitHub repositories. Give one a stale origin and the other its canonical + origin. +- Use real Git repositories and the real origin-update behavior. Lock the canonical repository's + Git configuration so an attempted rewrite fails. +- Wrap the real cloner to count `SetOriginURL` calls. At agent start, assert that both origins are + canonical and each managed repository received one call for this launch. +- Keep `TestEnsureRepoLocalPath_DoesNotRewriteUserManagedOrigin` as coverage for + `AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.12` and the local-checkout exclusion. + +## Work orders + +- [x] [Task 01: Reconcile prepared-workspace origins](task-01-reconcile-prepared-workspace-origins.md) + +## Verification results + +Implemented the launch-order correction and the real prepared-workspace regression on top of the +#3069 resolver contract. The focused regression passed, followed by the complete executor and +repoclone package command: + +```text +go test -tags fts5 ./internal/orchestrator/executor -run 'TestLaunchPreparedSession_ExistingWorkspace_ReconcilesGitHubOriginsBeforeAgentStart$' -count=1 +Go test: 1 passed in 1 packages + +go test -tags fts5 ./internal/orchestrator/executor ./internal/repoclone +Go test: 620 passed in 2 packages +``` + +The dynamic protocol reevaluation regression from #3069 also passed: + +```text +go test -tags fts5 ./internal/orchestrator/executor -run 'TestEnsureRepoLocalPathReevaluatesGitHubProtocol$' -count=1 +Go test: 1 passed in 1 packages +``` + +`python3 scripts/lint-spec-files.py --all` also passed. PR #3078 supplies the dynamic, +host-aware protocol resolver and context-aware `RepoCloner.BuildCloneURLWithHost` contract; it is +merged into `main` as `e4d17b3925`, and this branch adds no protocol detection. + +## Risks + +- The context-aware protocol-resolution seam from #3069 is now integrated. Future changes to that + contract must update this regression fixture and its adapter together. +- Repository preparation can now stop an existing-workspace launch before agent start. This is the + required fail-closed behavior, but it makes stale checkout ownership and Git errors visible on + this path. +- A second resolution call can cause repeated work for multi-repository tasks. The regression + must count preparation per repository. diff --git a/docs/plans/prepared-workspace-origin-reconciliation/task-01-reconcile-prepared-workspace-origins.md b/docs/plans/prepared-workspace-origin-reconciliation/task-01-reconcile-prepared-workspace-origins.md new file mode 100644 index 0000000000..2f683cc6a3 --- /dev/null +++ b/docs/plans/prepared-workspace-origin-reconciliation/task-01-reconcile-prepared-workspace-origins.md @@ -0,0 +1,109 @@ +--- +id: "01-reconcile-prepared-workspace-origins" +title: "Reconcile prepared-workspace origins" +status: done +wave: 1 +depends_on: [] +plan: "plan.md" +requirements: + - REQ-INTEGRATIONS-GITHUB-AUTHENTICATION-001 +acceptance_criteria: + - AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.11 + - AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.12 +system_design: + - ../../specs/integrations/system-design/github-authentication-01.md + - ../../specs/integrations/system-design/github-authentication-02.md + - ../../specs/integrations/system-design/github-authentication-03.md +--- + +# Task 01: Reconcile Prepared-Workspace Origins + +## Summary + +Run the existing repository-preparation pass before `LaunchPreparedSession` enters its +existing-workspace branch. Reuse the resolved repository set if the request falls through to the +full launch path. + +## In scope + +- Add the fast-path regression before production changes. +- Prove that origin convergence finishes before the agent starts. +- Prove that an already-canonical origin has no write. +- Prove that one launch prepares each attached repository once. +- Wrap the real cloner to count calls while preserving its Git inspection and no-op behavior. +- Hoist and reuse the existing repository-resolution result. +- Preserve fail-closed repository-preparation errors. + +## Out of scope + +- Implementing or changing #3069 protocol detection, which is supplied by PR #3078. +- Adding #3072 host `gh` credential bridging. +- Changing `repoclone.Cloner.SetOriginURL` no-op or serialization behavior. +- Changing user-managed local checkout behavior. + +## Acceptance + +- The regression fails before the correction because the prepared-workspace branch starts the + agent with a stale managed origin. +- After the correction, all attached managed GitHub origins are canonical before agent start. +- One launch prepares each attached repository once, and an already-canonical origin has no write. + +## Verification + +```bash +go test -tags fts5 ./internal/orchestrator/executor -run 'TestLaunchPreparedSession_ExistingWorkspace_ReconcilesGitHubOriginsBeforeAgentStart$' -count=1 +go test -tags fts5 ./internal/orchestrator/executor ./internal/repoclone +``` + +Run these commands from `apps/backend`. + +## Files likely touched + +- `apps/backend/internal/orchestrator/executor/executor_execute.go` +- `apps/backend/internal/orchestrator/executor/executor_resume_clone_transport_test.go` + +## Dependencies + +- PR #3078, originally headed by commit `b976260e69b5abf421cfa9742dfc5c37d533ac0f`, is merged + into `main` as `e4d17b3925` and supplies the dynamic, host-aware protocol resolver. Use its + context-aware `RepoCloner` contract. + +## Risks + +- The asynchronous agent-start test needs a bounded completion signal. It must not use a fixed + sleep. +- The context-aware #3069 contract is now integrated; the regression fixture must continue to pass + the launch context through protocol-aware clone URL construction. + +## Parallelism + +`sequential` + +## Inputs + +- `REQ-INTEGRATIONS-GITHUB-AUTHENTICATION-001` and its acceptance criteria 001.11 and 001.12. +- The repository-preparation and task-resolution sections in the three GitHub authentication + system-design documents. +- `LaunchPreparedSession`, `startAgentOnExistingWorkspace`, and + `resolveAllRepoInfoForSession`. +- Existing origin tests in `executor_resume_clone_transport_test.go` and `repoclone/clone_test.go`. + +## Results + +The RED regression failed before the production change because the prepared-workspace fast path +started the agent with the stale HTTPS origin. The GREEN implementation hoists +`resolveAllRepoInfoForSession` before that branch and reuses the resolved slice for full-launch +fallbacks. + +The regression uses two real Git checkouts and the real `repoclone.Cloner.SetOriginURL` behavior. +It proves both origins are canonical before `StartAgentProcess`, the canonical checkout remains +write-locked without failure, and each attached repository receives one preparation call. + +Verification passed: + +```text +go test -tags fts5 ./internal/orchestrator/executor -run 'TestLaunchPreparedSession_ExistingWorkspace_ReconcilesGitHubOriginsBeforeAgentStart$' -count=1 +go test -tags fts5 ./internal/orchestrator/executor ./internal/repoclone +go test -tags fts5 ./internal/orchestrator/executor -run 'TestEnsureRepoLocalPathReevaluatesGitHubProtocol$' -count=1 +python3 scripts/lint-spec-files.py --all +``` diff --git a/docs/specs/integrations/requirements/github-authentication.md b/docs/specs/integrations/requirements/github-authentication.md index f95726c0c5..bbb10284e2 100644 --- a/docs/specs/integrations/requirements/github-authentication.md +++ b/docs/specs/integrations/requirements/github-authentication.md @@ -29,6 +29,8 @@ GitHub credentials must not silently cross workspace boundaries. A local workspa - **AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.8:** PAT and named CLI automation act as the verified human account. A separate `My GitHub` connection is only offered when workspace automation uses a GitHub App, because App installations are not people and cannot provide authenticated-viewer semantics. - **AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.9:** When a Local or Worktree task inherits executor Git credentials, every Kandev-managed GitHub checkout shall use the current host `gh` clone protocol for `github.com`. Host-specific configuration takes precedence over global configuration, and SSH is used when neither scope provides a supported protocol. - **AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.10:** Every Local or Worktree launch and resume shall re-evaluate the inherited clone protocol. The system shall reconcile the Kandev-managed checkout before task preparation continues. This behavior shall not require a backend restart. Kandev shall not rewrite the origin of a user-managed local checkout. +- **AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.11:** When a Local or Worktree task launches or resumes, the system shall inspect each attached Kandev-managed GitHub checkout before the agent starts. This behavior includes a prepared workspace that the task reuses. +- **AC-INTEGRATIONS-GITHUB-AUTHENTICATION-001.12:** The system shall reconcile each managed checkout to the canonical transport for the current task policy. It shall not rewrite an already-canonical origin or a user-managed local checkout. ## System design diff --git a/docs/specs/integrations/system-design/github-authentication-01.md b/docs/specs/integrations/system-design/github-authentication-01.md index 391203a38b..e3f83b08af 100644 --- a/docs/specs/integrations/system-design/github-authentication-01.md +++ b/docs/specs/integrations/system-design/github-authentication-01.md @@ -108,6 +108,12 @@ automation under different GitHub Apps without operating separate Kandev deploym construction boundary. The long-lived cloner and review-repository adapter do not store a resolved protocol. Origin reconciliation is serialized per managed checkout. It compares the current and desired canonical URLs, and performs no write when they already match. +- Every launch or resume entry point prepares repositories before the agent starts. This includes + the prepared-workspace path that reuses a running executor. Repository preparation resolves each + attached repository once for that operation. The full launch path reuses the result for primary + and multi-repository configuration and credential routing. Origin reconciliation is serialized + per managed checkout. It compares the current and desired canonical URLs and performs no write + when they already match. - Repository preparation validates any contribution destination before issuing credentials, adds a collision-resistant dedicated fork remote, and reconstructs it on launch and resume. It never accepts a fork inferred from the checkout's current remotes or a caller-provided repository name. diff --git a/docs/specs/integrations/system-design/github-authentication-02.md b/docs/specs/integrations/system-design/github-authentication-02.md index 64444c3555..22301a8fae 100644 --- a/docs/specs/integrations/system-design/github-authentication-02.md +++ b/docs/specs/integrations/system-design/github-authentication-02.md @@ -75,6 +75,9 @@ post-signature processing failures produce `failing`; a later valid successful d the desired `github.com` origin. It queries host-specific `gh` configuration before global configuration and defaults to SSH when neither query returns a supported protocol. The resolver is called again for every launch and resume. Backend startup stores no protocol result. +- The prepared-workspace path resolves the same repository set before it returns or starts an + agent. An existing running-executor record does not bypass managed-checkout origin + reconciliation. - Broker issuance and redemption use the same persisted repository identity fields. A local Git checkout and its `origin` are materialization data, not authorization data. - A public `github.com` remote can supply an in-memory origin when persisted provider-host metadata diff --git a/docs/specs/integrations/system-design/github-authentication-03.md b/docs/specs/integrations/system-design/github-authentication-03.md index 3c06ea44d0..a2676fb32b 100644 --- a/docs/specs/integrations/system-design/github-authentication-03.md +++ b/docs/specs/integrations/system-design/github-authentication-03.md @@ -128,6 +128,8 @@ This design preserves the technical source detail for `REQ-INTEGRATIONS-GITHUB-A - **GIVEN** a task with one or more attached repositories, **WHEN** launch or resume builds the primary, multi-repository, and credential configuration, **THEN** each repository is prepared once and the same resolved result is reused by all three consumers. +- **GIVEN** a prepared workspace with a running executor, **WHEN** launch reuses that workspace, + **THEN** Kandev reconciles each attached managed GitHub checkout once before the agent starts. - **GIVEN** a managed checkout is owned by `brewuser` while the Kandev service runs as root, **WHEN** Git rejects origin inspection or reconciliation as dubious ownership, **THEN** task preparation stops and reports that the service account and managed repository owner disagree,