Skip to content
Source
Sign inSign up
pingdotgg/t3code

Feat/GitHub account per owner #17516

ClosedNoext(GitHub profile, opens in a new tab)wants to merge 8 commits intomain fromrefs/pull/17516/headopened View on GitHub

Problem

Change

Scope and approval

Verification

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. @@ -0,0 +258,21 @@
      258+ phaseTitle: agent.phase ?? null,
      259+ agentIndex: index,
      260+ runId: run.runId,
      261+ },
      262+ startedAt: parseIso(agent.startedAt),
      263+ completedAt: finished ? parseIso(agent.endedAt) : null,
      264+ updatedAt: parseIso(agent.endedAt ?? agent.startedAt) ?? context.emittedAt,
      265+ };
      266+};
      267+
      268+const memberProgress = (
      269+ run: PiWorkflowRunSnapshot,
      270+ mappedPhases: OrchestrationV2SubagentWorkflow["phases"],
      271+ members: Map<string, string>,
      272+ context: PiWorkflowProjectionContext,
      273+ force: boolean,
      274+): ReadonlyArray<OrchestrationV2Subagent> => {
      275+ const subagents: Array<OrchestrationV2Subagent> = [];
      276+ run.agents.forEach((agent, index) => {
      277+ const taskId = memberNativeId(run.runId, agent.id);
      278+ const fingerprint = memberFingerprint(agent);
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Adapters/PiWorkflowProgress.ts:278

      Members retain stale workflow.phaseIndex or agentIndex values when a phase is added or an earlier-sorting agent is inserted, so the client renders incorrect member positions. memberFingerprint(agent) excludes both values derived by buildMember; include the mapped phase index and array index in the deduplication fingerprint so those changes emit updated members.

      -    const fingerprint = memberFingerprint(agent);
      +    const fingerprint = `${memberFingerprint(agent)}\u001f${phaseIndexFor(mappedPhases, agent.phase) ?? ""}\u001f${index}`;
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration-v2/Adapters/PiWorkflowProgress.ts around line 278:
      
      Members retain stale `workflow.phaseIndex` or `agentIndex` values when a phase is added or an earlier-sorting agent is inserted, so the client renders incorrect member positions. `memberFingerprint(agent)` excludes both values derived by `buildMember`; include the mapped phase index and array index in the deduplication fingerprint so those changes emit updated members.
      @@ -2834,0 +2993,21 @@
      2993+ // tracker, rather than reporting its runs as ended.
      2994+ const [snapshotListing, feedListing] = yield* Effect.all(
      2995+ [
      2996+ workflowStores.snapshot.listRunsForSession({ cwd, sessionIds: [sessionId] }),
      2997+ workflowStores.feed.listRunsForSession({
      2998+ sessionIds: [sessionId],
      2999+ ...(workflowSessionFile === null ? {} : { sessionFile: workflowSessionFile }),
      3000+ }),
      3001+ ],
      3002+ { concurrency: 2 },
      3003+ );
      3004+ const emittedAt = yield* DateTime.now;
      3005+ const reconciled = reconcilePiWorkflowRuns({
      3006+ runs: [...snapshotListing.runs, ...feedListing.runs],
      3007+ unresolvedRunIds: [
      3008+ ...snapshotListing.unresolvedRunIds,
      3009+ ...feedListing.unresolvedRunIds,
      3010+ ],
      3011+ tracker,
      3012+ context: {
      3013+ threadId: input.threadId,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Adapters/PiAdapterV2.ts:3013

      Workflow progress discovered after forkThread or resumeThread is emitted under the original input.threadId, so destination-session subagents appear in the wrong app thread despite carrying the destination provider thread and parent node. The sweep hardcodes the original ID; use the currently registered provider thread’s appThreadId, falling back to input.threadId when none is registered.

      -              threadId: input.threadId,
      +              threadId: threadState?.providerThread.appThreadId ?? input.threadId,
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration-v2/Adapters/PiAdapterV2.ts around line 3013:
      
      Workflow progress discovered after `forkThread` or `resumeThread` is emitted under the original `input.threadId`, so destination-session subagents appear in the wrong app thread despite carrying the destination provider thread and parent node. The sweep hardcodes the original ID; use the currently registered provider thread’s `appThreadId`, falling back to `input.threadId` when none is registered.
      @@ -0,0 +504,21 @@
      504+ // A file that shrank or was replaced is not the file this reader folded.
      505+ const state =
      506+ previous !== undefined && previous.ino === info.ino && previous.offset <= info.size
      507+ ? previous
      508+ : { offset: 0, ino: info.ino, view: emptyFold() };
      509+ const remaining = info.size - state.offset;
      510+ if (remaining <= 0) return state.view;
      511+
      512+ const budget = Math.min(remaining, MAX_FEED_BYTES_PER_SWEEP);
      513+ const bytes = yield* Effect.scoped(
      514+ Effect.gen(function* () {
      515+ const file = yield* fileSystem.open(filePath, { flag: "r" });
      516+ // `seek` takes a bigint offset; the folded state tracks JS numbers.
      517+ yield* file.seek(BigInt(state.offset), "start");
      518+ return yield* readUpTo(file, budget);
      519+ }),
      520+ );
      521+ // 0x0a is a whole byte in UTF-8, so the boundary can be found before
      522+ // decoding and a record split across two writes is never half-parsed.
      523+ const lastNewline = bytes.lastIndexOf(0x0a);
      524+ if (lastNewline < 0) {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Adapters/PiClaudeWorkflowStore.ts:524

      A feed record larger than 4 MiB leaves the run stuck as running forever because later sweeps retry the same bytes and never reach its newline or subsequent status records. When the read window has no newline and more than the budget remains, return null so the run is reported as unresolved instead of saving the unchanged offset.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration-v2/Adapters/PiClaudeWorkflowStore.ts around line 524:
      
      A feed record larger than 4 MiB leaves the run stuck as `running` forever because later sweeps retry the same bytes and never reach its newline or subsequent status records. When the read window has no newline and more than the budget remains, return `null` so the run is reported as unresolved instead of saving the unchanged offset.
      @@ -0,0 +321,21 @@
      321+ // The writer's index, never its `agentId`: that id only appears on the
      322+ // agent's terminal record, and a member row that changed its task id
      323+ // mid-flight would show up twice.
      324+ id: String(index),
      325+ label: agent.label ?? `agent ${index}`,
      326+ phase: agent.phase,
      327+ status: agent.status ?? "queued",
      328+ model: agent.model,
      329+ tokens: agent.tokens,
      330+ startedAt: isoOrUndefined(agent.startedAtMs),
      331+ endedAt: isoOrUndefined(agent.endedAtMs),
      332+ }));
      333+
      334+/**
      335+ * The phase the card reports as current: the one the newest agent ran in. The feed
      336+ * carries no other honest signal — every declared phase is written up front, so
      337+ * the newest `workflow_phase` record is always the last one declared — and it only
      338+ * moves forward as agents start.
      339+ */
      340+const currentPhaseOf = (view: FoldedFeed): string | undefined => {
      341+ const newest = [...view.agents.entries()].sort(([a], [b]) => b - a)[0];
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Adapters/PiClaudeWorkflowStore.ts:341

      For runs with more than 100 agents, currentPhaseOf keeps reporting the phase of one of the first 100 agents even after later agents execute in a new phase. foldRecord drops those later agents when the display map reaches its cap, so track the newest phase independently of that map.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration-v2/Adapters/PiClaudeWorkflowStore.ts around line 341:
      
      For runs with more than 100 agents, `currentPhaseOf` keeps reporting the phase of one of the first 100 agents even after later agents execute in a new phase. `foldRecord` drops those later agents when the display map reaches its cap, so track the newest phase independently of that map.
      @@ -0,0 +349,21 @@
      349+ // the first to see the last agents at all. The coordinator's terminal row
      350+ // still settles the run; these rows only describe what it settled.
      351+ subagents.push(...memberProgress(run, mapPhases(run.phases), members, input.context, false));
      352+ subagents.push(buildCoordinator(run, input.context, previous.subagent.parentNodeId));
      353+ coordinator.delete(run.runId);
      354+ dropMemberFingerprints(members, run.runId);
      355+ continue;
      356+ }
      357+
      358+ if (run.status === "paused") {
      359+ const built = buildCoordinator(run, input.context, previous.subagent.parentNodeId);
      360+ if (previous.status !== "paused") subagents.push(built);
      361+ // Store the *paused* fingerprint, not the pre-pause one: a resume whose
      362+ // other fields are unchanged must still emit, or the coordinator row keeps
      363+ // reading idle while the run is running again.
      364+ coordinator.set(run.runId, {
      365+ status: run.status,
      366+ fingerprint: coordinatorFingerprint(run),
      367+ subagent: built,
      368+ });
      369+ continue;
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Adapters/PiWorkflowProgress.ts:369

      When a member finishes between sweeps and the next snapshot is paused, this branch emits no member update, so the UI keeps that member as running throughout the pause despite the store's final status and timestamp. Reconcile memberProgress(...) in the paused branch with force set to false before continuing, so only changed rows are emitted.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration-v2/Adapters/PiWorkflowProgress.ts around line 369:
      
      When a member finishes between sweeps and the next snapshot is paused, this branch emits no member update, so the UI keeps that member as running throughout the pause despite the store's final status and timestamp. Reconcile `memberProgress(...)` in the paused branch with `force` set to `false` before continuing, so only changed rows are emitted.
      @@ -1022,3 +1025,5 @@
      10221025 host,
      10231026 operation: "createRepository",
      10241027 method: "POST",
      1028+ // An organization's repository is created by a login that may belong to another account.
      1029+ account: owner ?? "",
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High sourceControl/GitHubCli.ts:1029

      Creating a personal repository for a second signed-in login sends the request to orgs/{owner}/repos instead of user/repos, so the repository is routed as an organization. readViewerLogin uses the default credential while this POST uses account: owner, causing isViewer to compare identities from different accounts; read the viewer using the owner-selected credential before choosing the endpoint.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/sourceControl/GitHubCli.ts around line 1029:
      
      Creating a personal repository for a second signed-in login sends the request to `orgs/{owner}/repos` instead of `user/repos`, so the repository is routed as an organization. `readViewerLogin` uses the default credential while this POST uses `account: owner`, causing `isViewer` to compare identities from different accounts; read the viewer using the owner-selected credential before choosing the endpoint.
      @@ -1100,0 +1111,21 @@
      1111+ /**
      1112+ * The environment a git process needs to reach its remote as the account that owns it. Resolved
      1113+ * before the command takes a process slot, because the `gh` probe it may need is itself a child
      1114+ * process and must not queue behind the command it is preparing.
      1115+ */
      1116+ const remoteAccountEnvironment = (input: {
      1117+ readonly cwd: string;
      1118+ readonly args: ReadonlyArray<string>;
      1119+ }): Effect.Effect<NodeJS.ProcessEnv> => {
      1120+ if (Option.isNone(gitHubAccounts)) return Effect.succeed<NodeJS.ProcessEnv>({});
      1121+ const credentials = gitHubAccounts.value;
      1122+ return gitRemoteAccountEnv({
      1123+ args: input.args,
      1124+ // `remote -v` is a local read, so this lookup resolves no account of its own.
      1125+ readRemoteUrls: () =>
      1126+ executeGit(
      1127+ "GitVcsDriver.remoteAccountEnvironment.remoteUrls",
      1128+ input.cwd,
      1129+ ["remote", "-v"],
      1130+ { allowNonZeroExit: true, timeoutMs: 10_000, maxOutputBytes: 32_000 },
      1131+ ).pipe(
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High vcs/GitVcsDriverCore.ts:1126

      When eight remote Git commands hold all gitProcesses permits, they wait forever for their nested remote -v probes, preventing those commands and subsequent local Git operations from completing. execute acquires a permit before resolving credentials, and readRemoteUrls calls executeGit, which tries to acquire another permit; use executeRaw for this local probe so it does not reacquire a permit.

      -        executeGit(
      -          "GitVcsDriver.remoteAccountEnvironment.remoteUrls",
      -          input.cwd,
      -          ["remote", "-v"],
      -          { allowNonZeroExit: true, timeoutMs: 10_000, maxOutputBytes: 32_000 },
      -        ).pipe(
      +        executeRaw({
      +          operation: "GitVcsDriver.remoteAccountEnvironment.remoteUrls",
      +          cwd: input.cwd,
      +          args: ["remote", "-v"],
      +          allowNonZeroExit: true,
      +          timeoutMs: 10_000,
      +          maxOutputBytes: 32_000,
      +        }).pipe(
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/vcs/GitVcsDriverCore.ts around lines 1126-1131:
      
      When eight remote Git commands hold all `gitProcesses` permits, they wait forever for their nested `remote -v` probes, preventing those commands and subsequent local Git operations from completing. `execute` acquires a permit before resolving credentials, and `readRemoteUrls` calls `executeGit`, which tries to acquire another permit; use `executeRaw` for this local probe so it does not reacquire a permit.
      @@ -0,0 +377,21 @@
      377+ const readCachedRun = (filePath: string, info: PiWorkflowRunFileInfo) =>
      378+ Effect.gen(function* () {
      379+ if (info.size > MAX_RUN_BYTES) {
      380+ yield* Effect.logDebug("Pi workflow run file exceeds the size cap; skipping it.", {
      381+ filePath,
      382+ size: info.size,
      383+ });
      384+ cache.delete(filePath);
      385+ return null;
      386+ }
      387+ const cached = cache.get(filePath);
      388+ if (
      389+ cached &&
      390+ cached.mtimeMs === info.mtimeMs &&
      391+ cached.size === info.size &&
      392+ cached.ino === info.ino
      393+ ) {
      394+ return cached.run;
      395+ }
      396+ const run = yield* readRunFile(filePath);
      397+ cache.set(filePath, { mtimeMs: info.mtimeMs, size: info.size, ino: info.ino, run });
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Adapters/PiWorkflowStore.ts:397

      Runs remain unresolved after a transient read failure, and changes to a .bak cannot recover a run while the primary's stat tuple stays unchanged. readCachedRun caches both null and backup-derived snapshots using only the primary's metadata, so later sweeps hit the cache without retrying readRunFile; avoid caching failed reads and track backup freshness when caching fallback results.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration-v2/Adapters/PiWorkflowStore.ts around line 397:
      
      Runs remain unresolved after a transient read failure, and changes to a `.bak` cannot recover a run while the primary's stat tuple stays unchanged. `readCachedRun` caches both `null` and backup-derived snapshots using only the primary's metadata, so later sweeps hit the cache without retrying `readRunFile`; avoid caching failed reads and track backup freshness when caching fallback results.
    3. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This change combines a substantial new Pi workflow capability and UI with authentication/token-routing changes, provider/projection behavior changes, self-hosted CI infrastructure, and new static-analysis suppressions. Its default runtime enablement and unresolved workflow, GitHub, and concurrency risks require human review.

      Not approved because:

      • 8 blocking correctness issues found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.