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: decline diff-only verdicts for verified empty dependency audits

[._.]/ Adam Eivyfbfd7c86fa5d
diff --git a/server/lib/README.md b/server/lib/README.md
index 219ce4f56b..358bb08118 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -536,7 +536,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `avatarStyles.js` | The CoS avatar-style vocabulary (#6253) — `AVATAR_STYLES` (`{id, label, webgl}`), `AVATAR_STYLE_IDS` (the `avatarStyle` zod enum in `cosStatusRoutes.js`), `AVATAR_STYLE_LABELS`, and `WEBGL_AVATAR_STYLE_IDS` (the three.js-stage set). `client/src/lib/avatarStyles.js` re-exports it for the picker and the lazy-load map. |
| `migrationMarker.js` | Shared marker-file helpers for one-time migration/repair/reconcile scripts — `markerExists(filename)` (boolean gate), `readMarker(filename)` (parsed payload or null), `writeMarker(filename, payload)` (atomic write). All anchor `filename` under `PATHS.data` and use `tryReadFile`/`atomicWrite` so a crash can't leave a truncated marker. |
| `goalFeatureMap.js` | Deterministic goal `category` → PortOS feature-area map (deep-links sourced from `NAV_COMMANDS`). `getGoalFeatureAreas(goal)` honors the per-goal `featureAreas` override, else the category default. Mirrored byte-for-byte to `client/src/lib/`. |
-| `goalFidelity.js` | Goal-fidelity review contract (#5994) — the value half of "does this diff deliver what was asked?", the question the quality-review chain structurally cannot answer because it never sees the request. `GOAL_FIDELITY_VERDICTS` (`ship` / `fix-first` / `rethink`, only `rethink` gating a run via `goalFidelityHoldsRun`), `taskObjective(task)` (the trusted operator-authored objective — the TASK's description + prompt block, never the agent's transcript, since a reviewer handed the transcript inherits the assumptions that produced the drift), `resolveGoalFidelityConfig(codeReview, chain)` (enabled/backend/model/effort, restricted to the local-LLM reviewers PortOS can call server-side and falling back to the quality chain's own local reviewer + its `<backend>Model`/`Effort` scalars), `normalizeGoalFidelityVerdict(parsed)` (`null` = nothing judged the run, never collapsed into a `ship` pass or a `rethink` hold) and `formatGoalFidelitySummary(review)`. `mergeOutcomeObjective(task)` / `mergeOutcomeReview({ number, prState })` / `GOAL_FIDELITY_SOURCE_FORGE` are the second answer shape: a review-loop follow-up is asked to LAND a change request, which no diff evidences, so its verdict is established from forge state (`MERGED` ⇒ `ship`, everything else ⇒ nothing). `MAX_OBJECTIVE_CHARS` / `MAX_FIDELITY_DIFF_CHARS` bound what crosses into a fixed-window local model. Pure. |
+| `goalFidelity.js` | Goal-fidelity review contract (#5994) — the value half of "does this diff deliver what was asked?", the question the quality-review chain structurally cannot answer because it never sees the request. `GOAL_FIDELITY_VERDICTS` (`ship` / `fix-first` / `rethink`, only `rethink` gating a run via `goalFidelityHoldsRun`), `taskObjective(task)` (the trusted operator-authored objective — the TASK's description + prompt block, never the agent's transcript, since a reviewer handed the transcript inherits the assumptions that produced the drift), `resolveGoalFidelityConfig(codeReview, chain)` (enabled/backend/model/effort, restricted to the local-LLM reviewers PortOS can call server-side and falling back to the quality chain's own local reviewer + its `<backend>Model`/`Effort` scalars), `normalizeGoalFidelityVerdict(parsed)` (`null` = nothing judged the run, never collapsed into a `ship` pass or a `rethink` hold) and `formatGoalFidelitySummary(review)`. `mergeOutcomeObjective(task)` / `mergeOutcomeReview({ number, prState })` / `GOAL_FIDELITY_SOURCE_FORGE` are the second answer shape: a review-loop follow-up is asked to LAND a change request, which no diff evidences, so its verdict is established from forge state (`MERGED` ⇒ `ship`, everything else ⇒ nothing). `isDependencyAuditSummaryDiff` recognizes only edits to the two existing `docs/DEPS.md` audit-summary fields; finalization declines diff-only review for that dependency-audit shape only after independently reading empty alert and PR inventories (no invented `ship` verdict). `MAX_OBJECTIVE_CHARS` / `MAX_FIDELITY_DIFF_CHARS` bound what crosses into a fixed-window local model. Pure. |
| `goalFidelityCalibration.js` | Goal-fidelity CALIBRATION contract — what happens when the follow-up investigation overturns a finding, i.e. the objective WAS delivered and the reviewer misjudged it. `GOAL_FIDELITY_CONTEXT_GAPS` is the closed vocabulary of what the reviewer could not see (`truncated-diff`, `truncated-objective`, `objective-omits-context`, `work-outside-diff`, `execution-step-misread`, `rubric-gap`, `other`), enforced ONLY by `normalizeGoalFidelityContextGap` (the report route takes a bounded string, so a near-miss gap name folds to `other` with its diagnosis intact instead of 400ing the report away). `GOAL_FIDELITY_REVIEW_SURFACES` addresses the reviewer's three context surfaces once — objective / diff / rubric — and `GOAL_FIDELITY_CONTEXT_GAP_FIXES` maps each gap onto one of them, so a rename cannot leave seven prose copies lying (`goalFidelityCalibration.pointers.test.js` walks the table against the real files). `goalFidelityCalibrationFingerprint(gap)` keys the dedup on the GAP alone, so many false positives from one blind spot fold into one fix instead of minting an agent each. `buildGoalFidelityCalibrationTask` composes the PortOS-side task body (including the do-not-disarm-the-detector contract) and `buildGoalFidelityFalsePositiveReportBlock` the `curl` instructions appended to a follow-up task, taking `apiBase` as an argument and the call shape from `agentApiToken.js`. I/O lives in `services/goalFidelityCalibration.js`. |
| `goalFidelityFollowUp.js` | Goal-fidelity FOLLOW-UP contract — what happens once the review HAS a finding, as opposed to what the finding is. `resolveGoalFidelityFollowUp(codeReview)` (`null` when neither action is configured; reads the RAW block, since a verdict already exists by the time this is asked), `normalizeGoalFidelityFollowUpTrigger` (shared with the settings projection so the form and the runtime cannot disagree), and `goalFidelityFollowUpApplies(review, trigger)` over `GOAL_FIDELITY_FOLLOW_UP_TRIGGERS` (`rethink` = only the verdict that holds a run, the default; `any-finding` also fires on the advisory `fix-first`). `goalFidelityFingerprint(task)` is the one dedup identity three parties share — the issue body marker (`goalFidelityIssueMarker` / `issueMatchesGoalFidelityMarker`), the tracker listing that reads it back, and the queued task fingerprint — keyed on taskType + app + objective slug so a perpetual task regenerating with a fresh id cannot re-file forever. `buildGoalFidelityIssue` / `buildGoalFidelityFollowUpTask` compose the bodies. Closure-free apart from `textUtils.js` (see the header); I/O lives in `services/goalFidelityFollowUp.js`. |
| `navManifest.js` | Single source of truth for nav (`⌘K` palette + voice). Add an entry when you add a page. Also `getNavPageForPath(pathname)` → `{ label, section, breadcrumb }` for the most specific command that owns a route (`null` for one nothing declares) — how user-facing copy NAMES a page it links to, instead of typing "Models → LLMs" beside the link and stranding it on the next move (#7414). `expandPageToken(text, runtime)` expands a `{page}` token in `text` using `getNavPageForPath(runtime?.manageUrl)`, falling back to generic prose rather than shipping a literal `{page}` (#7419). |
diff --git a/server/lib/goalFidelity.js b/server/lib/goalFidelity.js
index 917f2f576f..f4f743d75b 100644
--- a/server/lib/goalFidelity.js
+++ b/server/lib/goalFidelity.js
@@ -89,6 +89,29 @@ export function taskObjective(task) {
return `${joined.slice(0, MAX_OBJECTIVE_CHARS - marker.length)}${marker}`;
}
+/**
+ * The audit-note-only shape from #7899: exactly the two summary fields in an
+ * existing DEPS document. It cannot evidence forge queries or scanner runs.
+ * This is NOT an audit pass: the caller must also establish empty forge
+ * inventories before declining diff-only review. Any other edit, file, mode
+ * change, or truncated diff stays subject to ordinary fidelity review.
+ */
+export function isDependencyAuditSummaryDiff({ diff, truncated }) {
+ if (truncated || typeof diff !== 'string') return false;
+ const header = /^diff --git a\/docs\/DEPS\.md b\/docs\/DEPS\.md\nindex [a-f\d]+\.\.[a-f\d]+ 100644\n--- a\/docs\/DEPS\.md\n\+\+\+ b\/docs\/DEPS\.md\n/;
+ if (!header.test(diff)) return false;
+ const lines = diff.replace(header, '').trimEnd().split('\n');
+ if (!lines[0]?.startsWith('@@ ')) return false;
+ const changed = [];
+ for (const line of lines) {
+ if (line.startsWith(' ') || /^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/.test(line)) continue;
+ const field = line.match(/^([+-])\*\*(Last audited|Verdict):\*\* .+/);
+ if (!field) return false;
+ changed.push(`${field[1]}${field[2]}`);
+ }
+ return changed.length === 4 && new Set(changed).size === 4;
+}
+
/**
* Resolve the goal-fidelity settings block into `{ enabled, backend, model,
* effort }`, or `null` when the gate cannot run.
diff --git a/server/services/agentFinalization.goalFidelity.test.js b/server/services/agentFinalization.goalFidelity.test.js
index 7c1ec1b2bd..1dd72c3ab0 100644
--- a/server/services/agentFinalization.goalFidelity.test.js
+++ b/server/services/agentFinalization.goalFidelity.test.js
@@ -98,7 +98,7 @@ import { resolveForgeForRepo } from './git.js';
import { getAgentRecord } from './cosAgentLifecycle.js';
import { detectPrimaryCheckoutDrift, PRIMARY_CHECKOUT_MUTATED_REASON } from '../lib/primaryCheckoutGuard.js';
import { finalizeAgent } from './agentFinalization.js';
-import { cosEvents } from './cosEvents.js';
+import { cosEvents, emitLog } from './cosEvents.js';
import { completeAgentRun } from './agentRunTracking.js';
import { resolveFailedTaskUpdate } from './agentErrorAnalysis.js';
import { declaresNoCommitCriterion, getTaskOutputHook, isProgrammaticIoTaskType, resolveTaskHookType } from './taskTypeHooks.js';
@@ -216,6 +216,127 @@ describe('finalizeAgent — goal-fidelity gate', () => {
expect(args.backend).toBe('ollama');
});
+ describe('dependency audit summary with work outside the diff (#7899)', () => {
+ // Synthetic reconstruction: the deliverable is a completed inventory and
+ // audit, with no warranted bump. The only committed change is its note.
+ const task = {
+ id: 'dependency-audit', taskType: 'internal',
+ description: 'Inventory all security alerts, resolve open automated dependency PRs, then audit dependencies.',
+ metadata: {
+ analysisType: 'dependency-updates',
+ prompt: 'Paginate the alert and PR inventories. Report unavailable scanners as coverage gaps. Update dependencies only when warranted.',
+ },
+ };
+ const auditDiff = [
+ 'diff --git a/docs/DEPS.md b/docs/DEPS.md',
+ 'index abc1234..def5678 100644',
+ '--- a/docs/DEPS.md',
+ '+++ b/docs/DEPS.md',
+ '@@ -1,3 +1,3 @@',
+ ' # Dependency audit',
+ '-**Last audited:** previous sweep',
+ '-**Verdict:** prior audit results',
+ '+**Last audited:** routine sweep; no open security alerts',
+ '+**Verdict:** dependencies current; a peer-constrained upgrade remains tracked.',
+ '',
+ ].join('\n');
+ const outputBuffer = 'Paginated alerts: 0. Open PR inventory (limit 500): 0. Dependency guards passed. Python scanner unavailable; coverage gap disclosed.';
+ const finish = (overrides = {}) => finalize({ task, outputBuffer, ...overrides });
+
+ beforeEach(() => {
+ execGit.mockResolvedValue({ stdout: 'https://github.com/example/project.git', exitCode: 0 });
+ resolveForgeForRepo.mockResolvedValue({ cli: 'gh', host: 'github.com', owner: 'example', env: { GH_TOKEN: 'synthetic-token' } });
+ execGh.mockResolvedValue('[[]]');
+ runWindowDiffMock.mockResolvedValue({ diff: auditDiff, base: 'abc', truncated: false, reason: null });
+ runLocalGoalFidelityReviewMock.mockResolvedValue(verdict({
+ verdict: 'rethink', missing: ['Security inventory and bot PR resolution'],
+ unrequested: ['The audit note'], evidence: 'Only an audit note is visible.',
+ }));
+ });
+
+ it('declines the diff-only judgement after independent empty inventories, without inventing a ship verdict or follow-up', async () => {
+ await finish();
+
+ expect(completion()).toMatchObject({ success: true });
+ expect(completion().goalFidelity).toBeUndefined();
+ expect(execGh.mock.calls).toEqual(['dependabot/alerts', 'pulls'].map(resource => [
+ ['api', '--hostname', 'github.com', '--paginate', '--slurp', `repos/example/project/${resource}?state=open&per_page=100`],
+ 30_000, { cwd: '/example/worktree', env: { GH_TOKEN: 'synthetic-token' } },
+ ]));
+ expect(runLocalGoalFidelityReviewMock).not.toHaveBeenCalled();
+ expect(emitLog).toHaveBeenCalledWith('warn', expect.stringContaining('not judgeable from a diff'), expect.any(Object));
+ expect(cosEvents.emit).not.toHaveBeenCalledWith(GOAL_FIDELITY_HOLD_EVENT, expect.anything());
+ expect(runGoalFidelityFollowUpMock).not.toHaveBeenCalled();
+ expect(updateTaskMock).toHaveBeenCalledWith(task.id, { status: 'completed' }, 'internal');
+ });
+
+ it.each([
+ ['an open alert on a later page', 'dependabot/alerts', '[[], [{"number":42}]]'],
+ ['an open PR', 'pulls', '[[{"number":7}]]'],
+ ['an access-error response', 'dependabot/alerts', '{"message":"Forbidden"}'],
+ ['no pages returned', 'pulls', '[]'],
+ ['a malformed response', 'pulls', 'not JSON'],
+ ])('retains review and its hold for %s even when the transcript claims zero', async (_label, resource, response) => {
+ execGh.mockImplementation(async args => args.at(-1).includes(`/${resource}?`) ? response : '[[]]');
+ await finish();
+ expect(runLocalGoalFidelityReviewMock).toHaveBeenCalledWith(expect.objectContaining({ diff: auditDiff }));
+ expect(completion()).toMatchObject({ success: false, completionReason: GOAL_FIDELITY_CATEGORY });
+ });
+
+ it('does not fall back to ambient credentials when the owner-pinned resolver fails', async () => {
+ resolveForgeForRepo.mockRejectedValue(new Error('Credential unavailable'));
+ 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' });
+ await finish();
+ expect(execGh).not.toHaveBeenCalled();
+ expect(completion()).toMatchObject({ success: false, completionReason: GOAL_FIDELITY_CATEGORY });
+ });
+
+ it.each([
+ ['a dependency bump', `${auditDiff}diff --git a/package.json b/package.json\n+{"dependencies":{"example":"2.0.0"}}\n`, false],
+ ['an unrelated documentation edit', `${auditDiff}+Remove the supported installation instructions.\n`, false],
+ ['a different document', auditDiff.replaceAll('docs/DEPS.md', 'docs/INSTALL.md'), false],
+ ['a file mode change', auditDiff.replace('index ', 'old mode 100644\nnew mode 100755\nindex '), false],
+ ['a truncated diff', auditDiff, true],
+ ])('still judges %s without consulting forge inventories', async (_label, diff, truncated) => {
+ runWindowDiffMock.mockResolvedValue({ diff, base: 'abc', truncated, reason: null });
+ await finish();
+ expect(execGh).not.toHaveBeenCalled();
+ expect(runLocalGoalFidelityReviewMock).toHaveBeenCalledWith(expect.objectContaining({ diff }));
+ expect(completion()).toMatchObject({ success: false, completionReason: GOAL_FIDELITY_CATEGORY });
+ });
+
+ it('still holds an ordinary implementation task that delivered only the audit note', async () => {
+ await finish({ task: { id: 'feature-task', taskType: 'internal', description: 'Implement dependency inventory automation', metadata: {} } });
+ expect(execGh).not.toHaveBeenCalled();
+ expect(completion()).toMatchObject({ success: false, completionReason: GOAL_FIDELITY_CATEGORY });
+ });
+
+ it('judges selected issue requirements when a dependency task is also marked as a claim', async () => {
+ execGit.mockResolvedValue({ stdout: 'claim/issue-42', exitCode: 0 });
+ execGh.mockResolvedValue(JSON.stringify({ number: 42, title: 'Implement inventory', body: 'Implement automated dependency inventory.' }));
+ await finish({ task: { ...task, metadata: { ...task.metadata, claimFlow: true } } });
+ expect(execGh).toHaveBeenCalledTimes(1);
+ expect(runLocalGoalFidelityReviewMock).toHaveBeenCalledWith(expect.objectContaining({
+ objective: expect.stringContaining('Implement automated dependency inventory.'), diff: auditDiff,
+ }));
+ expect(completion()).toMatchObject({ success: false, completionReason: GOAL_FIDELITY_CATEGORY });
+ });
+
+ it('respects the disabled gate before performing extra forge queries', async () => {
+ getGoalFidelityConfigMock.mockResolvedValue(null);
+ await finish();
+ expect(execGh).not.toHaveBeenCalled();
+ expect(runLocalGoalFidelityReviewMock).not.toHaveBeenCalled();
+ });
+ });
+
it.each([
{ swarmCount: 3, analysisType: 'claim-issue' },
{ swarmCount: '3', analysisType: 'claim-issue-gitlab' },
diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.js
index 8f66ff3efa..63fd731b7f 100644
--- a/server/services/agentFinalization.js
+++ b/server/services/agentFinalization.js
@@ -47,6 +47,7 @@ import {
MAX_OBJECTIVE_CHARS,
formatGoalFidelitySummary,
goalFidelityHoldsRun,
+ isDependencyAuditSummaryDiff,
mergeOutcomeObjective,
mergeOutcomeReview,
taskObjective,
@@ -676,6 +677,35 @@ async function verifyMergeOutcome(workspacePath, mergeObjective) {
return { verdict: review.verdict, review: { ...review, checkedAt: new Date().toISOString() }, error: null };
}
+/**
+ * Independent evidence for the narrow audit-note-only decline below. Re-read
+ * both complete inventories with the repository's pinned credentials; neither
+ * transcript claims nor an inaccessible/malformed response can mean empty.
+ * Other forges and nonempty inventories retain the normal review path.
+ */
+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 { resolveForgeForRepo } = await import('./git.js');
+ const forge = await resolveForgeForRepo(workspacePath);
+ if (forge.cli !== 'gh' || forge.host !== origin.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',
+ `repos/${origin.owner}/${origin.repo}/${resource}?state=open&per_page=100`,
+ ], 30_000, { cwd: workspacePath, env: forge.env });
+ const pages = safeJSONParse(raw, null);
+ return Array.isArray(pages) && pages.length > 0
+ && pages.every(page => Array.isArray(page) && page.length === 0);
+ }));
+ return inventories.every(empty => empty);
+}
+
/**
* Goal-fidelity completion gate (#5994).
*
@@ -742,6 +772,17 @@ async function evaluateGoalFidelity({ task, workspacePath, startedAt }) {
// commit criterion, which is the check that actually owns that question.
if (reason || !diff) return noFidelityVerdict();
+ // #7899: an audit summary with no outstanding forge work cannot establish
+ // whether the inventory/scanners ran. Decline that exact shape, never stamp
+ // it `ship` or let a diff-only model invent missing bot resolutions. Ordinary
+ // changes (including dependency bumps), claim objectives, and incomplete or
+ // unavailable inventories keep the existing detector and hold behavior.
+ if (!claimFlow && resolveTaskHookType(task) === 'dependency-updates'
+ && isDependencyAuditSummaryDiff({ diff, truncated })
+ && await hasEmptyDependencyInventories(workspacePath).catch(() => false)) {
+ return noFidelityVerdict('Dependency audit summary is not judgeable from a diff: independent forge queries found no open alerts or PRs, but the diff cannot verify the audit execution or scanner coverage.');
+ }
+
const result = await runLocalGoalFidelityReview({
backend: config.backend,
model: config.model,