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: record quality snapshots per UTC date and collapse same-day reruns
Adam Eivy72c7df06c397
diff --git a/.quality.json b/.quality.jsonindex 69d9508bc4..b44db95d70 100644--- a/.quality.json+++ b/.quality.json@@ -47,127 +47,127 @@"high"],"measurements": [- ["2026-09-10T06:14:17.032Z",7,68,5,0,1,4175,4175],- ["2026-09-10T08:32:49.922Z",25,70,5,0,1,7278,7278],- ["2026-09-10T10:25:44.286Z",19,72,5,0,2,3763,3763],- ["2026-09-10T12:38:20.981Z",3,58,6,0,1,4185,4185],- ["2026-09-10T14:41:26.439Z",21,68,5,0,1,4186,4186],- ["2026-09-10T17:06:43.676Z",2,64,7,0,1,4185,4185],- ["2026-09-10T19:06:38.953Z",15,76,5,0,1,239,239],- ["2026-09-10T23:59:42.485Z",24,94,0,0,2,7462,7462],- ["2026-09-11T00:11:45.376Z",9,82,6,0,2,7367,7367],- ["2026-09-11T00:19:27.463Z",26,82,8,0,2,7291,7291],- ["2026-09-11T02:09:13.557Z",0,68,8,0,2,1713,1713],- ["2026-09-11T02:45:28.794Z",28,82,6,0,2,2541,2541],- ["2026-09-11T04:48:25.502Z",18,86,4,0,1,7334,7334],- ["2026-09-11T05:25:58.268Z",16,71,8,0,2,4188,4188],- ["2026-09-11T05:26:04.263Z",30,58,8,0,2,1598,1598],- ["2026-09-11T05:26:14.358Z",1,72,7,0,1,371,371],- ["2026-09-11T05:26:52.844Z",20,62,6,0,2,4191,4191],- ["2026-09-11T06:13:55.436Z",14,68,8,0,1,7364,7364],- ["2026-09-11T19:44:53.227Z",27,null,0,3,2,8140,8140],- ["2026-09-11T19:55:10.104Z",29,74,8,0,2,2520,2520],- ["2026-09-11T20:00:38.410Z",11,76,5,0,2,1595,1595],- ["2026-09-11T20:05:26.381Z",6,78,7,0,2,7182,7182],- ["2026-09-11T20:13:57.414Z",4,78,7,0,2,8140,8140],- ["2026-09-11T20:19:43.474Z",8,82,5,0,2,3139,3139],- ["2026-09-11T22:12:39.345Z",21,72,6,0,1,7341,7341],- ["2026-09-11T23:24:29.322Z",3,61,7,0,2,6526,6526],- ["2026-09-12T05:33:12.949Z",7,84,5,0,1,7447,7447],- ["2026-09-12T05:44:02.767Z",25,82,5,0,1,7392,7392],- ["2026-09-12T05:52:50.597Z",19,82,5,0,1,3809,3809],- ["2026-09-12T06:18:10.363Z",21,82,6,0,1,7404,7404],- ["2026-09-12T06:34:32.069Z",2,79,6,0,1,7396,7396],- ["2026-09-12T06:44:46.386Z",15,78,7,0,1,7598,7598],- ["2026-09-12T07:02:07.868Z",20,75,6,0,1,7389,7389],- ["2026-09-12T14:24:37.137Z",4,95,0,0,1,7952,7952],- ["2026-09-12T14:24:52.808Z",6,78,8,0,1,4237,4237],- ["2026-09-12T14:55:53.463Z",1,82,6,0,1,7393,7393],- ["2026-09-12T14:56:09.495Z",10,82,6,0,1,7389,7389],- ["2026-09-12T16:22:39.982Z",3,78,4,0,1,3823,3823],- ["2026-09-12T22:07:58.415Z",30,68,6,1,1,7424,7424],- ["2026-09-12T22:47:33.908Z",0,73,7,0,2,1607,1607],- ["2026-09-12T22:47:42.163Z",16,80,7,0,1,4213,4213],- ["2026-09-12T22:47:50.466Z",14,62,8,1,1,7798,7798],- ["2026-09-12T22:48:00.742Z",29,74,6,0,2,1603,1603],- ["2026-09-13T03:16:17.962Z",14,80,7,1,2,2600,4238],- ["2026-09-13T05:21:50.077Z",30,78,5,0,2,247,247],- ["2026-09-17T01:00:58.478Z",0,68,6,0,1,4385,4385],- ["2026-09-17T01:01:17.886Z",2,78,5,0,1,4354,4354],- ["2026-09-17T04:14:14.575Z",20,68,7,0,2,4356,4356],- ["2026-09-21T11:00:03.506Z",25,78,4,0,2,8785,8785],- ["2026-09-21T22:10:15.312Z",20,55,7,1,1,2900,4518],- ["2026-09-22T16:24:31.577Z",29,62,8,0,2,1701,1701],- ["2026-09-22T16:24:54.078Z",19,62,5,0,1,8110,8110],- ["2026-09-22T16:37:36.903Z",9,76,7,0,2,7995,7995],- ["2026-09-22T19:28:42.988Z",20,80,4,0,1,8149,8149],- ["2026-09-23T06:17:15.844Z",0,80,6,0,1,1709,1709],- ["2026-09-23T06:17:20.885Z",29,58,7,0,1,1709,1709],- ["2026-09-23T16:45:14.446Z",19,64,7,0,2,4188,4188],- ["2026-09-24T18:01:22.980Z",24,34,9,0,2,8186,8186],- ["2026-09-24T18:32:25.248Z",9,84,0,1,1,3427,8257],- ["2026-09-24T18:34:31.917Z",26,78,7,0,2,8117,8117],- ["2026-09-24T18:56:29.947Z",21,72,6,0,1,8196,8196],- ["2026-09-24T19:44:21.021Z",0,83,3,0,2,2785,2785],- ["2026-09-24T19:52:25.288Z",15,88,0,1,1,653,653],- ["2026-09-24T19:54:23.842Z",28,78,6,0,2,8139,8139],- ["2026-09-24T20:10:50.587Z",18,78,4,1,1,2793,8122],- ["2026-09-24T20:50:58.251Z",16,82,7,0,2,4699,4699],- ["2026-09-24T21:14:42.342Z",10,83,4,0,2,8135,8135],- ["2026-09-24T22:24:28.000Z",30,82,6,0,1,1719,1719],- ["2026-09-24T22:38:15.425Z",14,71,7,0,2,8199,8199],- ["2026-09-24T23:00:10.616Z",25,58,5,1,1,8284,8288],- ["2026-09-24T23:02:51.189Z",19,78,4,0,1,4187,4187],- ["2026-09-24T23:06:32.153Z",1,78,7,0,2,8221,8221],- ["2026-09-24T23:36:25.598Z",29,60,8,0,2,2786,2786],- ["2026-09-25T00:36:21.497Z",11,78,4,0,2,4684,4684],- ["2026-09-25T01:04:41.131Z",2,74,5,1,1,8215,8215],- ["2026-09-25T01:48:08.048Z",6,84,5,0,1,8208,8208],- ["2026-09-25T01:58:20.646Z",4,95,0,0,2,8780,8780],- ["2026-09-25T02:30:25.626Z",8,82,4,0,1,3525,3525],- ["2026-09-25T05:16:10.372Z",12,76,6,0,1,8287,8287],- ["2026-09-25T15:32:09.819Z",24,64,7,1,1,700,4657],- ["2026-09-25T16:08:41.730Z",14,66,8,1,1,2897,8208],- ["2026-09-25T16:16:51.790Z",25,72,5,0,1,8208,8208],- ["2026-09-25T16:24:01.274Z",29,60,7,0,1,1756,1756],- ["2026-09-25T16:35:06.601Z",20,72,5,0,1,4658,4658],- ["2026-09-25T16:41:48.754Z",3,65,5,0,1,4208,4208],- ["2026-09-25T16:52:16.793Z",7,72,5,0,1,8208,8208],- ["2026-09-25T16:59:35.265Z",17,78,6,1,1,20,48],- ["2026-09-25T17:02:56.778Z",13,62,7,1,1,2285,4665],- ["2026-09-25T17:10:37.569Z",23,74,6,1,1,60,8201],- ["2026-09-25T17:18:03.615Z",22,72,6,0,1,4652,4652],- ["2026-09-25T23:46:41.843Z",21,78,6,0,1,8304,8304],- ["2026-09-26T00:07:11.490Z",29,78,6,0,1,4640,4640],- ["2026-09-26T00:20:58.672Z",3,90,0,0,1,7384,7384],- ["2026-09-26T00:21:49.202Z",7,78,6,0,1,8953,8953],- ["2026-09-26T00:46:45.291Z",12,82,5,0,1,8240,8240],- ["2026-09-26T00:46:53.553Z",2,78,5,0,1,8227,8227],- ["2026-09-26T02:22:31.093Z",25,82,4,0,1,8233,8233],- ["2026-09-26T02:51:49.538Z",22,78,6,0,1,8304,8304],- ["2026-09-26T04:31:31.224Z",20,78,6,0,1,8386,8386],- ["2026-09-26T04:47:27.257Z",23,78,6,0,1,8438,8438],- ["2026-09-26T15:00:07.727Z",0,72,7,0,2,2827,2827],- ["2026-09-26T17:36:27.162Z",13,78,6,0,1,8349,8349],- ["2026-09-26T17:52:17.558Z",9,91,0,0,1,8370,8370],- ["2026-09-26T17:57:21.223Z",15,84,6,0,1,8667,8667],- ["2026-09-26T18:03:57.642Z",18,82,4,0,1,8353,8353],- ["2026-09-26T18:17:55.775Z",1,68,8,0,1,8418,8418],- ["2026-09-26T18:26:09.992Z",17,68,7,0,1,150,150],- ["2026-09-26T18:57:12.634Z",14,68,8,0,1,8655,8655],- ["2026-09-26T18:57:19.410Z",24,55,9,0,1,8350,8350],- ["2026-09-27T01:32:19.005Z",1,77,7,0,1,8357,8357],- ["2026-09-27T01:32:29.224Z",14,76,8,0,1,8476,8476],- ["2026-09-27T12:00:05.193Z",7,75,5,0,1,9282,9282],- ["2026-09-27T14:00:05.617Z",6,72,8,0,2,8399,8399],- ["2026-09-27T17:00:07.905Z",9,82,6,0,1,8441,8441],- ["2026-09-27T19:55:06.468Z",24,35,9,0,1,8430,8430],- ["2026-09-27T19:55:14.973Z",17,65,8,0,1,65,65],- ["2026-09-29T00:15:42.410Z",24,88,0,1,1,2518,9458],- ["2026-09-29T00:15:53.877Z",17,88,4,1,1,14,14],- ["2026-09-29T00:16:02.978Z",7,72,3,1,1,9458,9458],- ["2026-09-29T00:16:19.000Z",5,82,4,1,1,2563,2563],- ["2026-09-29T00:35:10.401Z",0,78,7,0,2,2902,2902],- ["2026-09-29T00:36:00.518Z",6,78,7,0,1,8581,8581]+ ["2026-09-10",2,64,7,0,1,4185,4185],+ ["2026-09-10",3,58,6,0,1,4185,4185],+ ["2026-09-10",7,68,5,0,1,4175,4175],+ ["2026-09-10",15,76,5,0,1,239,239],+ ["2026-09-10",19,72,5,0,2,3763,3763],+ ["2026-09-10",21,68,5,0,1,4186,4186],+ ["2026-09-10",24,94,0,0,2,7462,7462],+ ["2026-09-10",25,70,5,0,1,7278,7278],+ ["2026-09-11",0,68,8,0,2,1713,1713],+ ["2026-09-11",1,72,7,0,1,371,371],+ ["2026-09-11",3,61,7,0,2,6526,6526],+ ["2026-09-11",4,78,7,0,2,8140,8140],+ ["2026-09-11",6,78,7,0,2,7182,7182],+ ["2026-09-11",8,82,5,0,2,3139,3139],+ ["2026-09-11",9,82,6,0,2,7367,7367],+ ["2026-09-11",11,76,5,0,2,1595,1595],+ ["2026-09-11",14,68,8,0,1,7364,7364],+ ["2026-09-11",16,71,8,0,2,4188,4188],+ ["2026-09-11",18,86,4,0,1,7334,7334],+ ["2026-09-11",20,62,6,0,2,4191,4191],+ ["2026-09-11",21,72,6,0,1,7341,7341],+ ["2026-09-11",26,82,8,0,2,7291,7291],+ ["2026-09-11",27,null,0,3,2,8140,8140],+ ["2026-09-11",28,82,6,0,2,2541,2541],+ ["2026-09-11",29,74,8,0,2,2520,2520],+ ["2026-09-11",30,58,8,0,2,1598,1598],+ ["2026-09-12",0,73,7,0,2,1607,1607],+ ["2026-09-12",1,82,6,0,1,7393,7393],+ ["2026-09-12",2,79,6,0,1,7396,7396],+ ["2026-09-12",3,78,4,0,1,3823,3823],+ ["2026-09-12",4,95,0,0,1,7952,7952],+ ["2026-09-12",6,78,8,0,1,4237,4237],+ ["2026-09-12",7,84,5,0,1,7447,7447],+ ["2026-09-12",10,82,6,0,1,7389,7389],+ ["2026-09-12",14,62,8,1,1,7798,7798],+ ["2026-09-12",15,78,7,0,1,7598,7598],+ ["2026-09-12",16,80,7,0,1,4213,4213],+ ["2026-09-12",19,82,5,0,1,3809,3809],+ ["2026-09-12",20,75,6,0,1,7389,7389],+ ["2026-09-12",21,82,6,0,1,7404,7404],+ ["2026-09-12",25,82,5,0,1,7392,7392],+ ["2026-09-12",29,74,6,0,2,1603,1603],+ ["2026-09-12",30,68,6,1,1,7424,7424],+ ["2026-09-13",14,80,7,1,2,2600,4238],+ ["2026-09-13",30,78,5,0,2,247,247],+ ["2026-09-17",0,68,6,0,1,4385,4385],+ ["2026-09-17",2,78,5,0,1,4354,4354],+ ["2026-09-17",20,68,7,0,2,4356,4356],+ ["2026-09-21",20,55,7,1,1,2900,4518],+ ["2026-09-21",25,78,4,0,2,8785,8785],+ ["2026-09-22",9,76,7,0,2,7995,7995],+ ["2026-09-22",19,62,5,0,1,8110,8110],+ ["2026-09-22",20,80,4,0,1,8149,8149],+ ["2026-09-22",29,62,8,0,2,1701,1701],+ ["2026-09-23",0,80,6,0,1,1709,1709],+ ["2026-09-23",19,64,7,0,2,4188,4188],+ ["2026-09-23",29,58,7,0,1,1709,1709],+ ["2026-09-24",0,83,3,0,2,2785,2785],+ ["2026-09-24",1,78,7,0,2,8221,8221],+ ["2026-09-24",9,84,0,1,1,3427,8257],+ ["2026-09-24",10,83,4,0,2,8135,8135],+ ["2026-09-24",14,71,7,0,2,8199,8199],+ ["2026-09-24",15,88,0,1,1,653,653],+ ["2026-09-24",16,82,7,0,2,4699,4699],+ ["2026-09-24",18,78,4,1,1,2793,8122],+ ["2026-09-24",19,78,4,0,1,4187,4187],+ ["2026-09-24",21,72,6,0,1,8196,8196],+ ["2026-09-24",24,34,9,0,2,8186,8186],+ ["2026-09-24",25,58,5,1,1,8284,8288],+ ["2026-09-24",26,78,7,0,2,8117,8117],+ ["2026-09-24",28,78,6,0,2,8139,8139],+ ["2026-09-24",29,60,8,0,2,2786,2786],+ ["2026-09-24",30,82,6,0,1,1719,1719],+ ["2026-09-25",2,74,5,1,1,8215,8215],+ ["2026-09-25",3,65,5,0,1,4208,4208],+ ["2026-09-25",4,95,0,0,2,8780,8780],+ ["2026-09-25",6,84,5,0,1,8208,8208],+ ["2026-09-25",7,72,5,0,1,8208,8208],+ ["2026-09-25",8,82,4,0,1,3525,3525],+ ["2026-09-25",11,78,4,0,2,4684,4684],+ ["2026-09-25",12,76,6,0,1,8287,8287],+ ["2026-09-25",13,62,7,1,1,2285,4665],+ ["2026-09-25",14,66,8,1,1,2897,8208],+ ["2026-09-25",17,78,6,1,1,20,48],+ ["2026-09-25",20,72,5,0,1,4658,4658],+ ["2026-09-25",21,78,6,0,1,8304,8304],+ ["2026-09-25",22,72,6,0,1,4652,4652],+ ["2026-09-25",23,74,6,1,1,60,8201],+ ["2026-09-25",24,64,7,1,1,700,4657],+ ["2026-09-25",25,72,5,0,1,8208,8208],+ ["2026-09-25",29,60,7,0,1,1756,1756],+ ["2026-09-26",0,72,7,0,2,2827,2827],+ ["2026-09-26",1,68,8,0,1,8418,8418],+ ["2026-09-26",2,78,5,0,1,8227,8227],+ ["2026-09-26",3,90,0,0,1,7384,7384],+ ["2026-09-26",7,78,6,0,1,8953,8953],+ ["2026-09-26",9,91,0,0,1,8370,8370],+ ["2026-09-26",12,82,5,0,1,8240,8240],+ ["2026-09-26",13,78,6,0,1,8349,8349],+ ["2026-09-26",14,68,8,0,1,8655,8655],+ ["2026-09-26",15,84,6,0,1,8667,8667],+ ["2026-09-26",17,68,7,0,1,150,150],+ ["2026-09-26",18,82,4,0,1,8353,8353],+ ["2026-09-26",20,78,6,0,1,8386,8386],+ ["2026-09-26",22,78,6,0,1,8304,8304],+ ["2026-09-26",23,78,6,0,1,8438,8438],+ ["2026-09-26",24,55,9,0,1,8350,8350],+ ["2026-09-26",25,82,4,0,1,8233,8233],+ ["2026-09-26",29,78,6,0,1,4640,4640],+ ["2026-09-27",1,77,7,0,1,8357,8357],+ ["2026-09-27",6,72,8,0,2,8399,8399],+ ["2026-09-27",7,75,5,0,1,9282,9282],+ ["2026-09-27",9,82,6,0,1,8441,8441],+ ["2026-09-27",14,76,8,0,1,8476,8476],+ ["2026-09-27",17,65,8,0,1,65,65],+ ["2026-09-27",24,35,9,0,1,8430,8430],+ ["2026-09-29",0,78,7,0,2,2902,2902],+ ["2026-09-29",5,82,4,1,1,2563,2563],+ ["2026-09-29",6,78,7,0,1,8581,8581],+ ["2026-09-29",7,72,3,1,1,9458,9458],+ ["2026-09-29",17,88,4,1,1,14,14],+ ["2026-09-29",24,88,0,1,1,2518,9458]]}diff --git a/docs/decisions/2026-09-10-portos-quality-federation.md b/docs/decisions/2026-09-10-portos-quality-federation.mdindex 9a38f88bfb..3581cbeea1 100644--- a/docs/decisions/2026-09-10-portos-quality-federation.md+++ b/docs/decisions/2026-09-10-portos-quality-federation.md@@ -168,9 +168,8 @@ remains the bounded release projection: one row per UTC day and category, theReaders accept v1 `.quality.json` and, only when that file is absent, thehistorical `quality-snapshot.json` filename. A read never mutates the checkout.-Malformed rows, unknown keys, invalid dictionary indexes, duplicate UTC-day/category winners, a mismatched origin fingerprint, and oversize files fail-closed. A future `schemaVersion` is recognized and left unparsed.+Malformed rows, unknown keys, invalid dictionary indexes, a mismatched origin fingerprint, and oversize files fail+closed. Rows are date-only (`YYYY-MM-DD`); duplicate UTC day/category rows collapse to the latest run instead of failing. A future `schemaVersion` is recognized and left unparsed.`npm run quality:snapshot` writes canonical v2 whenever the database has currentevidence, including when the committed file is still valid v1. It does notdiff --git a/docs/features/app-quality.md b/docs/features/app-quality.mdindex 6ce2e03905..ae0b27d237 100644--- a/docs/features/app-quality.md+++ b/docs/features/app-quality.md@@ -131,7 +131,7 @@ left as it is.The checked-in schema is v2. It stores an opaque origin fingerprint, sortedcategory and enum dictionaries, and fixed rows`[assessedAt, categoryIndex, score, worstSeverity, coverageIndex, confidenceIndex, scannedFiles, totalFiles]`.-Scores stay nullable. Timestamps stay ISO instants. The file does not store+Scores stay nullable. `assessedAt` is a UTC date (`YYYY-MM-DD`); older files with full ISO instants are still read. The file does not storesummaries, paths, app names, agent ids, or `measurementId`. Same-timestampordering uses a transient digest of the row, computed when the file is read.@@ -163,8 +163,9 @@ be harder to validate, while the database is already the history.when the committed file is still v1. `npm run quality:snapshot -- --migrate`converts a v1 file or the historical filename to canonical v2 using only therows already stored, through the same pull request. A second publish of the-same normalized v2 snapshot does not open another pull request. Duplicate rows-for one UTC day and category are rejected rather than silently dropped.+same normalized v2 snapshot does not open another pull request. Rows sharing+one UTC day and category collapse to the latest on every read and write, so a+second run the same day replaces the first and older files upgrade on their next save.## Weekly quality schedulediff --git a/server/services/appQualitySnapshotFile.test.js b/server/services/appQualitySnapshotFile.test.jsindex e1adbb2a35..aed4a6218c 100644--- a/server/services/appQualitySnapshotFile.test.js+++ b/server/services/appQualitySnapshotFile.test.js@@ -91,7 +91,7 @@ it('lands a changed snapshot from a detached worktree so the PR branch stays attschemaVersion: 2,reportVersion: 1,categories: ['security'],- measurements: [['2026-09-10T10:00:00Z', 0, 82, 5, 0, 2, 12, 12]],+ measurements: [['2026-09-10', 0, 82, 5, 0, 2, 12, 12]],});expect(body.endsWith('\n')).toBe(true);expect(body).not.toMatch(/measurementId|Users|summary|app_id|agent-|github/);@@ -511,7 +511,7 @@ it('migrates a legacy file to v2 without inventing measurements or writing the lconst [path, body] = deps.writeFile.mock.calls[0];expect(path).toBe(join(worktreePath, '.quality.json'));expect(path.startsWith(app.repoPath)).toBe(false);- expect(JSON.parse(body).measurements).toEqual([['2026-09-10T10:00:00Z', 0, 82, 5, 0, 2, 12, 12]]);+ expect(JSON.parse(body).measurements).toEqual([['2026-09-10', 0, 82, 5, 0, 2, 12, 12]]);expect(deps.git.execGit).toHaveBeenCalledWith(['rm', '-f', '--', APP_QUALITY_LEGACY_SNAPSHOT_FILENAME], worktreePath);expect(deps.git.commit).toHaveBeenCalledWith(worktreePath,diff --git a/server/services/appQualitySnapshotFormat.js b/server/services/appQualitySnapshotFormat.jsindex 43fd91dd5b..d003e50076 100644--- a/server/services/appQualitySnapshotFormat.js+++ b/server/services/appQualitySnapshotFormat.js@@ -6,7 +6,8 @@* `quality-snapshot.json` body normalize to the same records; a future schema* is recognized and left for the publisher to report, not reinterpreted.*- * Rows are `[assessedAt, categoryIndex, score, worstSeverity, coverageIndex,+ * `assessedAt` is a UTC date (`YYYY-MM-DD`); one row per day per category, latest+ * run wins. Rows are `[assessedAt, categoryIndex, score, worstSeverity, coverageIndex,* confidenceIndex, scannedFiles, totalFiles]`. `measurementId` is not stored.* Same-timestamp selection uses the v1 id while a file still has one, otherwise* a transient digest of the normalized row (`releaseTieId`). The digest is not@@ -38,7 +39,10 @@ const REPORT_KEYS = new Set(['version', 'category', 'score', 'worstSeverity', 'cconst PLACEHOLDER_SUMMARY = 'Numeric assessment';// Z and numeric offsets are both ISO instants. Zod's default datetime() rejects// offsets, which would treat one UTC day as two when the date prefix differs.-const timestampSchema = z.iso.datetime({ offset: true });+const datetimeSchema = z.iso.datetime({ offset: true });+// Rows are stored date-only; full instants are still read (v1 and older v2 files).+const timestampSchema = { safeParse: value => (typeof value === 'string' && z.iso.date().safeParse(value).success+ ? { success: true } : datetimeSchema.safeParse(value)) };function compareText(a, b) {if (a < b) return -1;@@ -63,16 +67,22 @@ function isInt(value, min, max) {return typeof value === 'number' && Number.isInteger(value) && value >= min && value <= max;}-function duplicateDays(records) {- const seen = new Set();+/**+ * One row per UTC day per category: the latest assessment that day wins, and a+ * timestamp tie goes to the later-sorting row. Older files that stored several+ * runs per day collapse here, on every parse and every write, so no install has+ * to migrate. Returns null when a timestamp has no day.+ */+function collapseToDays(records) {+ const latest = new Map();for (const record of records) {const day = utcDay(record.assessedAt);- if (!day) return true;+ if (!day) return null;const key = `${day}|${record.category}`;- if (seen.has(key)) return true;- seen.add(key);+ const kept = latest.get(key);+ if (!kept || compareRecords(kept, record) <= 0) latest.set(key, record);}- return false;+ return [...latest.values()].map(record => ({ ...record, assessedAt: `${utcDay(record.assessedAt)}T00:00:00.000Z` }));}function numericReport(report) {@@ -97,7 +107,7 @@ function normalizeRecord(record, measurementId = null) {});if (!report) return null;return {- assessedAt: record.assessedAt,+ assessedAt: /^\d{4}-\d{2}-\d{2}$/.test(record.assessedAt) ? `${record.assessedAt}T00:00:00.000Z` : record.assessedAt,category: report.category,score: report.score,worstSeverity: report.worstSeverity,@@ -127,7 +137,7 @@ function canonicalize(repository, records) {const coverageIndex = new Map(QUALITY_COVERAGE_VALUES.map((value, index) => [value, index]));const confidenceIndex = new Map(QUALITY_CONFIDENCE_VALUES.map((value, index) => [value, index]));const measurements = [...records].sort(compareRecords).map(record => [- record.assessedAt,+ utcDay(record.assessedAt),categoryIndex.get(record.category),record.score,record.worstSeverity,@@ -162,8 +172,8 @@ export function serializeQualitySnapshot(repository, records) {if (!next) return null;normalized.push(next);}- if (duplicateDays(normalized)) return null;- return canonicalize(repository, normalized);+ const days = collapseToDays(normalized);+ return days ? canonicalize(repository, days) : null;}/**@@ -203,10 +213,11 @@ function parseV1(value) {if (!record) return { status: 'malformed' };records.push(record);}- if (duplicateDays(records)) return { status: 'malformed' };- const canonical = canonicalize(value.repository, records);+ const days = collapseToDays(records);+ if (!days) return { status: 'malformed' };+ const canonical = canonicalize(value.repository, days);return canonical- ? { status: 'v1', repository: value.repository, records, canonical }+ ? { status: 'v1', repository: value.repository, records: days, canonical }: { status: 'malformed' };}@@ -260,13 +271,14 @@ function parseV2(value) {}records.push(record);}- if (duplicateDays(records)) return { status: 'malformed' };+ const days = collapseToDays(records);+ if (!days) return { status: 'malformed' };// Readable, but not ours to rewrite: canonicalizing would drop the rows a// newer install wrote. Readers use the known records; writers leave the file.- if (unknownRows) return { status: 'future-categories', repository: value.repository, records, canonical: null };- const canonical = canonicalize(value.repository, records);+ if (unknownRows) return { status: 'future-categories', repository: value.repository, records: days, canonical: null };+ const canonical = canonicalize(value.repository, days);return canonical- ? { status: 'v2', repository: value.repository, records, canonical }+ ? { status: 'v2', repository: value.repository, records: days, canonical }: { status: 'malformed' };}diff --git a/server/services/appQualitySnapshotFormat.test.js b/server/services/appQualitySnapshotFormat.test.jsindex d07b035e80..d31c510fea 100644--- a/server/services/appQualitySnapshotFormat.test.js+++ b/server/services/appQualitySnapshotFormat.test.js@@ -65,8 +65,8 @@ it('serializes canonical v2 rows with stable indexes and no provenance', () => {coverage: [...QUALITY_COVERAGE_VALUES],confidence: [...QUALITY_CONFIDENCE_VALUES],measurements: [- ['2026-09-20T00:00:00.000Z', 0, 82, 5, 0, 2, 120, 120],- ['2026-09-21T00:00:00.000Z', 1, null, 0, 3, 0, 0, 4],+ ['2026-09-20', 0, 82, 5, 0, 2, 120, 120],+ ['2026-09-21', 1, null, 0, 3, 0, 0, 4],],});expect(text).toBe([@@ -90,8 +90,8 @@ it('serializes canonical v2 rows with stable indexes and no provenance', () => {' "high"',' ],',' "measurements": [',- ' ["2026-09-20T00:00:00.000Z",0,82,5,0,2,120,120],',- ' ["2026-09-21T00:00:00.000Z",1,null,0,3,0,0,4]',+ ' ["2026-09-20",0,82,5,0,2,120,120],',+ ' ["2026-09-21",1,null,0,3,0,0,4]',' ]','}','',@@ -136,7 +136,7 @@ it('reads retired task categories and emits them under their current audit name'expect(JSON.parse(parsed.canonical).categories).toEqual(['ui-lifecycle']);});-it('rejects future, unrecognized, malformed, duplicate-day, and invalid-index documents', () => {+it('rejects future, unrecognized, malformed, and invalid-index documents; collapses duplicate days', () => {expect(classifyQualitySnapshot('category\tscore\n').status).toBe('unrecognized');expect(classifyQualitySnapshot('{"quality":true}').status).toBe('unrecognized');expect(classifyQualitySnapshot(JSON.stringify({ schemaVersion: 3, repository })).status).toBe('future');@@ -147,7 +147,11 @@ it('rejects future, unrecognized, malformed, duplicate-day, and invalid-index dosecurity,{ ...security, assessedAt: '2026-09-19T22:30:00-04:00', score: 10 },]);- expect(classifyQualitySnapshot(JSON.stringify(sameDay)).status).toBe('malformed');+ const collapsed = classifyQualitySnapshot(JSON.stringify(sameDay));+ expect(collapsed.status).toBe('v1');+ expect(collapsed.records).toHaveLength(1);+ expect(collapsed.records[0].score).toBe(10);+ expect(JSON.parse(collapsed.canonical).measurements).toEqual([['2026-09-20', 0, 10, 5, 0, 2, 120, 120]]);const nextDay = v1Document([security,{ ...security, assessedAt: '2026-09-20T20:30:00-04:00', score: 70 },@@ -160,7 +164,15 @@ it('rejects future, unrecognized, malformed, duplicate-day, and invalid-index domeasurements: [['2026-09-20T00:00:00.000Z', 4, 82, 5, 0, 2, 120, 120]],}));expect(badIndex.status).toBe('malformed');- expect(serializeQualitySnapshot(repository, [security, { ...security, score: 1 }])).toBeNull();+ // Same day, same category: the later run replaces the earlier one.+ const replaced = serializeQualitySnapshot(repository, [+ { ...security, assessedAt: '2026-09-20T09:00:00.000Z', score: 1 },+ { ...security, assessedAt: '2026-09-20T18:00:00.000Z', score: 2 },+ { ...security, assessedAt: '2026-09-20T03:00:00.000Z', score: 3 },+ ]);+ expect(JSON.parse(replaced).measurements).toEqual([['2026-09-20', 0, 2, 5, 0, 2, 120, 120]]);+ // A date-only file (the canonical form) round-trips byte-for-byte.+ expect(classifyQualitySnapshot(replaced).canonical).toBe(replaced);});it('keeps v1 tie ids and orders v2 rows with a transient digest', () => {