Skip to content

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

fix: align pinned forge documentation and inventory hosts

[._.]/ Adam Eivy5ff89ce2a5fb
diff --git a/docs/MANAGED_APP_FORGE_ACCOUNTS.md b/docs/MANAGED_APP_FORGE_ACCOUNTS.md
index 3757d133b7..f25b5cf910 100644
--- a/docs/MANAGED_APP_FORGE_ACCOUNTS.md
+++ b/docs/MANAGED_APP_FORGE_ACCOUNTS.md
@@ -61,8 +61,8 @@ issue 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_TOKEN` / `GH_ENTERPRISE_TOKEN` | minted for that account on the repository's host; public GitHub and Enterprise Cloud (`*.ghe.com`) use `GH_TOKEN`, Enterprise Server uses `GH_ENTERPRISE_TOKEN` |
+| `GIT_AUTHOR_*` / `GIT_COMMITTER_*` | public GitHub uses `<id>+<login>@users.noreply.github.com`; Enterprise hosts use the account email returned by their API, leaving commit identity unchanged when no email is exposed |
Without the probe pin, those checks inherit the install's ambient `GH_TOKEN` or
active `gh` user, so a private repo under another logged-in account fails the
@@ -85,13 +85,14 @@ account 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 repo
whose 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.)
+A pinned account is never second-guessed. If `gh` has no token for it on the
+repository's host, credential resolution refuses agent launches and PortOS-owned
+forge operations with `409 FORGE_ACCOUNT_UNAVAILABLE`. If the agent-spawn lookup
+exceeds its budget while the pin is present or still unresolved, it refuses the
+launch with `503 FORGE_AUTH_TIMEOUT`. Neither path silently falls back to a
+different account's token. Check `gh auth status -h <host>` and authenticate the
+pinned account on that host before retrying. Unpinned repositories retain their
+ambient-auth fallback.
## Related
diff --git a/server/services/agentFinalization.goalFidelity.test.js b/server/services/agentFinalization.goalFidelity.test.js
index 59a3be7d8d..fd9ef9a10c 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.each(['github.com', 'SSH.GitHub.COM'])('declines the diff-only judgement after independent empty inventories on %s, without inventing a ship verdict or follow-up', async (host) => {
+ execGit.mockResolvedValue({ stdout: `git@${host}: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.',
@@ -384,6 +385,13 @@ describe('finalizeAgent — goal-fidelity gate', () => {
expect(completion()).toMatchObject({ success: false, completionReason: GOAL_FIDELITY_CATEGORY });
});
+ it('keeps mismatched credential hosts on the ordinary review path', async () => {
+ resolveForgeForRepo.mockResolvedValue({ cli: 'gh', host: 'github.example.com', owner: 'example', env: { GH_ENTERPRISE_TOKEN: 'synthetic-token' } });
+ await finish();
+ expect(execGh).not.toHaveBeenCalled();
+ expect(completion()).toMatchObject({ success: false, completionReason: GOAL_FIDELITY_CATEGORY });
+ });
+
it('keeps unsupported forges on the ordinary review path without calling GitHub', async () => {
execGit.mockResolvedValue({ stdout: 'https://gitlab.example.com/example/project.git', exitCode: 0 });
resolveForgeForRepo.mockResolvedValue({ cli: 'glab', host: 'gitlab.example.com', owner: 'example' });
diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.js
index a878ecbb5e..62da817863 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' || forge.host !== 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);