@tequila99/githuman 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -2
- package/dist/cli/commands/mcp.js +112 -0
- package/dist/cli/commands/pi-acp.js +21 -0
- package/dist/cli/config.js +7 -1
- package/dist/cli/index.js +19 -8
- package/dist/cli/server-runtime.js +1 -0
- package/dist/server/adapters/agents/artifact-permission.js +88 -0
- package/dist/server/adapters/pi-acp/agent.js +98 -0
- package/dist/server/adapters/pi-acp/compatibility.js +57 -0
- package/dist/server/adapters/pi-acp/control.js +76 -0
- package/dist/server/adapters/pi-acp/errors.js +17 -0
- package/dist/server/adapters/pi-acp/extension.js +255 -0
- package/dist/server/adapters/pi-acp/launch.js +16 -0
- package/dist/server/adapters/pi-acp/mcp.js +153 -0
- package/dist/server/adapters/pi-acp/process.js +199 -0
- package/dist/server/adapters/pi-acp/session.js +409 -0
- package/dist/server/adapters/pi-acp/vendor/LICENSE +21 -0
- package/dist/server/adapters/pi-acp/vendor/README.md +29 -0
- package/dist/server/adapters/pi-acp/vendor/prompt.js +56 -0
- package/dist/server/app.js +94 -5
- package/dist/server/config/agents.js +4 -6
- package/dist/server/db/artifact-graph-migrations.js +56 -0
- package/dist/server/db/artifact-migrations.js +70 -0
- package/dist/server/db/artifact-review-migrations.js +24 -0
- package/dist/server/db/artifact-search-migrations.js +31 -0
- package/dist/server/db/artifact-validation-migrations.js +70 -0
- package/dist/server/db/index.js +3 -0
- package/dist/server/db/migrations.js +10 -0
- package/dist/server/db/sqlite-error.js +15 -0
- package/dist/server/db/transaction.js +40 -0
- package/dist/server/errors/artifacts.js +28 -0
- package/dist/server/errors/database.js +2 -0
- package/dist/server/hooks/access/require-access.js +8 -0
- package/dist/server/repositories/artifact-catalog.repo.js +283 -0
- package/dist/server/repositories/artifact-files.repo.js +181 -0
- package/dist/server/repositories/artifact-graph.repo.js +50 -0
- package/dist/server/repositories/artifact-search.repo.js +192 -0
- package/dist/server/repositories/artifact-transition.repo.js +85 -0
- package/dist/server/repositories/artifact-validation.repo.js +146 -0
- package/dist/server/repositories/notes-catalog.repo.js +2 -10
- package/dist/server/repositories/task.repo.js +114 -0
- package/dist/server/routes/agent.js +8 -1
- package/dist/server/routes/artifact-actions.js +129 -0
- package/dist/server/routes/artifact-agent.js +183 -0
- package/dist/server/routes/artifact-definitions.js +163 -0
- package/dist/server/routes/artifact-transitions.js +80 -0
- package/dist/server/routes/artifacts.js +111 -0
- package/dist/server/routes/events.js +5 -1
- package/dist/server/routes/project-files.js +90 -0
- package/dist/server/services/agent/agent-session.js +180 -10
- package/dist/server/services/agent/context-builder.js +30 -2
- package/dist/server/services/agent/session-registry.js +106 -2
- package/dist/server/services/agent/turn-task-context.js +1 -0
- package/dist/server/services/artifact-authorization.service.js +174 -0
- package/dist/server/services/artifact-definition.service.js +96 -0
- package/dist/server/services/artifact-export.service.js +44 -0
- package/dist/server/services/artifact-graph-validation.js +497 -0
- package/dist/server/services/artifact-graph.service.js +81 -0
- package/dist/server/services/artifact-lifecycle.service.js +343 -0
- package/dist/server/services/artifact-maintenance.service.js +55 -0
- package/dist/server/services/artifact-search.service.js +331 -0
- package/dist/server/services/artifact-storage.service.js +646 -0
- package/dist/server/services/artifact-transition.service.js +607 -0
- package/dist/server/services/artifact-type.service.js +74 -0
- package/dist/server/services/artifact-validation-jobs.service.js +518 -0
- package/dist/server/services/device-connections.js +9 -1
- package/dist/server/services/project-files.service.js +144 -0
- package/dist/server/services/review.service.js +6 -5
- package/dist/server/services/task.service.js +225 -0
- package/dist/server/utils/artifact-actor.js +13 -0
- package/dist/server/utils/artifact-page.js +42 -0
- package/dist/server/utils/take-within-bytes.js +16 -0
- package/dist/server/utils/text.js +7 -0
- package/dist/shared/agents/schemas.js +27 -0
- package/dist/shared/app/storage-constants.js +2 -0
- package/dist/shared/artifact-tools/descriptions.js +11 -0
- package/dist/shared/artifact-tools/instructions.js +14 -0
- package/dist/shared/artifact-tools/schemas.js +119 -0
- package/dist/shared/artifact-transitions/constants.js +21 -0
- package/dist/shared/artifact-transitions/schemas.js +111 -0
- package/dist/shared/artifact-transitions/transitions.js +61 -0
- package/dist/shared/artifact-transitions/types.js +1 -0
- package/dist/shared/artifacts/constants.js +34 -0
- package/dist/shared/artifacts/mcp-constants.js +24 -0
- package/dist/shared/artifacts/normalize.js +9 -0
- package/dist/shared/artifacts/schemas.js +820 -0
- package/dist/shared/artifacts/search.js +101 -0
- package/dist/shared/artifacts/types.js +1 -0
- package/dist/shared/events/schemas.js +1 -1
- package/dist/shared/events/types.js +1 -0
- package/dist/shared/git/constants.js +2 -0
- package/dist/shared/project-files/constants.js +18 -0
- package/dist/shared/project-files/schemas.js +35 -0
- package/dist/shared/project-files/types.js +1 -0
- package/dist/shared/tasks/schemas.js +261 -0
- package/dist/shared/tasks/types.js +1 -0
- package/dist/shared/utils/artifact-body.js +10 -0
- package/dist/shared/utils/canonical-json.js +22 -0
- package/dist/shared/utils/is-safe-prefixed-filename.js +10 -0
- package/dist/shared/utils/is-uuid.js +4 -2
- package/dist/shared/utils/is-valid-artifact-type-id.js +9 -0
- package/dist/shared/utils/is-valid-filename-prefix.js +13 -0
- package/dist/shared/utils/markdown-path.js +4 -0
- package/dist/shared/utils/pdf-path.js +4 -0
- package/dist/web/assets/AccessPage-Dvj0aCkm.js +1 -0
- package/dist/web/assets/AddButton-CMC9qf51.js +4 -0
- package/dist/web/assets/AddToAgentButton-BitTdCEg.js +1 -0
- package/dist/web/assets/AppPage-Cozv2vqG.js +1 -0
- package/dist/web/assets/ArtifactDefinitionPicker-BQOoU60k.js +3 -0
- package/dist/web/assets/ArtifactDefinitionPicker-D3qdrxlC.css +1 -0
- package/dist/web/assets/ArtifactsPage-BJR-XYYs.js +2 -0
- package/dist/web/assets/ArtifactsPage-Cu1xdYNf.css +1 -0
- package/dist/web/assets/CancelButton-mkxRHwoZ.js +1 -0
- package/dist/web/assets/ClosePopup-BtDeDZsk.js +1 -0
- package/dist/web/assets/CreateButton-zCmb7snC.js +1 -0
- package/dist/web/assets/CreateReviewFabButton-BCg1TvFh.js +1 -0
- package/dist/web/assets/DialogHeader-CPL9OtDV.css +1 -0
- package/dist/web/assets/DialogHeader-CQvAZVx7.js +1 -0
- package/dist/web/assets/{ErrorNotFound-DtnO85PU.js → ErrorNotFound-fXS367lZ.js} +1 -1
- package/dist/web/assets/{IndexPage-D5PvyGrX.css → IndexPage-5V5GLtgi.css} +1 -1
- package/dist/web/assets/IndexPage-DMTZyWQA.js +1 -0
- package/dist/web/assets/MainLayout-DWJ_-EMV.js +7 -0
- package/dist/web/assets/MainLayout-Dy74m_q1.css +1 -0
- package/dist/web/assets/NoteVisualEditor-5rHBQ3j0.js +1054 -0
- package/dist/web/assets/{NoteVisualEditor-BYikrY7Q.css → NoteVisualEditor-DE4ACTRJ.css} +1 -1
- package/dist/web/assets/NotesPage-C_eoCUl7.css +1 -0
- package/dist/web/assets/NotesPage-CjaxjLBW.js +4 -0
- package/dist/web/assets/{PdfPreview-kL_nk9my.js → PdfPreview-2NQ5gkjh.js} +2 -2
- package/dist/web/assets/ProjectFilePage-B-WUUxnq.js +1 -0
- package/dist/web/assets/QBtn-V3VXtJXi.js +1 -0
- package/dist/web/assets/QFab-CxpedhPI.js +1 -0
- package/dist/web/assets/QForm-ClpSneeD.js +1 -0
- package/dist/web/assets/QInput-BnqLJGXl.js +1 -0
- package/dist/web/assets/QScrollArea-js5dkUz1.js +1 -0
- package/dist/web/assets/QSpace-C7iAnGlU.js +1 -0
- package/dist/web/assets/QTabs-DIy5gWMb.js +1 -0
- package/dist/web/assets/QVirtualScroll-DkD0TczV.js +1 -0
- package/dist/web/assets/ReviewDetailPage-BgxcsTqY.css +1 -0
- package/dist/web/assets/ReviewDetailPage-Bmc8DmSu.js +1 -0
- package/dist/web/assets/ReviewsPage-DR1IWCmu.js +1 -0
- package/dist/web/assets/SearchInput-BRyN93Z1.js +1 -0
- package/dist/web/assets/StatusSwitcher-CpkH8BuC.js +1 -0
- package/dist/web/assets/{StatusSwitcher-D6i8_OfR.css → StatusSwitcher-DaE1ufAA.css} +1 -1
- package/dist/web/assets/TagFilterField-Bl3FBkB5.js +1 -0
- package/dist/web/assets/TagFilterField-DjUH0m3_.css +1 -0
- package/dist/web/assets/{TerminalView-617DZuPt.css → TerminalView-BCeke4xd.css} +1 -1
- package/dist/web/assets/{TerminalView-BsO_SZut.js → TerminalView-tEyLM5qZ.js} +12 -12
- package/dist/web/assets/{abnfDiagram-O67JEVCF-qUSrlp_c.js → abnfDiagram-O67JEVCF-DN9xiV9p.js} +1 -1
- package/dist/web/assets/{access-store-Q8nkv4Nb.js → access-store-CwkOl71l.js} +1 -1
- package/dist/web/assets/{agent-store-D2jgeBgi.js → agent-store-Grbx4jkz.js} +5 -5
- package/dist/web/assets/architecture-7GRP2DOG-DmaYCP8T.js +1 -0
- package/dist/web/assets/{architectureDiagram-NJMV4G6O-D7RC6OS2.js → architectureDiagram-NJMV4G6O-BVAJOucG.js} +1 -1
- package/dist/web/assets/{blockDiagram-BEXU5L5S-CmNtTpfK.js → blockDiagram-BEXU5L5S-TJAfSX44.js} +1 -1
- package/dist/web/assets/{c4Diagram-YGBWAQC7-CKCcu1qx.js → c4Diagram-YGBWAQC7-5UHyT_tW.js} +1 -1
- package/dist/web/assets/channel-B4_5H-fb.js +1 -0
- package/dist/web/assets/{chunk-3FUC2YCW-Drz6oeKx.js → chunk-3FUC2YCW-CelgLyJi.js} +1 -1
- package/dist/web/assets/{chunk-5DYCD2WN-RItzEgV_.js → chunk-5DYCD2WN-bhEAVIbQ.js} +1 -1
- package/dist/web/assets/{chunk-742MDFTN-D6hKdOv7.js → chunk-742MDFTN-ByLz4EcD.js} +1 -1
- package/dist/web/assets/{chunk-7INBJB4K-Dk7-Eior.js → chunk-7INBJB4K-CK2i0csa.js} +1 -1
- package/dist/web/assets/{chunk-7M6MHVWA-Cw8E0Nkn.js → chunk-7M6MHVWA-CoCiujjC.js} +1 -1
- package/dist/web/assets/{chunk-7PRAP22T-t-mTeNXF.js → chunk-7PRAP22T-CY4NCrCY.js} +1 -1
- package/dist/web/assets/{chunk-GTNCS2PH-C7j2atV8.js → chunk-GTNCS2PH-DMB7bQGB.js} +1 -1
- package/dist/web/assets/{chunk-GWA4HPMP-CH9T9LZO.js → chunk-GWA4HPMP-F6qclPTR.js} +1 -1
- package/dist/web/assets/{chunk-MBY4JIJT-yXOO37xD.js → chunk-MBY4JIJT-CSiiBtlX.js} +1 -1
- package/dist/web/assets/{chunk-NETBCI7D-C-s2UtAR.js → chunk-NETBCI7D-CBh7GChL.js} +1 -1
- package/dist/web/assets/{chunk-O7XYJQB3-5Me_aV8o.js → chunk-O7XYJQB3-B2aqz0sN.js} +1 -1
- package/dist/web/assets/{chunk-UA2S7LBM-BQaibeff.js → chunk-UA2S7LBM-B_-P_eR0.js} +1 -1
- package/dist/web/assets/{chunk-WEXAMYUT-UBcOE4Lf.js → chunk-WEXAMYUT-19nMFxzK.js} +1 -1
- package/dist/web/assets/{chunk-Z7XXMR3K-BsA8o3Pt.js → chunk-Z7XXMR3K-Co7gzRY1.js} +1 -1
- package/dist/web/assets/{chunk-ZIGJFQKS--KwSI1U0.js → chunk-ZIGJFQKS-Eoi4K5bK.js} +1 -1
- package/dist/web/assets/{classDiagram-v2-NBCMYWYE-pMF8oCmq.js → classDiagram-v2-NBCMYWYE-CfFGzL-A.js} +1 -1
- package/dist/web/assets/copy-code-DaqEfdXL.js +1 -0
- package/dist/web/assets/create-DedXY-KP.js +1 -0
- package/dist/web/assets/{cynefin-OW5HDTMX-DFgtXolF.js → cynefin-OW5HDTMX-DdZXl3KU.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-VND7K2PF-CPY0JRyq.js → cynefinDiagram-VND7K2PF-WU21nYH-.js} +1 -1
- package/dist/web/assets/{dagre-6A5THRUB-KdjJKAB7.js → dagre-6A5THRUB-48z3F8Pl.js} +1 -1
- package/dist/web/assets/date-DZIuZp-w.js +1 -0
- package/dist/web/assets/devices-store-Bfk2wdrQ.js +1 -0
- package/dist/web/assets/{diagram-22UHCM2B-BDcOcvF_.js → diagram-22UHCM2B-B0AZgJW9.js} +1 -1
- package/dist/web/assets/{diagram-3UASUU5V-6j2nlZL3.js → diagram-3UASUU5V-CzEzrxuO.js} +1 -1
- package/dist/web/assets/{diagram-ATOU4E4O-BN8cdxED.js → diagram-ATOU4E4O-w6h1bD3w.js} +1 -1
- package/dist/web/assets/{diagram-CDSNMT55-cWPiXHkr.js → diagram-CDSNMT55-BdTHQd_o.js} +1 -1
- package/dist/web/assets/{diagram-MLGK6HIB-DcgkH_Vl.js → diagram-MLGK6HIB-pB4cj6c2.js} +1 -1
- package/dist/web/assets/{diagram-MPIPVDR6-D_e86L99.js → diagram-MPIPVDR6-C7C06qyV.js} +1 -1
- package/dist/web/assets/diff-store-DBDL5Hw5.js +93 -0
- package/dist/web/assets/{dist-Bdsq-Ze1.js → dist-B7Cu0FBW.js} +1 -1
- package/dist/web/assets/{dist-BVVhgjWT.js → dist-B8i8y3GY.js} +1 -1
- package/dist/web/assets/{dist-CjkUzU4s.js → dist-BNgPhnKo.js} +1 -1
- package/dist/web/assets/{dist-Bz40Nd9I.js → dist-BWoPV5P3.js} +1 -1
- package/dist/web/assets/{dist-BP40mvwJ.js → dist-CJ7isxli.js} +1 -1
- package/dist/web/assets/{dist-C9enVshI.js → dist-CTJJYvYG.js} +1 -1
- package/dist/web/assets/{dist-BwpyANeW.js → dist-CZz0KXAA.js} +1 -1
- package/dist/web/assets/{dist-CU43ytsh.js → dist-DNpwgDba.js} +1 -1
- package/dist/web/assets/{dist-BMFtkY2y.js → dist-DWCdhk-O.js} +1 -1
- package/dist/web/assets/{dist-MUQaJRtC.js → dist-DqSUdjG9.js} +1 -1
- package/dist/web/assets/{dist-CLCP7f3x.js → dist-Dy9K9LOR.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-ZINNZB2B-D8xHOFOi.js → ebnfDiagram-ZINNZB2B-75vt7539.js} +1 -1
- package/dist/web/assets/{elk-276RUBZZ-JiDwNyLy.js → elk-276RUBZZ-DXDjJVTy.js} +1 -1
- package/dist/web/assets/{erDiagram-OPXOYQCR-D3J6u81a.js → erDiagram-OPXOYQCR-tNNInTmk.js} +1 -1
- package/dist/web/assets/eventmodeling-NTZA5JFV-QMRehQtM.js +1 -0
- package/dist/web/assets/flowDiagram-KWPJA3E3-DJAgsbXC.js +1 -0
- package/dist/web/assets/{ganttDiagram-FUAMR5RP-nvAVhbgI.js → ganttDiagram-FUAMR5RP-h3E8lnCd.js} +1 -1
- package/dist/web/assets/{gitGraph-4MIJSDKK-Bv_wkB2T.js → gitGraph-4MIJSDKK-BUwY-iv2.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-X574FWY7-DxxwadhH.js → gitGraphDiagram-X574FWY7-C0AgQH5k.js} +1 -1
- package/dist/web/assets/i18n-CfTd46OX.js +1 -0
- package/dist/web/assets/icons-BoaZfGBj.js +1 -0
- package/dist/web/assets/index-BQU3KK1E.css +1 -0
- package/dist/web/assets/index-BTpokWxr.js +2 -0
- package/dist/web/assets/{info-A6RAGUB7-Dw18yeIE.js → info-A6RAGUB7-DVMZ4hdK.js} +1 -1
- package/dist/web/assets/{infoDiagram-VRGFBTTK-C3BrgjYg.js → infoDiagram-VRGFBTTK-kLaGXGQ2.js} +1 -1
- package/dist/web/assets/init-app-Bxc_l2yT.js +1 -0
- package/dist/web/assets/{is-D0waCELe.js → is-B1kBQ5Va.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-OU5B5YK6-DU2p9szX.js → ishikawaDiagram-OU5B5YK6-Oj7bZlyo.js} +1 -1
- package/dist/web/assets/{journeyDiagram-ZHPQQLJL-Bs2zQnew.js → journeyDiagram-ZHPQQLJL-BG7V2Srs.js} +1 -1
- package/dist/web/assets/{kanban-definition-PNTS6WVX-pqXd5uNi.js → kanban-definition-PNTS6WVX-CIJiDE6d.js} +1 -1
- package/dist/web/assets/{line-CN4Dxpei.js → line-D2vEKYRZ.js} +1 -1
- package/dist/web/assets/markdown-Bm2wfvok.js +16 -0
- package/dist/web/assets/mdi-Byw1NZrZ.js +1 -0
- package/dist/web/assets/{mermaid-parser.core-DZqDOGRM.js → mermaid-parser.core-BcBEWjW6.js} +3 -3
- package/dist/web/assets/{mermaid.core-CUndCvkz.js → mermaid.core-DobO0deo.js} +4 -4
- package/dist/web/assets/{mindmap-definition-NLK3R4M7-DyK7YqB7.js → mindmap-definition-NLK3R4M7-y7Qz5gBF.js} +1 -1
- package/dist/web/assets/{packet-AYTQ26CC-DvlW_0BP.js → packet-AYTQ26CC-oRQgKr9d.js} +1 -1
- package/dist/web/assets/{pegDiagram-GJSIUBJH-k2e_-FWQ.js → pegDiagram-GJSIUBJH-RIU8XOHq.js} +1 -1
- package/dist/web/assets/{pie-WAS4IAKB-B99zaYjO.js → pie-WAS4IAKB-qmOlsLkx.js} +1 -1
- package/dist/web/assets/{pieDiagram-5QR66LMP-BPbS05lK.js → pieDiagram-5QR66LMP-BM932TDA.js} +1 -1
- package/dist/web/assets/pinia-BfqEuvsi.js +1 -0
- package/dist/web/assets/pinia-Cmp1GI8k.js +1 -0
- package/dist/web/assets/preview-store-D7qF6SgX.js +2 -0
- package/dist/web/assets/project-files-store-OhGs_H7U.js +1 -0
- package/dist/web/assets/{quadrantDiagram-O4NWA36T-DqNNdsd2.js → quadrantDiagram-O4NWA36T-qQZYwTy7.js} +1 -1
- package/dist/web/assets/{radar-RG4KPBEZ-BIAAr9LO.js → radar-RG4KPBEZ-Kdglk6eY.js} +1 -1
- package/dist/web/assets/{railroad-74A4TZTK-DYxr-1-f.js → railroad-74A4TZTK-kVhMYx4I.js} +1 -1
- package/dist/web/assets/railroad-abnf-HS5TGJTU-MiKgjOXr.js +1 -0
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-BFL9h7Zx.js +1 -0
- package/dist/web/assets/railroad-peg-WCYAUIDC-ChGGfIn7.js +1 -0
- package/dist/web/assets/{railroadDiagram-XR7U4H2S-TNg-LqRR.js → railroadDiagram-XR7U4H2S-K9SrOGcT.js} +1 -1
- package/dist/web/assets/render-Brao9Nj2.js +1 -0
- package/dist/web/assets/repository-store-DZgQ5H7J.js +1 -0
- package/dist/web/assets/{requirementDiagram-PLB6GJNP-hKAyJR6W.js → requirementDiagram-PLB6GJNP-CtA9ZKEx.js} +1 -1
- package/dist/web/assets/runtime-core.esm-bundler-DDnHUoIy.js +1 -0
- package/dist/web/assets/{safe-storage-B1Aq5CGi.js → safe-storage-CvVvrm4v.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-IPEJSGJF-_MSL-tES.js → sankeyDiagram-IPEJSGJF-BH_t4exx.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-PO4LG4MO-Byq-joBG.js → sequenceDiagram-PO4LG4MO-hPNPqpDa.js} +1 -1
- package/dist/web/assets/single-flight-CyDZB3rb.js +1 -0
- package/dist/web/assets/{stateDiagram-v2-GCMORJYK-BR2jAgaa.js → stateDiagram-v2-GCMORJYK-BVmjZDRD.js} +1 -1
- package/dist/web/assets/{swimlanes-2SLR337P-Nt8ojGKK.js → swimlanes-2SLR337P-Tgk8-6jj.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-TC7HE7FX-W1zDrK61.js +8 -0
- package/dist/web/assets/{terminal-store-D0abibMa.js → terminal-store-CKgJjtC6.js} +1 -1
- package/dist/web/assets/theme-slSxLNv6.js +1 -0
- package/dist/web/assets/{timeline-definition-EJHVYXUP-BtihLvxk.js → timeline-definition-EJHVYXUP-lAIHEGe8.js} +1 -1
- package/dist/web/assets/{treeView-Q6P3EWNA-D5HzXeKd.js → treeView-Q6P3EWNA-CdvzKtWf.js} +1 -1
- package/dist/web/assets/{treemap-WGGIJYW6-Dovjuutg.js → treemap-WGGIJYW6-BxDSJfrJ.js} +1 -1
- package/dist/web/assets/uid-B1JNhznI.js +1 -0
- package/dist/web/assets/use-add-agent-context-BSHGL5iV.js +1 -0
- package/dist/web/assets/use-app-theme-fmVV2QM8.js +1 -0
- package/dist/web/assets/use-countdown-D6_qSOZJ.js +1 -0
- package/dist/web/assets/use-notify-error-Dx2D9IEP.js +1 -0
- package/dist/web/assets/use-panel-width-BYOPuHat.js +1 -0
- package/dist/web/assets/use-router-link-D7geCGQI.js +1 -0
- package/dist/web/assets/use-row-height-BK8kNihW.js +1 -0
- package/dist/web/assets/use-server-events-CvcbsbIf.js +1 -0
- package/dist/web/assets/use-virtual-scroll-DixIsJk4.js +1 -0
- package/dist/web/assets/use-workspace-navigation-AaRMWmjQ.js +1 -0
- package/dist/web/assets/{usecaseDiagram-POWQR4AR-DSwRE8zj.js → usecaseDiagram-POWQR4AR-BH3KvMpz.js} +1 -1
- package/dist/web/assets/{vennDiagram-UO4OBE2U-C-B8yP1K.js → vennDiagram-UO4OBE2U-Dfi-raKp.js} +1 -1
- package/dist/web/assets/viewport-store-NqQS7itT.js +1 -0
- package/dist/web/assets/{vue-i18n.runtime-CEtihHHL.js → vue-i18n.runtime-JOo8b7-t.js} +2 -2
- package/dist/web/assets/{wardley-WFR3VGLG-wWgaZuh6.js → wardley-WFR3VGLG-DmbtSM24.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-VNRHLVJA-DbhenrHd.js → wardleyDiagram-VNRHLVJA-DIzhGvI7.js} +1 -1
- package/dist/web/assets/weighted-lru-BFtZKA_y.js +1 -0
- package/dist/web/assets/workspace-navigation-xfxULfM7.js +1 -0
- package/dist/web/assets/{xychartDiagram-PMCCYNJV-CxFDmAEt.js → xychartDiagram-PMCCYNJV-XgqSHH_N.js} +1 -1
- package/dist/web/index.html +10 -8
- package/package.json +5 -3
- package/dist/web/assets/AccessPage-_OKn9U0P.js +0 -1
- package/dist/web/assets/AppPage-oQ9Rz0be.js +0 -1
- package/dist/web/assets/CreateButton-D1EtoicG.js +0 -1
- package/dist/web/assets/CreateReviewFabButton-BxvT3i9e.js +0 -1
- package/dist/web/assets/IndexPage-gdD7BHxA.js +0 -1
- package/dist/web/assets/MainLayout-47PTLKZf.js +0 -6
- package/dist/web/assets/MainLayout-ikSrFqBh.css +0 -1
- package/dist/web/assets/NoteVisualEditor-BQ6mVfj0.js +0 -1054
- package/dist/web/assets/NotesPage-DNR9iW_G.js +0 -4
- package/dist/web/assets/NotesPage-_8naQciW.css +0 -1
- package/dist/web/assets/PanelResize-CAQFVc8b.js +0 -1
- package/dist/web/assets/QBtn-CB-yw_iP.js +0 -1
- package/dist/web/assets/QExpansionItem-Dr5oXO0m.js +0 -4
- package/dist/web/assets/QFab-DPz8RiP0.js +0 -1
- package/dist/web/assets/QForm-CASiKhGm.js +0 -1
- package/dist/web/assets/QInput-k34nCPWg.js +0 -1
- package/dist/web/assets/QSelect-CaKn9Tkg.js +0 -1
- package/dist/web/assets/QSpace-Di_bZQY6.js +0 -1
- package/dist/web/assets/QVirtualScroll-oGN_Tl5J.js +0 -1
- package/dist/web/assets/ReviewDetailPage-BKgIprY0.js +0 -1
- package/dist/web/assets/ReviewDetailPage-CkCilMNW.css +0 -1
- package/dist/web/assets/ReviewsPage-6PJ6wofN.js +0 -1
- package/dist/web/assets/StatusSwitcher-s9w6iKpR.js +0 -1
- package/dist/web/assets/architecture-7GRP2DOG-D6PShS0_.js +0 -1
- package/dist/web/assets/channel-D6lb5DbY.js +0 -1
- package/dist/web/assets/create-B9Tn5Xvi.js +0 -1
- package/dist/web/assets/devices-store-CrZ4MxyY.js +0 -1
- package/dist/web/assets/diff-store-ByxMCKoa.js +0 -93
- package/dist/web/assets/eventmodeling-NTZA5JFV-QCwZLvmm.js +0 -1
- package/dist/web/assets/flUhRq6tzZclQEJ-Vdg-IuiaDsNa-Dr0goTwe.woff +0 -0
- package/dist/web/assets/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ-D-x-0Q06.woff2 +0 -0
- package/dist/web/assets/flowDiagram-KWPJA3E3-CgF90hDi.js +0 -1
- package/dist/web/assets/i18n-DDCqtTTW.js +0 -1
- package/dist/web/assets/index-BNHt6zmP.js +0 -2
- package/dist/web/assets/index-BwbM_RKi.css +0 -1
- package/dist/web/assets/init-app-BouXTk8p.js +0 -1
- package/dist/web/assets/markdown-jR0fhe4d.js +0 -15
- package/dist/web/assets/pinia-BETEFLDG.js +0 -1
- package/dist/web/assets/pinia-DO0AdKGg.js +0 -1
- package/dist/web/assets/railroad-abnf-HS5TGJTU-GESjhc3t.js +0 -1
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-Cybu0A7J.js +0 -1
- package/dist/web/assets/railroad-peg-WCYAUIDC-DCHxrtbI.js +0 -1
- package/dist/web/assets/runtime-core.esm-bundler-CAvPiMpd.js +0 -1
- package/dist/web/assets/single-flight-DLCbzLI3.js +0 -1
- package/dist/web/assets/swimlanesDiagram-TC7HE7FX-Ds1hVYqh.js +0 -8
- package/dist/web/assets/theme-QEcOl0lf.js +0 -1
- package/dist/web/assets/use-add-agent-context-BaPUIO93.js +0 -1
- package/dist/web/assets/use-app-theme-B1cdbnHn.js +0 -1
- package/dist/web/assets/use-countdown-CTag4T13.js +0 -1
- package/dist/web/assets/use-panel-width-CB-0S3zX.js +0 -1
- package/dist/web/assets/use-router-link-Dr9wnnyZ.js +0 -1
- package/dist/web/assets/use-row-height-DQHVMtUe.js +0 -1
- package/dist/web/assets/use-server-events-BrBCbeHu.js +0 -1
- package/dist/web/assets/use-virtual-scroll-DG0UKjVk.js +0 -1
- package/dist/web/assets/weighted-lru-BSxRnMHR.js +0 -1
- /package/dist/web/assets/{PanelResize-XjrbOj2S.css → AddToAgentButton-XjrbOj2S.css} +0 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { errorMessage } from "../../shared/utils/error-message.js";
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { Value } from '@sinclair/typebox/value';
|
|
4
|
+
import { ArtifactChangeSetProposeBody, ArtifactAuthorizationRequestBody, ArtifactLifecycleCommitBody } from "../../shared/artifacts/schemas.js";
|
|
5
|
+
import { canonicalJson } from "../../shared/utils/canonical-json.js";
|
|
6
|
+
import { sha256Hex } from "../utils/hash.js";
|
|
7
|
+
import { HEARTBEAT_STALE_MS } from "../../shared/artifact-transitions/constants.js";
|
|
8
|
+
import { hasErrorCode } from "../utils/system-error.js";
|
|
9
|
+
import { ArtifactConflictError, ArtifactInputError } from "../errors/artifacts.js";
|
|
10
|
+
import { canonicalChangeSet, previewArtifactChangeSet } from "./artifact-graph-validation.js";
|
|
11
|
+
import { ArtifactValidationRepository } from "../repositories/artifact-validation.repo.js";
|
|
12
|
+
import { ArtifactAuthorizationService, artifactActionDigest } from "./artifact-authorization.service.js";
|
|
13
|
+
import { ArtifactValidationJobsService } from "./artifact-validation-jobs.service.js";
|
|
14
|
+
import { ArtifactTransitionRepository } from "../repositories/artifact-transition.repo.js";
|
|
15
|
+
import { ArtifactTransitionService } from "./artifact-transition.service.js";
|
|
16
|
+
// Manifest changes invalidate all earlier semantic conclusions.
|
|
17
|
+
const VALIDATION_RULES_VERSION = 2;
|
|
18
|
+
export function artifactSessionId(actor) {
|
|
19
|
+
return actor.kind === 'user' ? `user:${actor.id}` : actor.id;
|
|
20
|
+
}
|
|
21
|
+
export class ArtifactLifecycleService {
|
|
22
|
+
repository;
|
|
23
|
+
authorization;
|
|
24
|
+
jobs;
|
|
25
|
+
transitions;
|
|
26
|
+
registry;
|
|
27
|
+
storage;
|
|
28
|
+
now;
|
|
29
|
+
constructor(storage, db, now = Date.now) {
|
|
30
|
+
this.storage = storage;
|
|
31
|
+
this.now = now;
|
|
32
|
+
this.repository = new ArtifactValidationRepository(db, storage.storeId);
|
|
33
|
+
this.authorization = new ArtifactAuthorizationService(this.repository, now, action => this.checkAction(action), id => id.startsWith('user:') ||
|
|
34
|
+
Boolean(this.registry?.get(id) && this.registry.get(id).status !== 'closed'), () => this.registry?.notifyArtifactActionsChanged?.());
|
|
35
|
+
this.jobs = new ArtifactValidationJobsService(this, now);
|
|
36
|
+
this.transitions = new ArtifactTransitionService(this, new ArtifactTransitionRepository(db, storage.storeId), now);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* True when the process of `owner` exists and its heartbeat is fresh. A
|
|
40
|
+
* missing heartbeat counts as alive, so old data keeps its behavior. The own
|
|
41
|
+
* instance is always alive (ADR 0108).
|
|
42
|
+
*/
|
|
43
|
+
ownerAlive(owner, pid) {
|
|
44
|
+
if (owner === this.jobs.ownerId) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
process.kill(pid, 0);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (hasErrorCode(error, 'ESRCH')) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const beat = this.repository.heartbeat(owner);
|
|
56
|
+
return beat === undefined || this.now() - beat <= HEARTBEAT_STALE_MS;
|
|
57
|
+
}
|
|
58
|
+
attachSessions(registry) {
|
|
59
|
+
this.registry = registry;
|
|
60
|
+
this.jobs.attachSessions(registry);
|
|
61
|
+
}
|
|
62
|
+
propose(input, actor) {
|
|
63
|
+
if (!Value.Check(ArtifactChangeSetProposeBody, input) ||
|
|
64
|
+
!input.changeSet.reason.trim()) {
|
|
65
|
+
throw new ArtifactInputError('Invalid change set proposal.');
|
|
66
|
+
}
|
|
67
|
+
if (Buffer.byteLength(JSON.stringify(input.changeSet)) > 48 * 1024) {
|
|
68
|
+
throw new ArtifactInputError('Change set exceeds the bounded proposal size.');
|
|
69
|
+
}
|
|
70
|
+
return this.storage.catalog.transaction(() => this.proposeInTransaction(input, actor));
|
|
71
|
+
}
|
|
72
|
+
/** Proposes inside a transaction owned by the caller. */
|
|
73
|
+
proposeInTransaction(input, actor) {
|
|
74
|
+
const changeDigest = artifactActionDigest(canonicalChangeSet(input.changeSet));
|
|
75
|
+
const requestDigest = artifactActionDigest({
|
|
76
|
+
id: input.id ?? null,
|
|
77
|
+
expectedVersion: input.expectedVersion ?? null,
|
|
78
|
+
changeDigest,
|
|
79
|
+
actor
|
|
80
|
+
});
|
|
81
|
+
const replay = this.repository.proposalRequest(input.requestId);
|
|
82
|
+
if (replay) {
|
|
83
|
+
if (replay.requestDigest !== requestDigest ||
|
|
84
|
+
canonicalJson(replay.actor) !== canonicalJson(actor) ||
|
|
85
|
+
(input.id && replay.id !== input.id)) {
|
|
86
|
+
throw new ArtifactConflictError('Proposal request ID was reused.');
|
|
87
|
+
}
|
|
88
|
+
return replay;
|
|
89
|
+
}
|
|
90
|
+
const preview = this.preview(input.changeSet);
|
|
91
|
+
if (preview.errors.length) {
|
|
92
|
+
throw new ArtifactInputError(preview.errors.map(item => item.message).join(' '));
|
|
93
|
+
}
|
|
94
|
+
const previous = input.id ? this.repository.proposal(input.id) : undefined;
|
|
95
|
+
if ((previous && previous.version !== input.expectedVersion) ||
|
|
96
|
+
(!previous && input.expectedVersion)) {
|
|
97
|
+
throw new ArtifactConflictError('Change set version changed.');
|
|
98
|
+
}
|
|
99
|
+
const proposal = {
|
|
100
|
+
id: previous?.id ?? randomUUID(),
|
|
101
|
+
version: (previous?.version ?? 0) + 1,
|
|
102
|
+
requestId: input.requestId,
|
|
103
|
+
requestDigest,
|
|
104
|
+
actor,
|
|
105
|
+
changeSet: preview.canonical,
|
|
106
|
+
changeDigest: preview.changeDigest
|
|
107
|
+
};
|
|
108
|
+
this.repository.appendProposal(proposal);
|
|
109
|
+
return proposal;
|
|
110
|
+
}
|
|
111
|
+
inspectValidation(id) {
|
|
112
|
+
return this.storage.catalog.readSnapshot(() => {
|
|
113
|
+
const validation = this.jobs.get(id);
|
|
114
|
+
const proposal = this.repository.proposalVersion(validation.changeSetId, validation.version);
|
|
115
|
+
const preview = this.preview(proposal.changeSet);
|
|
116
|
+
let ready = false;
|
|
117
|
+
let problem = null;
|
|
118
|
+
try {
|
|
119
|
+
this.checkAction({
|
|
120
|
+
kind: 'lifecycle',
|
|
121
|
+
changeSetId: proposal.id,
|
|
122
|
+
version: proposal.version,
|
|
123
|
+
validationId: id
|
|
124
|
+
});
|
|
125
|
+
ready = true;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
problem = errorMessage(error);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
storeId: this.storage.storeId,
|
|
132
|
+
validation,
|
|
133
|
+
proposal,
|
|
134
|
+
preview,
|
|
135
|
+
ready,
|
|
136
|
+
problem
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
inspectAction(id, actor) {
|
|
141
|
+
return this.storage.catalog.readSnapshot(() => {
|
|
142
|
+
const value = this.authorization.describe(id);
|
|
143
|
+
const action = value.pending.action;
|
|
144
|
+
const proposal = this.repository.proposalVersion(action.changeSetId, action.version);
|
|
145
|
+
const validation = this.jobs.get(action.validationId);
|
|
146
|
+
const preview = this.preview(proposal.changeSet);
|
|
147
|
+
let ready = false;
|
|
148
|
+
let problem = null;
|
|
149
|
+
if (value.phase !== 'consumed') {
|
|
150
|
+
try {
|
|
151
|
+
const binding = this.checkAction(action);
|
|
152
|
+
if (binding.actionDigest !== value.pending.actionDigest ||
|
|
153
|
+
binding.manifestDigest !== value.pending.manifestDigest) {
|
|
154
|
+
throw new ArtifactConflictError('Action scope changed.');
|
|
155
|
+
}
|
|
156
|
+
ready = true;
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
problem = errorMessage(error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const canExecute = value.pending.sessionId === artifactSessionId(actor);
|
|
163
|
+
// Project only the original request fields; grants also hold private audit bindings.
|
|
164
|
+
const { id: pendingId, sessionId, action: pendingAction, actionDigest, manifestDigest, expiresAt } = value.pending;
|
|
165
|
+
return {
|
|
166
|
+
storeId: this.storage.storeId,
|
|
167
|
+
pending: {
|
|
168
|
+
id: pendingId,
|
|
169
|
+
sessionId,
|
|
170
|
+
action: pendingAction,
|
|
171
|
+
actionDigest,
|
|
172
|
+
manifestDigest,
|
|
173
|
+
expiresAt
|
|
174
|
+
},
|
|
175
|
+
phase: value.phase,
|
|
176
|
+
canExecute,
|
|
177
|
+
ready,
|
|
178
|
+
problem,
|
|
179
|
+
proposal,
|
|
180
|
+
validation,
|
|
181
|
+
preview,
|
|
182
|
+
authorizationId: canExecute ? value.authorizationId : null
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
get(id) {
|
|
187
|
+
return this.repository.proposal(id);
|
|
188
|
+
}
|
|
189
|
+
preview(changeSet) {
|
|
190
|
+
return previewArtifactChangeSet(this.storage.catalog.all(), changeSet, this.storage.catalog.supersededArtifactIds());
|
|
191
|
+
}
|
|
192
|
+
prepare(changeSetId, version) {
|
|
193
|
+
return this.storage.catalog.transaction(() => this.prepareInTransaction(changeSetId, version));
|
|
194
|
+
}
|
|
195
|
+
/** Prepares inside a transaction owned by the caller. */
|
|
196
|
+
prepareInTransaction(changeSetId, version) {
|
|
197
|
+
const proposal = this.repository.proposal(changeSetId);
|
|
198
|
+
if (proposal.version !== version) {
|
|
199
|
+
throw new ArtifactConflictError('Change set version changed.');
|
|
200
|
+
}
|
|
201
|
+
const manifest = this.manifest(proposal);
|
|
202
|
+
const value = {
|
|
203
|
+
id: randomUUID(),
|
|
204
|
+
changeSetId,
|
|
205
|
+
version,
|
|
206
|
+
manifest,
|
|
207
|
+
manifestDigest: artifactActionDigest(manifest),
|
|
208
|
+
state: 'prepared',
|
|
209
|
+
validatorSessionId: null,
|
|
210
|
+
owner: null,
|
|
211
|
+
expiresAt: null
|
|
212
|
+
};
|
|
213
|
+
this.repository.appendValidation(value);
|
|
214
|
+
return value;
|
|
215
|
+
}
|
|
216
|
+
manifest(proposal) {
|
|
217
|
+
const preview = this.preview(proposal.changeSet);
|
|
218
|
+
if (preview.errors.length) {
|
|
219
|
+
throw new ArtifactConflictError(preview.errors.map(item => item.message).join(' '));
|
|
220
|
+
}
|
|
221
|
+
const artifacts = preview.affectedIds.map(id => this.storage.readVerifiedFile(id).artifact);
|
|
222
|
+
return {
|
|
223
|
+
rulesVersion: VALIDATION_RULES_VERSION,
|
|
224
|
+
validationEpoch: this.storage.catalog.validationEpoch(),
|
|
225
|
+
changeDigest: proposal.changeDigest,
|
|
226
|
+
changeSet: proposal.changeSet,
|
|
227
|
+
artifacts,
|
|
228
|
+
requiredContentIds: artifacts.map(item => item.id)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
assertFresh(validation) {
|
|
232
|
+
const proposal = this.repository.proposal(validation.changeSetId);
|
|
233
|
+
if (validation.manifest.rulesVersion !== VALIDATION_RULES_VERSION ||
|
|
234
|
+
proposal.version !== validation.version ||
|
|
235
|
+
artifactActionDigest(this.manifest(proposal)) !==
|
|
236
|
+
validation.manifestDigest) {
|
|
237
|
+
throw new ArtifactConflictError('VALIDATION_STALE: manifest changed; prepare a new validation.');
|
|
238
|
+
}
|
|
239
|
+
return proposal;
|
|
240
|
+
}
|
|
241
|
+
checkAction(action) {
|
|
242
|
+
if (!Value.Check(ArtifactAuthorizationRequestBody, action)) {
|
|
243
|
+
throw new ArtifactInputError('Invalid authorization action.');
|
|
244
|
+
}
|
|
245
|
+
const validation = this.repository.validation(action.validationId);
|
|
246
|
+
const proposal = this.assertFresh(validation);
|
|
247
|
+
if (validation.state !== 'pass' ||
|
|
248
|
+
proposal.id !== action.changeSetId ||
|
|
249
|
+
proposal.version !== action.version) {
|
|
250
|
+
throw new ArtifactConflictError('A fresh matching validation pass is required.');
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
actionDigest: proposal.changeDigest,
|
|
254
|
+
manifestDigest: validation.manifestDigest
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
commit(id, input, actor) {
|
|
258
|
+
if (!Value.Check(ArtifactLifecycleCommitBody, input)) {
|
|
259
|
+
throw new ArtifactInputError('Invalid commit request.');
|
|
260
|
+
}
|
|
261
|
+
const payloadHash = sha256Hex(canonicalJson({ id, input, actor }));
|
|
262
|
+
const result = this.storage.catalog.transaction(() => {
|
|
263
|
+
const replay = this.repository.commitRequest(input.requestId);
|
|
264
|
+
if (replay) {
|
|
265
|
+
if (replay.payloadHash !== payloadHash) {
|
|
266
|
+
throw new ArtifactConflictError('Commit request ID was reused.');
|
|
267
|
+
}
|
|
268
|
+
return replay.result;
|
|
269
|
+
}
|
|
270
|
+
const action = {
|
|
271
|
+
kind: 'lifecycle',
|
|
272
|
+
changeSetId: id,
|
|
273
|
+
version: input.version,
|
|
274
|
+
validationId: input.validationId
|
|
275
|
+
};
|
|
276
|
+
this.authorization.assert(input.authorizationId, artifactSessionId(actor), action);
|
|
277
|
+
const value = this.applyChangeSet(id, input.version, input.requestId, payloadHash, actor);
|
|
278
|
+
this.authorization.consume(input.authorizationId);
|
|
279
|
+
return value;
|
|
280
|
+
});
|
|
281
|
+
this.storage.pollChanges();
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Commits a proposal on the strength of a stored prior consent instead of a
|
|
286
|
+
* session grant. The caller checks the consent; `inTransaction` writes the
|
|
287
|
+
* consumption and the operation result atomically with the status changes.
|
|
288
|
+
*/
|
|
289
|
+
commitConfirmed(input, actor, inTransaction) {
|
|
290
|
+
const payloadHash = sha256Hex(canonicalJson({ input, actor }));
|
|
291
|
+
const result = this.storage.catalog.transaction(() => {
|
|
292
|
+
const replay = this.repository.commitRequest(input.requestId);
|
|
293
|
+
if (replay) {
|
|
294
|
+
if (replay.payloadHash !== payloadHash) {
|
|
295
|
+
throw new ArtifactConflictError('Commit request ID was reused.');
|
|
296
|
+
}
|
|
297
|
+
return replay.result;
|
|
298
|
+
}
|
|
299
|
+
this.checkAction({
|
|
300
|
+
kind: 'lifecycle',
|
|
301
|
+
changeSetId: input.changeSetId,
|
|
302
|
+
version: input.version,
|
|
303
|
+
validationId: input.validationId
|
|
304
|
+
});
|
|
305
|
+
const value = this.applyChangeSet(input.changeSetId, input.version, input.requestId, payloadHash, actor);
|
|
306
|
+
inTransaction();
|
|
307
|
+
return value;
|
|
308
|
+
});
|
|
309
|
+
this.storage.pollChanges();
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
applyChangeSet(id, version, requestId, payloadHash, actor) {
|
|
313
|
+
const proposal = this.repository.proposal(id);
|
|
314
|
+
const preview = this.preview(proposal.changeSet);
|
|
315
|
+
if (preview.errors.length) {
|
|
316
|
+
throw new ArtifactConflictError('Change set post-state is invalid.');
|
|
317
|
+
}
|
|
318
|
+
const updated = [];
|
|
319
|
+
for (const node of preview.postState) {
|
|
320
|
+
const previous = this.storage.get(node.id);
|
|
321
|
+
if (canonicalJson(node) === canonicalJson(previous))
|
|
322
|
+
continue;
|
|
323
|
+
const next = {
|
|
324
|
+
...node,
|
|
325
|
+
metadataVersion: previous.metadataVersion + 1,
|
|
326
|
+
metadataUpdatedAt: new Date(this.now()).toISOString()
|
|
327
|
+
};
|
|
328
|
+
this.storage.catalog.appendMetadata(next, `lifecycle:${sha256Hex(canonicalJson([requestId, node.id]))}`, actor, 'metadata_updated');
|
|
329
|
+
updated.push({ id: next.id, metadataVersion: next.metadataVersion });
|
|
330
|
+
}
|
|
331
|
+
const value = {
|
|
332
|
+
storeId: this.storage.storeId,
|
|
333
|
+
changeSetId: id,
|
|
334
|
+
version,
|
|
335
|
+
affectedIds: updated.map(item => item.id),
|
|
336
|
+
metadataVersions: updated,
|
|
337
|
+
includedIn: preview.includedIn,
|
|
338
|
+
storeEpoch: this.storage.catalog.epoch()
|
|
339
|
+
};
|
|
340
|
+
const eventSeq = this.repository.appendCommit(requestId, payloadHash, value);
|
|
341
|
+
return { ...value, eventSeq };
|
|
342
|
+
}
|
|
343
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { errorMessage } from "../../shared/utils/error-message.js";
|
|
2
|
+
// Detect other writers and retry expired operation leases without device settings.
|
|
3
|
+
const MAINTENANCE_INTERVAL_MS = 2000;
|
|
4
|
+
export class ArtifactMaintenanceService {
|
|
5
|
+
options;
|
|
6
|
+
timer;
|
|
7
|
+
running = false;
|
|
8
|
+
// Last reported message per phase; a repeating failure is reported once.
|
|
9
|
+
reported = new Map();
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
start() {
|
|
14
|
+
if (this.running)
|
|
15
|
+
return;
|
|
16
|
+
this.running = true;
|
|
17
|
+
// Reads verify every file, so a failed first pass must not block the server.
|
|
18
|
+
this.run(true);
|
|
19
|
+
if (!this.running)
|
|
20
|
+
return;
|
|
21
|
+
this.timer = setInterval(() => this.check(), MAINTENANCE_INTERVAL_MS);
|
|
22
|
+
this.timer.unref();
|
|
23
|
+
}
|
|
24
|
+
stop() {
|
|
25
|
+
this.running = false;
|
|
26
|
+
clearInterval(this.timer);
|
|
27
|
+
this.timer = undefined;
|
|
28
|
+
}
|
|
29
|
+
check() {
|
|
30
|
+
if (!this.running)
|
|
31
|
+
return;
|
|
32
|
+
this.run(false);
|
|
33
|
+
}
|
|
34
|
+
run(cleanupCommitted) {
|
|
35
|
+
this.attempt('recovery', () => this.options.storage.recover(cleanupCommitted));
|
|
36
|
+
// The error handler may stop the service.
|
|
37
|
+
if (!this.running)
|
|
38
|
+
return;
|
|
39
|
+
// A failed recovery must not hide changes committed by another process.
|
|
40
|
+
this.attempt('poll', () => this.options.storage.pollChanges());
|
|
41
|
+
}
|
|
42
|
+
attempt(phase, run) {
|
|
43
|
+
try {
|
|
44
|
+
run();
|
|
45
|
+
this.reported.delete(phase);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const message = errorMessage(error);
|
|
49
|
+
if (this.reported.get(phase) === message)
|
|
50
|
+
return;
|
|
51
|
+
this.reported.set(phase, message);
|
|
52
|
+
this.options.onError(error, phase);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|