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: preserve existing forge label metadata
faizanxdev408c7b28d941
diff --git a/server/lib/forgeIssueCli.js b/server/lib/forgeIssueCli.jsindex 6224d1fdbf..37e1c35ec7 100644--- a/server/lib/forgeIssueCli.js+++ b/server/lib/forgeIssueCli.js@@ -5,7 +5,7 @@* rediscovered that disagreement has re-encoded it: the body flag* (`--body` vs `--description`), how labels attach (repeated `--label` flags vs* one comma-joined value), and how a label is created (gh takes the name- * positionally with a bare hex color and `--force`; glab needs `--name` and a+ * positionally with a bare hex color; glab needs `--name` and a* `#`-prefixed color). Keeping those here means a new filer inherits the rules* instead of learning them from a failed 422.*@@ -17,7 +17,7 @@export const forgeLabelCreateArgs = (cli, spec, { repo = null } = {}) => (cli === 'glab'? ['label', 'create', '--name', spec.name, '--color', `#${spec.color}`, '--description', spec.description]: ['label', 'create', spec.name, ...(repo ? ['--repo', repo] : []),- '--color', spec.color, '--description', spec.description, '--force']);+ '--color', spec.color, '--description', spec.description]);/** `issue create` arguments for one issue. */export const forgeIssueCreateArgs = (cli, { title, body, labels = [], repo = null } = {}) => (cli === 'glab'diff --git a/server/services/layeredIntelligence.test.js b/server/services/layeredIntelligence.test.jsindex b73328d461..e9a23e5451 100644--- a/server/services/layeredIntelligence.test.js+++ b/server/services/layeredIntelligence.test.js@@ -2875,8 +2875,23 @@ describe('forge I/O (injected exec)', () => {const created = exec.mock.calls.map(c => c[1][2]); // gh: ['label','create',<name>,...]expect(created).toContain(LI_LABEL);expect(created).toContain(LI_BLOCKING_LABEL);- // gh uses --force for idempotency- expect(exec.mock.calls[0][1]).toContain('--force');+ expect(exec.mock.calls[0][1]).not.toContain('--force');+ });++ it('ensureForgeLabels accepts an existing label without overwriting it', async () => {+ const exec = vi.fn().mockResolvedValue({+ code: 1,+ stdout: '',+ stderr: 'label with this name already exists'+ });+ await expect(ensureForgeLabels({ cli: 'gh', cwd: '/x', exec })).resolves.toBeUndefined();+ expect(exec).toHaveBeenCalledTimes(2);+ expect(exec.mock.calls[0][1]).not.toContain('--force');+ });++ it('ensureForgeLabels surfaces label-create failures other than duplicates', async () => {+ const exec = vi.fn().mockResolvedValue({ code: 1, stdout: '', stderr: 'HTTP 403: Resource not accessible' });+ await expect(ensureForgeLabels({ cli: 'gh', cwd: '/x', exec })).rejects.toThrow('HTTP 403');});it('fileProposalToForge embeds slug marker and returns issue number from URL', async () => {diff --git a/server/services/layeredIntelligence/forgeFiler.js b/server/services/layeredIntelligence/forgeFiler.jsindex 5518720938..e08a44ef12 100644--- a/server/services/layeredIntelligence/forgeFiler.js+++ b/server/services/layeredIntelligence/forgeFiler.js@@ -219,8 +219,9 @@ export async function listBlockingIssues({ cli, cwd, env, exec = runCli } = {})/*** Ensure the layered-intelligence labels exist before the first `issue create`- * (gh/glab both fail creating an issue with a non-existent label). Idempotent —- * `--force` (gh) / re-create (glab) is a no-op when the label already exists.+ * (gh/glab both fail creating an issue with a non-existent label). An existing+ * label is deliberately left unchanged: it belongs to the repository, so only+ * that expected duplicate error is treated as success.*/export async function ensureForgeLabels({ cli, cwd, env, extraLabels = [], exec = runCli } = {}) {const labels = [@@ -231,7 +232,15 @@ export async function ensureForgeLabels({ cli, cwd, env, extraLabels = [], exec}))];for (const l of labels) {- await exec(cli, forgeLabelCreateArgs(cli, { name: l.name, color: l.color, description: l.desc }), { cwd, env });+ const { code, stdout, stderr } = await exec(+ cli,+ forgeLabelCreateArgs(cli, { name: l.name, color: l.color, description: l.desc }),+ { cwd, env }+ );+ const output = `${stderr || ''}\n${stdout || ''}`;+ if (code !== 0 && !/label.*already exists|already exists.*label/i.test(output)) {+ throw new Error(`${cli} label create failed for "${l.name}": ${stderr || `exited with code ${code}`}`);+ }}}@@ -268,8 +277,8 @@ export async function fileProposalToForge({* call with a 422 when the repo has never defined the named label, and this is* the only path that applies `LI_BLOCKING_LABEL` — so on any install where the* Layered Intelligence loop has not yet FILED an issue (the other caller of- * `ensureForgeLabels`), the very first pause would fail. Creation is idempotent- * and its failures are swallowed there.+ * `ensureForgeLabels`), the very first pause would fail. Existing labels are+ * accepted there, while other creation failures are surfaced.*/export async function applyBlockingLabel({ cli, cwd, env, number, exec = runCli } = {}) {if (!Number.isInteger(number)) return { success: false, error: 'no issue number' };