Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: normalize audit inventory hosts and document account refusal (#13233)
Adam Eivy9059bdc6b59a
diff --git a/docs/MANAGED_APP_FORGE_ACCOUNTS.md b/docs/MANAGED_APP_FORGE_ACCOUNTS.mdindex 3757d133b7..5a201e745b 100644--- a/docs/MANAGED_APP_FORGE_ACCOUNTS.md+++ b/docs/MANAGED_APP_FORGE_ACCOUNTS.md@@ -35,9 +35,9 @@ host. Without it, an aliased repo hits three separate failures at once:- **The work tracker falls back to PLAN.md.** `auto` classifies a repo from itsorigin host, and an unrecognized host is not GitHub, so the app's issues areinvisible to `claim-issue` and to the task data inputs.-- **Agents get no account-pinned token.** The `GH_TOKEN` overlay is gated on a- real `github.com` host, so an aliased repo's agent falls back to `gh`'s mutable- active user — the "must be a collaborator" failure.+- **Account probes target the wrong host.** Account discovery and token lookup+ must use the resolved GitHub host, including Enterprise hosts. A token stored+ for the alias or another host cannot satisfy the app's account pin.Only literal `Host` → `HostName` pairs are honored. `Match` blocks, `Include`directives, wildcard patterns, and `%h`-style `HostName` tokens are left alone:@@ -51,26 +51,34 @@ Set **GitHub Account** on the app (Apps → edit → Workflow), or `forgeAccountthe app record. It takes a `gh` login you are already authenticated as:```bash-gh auth login # once per account; `gh auth status` should list them all+gh auth login --hostname github.com # use the app's Enterprise hostname when applicable+gh auth status --hostname github.com```-When set, PortOS pins **both halves** of that identity for every agent it+When set, PortOS resolves that account on the repository's host for every agent itlaunches against the app's repo (and every worktree of it), and for PortOS-owned`gh` probes against that repo (the claim-issue work detector and scheduled-taskissue preloads):| | ||---|---|-| `GH_TOKEN` | minted for that account, so `gh pr create`, `git push`, and issue-list probes act as it |-| `GIT_AUTHOR_*` / `GIT_COMMITTER_*` | `<id>+<login>@users.noreply.github.com`, the address GitHub attributes back to the account |+| `GH_HOST` | the normalized repository host; `ssh.github.com` maps to `github.com` |+| `GH_TOKEN` | the selected account's token on `github.com` and Enterprise Cloud hosts under `*.ghe.com` |+| `GH_ENTERPRISE_TOKEN` | the selected account's token on GitHub Enterprise Server hosts |+| `GIT_AUTHOR_*` / `GIT_COMMITTER_*` | Public GitHub uses `<id>+<login>@users.noreply.github.com`; Enterprise uses the authenticated user's API-returned email, when available |++Account probes clear all four ambient GitHub token variables before reading the+host's keyring. The execution environment carries only the selected host's token+family. An Enterprise account whose API exposes no email keeps the existing Git+identity; PortOS does not invent a public GitHub noreply address for it. Git's SSH+transport still uses the SSH identity configured for the remote.Without the probe pin, those checks inherit the install's ambient `GH_TOKEN` oractive `gh` user, so a private repo under another logged-in account fails thedetector as a transient forge error and never dispatches an agent.-The credential and the authorship move together on purpose: authenticating as-another account while committing under the machine owner's name and email writes-the wrong person into someone else's repository history.+When the account exposes a usable commit identity, PortOS applies it alongside+the credential so commits are attributed to the selected account.The identity arrives as environment variables on the agent process rather than as`git config`, so PortOS never mutates a repository it does not own, and the@@ -79,19 +87,26 @@ override lives exactly as long as the run.### When it is left blankThe account is inferred by matching the repo owner against your logged-in `gh`-logins, which is what PortOS has always done, and **no commit identity is-overridden**. That inference is correct whenever the owner's login *is* the+accounts on that host. When no account/token can be resolved, unpinned repositories+retain their ambient authentication. Owner matching **does not override commit+identity**. That inference is correct whenever the owner's login *is* theaccount that should push — so most personal repos need no configuration at all.Set the field when it is not: an organization repo, a bot account, or any repowhose owner login differs from the account you push with.-A pinned account is never second-guessed. If `gh` has no token for it, the run-gets no pinned forge credential — `resolveForgeTokenEnv` overlays nothing, and-`buildSafeEnv` strips the ambient `GH_TOKEN` from agent shells — rather than-silently falling back to a different account's token. (PortOS's own-`resolveForgeForRepo` probes still inherit the ambient environment when no-token is minted; the no-fallback guarantee covers the credential handed to the-run, not every ambient lookup PortOS performs itself.)+### When the selected account is unavailable++An explicit pin never falls back to another account or host. If `gh` cannot+return that account's token on the repository host, PortOS refuses the agent+launch or forge operation with `FORGE_ACCOUNT_UNAVAILABLE`. A missing repository+path or origin also refuses an explicit pin. A timed-out spawn lookup refuses+with `FORGE_AUTH_TIMEOUT` when a pin exists or the lookup has not yet established+whether one exists.++Check `gh auth status --hostname <host>` and sign in as the selected account on+that host. Scope refresh uses the same host and expected account; because+`gh auth refresh` refreshes only the active account, PortOS asks you to switch to+the selected account first when necessary.## Relateddiff --git a/server/services/agentFinalization.goalFidelity.test.js b/server/services/agentFinalization.goalFidelity.test.jsindex 59a3be7d8d..f2203aba63 100644--- a/server/services/agentFinalization.goalFidelity.test.js+++ b/server/services/agentFinalization.goalFidelity.test.js@@ -343,7 +343,8 @@ describe('finalizeAgent — goal-fidelity gate', () => {}));});- it('declines the diff-only judgement after independent empty inventories, without inventing a ship verdict or follow-up', async () => {+ it('declines the diff-only judgement after empty inventories on the canonical SSH host, without inventing a verdict or follow-up', async () => {+ execGit.mockResolvedValue({ stdout: '[email protected]:example/project.git', exitCode: 0 });runLocalGoalFidelityReviewMock.mockResolvedValue(verdict({verdict: 'fix-first', missing: ['Security inventory and bot PR resolution'],unrequested: ['The audit note'], evidence: 'Only an audit note is visible.',diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.jsindex a878ecbb5e..6f8e3ba9a2 100644--- a/server/services/agentFinalization.js+++ b/server/services/agentFinalization.js@@ -836,16 +836,18 @@ async function hasEmptyDependencyInventories(workspacePath) {const { getOriginInfo } = await import('../lib/gitRemote.js');const origin = await getOriginInfo(workspacePath);if (!origin.host || !origin.owner || !origin.repo) return false;+ const { githubApiHost } = await import('../lib/workTracker.js');+ const host = githubApiHost(origin.host.toLowerCase());const { resolveForgeForRepo } = await import('./git.js');const forge = await resolveForgeForRepo(workspacePath);- if (forge.cli !== 'gh' || forge.host !== origin.host || forge.owner !== origin.owner) return false;+ if (forge.cli !== 'gh' || githubApiHost(forge.host?.toLowerCase()) !== host || forge.owner !== origin.owner) return false;const { execGh } = await import('./github.js');const inventories = await Promise.all(['dependabot/alerts','pulls',].map(async resource => {const raw = await execGh([- 'api', '--hostname', origin.host, '--paginate', '--slurp',+ 'api', '--hostname', host, '--paginate', '--slurp',`repos/${origin.owner}/${origin.repo}/${resource}?state=open&per_page=100`,], 30_000, { cwd: workspacePath, env: forge.env });const pages = safeJSONParse(raw, null);