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
publish PortOS's own quality snapshot as .quality.json, through the managed-app publisher
[._.]/ Adam Eivy7561e7695303
diff --git a/quality-snapshot.json b/.quality.jsonsimilarity index 100%rename from quality-snapshot.jsonrename to .quality.jsondiff --git a/AGENTS.md b/AGENTS.mdindex d6c8145aef..a682b91eb7 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -248,7 +248,7 @@ This complements the Security Model (which governs the deployed product) — thi- **main**: active development. **release**: push `main` to `release` to trigger the GitHub Release workflow.- **Push pattern**: `git pull --rebase --autostash && git push`- **No per-branch changelog entries.** Individual PRs do not write a changelog file or fragment — commit messages are the record. `/do:release` synthesizes the release notes from the commit log since the last tag (grouped by feature/theme) when it runs, and writes the result to `.changelog/v{version}.md`. This replaced an earlier per-branch fragment workflow (`.changelog/next/*.md` + `npm run changelog:add`), which existed to avoid parallel branches conflicting on a shared `NEXT.md` — deriving notes from commits at release time sidesteps that problem entirely, since no branch writes to `.changelog/` anymore. Consequence: **write commit subjects/bodies for a human release-note reader**, not just for `git log` — see "Git commits and PRs" in the global instructions. Full rationale: `.changelog/README.md`.-- **Release quality snapshot**: Before a release, run `npm run quality:snapshot` on the install holding PortOS audit evidence and include `quality-snapshot.json` in the release commit. This publishes numeric local assessments only; no provider calls or private run prose. If no local evidence exists, retain the existing snapshot and report that it was not refreshed.+- **Release quality snapshot**: Before a release, run `npm run quality:snapshot` on the install holding PortOS audit evidence. It publishes numeric local assessments only — no provider calls, no private run prose — writing and committing the repo-root `.quality.json` through the same publisher every managed app uses. If no local evidence exists it commits nothing and reports that the existing snapshot was not refreshed.- **Versioning**: the version in `package.json` reflects the last release. Do not bump during development — `/do:release` handles it.- After each feature or bug fix, run `/simplify`, then commit and push.- **Capture deferred work, and decide rather than park it.** Deferred refactors/cleanups go into a filed GitHub issue labeled `plan`, specific enough to pick up cold — never left only in chat. When the sole obstacle is an undecided design choice, **make the call yourself** and file it ready-to-work; `future` / `needs-input` are last resorts. Invoke the `portos-file-issue` skill for the full labeling contract. Add independent slashdo dispatch hints (`model:light|medium|heavy`, `effort:low|medium|high|xhigh|max`) and contributor labels (`good first issue`, `help wanted`) only when the work you just inspected justifies them — omit an axis rather than guessing, never stamp `medium` on both, and never mark a wide mechanical sweep as a good first issue. Also stamp `planner:<model>` — a third, independent axis naming the model that WROTE the plan — taking the value verbatim from the "Planner Attribution" section of your own prompt (PortOS resolves it from the provider/model it dispatched you with); never guess it from what you believe you are, and omit it when your run was given none. Create missing labels lazily with slashdo/GitHub colors before `gh issue create`, use repeated `--label` flags, and keep category labels (`plan`, `ux`, `bug`, `tests`) intact.diff --git a/docs/API.md b/docs/API.mdindex 26d84df574..eb14b02b93 100644--- a/docs/API.md+++ b/docs/API.md@@ -100,7 +100,7 @@ legacy list for local Apps/Dashboard views.| GET | `/apps/:id/status` | Get PM2 status || GET | `/apps/:id/logs` | Get recent logs || POST | `/apps/:id/refresh-config` | Re-parse ecosystem config |-| POST | `/apps/:id/quality-snapshot` | Rebuild the app's numeric quality snapshot and commit it to `.quality.json` at its repo root (staged and committed as that one path; never pushed). Answers `{ success, published, path }` plus the commit `hash`, or a `reason` of `no-repo-path` / `not-a-repo` / `no-evidence` / `no-changes` when nothing was written. Not gated on the app's `publishQualitySnapshot` toggle — that toggle only automates the same publish after each audit. Any managed app's committed `.quality.json` is read back as a "Release snapshot" quality source. |+| POST | `/apps/:id/quality-snapshot` | Rebuild the app's numeric quality snapshot and commit it to `.quality.json` at its repo root (staged and committed as that one path; never pushed). Answers `{ success, published, path }` plus the commit `hash`, or a `reason` of `no-repo-path` / `not-a-repo` / `no-evidence` / `no-changes` when nothing was written. Not gated on the app's `publishQualitySnapshot` toggle — that toggle only automates the same publish after each audit. Any app's committed `.quality.json` is read back as a "Release snapshot" quality source, PortOS's own checkout included (`npm run quality:snapshot` is the same publish, run from the release step). |### Processes & Logsdiff --git a/docs/decisions/2026-09-10-portos-quality-federation.md b/docs/decisions/2026-09-10-portos-quality-federation.mdindex fc4b6795b7..cf74f8480d 100644--- a/docs/decisions/2026-09-10-portos-quality-federation.md+++ b/docs/decisions/2026-09-10-portos-quality-federation.md@@ -107,3 +107,23 @@ and original dates still apply, a 4 MiB cap, and the records are labeledfork ignores the file. The content stays numeric-only — no summaries, paths, runids or app names — so committing it to a public repository leaks nothing thefederation wire contract would not already carry.++## September 15: one snapshot file, one publisher++The two sections above left PortOS publishing a root `quality-snapshot.json`+through its own script and reading it through its own branch in `releasePayload`,+beside every managed app's `.quality.json` — same bytes, same schema, same+guards, two names and two code paths kept in step by hand.++PortOS is a managed app with a `repoPath` like any other, so its release snapshot+is now that same `.quality.json` at the checkout root, written by the same+publisher and read by the same reader. The per-app `publishQualitySnapshot`+toggle automates it for PortOS too, and stays **off by default there**: an audit+that commits into the primary checkout on its own is opt-in, since that checkout+is also where CoS worktrees and branches are managed. `npm run quality:snapshot`+remains the explicit release trigger and now commits the file itself.++The rename is a git rename of tracked, derived content — no migration, since+`scripts/migrations/` governs `data/` paths and there is no install state to+carry. A fork that published under the old name resolves one rename conflict;+worst case it regenerates the file from its own database on the next publish.diff --git a/scripts/publish-quality-snapshot.js b/scripts/publish-quality-snapshot.jsindex 964d5c7a08..cf41dfd7b6 100644--- a/scripts/publish-quality-snapshot.js+++ b/scripts/publish-quality-snapshot.js@@ -1,13 +1,20 @@-/** Explicit, local-only release step: no provider calls and no peer evidence. */-import { writeFile } from 'node:fs/promises';-import { join } from 'node:path';-import { PATHS } from '../server/lib/paths.js';-import { buildQualitySnapshot } from '../server/services/appQualityFederation.js';+/**+ * Explicit, local-only release step: no provider calls and no peer evidence.+ *+ * PortOS publishes its own `.quality.json` through the same publisher every other+ * managed app uses — this command is the manual trigger, equivalent to the audit+ * hook the app's `publishQualitySnapshot` toggle automates.+ */+import { getAppById, PORTOS_APP_ID } from '../server/services/apps.js';+import { publishAppQualitySnapshot, APP_QUALITY_SNAPSHOT_FILENAME } from '../server/services/appQualitySnapshotFile.js';const { close } = await import('../server/lib/db.js');await (async () => {- const snapshot = await buildQualitySnapshot();- if (!snapshot?.measurements.length) throw new Error('No local quality evidence to publish; existing snapshot preserved');- await writeFile(join(PATHS.root, 'quality-snapshot.json'), `${JSON.stringify(snapshot, null, 2)}\n`);- console.log(`Published ${snapshot.measurements.length} numeric assessments to quality-snapshot.json`);+ const app = await getAppById(PORTOS_APP_ID);+ if (!app) throw new Error('PortOS app record not found; cannot publish a quality snapshot');+ const result = await publishAppQualitySnapshot(app);+ // `no-changes` is a success: the committed snapshot already matches the evidence.+ if (!result.published && result.reason !== 'no-changes') {+ throw new Error(`Nothing published (${result.reason}); existing ${APP_QUALITY_SNAPSHOT_FILENAME} preserved`);+ }})().finally(close);diff --git a/server/services/appQuality.js b/server/services/appQuality.jsindex a5e80547fe..3c9df2e779 100644--- a/server/services/appQuality.js+++ b/server/services/appQuality.js@@ -39,7 +39,7 @@ export async function enrichAppsWithQuality(apps, deps = {}) {console.error(`❌ App quality unavailable: ${err.message}`);return null;});- // Shipped evidence: PortOS's own snapshot file, or any managed app's committed `.quality.json`.+ // Shipped evidence: any app's committed `.quality.json`.// One unreadable checkout (git spawn failure, timeout) must cost that app its release// records, never the whole list — same posture as the peer collect below.const releases = await Promise.all(apps.map(app => readReleaseQuality(deps, app).catch(() => [])));diff --git a/server/services/appQualityFederation.js b/server/services/appQualityFederation.jsindex 3a137e0dc4..23502d53af 100644--- a/server/services/appQualityFederation.js+++ b/server/services/appQualityFederation.js@@ -1,6 +1,4 @@/** Read-through federation of numeric app audit evidence; never exports prose or relays peers. */-import { readFile } from 'node:fs/promises';-import { join } from 'node:path';import { PATHS } from '../lib/paths.js';import { createHash } from 'node:crypto';import { z } from 'zod';@@ -30,11 +28,16 @@ const payloadSchema = z.object({measurements: z.array(measurementSchema).max(10000),}).strict();+// PortOS's own app record always carries a repoPath; the bare `{ id: PORTOS_APP_ID }`+// form used for self-directed calls resolves to this install's checkout.+const appRepoPath = app => app.repoPath || (app.id === PORTOS_APP_ID ? PATHS.root : null);+// Match repositories without sharing remote URLs, names, credentials or local paths.// Independent versions of the same repository intentionally contribute to one score.async function repositoryKey(deps, app = { id: PORTOS_APP_ID }) {- if (app.id !== PORTOS_APP_ID && !app.repoPath) return null;- const origin = await (deps.getOriginInfo || getOriginInfo)(app.repoPath);+ const repoPath = appRepoPath(app);+ if (!repoPath) return null;+ const origin = await (deps.getOriginInfo || getOriginInfo)(repoPath);return origin.host && origin.fullName ? hash(`${origin.host}/${origin.fullName}`.toLowerCase()) : null;}@@ -130,21 +133,14 @@ export async function collectAppQuality(app, days, deps = {}) {}/**- * PortOS reads its own committed `quality-snapshot.json`; every other managed app- * reads a `.quality.json` at its repo root. Both files are the same numeric- * snapshot shape and get the same guards — repository match, no future dates, 4 MiB cap.+ * Every app — PortOS's own checkout included — reads the `.quality.json` at its+ * repo root, under the same guards: repository match, no future dates, 4 MiB cap.*/async function releasePayload(deps, app) {- let raw = null;- if (app.id === PORTOS_APP_ID) {- const body = await (deps.readSnapshot || (() => readFile(join(PATHS.root, 'quality-snapshot.json'), 'utf8')))().catch(() => null);- // jsonIo stays out of this widely-reached module's static closure (import budget).- if (body && Buffer.byteLength(body) <= MAX_PAYLOAD_BYTES) raw = await Promise.resolve().then(() => JSON.parse(body)).catch(() => null);- } else if (app.repoPath) {- const { readAppQualitySnapshotFile } = await import('./appQualitySnapshotFile.js');- raw = await readAppQualitySnapshotFile(app.repoPath, deps);- }- const parsed = payloadSchema.safeParse(raw);+ const repoPath = appRepoPath(app);+ if (!repoPath) return null;+ const { readAppQualitySnapshotFile } = await import('./appQualitySnapshotFile.js');+ const parsed = payloadSchema.safeParse(await readAppQualitySnapshotFile(repoPath, deps));return parsed.success ? parsed.data : null;}diff --git a/server/services/appQualityFederation.test.js b/server/services/appQualityFederation.test.jsindex ac5acf05bd..912774ee20 100644--- a/server/services/appQualityFederation.test.js+++ b/server/services/appQualityFederation.test.js@@ -11,7 +11,7 @@ const row = (category, score, assessed_at = '2026-09-10T10:00:00Z', extra = {})report: { version: 1, category, score, worstSeverity: 5, coverage: 'broad', confidence: 'high',summary: 'Private paths /Users/person/project and audit narrative', scannedFiles: 12, totalFiles: 12 }, ...extra,});-const deps = rows => ({ now, getOriginInfo, readSnapshot: async () => null, getPeers: async () => [peer], query: vi.fn(async () => ({ rows })) });+const deps = rows => ({ now, getOriginInfo, readFile: async () => null, getPeers: async () => [peer], query: vi.fn(async () => ({ rows })) });const response = payload => new Response(JSON.stringify(payload), { status: 200 });// Uniquely pins numeric-only privacy, peer consent and cross-install score convergence.@@ -102,14 +102,19 @@ it('matches managed repositories with different local ids and excludes other oriexpect(await exportPortosQuality(peer.instanceId, 30, source, '0'.repeat(64))).toBeNull();});+// PortOS's own release evidence goes through the same `.quality.json` path as+// every managed app: same filename, same reader, same guards.it('loads release evidence without peers and never re-exports it', async () => {const payload = await buildQualitySnapshot(undefined, 30, deps([row('security', 82)]));- const local = { ...deps([]), getPeers: async () => [], readSnapshot: async () => JSON.stringify(payload) };+ const readPaths = [];+ const local = { ...deps([]), getPeers: async () => [],+ readFile: async path => { readPaths.push(path); return JSON.stringify(payload); } };expect((await enrichAppsWithQuality([{ id: 'portos-default' }], local))[0].quality.score).toBe(82);+ expect(readPaths.every(path => path.endsWith('.quality.json'))).toBe(true);expect((await getAppQualityHistory({ id: 'portos-default' }, 30, local)).points.at(-1).score).toBe(82);expect((await buildQualitySnapshot(undefined, 30, local)).measurements).toEqual([]);expect(await readReleaseQuality({ ...local, getOriginInfo: async () => ({ host: 'github.com', fullName: 'fork/PortOS' }) })).toEqual([]);- expect(await readReleaseQuality({ ...local, readSnapshot: async () => 'broken' })).toEqual([]);+ expect(await readReleaseQuality({ ...local, readFile: async () => 'broken' })).toEqual([]);});it('reads a managed app\'s committed .quality.json as release evidence and rejects a foreign or broken one', async () => {@@ -125,13 +130,12 @@ it('reads a managed app\'s committed .quality.json as release evidence and rejecexpect((await enrichAppsWithQuality([managed], local))[0].quality.score).toBe(76);expect((await getAppQualityHistory(managed, 30, local)).points.at(-1).score).toBe(76);- // PortOS's own root snapshot must not be read for a managed app, and vice versa.+ // A different fork's snapshot is never mixed in.expect(await readReleaseQuality({ ...local, getOriginInfo: async () => ({ host: 'github.com', fullName: 'owner/other' }) }, managed)).toEqual([]);expect(await readReleaseQuality(file('not json'), managed)).toEqual([]);expect(await readReleaseQuality(file(JSON.stringify({ ...published, schemaVersion: 2 })), managed)).toEqual([]);expect(await readReleaseQuality(file(JSON.stringify({ quality: published })), managed)).toEqual([]);expect(await readReleaseQuality(local, { id: 'local-id' })).toEqual([]);- expect(await readReleaseQuality(local)).toEqual([]);});it('keeps one broken checkout from failing the whole list or its own history read', async () => {diff --git a/server/services/appQualitySnapshotFile.js b/server/services/appQualitySnapshotFile.jsindex 9a272aa0c0..fe09f52a4b 100644--- a/server/services/appQualitySnapshotFile.js+++ b/server/services/appQualitySnapshotFile.js@@ -1,8 +1,11 @@/**- * `.quality.json` — the numeric quality snapshot a managed app can carry at its- * repo root. The file IS a `buildQualitySnapshot` result verbatim- * (`{ schemaVersion, repository, measurements }`), byte-shaped exactly like the- * root `quality-snapshot.json` PortOS publishes for itself.+ * `.quality.json` — the numeric quality snapshot a repository carries at its+ * root. The file IS a `buildQualitySnapshot` result verbatim+ * (`{ schemaVersion, repository, measurements }`).+ *+ * PortOS's own checkout is not special: it is a managed app like any other, so+ * its release snapshot is this same file, written by this same publisher, under+ * this same per-app `publishQualitySnapshot` toggle.** The filename is deliberately generic and PortOS-agnostic: it is generated* data any tool can read, not PortOS configuration. Publishing is opt-in per app@@ -16,7 +19,7 @@ export const APP_QUALITY_SNAPSHOT_FILENAME = '.quality.json';export const APP_QUALITY_SNAPSHOT_MAX_BYTES = 4 * 1024 * 1024;const snapshotPath = repoPath => join(repoPath, APP_QUALITY_SNAPSHOT_FILENAME);-// Byte-identical to scripts/publish-quality-snapshot.js so the two files stay comparable.+// Byte-identical across every publisher so two files of the same snapshot compare equal.const serialize = snapshot => `${JSON.stringify(snapshot, null, 2)}\n`;/** Raw bytes, or null when absent/unreadable/oversize. The publish path needs the