fuli-context 0.23.0-beta.8 → 0.23.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/dist/web/assets/{AboutPage-BHbNacTY.js → AboutPage-S8QFfzpA.js} +1 -1
- package/dist/web/assets/AboutSectionHeading-B5CzH4Zs.js +1 -0
- package/dist/web/assets/AboutSectionHeading-DjXpIV27.css +1 -0
- package/dist/web/assets/AgentAppsPage-BYXraPFM.js +1 -0
- package/dist/web/assets/{AgentHand-BGzGOjzl.js → AgentHand-BGGdVdd9.js} +1 -1
- package/dist/web/assets/AgentManagement-Bza8k5ra.js +7 -0
- package/dist/web/assets/AgentManagement-CeF4mjtg.css +1 -0
- package/dist/web/assets/AgentMentionCopy-C72hY2QL.js +1 -0
- package/dist/web/assets/{AgentName-C5HzUHaA.js → AgentName-CUjBNQ8j.js} +1 -1
- package/dist/web/assets/AgentProfilePage-D5QUzw5N.css +1 -0
- package/dist/web/assets/AgentProfilePage-kp7-gRRx.js +5 -0
- package/dist/web/assets/AgentServicesPage-IsGaz7FY.js +1 -0
- package/dist/web/assets/{AppViewerPage-N5C_6WLz.css → AppViewerPage-CJ0Zy6LA.css} +1 -1
- package/dist/web/assets/AppViewerPage-CcOlwxck.js +1 -0
- package/dist/web/assets/{BackToTop-SL4ai3_g.js → BackToTop-C3KYEoCW.js} +1 -1
- package/dist/web/assets/BoardCardFieldsMenu-BlBWT1j7.js +1 -0
- package/dist/web/assets/BoardMoveMenu-Bc7xC1Uh.js +1 -0
- package/dist/web/assets/Breadcrumb-BbwBNrG2.css +1 -0
- package/dist/web/assets/Breadcrumb-C_xMiD-Z.js +1 -0
- package/dist/web/assets/CaptureChangePage-Bekp1aWg.js +1 -0
- package/dist/web/assets/ConnectionsPage-BpvecWXD.js +1 -0
- package/dist/web/assets/{CopyFixPrompt-CCrPxN5x.js → CopyFixPrompt-Bp-UX4Hq.js} +1 -1
- package/dist/web/assets/DataFormatPage-dsy8d3oA.js +2 -0
- package/dist/web/assets/DataFormatPage-sSnjjUY4.css +1 -0
- package/dist/web/assets/DebugTurnPage-HdFAyc2D.css +1 -0
- package/dist/web/assets/DebugTurnPage-cIJV7xDW.js +1 -0
- package/dist/web/assets/DebugTurnsPage-B6Te_Alp.js +1 -0
- package/dist/web/assets/DebugTurnsPage-BFuOzyWR.css +1 -0
- package/dist/web/assets/{DialogTitle-CTKjDGQc.js → DialogTitle-Lj5s6nwG.js} +1 -1
- package/dist/web/assets/EmployeeRedirectPage-DnvwJeCN.js +1 -0
- package/dist/web/assets/EmployeeScopeDialog-CXNZ62Ab.js +1 -0
- package/dist/web/assets/EmployeeWorkbench-BhReI8l6.css +1 -0
- package/dist/web/assets/EmployeeWorkbench-DALIO-cM.js +4 -0
- package/dist/web/assets/FieldRoot-DRnAC66O.js +1 -0
- package/dist/web/assets/FlaGrowth-7wlv31Tl.js +1 -0
- package/dist/web/assets/FlaGrowth-BzXY8pcx.css +1 -0
- package/dist/web/assets/FlaTaskSheets-CNdaBy1P.js +1 -0
- package/dist/web/assets/FlasPage-BCs1Ffpf.js +1 -0
- package/dist/web/assets/{FlasPage-Cb6Q5lge.css → FlasPage-SLQDMv47.css} +1 -1
- package/dist/web/assets/{button-CaCh3Iim.css → GrowthLoading-CigPij0N.css} +1 -1
- package/dist/web/assets/GrowthLoading-Cr8xZwwO.js +1 -0
- package/dist/web/assets/HowtoPage-Cv1YQy1s.js +1 -0
- package/dist/web/assets/{HowtoPage-BRV2W1Go.css → HowtoPage-t12tDDpS.css} +1 -1
- package/dist/web/assets/{InboxPage-DSOmt6VL.js → InboxPage-CgJnymOY.js} +2 -2
- package/dist/web/assets/KnowledgeDeleteButton-FEyEvhlR.js +1 -0
- package/dist/web/assets/KnowledgeHardDeleteSection-CVwTeMEJ.js +1 -0
- package/dist/web/assets/KnowledgeItemEditPage-rwpM8cF1.js +1 -0
- package/dist/web/assets/{KnowledgeItemSummaryCard-D1h0e1Hn.js → KnowledgeItemSummaryCard-49EADY_Z.js} +1 -1
- package/dist/web/assets/KnowledgeOrganizerPage-7IdnjM3L.js +1 -0
- package/dist/web/assets/KnowledgePage-gxqOIZxf.js +1 -0
- package/dist/web/assets/KnowledgePeek-Bm5jRVA9.css +1 -0
- package/dist/web/assets/KnowledgePeek-CQyCxHFj.js +1 -0
- package/dist/web/assets/KnowledgeTurnReceiptPage-BOz7IpaK.js +1 -0
- package/dist/web/assets/KnowledgeWorkspace-A7zVb26p.js +4 -0
- package/dist/web/assets/KnowledgeWorkspace-DCoVFyf0.css +1 -0
- package/dist/web/assets/{MeAvatar-DHJA3h2E.js → MeAvatar-CYVcRiuW.js} +1 -1
- package/dist/web/assets/{MeLink-CU7zuYgD.js → MeLink-BdqkzhT6.js} +1 -1
- package/dist/web/assets/{MenuSeparator-DV3U0Y8_.js → MenuSeparator-quqkZZXY.js} +1 -1
- package/dist/web/assets/ModelSettingsPage-B8jC_uew.js +3 -0
- package/dist/web/assets/ModelSettingsPage-DhCn_SF6.css +1 -0
- package/dist/web/assets/{NotFoundPage-BMWxdf6r.js → NotFoundPage-Dmn32VWo.js} +1 -1
- package/dist/web/assets/OccupationsPage-BVREfX_R.js +1 -0
- package/dist/web/assets/OverviewPage-CHyEbdP4.js +1 -0
- package/dist/web/assets/OverviewPage-xdF5g6bZ.css +1 -0
- package/dist/web/assets/{PageColumns-D7jIeVv6.js → PageColumns-DpfaPeu7.js} +1 -1
- package/dist/web/assets/PageOutline-BKBQ1T4d.js +1 -0
- package/dist/web/assets/PageOutline-BqVgnlos.css +1 -0
- package/dist/web/assets/PersonalProfilePage-Cxp2gn6J.js +1 -0
- package/dist/web/assets/PersonalProjectsPage-821imOxR.js +1 -0
- package/dist/web/assets/{PinIcon-DzYhXU_p.js → PinIcon-B7dvh7ld.js} +1 -1
- package/dist/web/assets/{PopperContent-BnejG-fO.js → PopperContent-DNqbLkNa.js} +1 -1
- package/dist/web/assets/{Presence-o9BoSyBV.js → Presence-D3HKb5Hb.js} +1 -1
- package/dist/web/assets/ProfileAuthorChip-7HSHODdR.js +1 -0
- package/dist/web/assets/ProfileAuthorChip-C_0hzDoP.css +1 -0
- package/dist/web/assets/ProjectAgentsPage-DBsXS6Xa.js +5 -0
- package/dist/web/assets/{ProjectAgentsPage-Dt37ogX1.css → ProjectAgentsPage-RpfiV2Fm.css} +1 -1
- package/dist/web/assets/ProjectJudgmentPolicy-GA33aSRi.js +2 -0
- package/dist/web/assets/PublicProjectsPage-PJlBI8IE.js +1 -0
- package/dist/web/assets/{RoundtablesPage-C6vo4kl6.css → RoundtablesPage-DK9A9J-y.css} +1 -1
- package/dist/web/assets/{RoundtablesPage-B2mqkwwR.js → RoundtablesPage-DT5DUXsa.js} +2 -2
- package/dist/web/assets/{RovingFocusGroup-CKxT5j44.js → RovingFocusGroup-BB0d3k17.js} +1 -1
- package/dist/web/assets/{RovingFocusItem-Cr-XrVve.js → RovingFocusItem-CFd7tXzD.js} +1 -1
- package/dist/web/assets/SessionMigrationPage-BZ1lEDQr.js +1 -0
- package/dist/web/assets/SessionRecordsPage-BMAAtIAt.js +1 -0
- package/dist/web/assets/SettingsPage-BYNEk6BM.js +1 -0
- package/dist/web/assets/SettingsPage-Uj1IpZpS.css +1 -0
- package/dist/web/assets/SharedJefaReportPage-g35o6jUb.js +1 -0
- package/dist/web/assets/TagVocabularyPage-COubNJXz.js +1 -0
- package/dist/web/assets/{TaskBlockerClear-38qdj0bl.js → TaskBlockerClear-B5MpHdlh.js} +1 -1
- package/dist/web/assets/{TaskBlockerNotice--X8TtCGj.js → TaskBlockerNotice-CIN0HRiE.js} +1 -1
- package/dist/web/assets/{TaskReason-COiuiZVd.js → TaskReason-LQ0CFiKu.js} +1 -1
- package/dist/web/assets/{TeamCard-Bl4riuQt.css → TeamCard-CsmWDw2Q.css} +1 -1
- package/dist/web/assets/TeamCard-D-kLa5rT.js +1 -0
- package/dist/web/assets/TeamCardsWidget-DGX9k0S6.js +1 -0
- package/dist/web/assets/{TeamIsland-D8ycFpkZ.js → TeamIsland-BIo-l49b.js} +2 -2
- package/dist/web/assets/{Teleport-BAIkXp2z.js → Teleport-C1upABpY.js} +1 -1
- package/dist/web/assets/{TextField-BFGv0VA5.js → TextField-ZnmRqG0h.js} +1 -1
- package/dist/web/assets/{UiChip-h_SUumBM.js → UiChip-CizeOu1Q.js} +1 -1
- package/dist/web/assets/UiDialog-CGTzxn3-.js +1 -0
- package/dist/web/assets/{UiDisclosure-BO5EAYyS.js → UiDisclosure-ueMA4jl0.js} +1 -1
- package/dist/web/assets/UiIcon-sD1hUsOF.js +1 -0
- package/dist/web/assets/{UiIconButton-C0WP-F-p.js → UiIconButton-CCo4NPYv.js} +1 -1
- package/dist/web/assets/{UiNotice-NCEwjNQR.js → UiNotice-DGPFbVo7.js} +1 -1
- package/dist/web/assets/{UiSegmented-B49yYjJ3.js → UiSegmented-BZ-jqnPE.js} +1 -1
- package/dist/web/assets/{UiWeight-DRIwuLUX.js → UiWeight-BRO3oVMZ.js} +1 -1
- package/dist/web/assets/{VirtualDirectoryList-Dieq64pn.js → VirtualDirectoryList-BkV3gj5E.js} +1 -1
- package/dist/web/assets/{VisuallyHidden-DIWFV5lV.js → VisuallyHidden-B8wfJ_mU.js} +1 -1
- package/dist/web/assets/{VisuallyHiddenInput-WxcAZDj2.js → VisuallyHiddenInput-Bdcr9CwC.js} +1 -1
- package/dist/web/assets/WidgetSlot-DFojQaSo.js +2 -0
- package/dist/web/assets/_plugin-vue_export-helper-B9AJmZbc.js +9 -0
- package/dist/web/assets/{agent-apps-CXhZLNMa.js → agent-apps-CKGFfySp.js} +1 -1
- package/dist/web/assets/{agent-avatar-xTnj6P4n.js → agent-avatar-V6M_DF3r.js} +1 -1
- package/dist/web/assets/agent-occupation-PZ2YAIM8.js +1 -0
- package/dist/web/assets/{agent-pins-CMBM9w6b.js → agent-pins-8KX0ynzy.js} +1 -1
- package/dist/web/assets/agent-profile-Clb-gYu-.css +1 -0
- package/dist/web/assets/{agent-roster-records-pCYzR1as.js → agent-roster-records-PfAgndHp.js} +1 -1
- package/dist/web/assets/{agent-workflows-IeF737kp.js → agent-workflows-DQlqVOoA.js} +1 -1
- package/dist/web/assets/{attach-closest-edge-B34lttZK.js → attach-closest-edge-D2qlayPy.js} +1 -1
- package/dist/web/assets/{attention-store-BTKBC8TZ.js → attention-store-BnZ8l3kk.js} +1 -1
- package/dist/web/assets/{badge-Bnc2nVhV.js → badge-DX_xrLV6.js} +1 -1
- package/dist/web/assets/button-CEkPBC1E.js +1 -0
- package/dist/web/assets/button-CoXXgtY5.css +1 -0
- package/dist/web/assets/{card-B2JIXyum.js → card-DNQ0_6vT.js} +1 -1
- package/dist/web/assets/{catalog-C8eUDXUx.js → catalog-KnpBkv5t.js} +1 -1
- package/dist/web/assets/{checkbox-Blw3CguI.js → checkbox-DPyLHneg.js} +1 -1
- package/dist/web/assets/{client-AaxCWoEF.js → client-CSQcWFRh.js} +2 -2
- package/dist/web/assets/client-connection-model-vO2cap6a.js +1 -0
- package/dist/web/assets/{client-links-store-CmP5Qsfa.js → client-links-store-DMqe0MbK.js} +1 -1
- package/dist/web/assets/combobox-zUq9bkyM.js +1 -0
- package/dist/web/assets/{console-DtxpKdVW.js → console-DaoAO-EO.js} +1 -1
- package/dist/web/assets/{context-menu-DSGaOBX2.js → context-menu-CcGDnF_k.js} +1 -1
- package/dist/web/assets/{conversation-launcher-settings-DAL9Kf4y.js → conversation-launcher-settings-CXFE-q_A.js} +1 -1
- package/dist/web/assets/{dialog-CwFuZvhM.js → dialog-CxhKMo0D.js} +1 -1
- package/dist/web/assets/dist-B9GqMC5C.js +1 -0
- package/dist/web/assets/dist-DIJqkL4O.js +1 -0
- package/dist/web/assets/dropdown-menu-CXmMnCBh.js +1 -0
- package/dist/web/assets/field-LNsBZqam.js +1 -0
- package/dist/web/assets/{format-bytes-N7zRFzUD.js → format-bytes-Bqefdt37.js} +1 -1
- package/dist/web/assets/{identity-BUFzZs1s.js → identity-DRfhWjty.js} +1 -1
- package/dist/web/assets/index-B4AMPpl_.css +1 -0
- package/dist/web/assets/index-BYIOAXnn.js +2 -0
- package/dist/web/assets/{input-Db1wVnd4.js → input-UoZ-0Xne.js} +1 -1
- package/dist/web/assets/{label--RjFNYxb.js → label-DpjbTOxt.js} +1 -1
- package/dist/web/assets/label-table-BnWNYfyk.js +1 -0
- package/dist/web/assets/{model-crzN3PVX.js → model-13BQndfF.js} +1 -1
- package/dist/web/assets/{model-KuA63FiT.js → model-B5g0CFcM.js} +1 -1
- package/dist/web/assets/model-BYKHVgJr.js +1 -0
- package/dist/web/assets/{model-B5f68kqL.js → model-CDevUwUw.js} +1 -1
- package/dist/web/assets/model-CpuIG8Du.js +4 -0
- package/dist/web/assets/{model-B5dQs6Zt.js → model-P5fSGsiJ.js} +1 -1
- package/dist/web/assets/{model-DOf6QDiY.js → model-pJ6k3zYD.js} +1 -1
- package/dist/web/assets/{motion-CeLn8y1x.js → motion-C-ZimCUS.js} +1 -1
- package/dist/web/assets/{motion-wEp9RlID.js → motion-QY5FKKko.js} +1 -1
- package/dist/web/assets/{motion-preference-DfUreaML.js → motion-preference-BQiiwhab.js} +1 -1
- package/dist/web/assets/{occupation-catalog-Crs_Zc8R.js → occupation-catalog-uDDhZwKK.js} +1 -1
- package/dist/web/assets/{option-DCSIgajR.js → option-CcHPBOo6.js} +1 -1
- package/dist/web/assets/{orchestration-filters-Cu9KEzWE.js → orchestration-filters-DmF4Qs8E.js} +1 -1
- package/dist/web/assets/{page-title-Bvm24KbY.js → page-title-NXphgeQI.js} +1 -1
- package/dist/web/assets/{person-profile-Cf0Sytyw.js → person-profile-DXXfpvta.js} +1 -1
- package/dist/web/assets/popover-xSRzcSmY.js +1 -0
- package/dist/web/assets/popup-host-Bmvrf-2t.js +1 -0
- package/dist/web/assets/{profile-model-DkDH6Qth.js → profile-model-6gTmScHC.js} +1 -1
- package/dist/web/assets/{project-board-layout-OeuzohUI.js → project-board-layout-DBQeP_QP.js} +1 -1
- package/dist/web/assets/{project-capture-BQAqeAJf.js → project-capture-BhYsDWwJ.js} +1 -1
- package/dist/web/assets/{project-origin-CENDtRuK.js → project-origin-D8jy8EF_.js} +1 -1
- package/dist/web/assets/{quick-edit-api-Qndjqk1h.js → quick-edit-api-WLh_88w6.js} +1 -1
- package/dist/web/assets/{radio-group-pfWejLFt.js → radio-group-B4r78nDh.js} +1 -1
- package/dist/web/assets/{role-names-aIXV-sMx.js → role-names-PECaMfQo.js} +1 -1
- package/dist/web/assets/{roundtable-live-D7Asm_GB.js → roundtable-live-DFeDF56c.js} +1 -1
- package/dist/web/assets/{runtime-dom.esm-bundler-BS2lpl87.js → runtime-dom.esm-bundler-f39i44Mt.js} +1 -1
- package/dist/web/assets/save-file-rPduHi2f.js +1 -0
- package/dist/web/assets/select-_JO3Mxdp.js +1 -0
- package/dist/web/assets/{session-launch-offers-kLW-dRsW.js → session-launch-offers-X9b0DwF1.js} +1 -1
- package/dist/web/assets/settings-restart-BnwcTv3i.js +1 -0
- package/dist/web/assets/shared-report-BxNVLalR.js +3 -0
- package/dist/web/assets/shared-report-mYIyRY9C.css +1 -0
- package/dist/web/assets/{source-adapters-CUxqZHz7.js → source-adapters-aupsL146.js} +1 -1
- package/dist/web/assets/{switch-Cdz4-JcE.js → switch-B3Y3oE_n.js} +1 -1
- package/dist/web/assets/{tabs-C3w1-eMu.js → tabs-BlcZiEMY.js} +1 -1
- package/dist/web/assets/{task-board-model-DSr4P56O.js → task-board-model-CmMKsWdY.js} +1 -1
- package/dist/web/assets/task-card-fields-DAx6zMLz.js +1 -0
- package/dist/web/assets/task-labels-BdDFvSAy.js +1 -0
- package/dist/web/assets/{task-reason-BywD_kfi.js → task-reason-7WnPreht.js} +1 -1
- package/dist/web/assets/{team-sheets-D8Y--CP4.js → team-sheets-Cr0ZTPw3.js} +1 -1
- package/dist/web/assets/{textarea-C228nxbD.js → textarea-CRzFqL9a.js} +1 -1
- package/dist/web/assets/{ui-BM8jZcP6.js → ui-BopQuQfc.js} +1 -1
- package/dist/web/assets/{useAgentRecords-D7x4xQ9O.js → useAgentRecords-CMtpd3Fj.js} +1 -1
- package/dist/web/assets/{useAgentWorkSummary-pc1i6nr0.js → useAgentWorkSummary-BQbhaHov.js} +1 -1
- package/dist/web/assets/{useApi-CROJJdhE-DZtkWJZv.js → useApi-CROJJdhE-CRCgNOqq.js} +1 -1
- package/dist/web/assets/{useClipboardCopy-sTthF_MD.js → useClipboardCopy-DkqKK3wY.js} +1 -1
- package/dist/web/assets/{useFocusReturn-BoyUh5y3.js → useFocusReturn-BZpVmQnM.js} +1 -1
- package/dist/web/assets/{useForwardExpose-CqXuqZvd.js → useForwardExpose-Di-MnbTz.js} +1 -1
- package/dist/web/assets/{useForwardPropsEmits-0F_e7unJ.js → useForwardPropsEmits-L9XcB5DG.js} +1 -1
- package/dist/web/assets/useForwardScopeId-CUQFIAIj.js +1 -0
- package/dist/web/assets/useKnowledgeItemPeek-PmQJixw5.js +1 -0
- package/dist/web/assets/{useMinimumLoadingDisplay-CzfqbQPs.js → useMinimumLoadingDisplay-CWPiOaDl.js} +1 -1
- package/dist/web/assets/useProjectAgentRoster-CWVpSsQ3.js +1 -0
- package/dist/web/assets/{useRoutePeek-BDgll9Fy.js → useRoutePeek-DxLVksbJ.js} +1 -1
- package/dist/web/assets/useTeamPeople-CDISP0PM.js +1 -0
- package/dist/web/assets/{useTeamWork-BSFi27vj.js → useTeamWork-BTZd_wKs.js} +1 -1
- package/dist/web/assets/{useTypeahead-D_g4j3Xp.js → useTypeahead-pEZNpBls.js} +1 -1
- package/dist/web/assets/{utils-C6vsxGrE.js → utils-B4pBTmyh.js} +1 -1
- package/dist/web/assets/utils-BsxOjD1Q.js +1 -0
- package/dist/web/assets/version-db3QWWjt.js +1 -0
- package/dist/web/assets/{vue-router-BPhQ0Qow.js → vue-router-B79HWW1l.js} +1 -1
- package/dist/web/assets/website-YgovUEcN.js +1 -0
- package/dist/web/index.html +71 -66
- package/docs/agent-interface-architecture.md +13 -4
- package/docs/client-connections.md +3 -2
- package/docs/employee-agents.md +11 -9
- package/docs/judgment-and-autonomy.md +4 -4
- package/graph-provider/fuli_graph/app.py +4 -0
- package/graph-provider/fuli_graph/collaboration_context.py +3 -7
- package/graph-provider/fuli_graph/graph_field_contract.py +10 -2
- package/graph-provider/fuli_graph/graph_format_builtin_occupations.py +33 -1
- package/graph-provider/fuli_graph/graph_format_migrations.py +18 -0
- package/graph-provider/fuli_graph/graph_query.py +3 -12
- package/graph-provider/fuli_graph/knowledge_index_scan.py +120 -0
- package/graph-provider/fuli_graph/knowledge_outdated.py +9 -1
- package/graph-provider/fuli_graph/knowledge_retrieval_models.py +95 -0
- package/graph-provider/fuli_graph/knowledge_retrieval_terms.py +116 -0
- package/graph-provider/fuli_graph/knowledge_search.py +220 -39
- package/graph-provider/fuli_graph/knowledge_semantic.py +87 -0
- package/graph-provider/fuli_graph/knowledge_semantic_index.py +98 -0
- package/graph-provider/fuli_graph/knowledge_semantic_models.py +72 -0
- package/graph-provider/fuli_graph/knowledge_semantic_query.py +19 -0
- package/graph-provider/fuli_graph/knowledge_versions.py +14 -7
- package/graph-provider/fuli_graph/models.py +4 -0
- package/graph-provider/fuli_graph/occupation_catalog.py +6 -3
- package/graph-provider/fuli_graph/personal_global_preferences.py +3 -7
- package/graph-provider/fuli_graph/preference_versions.py +110 -0
- package/graph-provider/fuli_graph/project_agent_models.py +3 -0
- package/graph-provider/fuli_graph/project_agent_recruitment_occupation.py +1 -1
- package/graph-provider/fuli_graph/provider_values.py +7 -0
- package/graph-provider/fuli_graph/search_projection.py +2 -6
- package/graph-provider/fuli_graph/store_knowledge.py +10 -1
- package/graph-provider/fuli_graph/task_context_routes.py +1 -1
- package/graph-provider/pyproject.toml +1 -1
- package/native/win32/fuli-win-helper.exe +0 -0
- package/npm-shrinkwrap.json +3 -4
- package/package.json +2 -1
- package/skills/capturing-session-knowledge/SKILL.md +14 -7
- package/skills/capturing-session-knowledge/references/capture.md +12 -2
- package/skills/capturing-session-knowledge/references/retrieval.md +13 -4
- package/skills/grilling-project/SKILL.md +2 -0
- package/skills/operating-fuli/SKILL.md +36 -8
- package/skills/operating-fuli/references/workflow-recipes.md +10 -9
- package/src/agent-apps/host-tools/catalog.js +3 -0
- package/src/agent-delegation/agent-tool.js +12 -2
- package/src/agent-delegation/delegation-header.js +32 -8
- package/src/agent-delegation/entry-prompts.js +54 -0
- package/src/agent-delegation/operation-log.js +17 -7
- package/src/agent-delegation/person-words.js +38 -0
- package/src/agent-delegation/port.js +6 -4
- package/src/agent-delegation/refusals.js +14 -0
- package/src/agent-kits/client-detection.js +7 -0
- package/src/agent-kits/client-installer.js +13 -0
- package/src/agent-tools/delegation-definitions.js +5 -3
- package/src/agent-tools/diagnostic-definitions.js +23 -0
- package/src/agent-tools/graph-definitions.js +4 -0
- package/src/agent-tools/graph-handlers.js +6 -1
- package/src/agent-tools/interface-catalog.js +47 -17
- package/src/agent-tools/model-backend-definitions.js +1 -1
- package/src/agent-tools/old-data-definitions.js +16 -0
- package/src/agent-tools/task-entry-definitions.js +1 -1
- package/src/agent-tools/work-surface-definitions.js +1 -1
- package/src/agents/claude-code/lifecycle-hook.js +19 -5
- package/src/agents/claude-code/transcript-format-probe.js +31 -0
- package/src/agents/codex/lifecycle-hook.js +27 -7
- package/src/agents/codex/transcript-format-probe.js +29 -0
- package/src/agents/cursor/lifecycle-hook.js +4 -1
- package/src/agents/lifecycle-failure.js +27 -0
- package/src/agents/lifecycle-message.js +10 -0
- package/src/agents/opencode/lifecycle-hook.js +18 -2
- package/src/agents/transcript-format-registry.js +34 -0
- package/src/agents/transcript-format-scan.js +71 -0
- package/src/cli/command-registry.js +3 -0
- package/src/cli/diagnostics-command.js +59 -0
- package/src/cli/setup-command.js +3 -0
- package/src/cli.js +5 -0
- package/src/conversations/entry-budget.js +1 -1
- package/src/conversations/entry-detail-readers.js +22 -0
- package/src/conversations/entry-inline-budget.js +24 -12
- package/src/conversations/entry-skeleton.js +27 -9
- package/src/conversations/preference-lifecycle.js +2 -1
- package/src/conversations/preference-session.js +5 -2
- package/src/conversations/preference-snapshot.js +4 -1
- package/src/conversations/preference-view.js +5 -1
- package/src/conversations/reply-citations.js +21 -0
- package/src/conversations/stop-auto-close.js +21 -9
- package/src/conversations/task-context-view.js +31 -0
- package/src/data-format/backup-retention.js +8 -0
- package/src/data-format/local-stores.js +24 -2
- package/src/debug-turns/fuli-surface.js +23 -0
- package/src/debug-turns/model-capture.js +84 -0
- package/src/debug-turns/model-request.js +97 -0
- package/src/debug-turns/record.js +178 -0
- package/src/debug-turns/recorder.js +53 -0
- package/src/debug-turns/store.js +91 -0
- package/src/debug-turns/transcript-reader.js +64 -0
- package/src/debug-turns/trigger.js +25 -0
- package/src/diagnostics/agent-tool.js +14 -0
- package/src/diagnostics/event-log.js +133 -0
- package/src/diagnostics/failure-records.js +43 -0
- package/src/diagnostics/query.js +114 -0
- package/src/diagnostics/safe-event.js +83 -0
- package/src/dreaming/run.js +310 -0
- package/src/dreaming/scheduler.js +58 -0
- package/src/employees/builtin/jefa/board-store.js +78 -19
- package/src/employees/builtin/jefa/http.js +8 -5
- package/src/employees/builtin/jefa/project-board.js +2 -0
- package/src/employees/builtin/jefa/tools.js +7 -6
- package/src/employees/recruitment.js +20 -2
- package/src/employees/service.js +11 -1
- package/src/graphiti/agent-growth.js +64 -0
- package/src/graphiti/collaboration-preference-projection.js +7 -0
- package/src/graphiti/collaboration-preference-workflow.js +3 -3
- package/src/graphiti/current-project-knowledge-search.js +24 -1
- package/src/graphiti/federated-application.js +19 -1
- package/src/graphiti/federated-search.js +8 -1
- package/src/graphiti/local-runtimes.js +13 -0
- package/src/graphiti/personal-projects.js +11 -0
- package/src/graphiti/project-agent-mapping.js +1 -0
- package/src/graphiti/project-agent-task-sheets.js +6 -2
- package/src/graphiti/project-agent-workflows.js +22 -4
- package/src/graphiti/project-profile-authors.js +14 -7
- package/src/graphiti/provider-client.js +36 -0
- package/src/graphiti/session-knowledge-migration.js +103 -3
- package/src/graphiti/session-migration-notices.js +65 -0
- package/src/graphiti/session-records.js +22 -4
- package/src/graphiti/task-context-entry.js +5 -1
- package/src/graphiti/task-entry-preferences.js +31 -2
- package/src/graphiti/task-entry-read-only.js +28 -0
- package/src/graphiti/task-knowledge-checkpoint.js +2 -0
- package/src/graphiti/task-knowledge-recall.js +96 -19
- package/src/graphiti/task-remember.js +7 -2
- package/src/graphiti/task-update-request.js +13 -0
- package/src/graphiti/temporary-project-scope.js +7 -1
- package/src/graphiti/turn-receipt-delivery.js +5 -3
- package/src/http/agent-delegation-gate.js +5 -4
- package/src/http/agent-growth-api-router.js +17 -0
- package/src/http/api-router.js +18 -2
- package/src/http/capture-onboarding-api-router.js +3 -2
- package/src/http/debug-turns-api-router.js +70 -0
- package/src/http/diagnostic-events-api-router.js +27 -0
- package/src/http/dreaming-api-router.js +32 -0
- package/src/http/graph-api-router.js +35 -1
- package/src/http/knowledge-item-api-router.js +19 -2
- package/src/http/knowledge-scope-api-router.js +3 -2
- package/src/http/old-data-api-router.js +47 -0
- package/src/http/person-profile-api-router.js +3 -2
- package/src/http/retrieval-terms-api-router.js +37 -0
- package/src/http/semantic-api-router.js +26 -0
- package/src/judgment/agent-view.js +1 -1
- package/src/judgment/backend.js +30 -0
- package/src/judgment/http.js +2 -1
- package/src/judgment/review-prompt.js +2 -0
- package/src/judgment/routing.js +10 -2
- package/src/judgment/service.js +8 -2
- package/src/judgment/store.js +17 -7
- package/src/local-runtime/lifecycle.js +3 -0
- package/src/local-runtime/windows-process-handle.js +9 -3
- package/src/mcp/create-mcp-server.js +42 -25
- package/src/mcp/process-registry.js +45 -3
- package/src/mcp/runtime.js +2 -1
- package/src/mcp/stdio-relay.js +4 -1
- package/src/mcp/tool-annotations.js +2 -0
- package/src/model-backends/adapters/anthropic-messages.js +1 -1
- package/src/model-backends/adapters/exchange.js +2 -2
- package/src/model-backends/adapters/openai-chat.js +1 -1
- package/src/model-backends/adapters/openai-embeddings.js +60 -0
- package/src/model-backends/adapters/registry.js +3 -1
- package/src/model-backends/adapters/typesafe-systemone.js +1 -1
- package/src/model-backends/budget.js +14 -8
- package/src/model-backends/config.js +49 -15
- package/src/model-backends/decision-contract.js +2 -1
- package/src/model-backends/http.js +19 -1
- package/src/model-backends/model-fetch.js +37 -0
- package/src/model-backends/port.js +165 -67
- package/src/model-backends/prompt.js +4 -3
- package/src/model-backends/request.js +42 -3
- package/src/native-runtime/runtime.js +28 -4
- package/src/old-data/agent-tools.js +17 -0
- package/src/old-data/backup-reader.js +78 -0
- package/src/old-data/console-actions.js +53 -0
- package/src/old-data/guarded-stores.js +18 -0
- package/src/old-data/inventory.js +142 -0
- package/src/old-data/port.js +53 -0
- package/src/person-profile/port.js +2 -1
- package/src/presence/windows-helper-pin.js +1 -1
- package/src/project-change-log/port.js +65 -0
- package/src/project-change-log/store.js +60 -0
- package/src/retrieval-terms/fill.js +102 -0
- package/src/retrieval-terms/runner.js +50 -0
- package/src/retrieval-terms/terms-model.js +99 -0
- package/src/security/sensitive-content.js +11 -0
- package/src/semantic/scheduler.js +50 -0
- package/src/semantic/semantic-index.js +94 -0
- package/src/server.js +20 -1
- package/src/setup/paths.js +1 -1
- package/src/setup/setup.js +7 -0
- package/src/system/client-connection-status.js +6 -4
- package/src/system/doctor-repair.js +16 -4
- package/src/system/doctor.js +75 -3
- package/src/system/log-paths.js +11 -0
- package/src/system/log-retention.js +2 -8
- package/src/system/mcp-process-scan.js +55 -0
- package/src/system/resource-monitor.js +18 -2
- package/src/system/system-service.js +39 -7
- package/src/system/windows-data-acl.js +109 -0
- package/src/work-surfaces/port.js +17 -11
- package/src/work-surfaces/sources.js +4 -3
- package/dist/web/assets/AboutSectionHeading-BOXKE5Le.js +0 -1
- package/dist/web/assets/AboutSectionHeading-CiD3M3eG.css +0 -1
- package/dist/web/assets/AgentAppsPage-DS2X485q.js +0 -1
- package/dist/web/assets/AgentConversations-D7QJVFIo.js +0 -2
- package/dist/web/assets/AgentConversations-oZFXZE1X.css +0 -1
- package/dist/web/assets/AgentMentionCopy-O6pAjjYE.js +0 -1
- package/dist/web/assets/AgentProfilePage-CKCTcTzc.js +0 -2
- package/dist/web/assets/AgentProfilePage-D1ha8O3z.css +0 -1
- package/dist/web/assets/AgentServicesPage-C3npKkHp.js +0 -1
- package/dist/web/assets/AgentWorkbench-CJ4TYQA1.css +0 -1
- package/dist/web/assets/AgentWorkbench-D9HGRW-n.js +0 -2
- package/dist/web/assets/AppViewerPage-Al4TzYJF.js +0 -1
- package/dist/web/assets/BoardMoveMenu-ncWgEitd.js +0 -1
- package/dist/web/assets/Breadcrumb-QzjzIJdS.js +0 -1
- package/dist/web/assets/Breadcrumb-bsc0JKtG.css +0 -1
- package/dist/web/assets/CaptureChangePage-BQdqH2qC.js +0 -1
- package/dist/web/assets/ConnectionsPage-Be8jIb93.js +0 -1
- package/dist/web/assets/DataFormatPage-0Ne27K6I.css +0 -1
- package/dist/web/assets/DataFormatPage-C92rwzHa.js +0 -2
- package/dist/web/assets/EmployeeScopeDialog-DdR2DzcW.js +0 -1
- package/dist/web/assets/EmployeeTaskBoard-Bo8JT36K.js +0 -3
- package/dist/web/assets/EmployeeTaskBoard-Dljjy_L7.css +0 -1
- package/dist/web/assets/EmployeeWorkbenchPage-B249Mgle.js +0 -3
- package/dist/web/assets/EmployeeWorkbenchPage-BBjZJ6Od.css +0 -1
- package/dist/web/assets/FieldRoot-YdKVCBhW.js +0 -1
- package/dist/web/assets/FlaTaskSheets-Cm5SLq7J.js +0 -1
- package/dist/web/assets/FlasPage-C57gTN5X.js +0 -1
- package/dist/web/assets/HowtoPage-CDJScY6b.js +0 -1
- package/dist/web/assets/KnowledgeDeleteButton-5EtCPPl4.js +0 -1
- package/dist/web/assets/KnowledgeHardDeleteSection-r0lZ7ijb.js +0 -1
- package/dist/web/assets/KnowledgeItemEditPage-BStIRllM.js +0 -1
- package/dist/web/assets/KnowledgeOrganizerPage-BByk8hbw.js +0 -1
- package/dist/web/assets/KnowledgePage-DuWS3bRP.js +0 -1
- package/dist/web/assets/KnowledgePeek-BycBJ2xR.js +0 -1
- package/dist/web/assets/KnowledgePeek-EvumfJER.css +0 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-DTcDN-pG.js +0 -1
- package/dist/web/assets/KnowledgeWorkspace-CJo-6xdn.js +0 -4
- package/dist/web/assets/KnowledgeWorkspace-DPBq-At0.css +0 -1
- package/dist/web/assets/ModelSettingsPage-C1ghraAh.js +0 -1
- package/dist/web/assets/ModelSettingsPage-ConWy_ec.css +0 -1
- package/dist/web/assets/OccupationsPage-BY1jej7i.js +0 -1
- package/dist/web/assets/OverviewPage-C7YJf-Cq.css +0 -1
- package/dist/web/assets/OverviewPage-Dl-H0EBe.js +0 -1
- package/dist/web/assets/PersonalProfilePage-BcaVzKM6.js +0 -1
- package/dist/web/assets/PersonalProjectsPage-CO4ZYVAI.js +0 -1
- package/dist/web/assets/ProjectAgentDetailPage-Bgh78Mr5.js +0 -8
- package/dist/web/assets/ProjectAgentDetailPage-h7hr9iee.css +0 -1
- package/dist/web/assets/ProjectAgentDialog--T6mU-FW.css +0 -1
- package/dist/web/assets/ProjectAgentDialog-DzTor5ky.js +0 -5
- package/dist/web/assets/ProjectAgentsPage-CzN183pa.js +0 -1
- package/dist/web/assets/ProjectJudgmentPolicy-BMlEBJM3.js +0 -2
- package/dist/web/assets/PublicProjectsPage-DAHT31B8.js +0 -1
- package/dist/web/assets/SessionMigrationPage-IW07XhmD.js +0 -1
- package/dist/web/assets/SessionRecordsPage-Du76tewc.js +0 -1
- package/dist/web/assets/SettingsPage-CJNXe313.js +0 -1
- package/dist/web/assets/SettingsPage-D3AYCNTC.css +0 -1
- package/dist/web/assets/SharedJefaReportPage-dzHSSGhu.js +0 -1
- package/dist/web/assets/TagVocabularyPage-C_oV6GFs.js +0 -1
- package/dist/web/assets/TeamCard-CdO0RiNB.js +0 -1
- package/dist/web/assets/TeamCardsWidget-Cg_kJmb-.js +0 -1
- package/dist/web/assets/UiDialog-CUgrU6SQ.js +0 -1
- package/dist/web/assets/UiIcon-DPv0eZIU.js +0 -1
- package/dist/web/assets/WidgetSlot-BSU_-l_4.js +0 -2
- package/dist/web/assets/_plugin-vue_export-helper-DQENg-QE.js +0 -9
- package/dist/web/assets/agent-occupation-BvOgDW-q.js +0 -1
- package/dist/web/assets/agent-profile-BBqkfac0.css +0 -1
- package/dist/web/assets/agent-task-board-Cf9il_1i.js +0 -1
- package/dist/web/assets/button-N4FjuQuJ.js +0 -1
- package/dist/web/assets/client-connection-model-C3gpYYl7.js +0 -1
- package/dist/web/assets/combobox-DHwWXUpj.js +0 -1
- package/dist/web/assets/desktop-client-DnfjyLBX.js +0 -1
- package/dist/web/assets/dist-BInsvNsv.js +0 -1
- package/dist/web/assets/dist-Dc8jFf8M.js +0 -1
- package/dist/web/assets/field-BQLn7Hfw.js +0 -1
- package/dist/web/assets/index-CXPYDcyq.js +0 -2
- package/dist/web/assets/index-x95VDmzK.css +0 -1
- package/dist/web/assets/judgment-api-CK9yqrpU.js +0 -1
- package/dist/web/assets/label-table-KdyaCTvK.js +0 -1
- package/dist/web/assets/model-D4kKYvpj.js +0 -1
- package/dist/web/assets/popover-D4YFkL_5.js +0 -1
- package/dist/web/assets/project-board-settings-DPP6xKLz.js +0 -1
- package/dist/web/assets/project-team-api-7ybLH-uJ.js +0 -1
- package/dist/web/assets/save-file-CRxAsski.js +0 -1
- package/dist/web/assets/select-CUy1AIwE.js +0 -1
- package/dist/web/assets/settings-restart-JYH81qB-.js +0 -1
- package/dist/web/assets/shared-report-8p3nBKr-.js +0 -1
- package/dist/web/assets/source-coverage-4PsHC9TK.js +0 -1
- package/dist/web/assets/task-labels-CXBG2chm.js +0 -1
- package/dist/web/assets/useForwardScopeId-DVUFcuwO.js +0 -1
- package/dist/web/assets/useKnowledgeItemPeek-KZveY8Wz.js +0 -1
- package/dist/web/assets/useTeamPeople-Dna3Yrm3.js +0 -1
- package/dist/web/assets/utils-BX1QI2N6.js +0 -1
- package/dist/web/assets/version-CBPeq5nI.js +0 -1
|
@@ -11,6 +11,7 @@ from .provider_values import (
|
|
|
11
11
|
json_object,
|
|
12
12
|
native_datetime as _native_datetime,
|
|
13
13
|
normalized_text as _normalized,
|
|
14
|
+
preference_key,
|
|
14
15
|
preference_qualifiers,
|
|
15
16
|
)
|
|
16
17
|
from .search_projection import (
|
|
@@ -20,11 +21,16 @@ from .search_projection import (
|
|
|
20
21
|
read_edge_epistemic_metadata,
|
|
21
22
|
source_uris_from_references,
|
|
22
23
|
)
|
|
24
|
+
from .knowledge_semantic import fused_ranking, meaning_matches, usable_vector
|
|
23
25
|
from .knowledge_weight import knowledge_weight, ranking_weight
|
|
24
26
|
from .knowledge_tag_ranking import TagRanking
|
|
25
27
|
from .knowledge_visibility import AgentReader, fla_endpoints_visible_cypher, fla_visible, reader_parameter
|
|
26
28
|
|
|
27
29
|
MIN_TERM_COVERAGE = 0.25
|
|
30
|
+
# How many items with a vector of the query's model one search compares (rec#88).
|
|
31
|
+
SEMANTIC_CANDIDATE_LIMIT = 5000
|
|
32
|
+
# A preference key's separators, so `reply-language` is also the words "reply language".
|
|
33
|
+
_KEY_SEPARATORS = re.compile(r'[-_.:/]+')
|
|
28
34
|
LATIN_QUERY_FILLERS = {
|
|
29
35
|
'a', 'an', 'and', 'are', 'can', 'could', 'do', 'does', 'find', 'for',
|
|
30
36
|
'from', 'give', 'how', 'i', 'in', 'is', 'it', 'me', 'of', 'on', 'please',
|
|
@@ -48,6 +54,14 @@ async def search_knowledge(store, actor: dict, request: SearchRequest, *, tag_ex
|
|
|
48
54
|
group_ids=group_ids,
|
|
49
55
|
num_results=min(max(request.limit * 8, 40), 100),
|
|
50
56
|
)
|
|
57
|
+
# Relationships found only by their retrieval terms join the lexical ones (rec#92).
|
|
58
|
+
edge_terms, term_edges = await _term_edge_candidates(store, personal_space, request)
|
|
59
|
+
found = {edge.uuid for edge in edges}
|
|
60
|
+
edges = [*edges, *(edge for edge in term_edges if edge.uuid not in found)]
|
|
61
|
+
lexical_ids = {edge.uuid for edge in edges}
|
|
62
|
+
# Relationships found by meaning pass the very same filters below.
|
|
63
|
+
meaning_vectors, meaning_edges = await _semantic_edge_candidates(store, personal_space, request)
|
|
64
|
+
edges = [*edges, *(edge for edge in meaning_edges if edge.uuid not in lexical_ids)]
|
|
51
65
|
if not request.include_historical:
|
|
52
66
|
edges = [edge for edge in edges if edge.invalid_at is None]
|
|
53
67
|
project_scopes = {}
|
|
@@ -82,6 +96,8 @@ async def search_knowledge(store, actor: dict, request: SearchRequest, *, tag_ex
|
|
|
82
96
|
]
|
|
83
97
|
names = await _entity_names(store, edges)
|
|
84
98
|
tag_ranking = await TagRanking.for_search(store, personal_space, request, project_scopes)
|
|
99
|
+
in_scope_vectors = {edge.uuid: meaning_vectors[edge.uuid] for edge in edges if edge.uuid in meaning_vectors}
|
|
100
|
+
edges = [edge for edge in edges if edge.uuid in lexical_ids]
|
|
85
101
|
ranked_edges = sorted(
|
|
86
102
|
(
|
|
87
103
|
(
|
|
@@ -92,6 +108,7 @@ async def search_knowledge(store, actor: dict, request: SearchRequest, *, tag_ex
|
|
|
92
108
|
names,
|
|
93
109
|
position,
|
|
94
110
|
len(edges),
|
|
111
|
+
edge_terms.get(edge.uuid),
|
|
95
112
|
),
|
|
96
113
|
epistemic.get(edge.uuid, {}),
|
|
97
114
|
),
|
|
@@ -103,6 +120,10 @@ async def search_knowledge(store, actor: dict, request: SearchRequest, *, tag_ex
|
|
|
103
120
|
reverse=True,
|
|
104
121
|
)
|
|
105
122
|
ranked_edges = [item for item in ranked_edges if item[0] > 0]
|
|
123
|
+
meaning_edges = {edge.uuid: edge for edge in meaning_edges}
|
|
124
|
+
ranked_edges, edge_matches = _fused_with_meaning(
|
|
125
|
+
ranked_edges, [meaning_edges[edge_id] for edge_id in _meaning_order(request, in_scope_vectors)],
|
|
126
|
+
lambda edge: edge.uuid)
|
|
106
127
|
if personal_space:
|
|
107
128
|
ranked_edges = _dedupe_ranked_edges(
|
|
108
129
|
ranked_edges,
|
|
@@ -132,7 +153,7 @@ async def search_knowledge(store, actor: dict, request: SearchRequest, *, tag_ex
|
|
|
132
153
|
space_ids_by_group[edge.group_id],
|
|
133
154
|
epistemic.get(edge.uuid, {}),
|
|
134
155
|
).model_copy(
|
|
135
|
-
update={'score': score}
|
|
156
|
+
update={'score': score, 'matched_by': edge_matches.get(edge.uuid, 'lexical')}
|
|
136
157
|
)
|
|
137
158
|
for score, edge in ranked_edges
|
|
138
159
|
],
|
|
@@ -352,9 +373,48 @@ async def _personal_entities(
|
|
|
352
373
|
) -> list[EntitySearchResult]:
|
|
353
374
|
if not project_scopes and not request.include_personal_global:
|
|
354
375
|
return []
|
|
376
|
+
scoped_records = await _scoped_entity_records(store, space, request, project_scopes)
|
|
377
|
+
ranked = sorted(
|
|
378
|
+
(
|
|
379
|
+
(
|
|
380
|
+
record,
|
|
381
|
+
_ranked_relevance(
|
|
382
|
+
_relevance(request.query, record),
|
|
383
|
+
record,
|
|
384
|
+
),
|
|
385
|
+
)
|
|
386
|
+
for record in scoped_records
|
|
387
|
+
),
|
|
388
|
+
key=lambda item: (item[1], _tie_weight(item[0]), _timestamp(item[0].get('created_at'))),
|
|
389
|
+
reverse=True,
|
|
390
|
+
)
|
|
391
|
+
ranked = [item for item in ranked if item[1] > 0]
|
|
392
|
+
meaning = await _semantic_entities(store, space, request, project_scopes)
|
|
393
|
+
fused, entity_matches = _fused_with_meaning(
|
|
394
|
+
[(score, record) for record, score in ranked], meaning, lambda record: record['id'])
|
|
395
|
+
ranked = _dedupe_ranked_entities(
|
|
396
|
+
[(record, score) for score, record in fused],
|
|
397
|
+
request.active_personal_project_id,
|
|
398
|
+
request.project_agent_id,
|
|
399
|
+
)
|
|
400
|
+
ranked = [(record, score) for _, score, record in await (tag_ranking or TagRanking()).rerank(
|
|
401
|
+
[(record['id'], score, record) for record, score in ranked], 'entity', tag_explanations
|
|
402
|
+
)][: request.limit]
|
|
403
|
+
return [
|
|
404
|
+
_entity_search_result(record, score, space['id'], entity_matches.get(record['id'], 'lexical'))
|
|
405
|
+
for record, score in ranked
|
|
406
|
+
]
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
async def _scoped_entity_records(store, space, request: SearchRequest, project_scopes: dict[str, dict],
|
|
410
|
+
*, semantic_model: str | None = None) -> list[dict]:
|
|
411
|
+
"""The entities this search may return, with their scope. With a
|
|
412
|
+
semantic_model, only those carrying a vector of that model, and the
|
|
413
|
+
vector: the same filters decide either way (rec#88)."""
|
|
355
414
|
records, _, _ = await store.runtime.driver.execute_query(
|
|
356
415
|
'''
|
|
357
416
|
MATCH (node:Entity {group_id: $group_id})
|
|
417
|
+
WHERE $semantic_model IS NULL OR node.fuli_semantic_model = $semantic_model
|
|
358
418
|
OPTIONAL MATCH (episode:Episodic {group_id: $group_id})-[:MENTIONS]->(node)
|
|
359
419
|
WITH node, collect(DISTINCT episode) AS episodes
|
|
360
420
|
OPTIONAL MATCH (assignment:FuliKnowledgeAssignment {
|
|
@@ -439,6 +499,12 @@ async def _personal_entities(
|
|
|
439
499
|
AS requires_attention,
|
|
440
500
|
node.fuli_last_feedback_kind AS last_feedback_kind,
|
|
441
501
|
node.fuli_last_feedback_at AS last_feedback_at,
|
|
502
|
+
node.fuli_retrieval_terms AS retrieval_terms,
|
|
503
|
+
node.fuli_retrieval_context AS retrieval_context,
|
|
504
|
+
CASE WHEN $semantic_model IS NOT NULL THEN node.fuli_semantic_vector END
|
|
505
|
+
AS semantic_vector,
|
|
506
|
+
CASE WHEN $semantic_model IS NOT NULL THEN node.fuli_semantic_hash END
|
|
507
|
+
AS semantic_hash,
|
|
442
508
|
[episode IN episodes | episode.uuid] AS evidence_ids,
|
|
443
509
|
[episode IN episodes
|
|
444
510
|
WHERE episode.fuli_source_uri IS NOT NULL |
|
|
@@ -455,7 +521,8 @@ async def _personal_entities(
|
|
|
455
521
|
project_ids=list(project_scopes),
|
|
456
522
|
include_historical=request.include_historical,
|
|
457
523
|
include_pending=request.include_pending,
|
|
458
|
-
|
|
524
|
+
semantic_model=semantic_model,
|
|
525
|
+
candidate_limit=SEMANTIC_CANDIDATE_LIMIT if semantic_model else store.settings.graph_limit,
|
|
459
526
|
routing_='r',
|
|
460
527
|
)
|
|
461
528
|
scoped_records = []
|
|
@@ -481,33 +548,119 @@ async def _personal_entities(
|
|
|
481
548
|
)
|
|
482
549
|
if scope is not None:
|
|
483
550
|
scoped_records.append({**record, **scope})
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
551
|
+
return scoped_records
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
async def _semantic_entities(store, space, request: SearchRequest, project_scopes: dict[str, dict]) -> list[dict]:
|
|
555
|
+
"""The in-scope entities that stand out for the query's meaning, best first."""
|
|
556
|
+
if request.semantic is None:
|
|
557
|
+
return []
|
|
558
|
+
records = await _scoped_entity_records(store, space, request, project_scopes,
|
|
559
|
+
semantic_model=request.semantic.model)
|
|
560
|
+
length = len(request.semantic.vector)
|
|
561
|
+
by_id, vectors = {}, {}
|
|
562
|
+
for record in records:
|
|
563
|
+
vector = usable_vector('entity', record, length)
|
|
564
|
+
if vector is not None:
|
|
565
|
+
by_id[record['id']], vectors[record['id']] = record, vector
|
|
566
|
+
return [by_id[item_id] for item_id in _meaning_order(request, vectors)]
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
async def _semantic_edge_candidates(store, space, request: SearchRequest) -> tuple[dict, list[EntityEdge]]:
|
|
570
|
+
"""Every relationship of the personal space with a usable vector of the
|
|
571
|
+
query's model, as candidates for the search's own filters (rec#88)."""
|
|
572
|
+
if request.semantic is None or space is None:
|
|
573
|
+
return {}, []
|
|
574
|
+
length = len(request.semantic.vector)
|
|
575
|
+
records, _, _ = await store.runtime.driver.execute_query(
|
|
576
|
+
'''
|
|
577
|
+
MATCH (source:Entity)-[edge:RELATES_TO {group_id: $group_id}]->(target:Entity)
|
|
578
|
+
WHERE edge.fuli_semantic_model = $semantic_model
|
|
579
|
+
AND size(edge.fuli_semantic_vector) = $length
|
|
580
|
+
RETURN edge.uuid AS uuid, source.uuid AS source_node_uuid, target.uuid AS target_node_uuid,
|
|
581
|
+
edge.group_id AS group_id, edge.name AS name, edge.fact AS fact,
|
|
582
|
+
coalesce(edge.episodes, []) AS episodes, edge.created_at AS created_at,
|
|
583
|
+
edge.valid_at AS valid_at, edge.invalid_at AS invalid_at, edge.expired_at AS expired_at,
|
|
584
|
+
edge.fuli_semantic_vector AS semantic_vector, edge.fuli_semantic_hash AS semantic_hash,
|
|
585
|
+
edge.fuli_retrieval_terms AS retrieval_terms, edge.fuli_retrieval_context AS retrieval_context
|
|
586
|
+
ORDER BY edge.uuid
|
|
587
|
+
LIMIT $candidate_limit
|
|
588
|
+
''',
|
|
589
|
+
group_id=space['group_id'],
|
|
590
|
+
semantic_model=request.semantic.model,
|
|
591
|
+
length=length,
|
|
592
|
+
candidate_limit=SEMANTIC_CANDIDATE_LIMIT,
|
|
593
|
+
routing_='r',
|
|
497
594
|
)
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
595
|
+
vectors, edges = {}, []
|
|
596
|
+
for record in records:
|
|
597
|
+
vector = usable_vector('relationship', record, length)
|
|
598
|
+
if vector is None:
|
|
599
|
+
continue
|
|
600
|
+
vectors[record['uuid']] = vector
|
|
601
|
+
edges.append(_edge_from_record(record))
|
|
602
|
+
return vectors, edges
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
async def _term_edge_candidates(store, space, request: SearchRequest) -> tuple[dict, list[EntityEdge]]:
|
|
606
|
+
"""The retrieval terms of the personal space's relationships, by id, and
|
|
607
|
+
the relationships the query finds through them, as candidates for the
|
|
608
|
+
search's own filters (rec#92). Word search over facts alone never sees
|
|
609
|
+
terms stored beside them."""
|
|
610
|
+
if space is None:
|
|
611
|
+
return {}, []
|
|
612
|
+
records, _, _ = await store.runtime.driver.execute_query(
|
|
613
|
+
'''
|
|
614
|
+
MATCH (source:Entity)-[edge:RELATES_TO {group_id: $group_id}]->(target:Entity)
|
|
615
|
+
WHERE edge.fuli_retrieval_terms IS NOT NULL
|
|
616
|
+
RETURN edge.uuid AS uuid, source.uuid AS source_node_uuid, target.uuid AS target_node_uuid,
|
|
617
|
+
edge.group_id AS group_id, edge.name AS name, edge.fact AS fact,
|
|
618
|
+
coalesce(edge.episodes, []) AS episodes, edge.created_at AS created_at,
|
|
619
|
+
edge.valid_at AS valid_at, edge.invalid_at AS invalid_at, edge.expired_at AS expired_at,
|
|
620
|
+
edge.fuli_retrieval_terms AS retrieval_terms, edge.fuli_retrieval_context AS retrieval_context
|
|
621
|
+
ORDER BY edge.uuid
|
|
622
|
+
LIMIT $candidate_limit
|
|
623
|
+
''',
|
|
624
|
+
group_id=space['group_id'],
|
|
625
|
+
candidate_limit=SEMANTIC_CANDIDATE_LIMIT,
|
|
626
|
+
routing_='r',
|
|
503
627
|
)
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
628
|
+
terms = {record['uuid']: {'retrieval_terms': record['retrieval_terms'],
|
|
629
|
+
'retrieval_context': record['retrieval_context']} for record in records}
|
|
630
|
+
found = [_edge_from_record(record) for record in records
|
|
631
|
+
if _relevance(request.query, {'summary': record['fact'], **terms[record['uuid']]}) > 0]
|
|
632
|
+
return terms, found
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
def _edge_from_record(record) -> EntityEdge:
|
|
636
|
+
return EntityEdge(
|
|
637
|
+
uuid=record['uuid'], source_node_uuid=record['source_node_uuid'],
|
|
638
|
+
target_node_uuid=record['target_node_uuid'], group_id=record['group_id'],
|
|
639
|
+
name=record['name'] or '', fact=record['fact'] or '', episodes=list(record['episodes']),
|
|
640
|
+
created_at=_native_datetime(record['created_at']), valid_at=_native_datetime(record['valid_at']),
|
|
641
|
+
invalid_at=_native_datetime(record['invalid_at']), expired_at=_native_datetime(record['expired_at']),
|
|
642
|
+
)
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
def _meaning_order(request: SearchRequest, vectors: dict) -> list[str]:
|
|
646
|
+
if request.semantic is None:
|
|
647
|
+
return []
|
|
648
|
+
return list(meaning_matches(vectors, request.semantic.vector, request.limit))
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
def _fused_with_meaning(lexical, meaning, item_id):
|
|
652
|
+
"""lexical: [(score, payload)] in its ranked order; meaning: [payload] best
|
|
653
|
+
first. Without meaning the lexical result stands as it is. Otherwise every
|
|
654
|
+
item's score is its reciprocal rank fusion value; an item found only by
|
|
655
|
+
meaning never met the term-coverage cut. Returns the ranked
|
|
656
|
+
[(score, payload)] and {item id: matched_by}."""
|
|
657
|
+
if not meaning:
|
|
658
|
+
return lexical, {}
|
|
659
|
+
fused = fused_ranking([item_id(payload) for _, payload in lexical], [item_id(payload) for payload in meaning])
|
|
660
|
+
payloads = {item_id(payload): payload for payload in meaning}
|
|
661
|
+
payloads.update({item_id(payload): payload for _, payload in lexical})
|
|
662
|
+
ranked = sorted(((fused[key][0], payloads[key]) for key in fused), key=lambda item: -item[0])
|
|
663
|
+
return ranked, {key: matched_by for key, (_, matched_by) in fused.items()}
|
|
511
664
|
|
|
512
665
|
|
|
513
666
|
def _item_scope_metadata(
|
|
@@ -717,16 +870,11 @@ def _tie_weight(metadata) -> float:
|
|
|
717
870
|
return ranking_weight(metadata, evidence_ids=metadata.get('evidence_ids') or [])
|
|
718
871
|
|
|
719
872
|
|
|
720
|
-
def _entity_search_result(record, score: float, space_id: str) -> EntitySearchResult:
|
|
873
|
+
def _entity_search_result(record, score: float, space_id: str, matched_by: str = 'lexical') -> EntitySearchResult:
|
|
721
874
|
value = dict(record)
|
|
722
875
|
value.update(knowledge_weight(record, evidence_ids=value.pop('evidence_ids', [])))
|
|
723
876
|
attributes = json_object(value.get('attributes_json'))
|
|
724
|
-
value['preference_key'] = (
|
|
725
|
-
attributes.get('preferenceKey')
|
|
726
|
-
or attributes.get('preference_key')
|
|
727
|
-
or value.get('key')
|
|
728
|
-
or value.get('id')
|
|
729
|
-
)
|
|
877
|
+
value['preference_key'] = preference_key(attributes, value.get('key'), value.get('id'))
|
|
730
878
|
value['preference_qualifiers'] = preference_qualifiers(attributes)
|
|
731
879
|
basis = json_object(value.pop('confirmation_basis_json', None))
|
|
732
880
|
source_references = value.pop('source_references', [])
|
|
@@ -754,6 +902,10 @@ def _entity_search_result(record, score: float, space_id: str) -> EntitySearchRe
|
|
|
754
902
|
'has_global_episode',
|
|
755
903
|
'reference_project_ids',
|
|
756
904
|
'inherited',
|
|
905
|
+
'semantic_vector',
|
|
906
|
+
'semantic_hash',
|
|
907
|
+
'retrieval_terms',
|
|
908
|
+
'retrieval_context',
|
|
757
909
|
):
|
|
758
910
|
value.pop(field, None)
|
|
759
911
|
return EntitySearchResult(
|
|
@@ -771,6 +923,7 @@ def _entity_search_result(record, score: float, space_id: str) -> EntitySearchRe
|
|
|
771
923
|
),
|
|
772
924
|
source_uris=source_uris_from_references(source_references),
|
|
773
925
|
score=score,
|
|
926
|
+
matched_by=matched_by,
|
|
774
927
|
)
|
|
775
928
|
|
|
776
929
|
|
|
@@ -794,7 +947,7 @@ def _relevance(query: str, record) -> float:
|
|
|
794
947
|
needle = _normalized(query)
|
|
795
948
|
haystack = _normalized(' '.join(filter(None, [
|
|
796
949
|
record.get('name'), record.get('type'), record.get('summary'),
|
|
797
|
-
record.get('reasoning_summary'), record.get('profile_aspect'),
|
|
950
|
+
record.get('reasoning_summary'), record.get('profile_aspect'), record.get('retrieval_context'),
|
|
798
951
|
])))
|
|
799
952
|
if not needle:
|
|
800
953
|
return 0.0
|
|
@@ -811,8 +964,10 @@ def _relevance(query: str, record) -> float:
|
|
|
811
964
|
return round(score, 4)
|
|
812
965
|
|
|
813
966
|
|
|
814
|
-
def _edge_relevance(query: str, edge, names: dict[str, str], position: int, total: int
|
|
967
|
+
def _edge_relevance(query: str, edge, names: dict[str, str], position: int, total: int,
|
|
968
|
+
retrieval: dict | None = None) -> float:
|
|
815
969
|
lexical = _relevance(query, {
|
|
970
|
+
**(retrieval or {}),
|
|
816
971
|
'name': edge.name,
|
|
817
972
|
'type': 'Relationship',
|
|
818
973
|
'summary': ' '.join(filter(None, [
|
|
@@ -831,7 +986,7 @@ def _edge_relevance(query: str, edge, names: dict[str, str], position: int, tota
|
|
|
831
986
|
|
|
832
987
|
def _terms(value: str) -> set[str]:
|
|
833
988
|
latin = {
|
|
834
|
-
term for term in re.findall(r'[a-z0-9_]+', value)
|
|
989
|
+
_word_stem(term) for term in re.findall(r'[a-z0-9_]+', value)
|
|
835
990
|
if term not in LATIN_QUERY_FILLERS
|
|
836
991
|
}
|
|
837
992
|
chinese_segments = re.findall(r'[\u4e00-\u9fff]+', value)
|
|
@@ -846,6 +1001,23 @@ def _terms(value: str) -> set[str]:
|
|
|
846
1001
|
return latin | grams
|
|
847
1002
|
|
|
848
1003
|
|
|
1004
|
+
def _word_stem(term: str) -> str:
|
|
1005
|
+
"""One English word form for its inflections, applied to both sides of a
|
|
1006
|
+
match: "owns", "owned" and "owner" meet, as do "codes" and "code"; a
|
|
1007
|
+
question names a concept in whatever form it happens to use (rec#63)."""
|
|
1008
|
+
if not term.isalpha() or len(term) < 4:
|
|
1009
|
+
return term
|
|
1010
|
+
if term.endswith('ies') and len(term) > 4:
|
|
1011
|
+
term = term[:-3] + 'y'
|
|
1012
|
+
elif term.endswith('s') and not term.endswith(('ss', 'us', 'is')):
|
|
1013
|
+
term = term[:-1]
|
|
1014
|
+
for suffix in ('ing', 'ed', 'er'):
|
|
1015
|
+
if term.endswith(suffix) and len(term) - len(suffix) >= 3:
|
|
1016
|
+
term = term[:-len(suffix)]
|
|
1017
|
+
break
|
|
1018
|
+
return term[:-1] if term.endswith('e') and len(term) > 3 else term
|
|
1019
|
+
|
|
1020
|
+
|
|
849
1021
|
def _retrieval_aliases(record) -> list[str]:
|
|
850
1022
|
attributes = record.get('attributes')
|
|
851
1023
|
if not isinstance(attributes, dict):
|
|
@@ -859,11 +1031,20 @@ def _retrieval_aliases(record) -> list[str]:
|
|
|
859
1031
|
values = [values]
|
|
860
1032
|
if not isinstance(values, list):
|
|
861
1033
|
return []
|
|
862
|
-
|
|
1034
|
+
# Terms stored beside the item later count like those it was saved with (rec#92).
|
|
1035
|
+
stored = record.get('retrieval_terms')
|
|
1036
|
+
values = [*values, *(stored if isinstance(stored, list) else [])]
|
|
1037
|
+
aliases = [
|
|
863
1038
|
value.strip()
|
|
864
|
-
for value in values[:
|
|
1039
|
+
for value in values[:64]
|
|
865
1040
|
if isinstance(value, str) and 0 < len(value.strip()) <= 256
|
|
866
1041
|
]
|
|
1042
|
+
# A preference is found by its key, as written and as words (rec#75).
|
|
1043
|
+
if record.get('profile_aspect'):
|
|
1044
|
+
key = preference_key(attributes, record.get('key'), None)
|
|
1045
|
+
if isinstance(key, str) and 0 < len(key.strip()) <= 256:
|
|
1046
|
+
aliases += [key.strip(), _KEY_SEPARATORS.sub(' ', key).strip()]
|
|
1047
|
+
return aliases
|
|
867
1048
|
|
|
868
1049
|
|
|
869
1050
|
def _alias_relevance(query: str, aliases: list[str]) -> float:
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Search by meaning (rec#88): the text a vector stands for, whether a stored
|
|
2
|
+
vector still fits, the relevance floor and the fusion with the lexical result.
|
|
3
|
+
|
|
4
|
+
FULI ships no embedding model. Node computes vectors with a model a person
|
|
5
|
+
connected and stores them through knowledge_semantic_index; a query brings its
|
|
6
|
+
own vector. A stored vector counts only for its model, at the query's length,
|
|
7
|
+
while its hash is still the sha256 of the item's text: an edit or a version
|
|
8
|
+
copy that changed the text leaves it pending, never stale.
|
|
9
|
+
"""
|
|
10
|
+
import math
|
|
11
|
+
from statistics import fmean, pstdev
|
|
12
|
+
|
|
13
|
+
from .provider_values import sha256_text
|
|
14
|
+
|
|
15
|
+
# Reciprocal rank fusion constant (Cormack et al.).
|
|
16
|
+
RRF_K = 60
|
|
17
|
+
# Under this many in-scope items with a vector the floor means nothing.
|
|
18
|
+
MIN_IN_SCOPE_ITEMS = 12
|
|
19
|
+
# Kept: a cosine at least this many standard deviations above the mean of
|
|
20
|
+
# every in-scope item for this query. No model-specific number is needed.
|
|
21
|
+
FLOOR_STANDARD_DEVIATIONS = 3
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def item_text(item_kind: str, record: dict) -> str:
|
|
25
|
+
"""The item's own words: an entity's name and summary, a relationship's fact."""
|
|
26
|
+
if item_kind == 'entity':
|
|
27
|
+
return '\n'.join(part for part in (record.get('name'), record.get('summary')) if part)
|
|
28
|
+
return record.get('fact') or ''
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def semantic_text(item_kind: str, record: dict) -> str:
|
|
32
|
+
"""The text embedded: the item's own words, then the retrieval context and
|
|
33
|
+
terms stored beside it, when there are any (rec#92)."""
|
|
34
|
+
terms = ' · '.join(record.get('retrieval_terms') or [])
|
|
35
|
+
return '\n'.join(part for part in (item_text(item_kind, record), record.get('retrieval_context'), terms) if part)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def semantic_hash(text: str) -> str:
|
|
39
|
+
return sha256_text(text)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def usable_vector(item_kind: str, record: dict, length: int) -> list[float] | None:
|
|
43
|
+
"""The record's stored vector (already read for the query's model) when it
|
|
44
|
+
has the query's length and was computed from the item's current text."""
|
|
45
|
+
vector = record.get('semantic_vector')
|
|
46
|
+
if not vector or len(vector) != length:
|
|
47
|
+
return None
|
|
48
|
+
if record.get('semantic_hash') != semantic_hash(semantic_text(item_kind, record)):
|
|
49
|
+
return None
|
|
50
|
+
return vector
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def meaning_matches(candidates: dict, query_vector: list[float], limit: int) -> dict:
|
|
54
|
+
"""{key: cosine} of the candidates ({key: vector}, every in-scope item with
|
|
55
|
+
a usable vector) that stand out for this query, best first, at most limit."""
|
|
56
|
+
query_norm = math.sqrt(sum(value * value for value in query_vector))
|
|
57
|
+
if not query_norm:
|
|
58
|
+
return {}
|
|
59
|
+
scores = {}
|
|
60
|
+
for key, vector in candidates.items():
|
|
61
|
+
norm = math.sqrt(sum(value * value for value in vector))
|
|
62
|
+
if norm:
|
|
63
|
+
scores[key] = sum(a * b for a, b in zip(query_vector, vector)) / (query_norm * norm)
|
|
64
|
+
if len(scores) < MIN_IN_SCOPE_ITEMS:
|
|
65
|
+
return {}
|
|
66
|
+
mean = fmean(scores.values())
|
|
67
|
+
deviation = pstdev(scores.values(), mean)
|
|
68
|
+
if not deviation:
|
|
69
|
+
return {}
|
|
70
|
+
floor = mean + FLOOR_STANDARD_DEVIATIONS * deviation
|
|
71
|
+
kept = sorted((key for key, score in scores.items() if score >= floor),
|
|
72
|
+
key=lambda key: (-scores[key], key))[:limit]
|
|
73
|
+
return {key: scores[key] for key in kept}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def fused_ranking(lexical_ids: list[str], semantic_ids: list[str]) -> dict[str, tuple[float, str]]:
|
|
77
|
+
"""{item id: (reciprocal rank fusion score, matched_by)} over the lexical
|
|
78
|
+
and the semantic order of one kind."""
|
|
79
|
+
lexical = {item_id: rank for rank, item_id in enumerate(lexical_ids, 1)}
|
|
80
|
+
semantic = {item_id: rank for rank, item_id in enumerate(semantic_ids, 1)}
|
|
81
|
+
fused = {}
|
|
82
|
+
for item_id in dict.fromkeys([*lexical_ids, *semantic_ids]):
|
|
83
|
+
score = sum(1 / (RRF_K + ranks[item_id]) for ranks in (lexical, semantic) if item_id in ranks)
|
|
84
|
+
matched_by = ('both' if item_id in lexical and item_id in semantic
|
|
85
|
+
else 'lexical' if item_id in lexical else 'semantic')
|
|
86
|
+
fused[item_id] = (round(score, 6), matched_by)
|
|
87
|
+
return fused
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""The meaning index (rec#88): which items still need a vector of a model,
|
|
2
|
+
storing the vectors Node computed, and how far the index is.
|
|
3
|
+
|
|
4
|
+
A vector is derived data, an index: storing one writes no history and no
|
|
5
|
+
human-change record, and changes no version, lock_version or timestamp. It
|
|
6
|
+
lives on the item, so a permanent delete takes it along. Only the items
|
|
7
|
+
knowledge_index_scan covers are indexed. The text embedded includes the
|
|
8
|
+
item's retrieval terms (rec#92), so storing terms leaves the item pending
|
|
9
|
+
until it is embedded again.
|
|
10
|
+
"""
|
|
11
|
+
from .knowledge_index_scan import indexable_from, indexable_items, locked_item, ITEM_KINDS
|
|
12
|
+
from .knowledge_item_view import personal_reader_space
|
|
13
|
+
from .knowledge_semantic import semantic_hash, semantic_text
|
|
14
|
+
from .knowledge_semantic_models import (
|
|
15
|
+
SemanticPendingItem,
|
|
16
|
+
SemanticPendingPage,
|
|
17
|
+
SemanticPendingRequest,
|
|
18
|
+
SemanticStatus,
|
|
19
|
+
SemanticStatusRequest,
|
|
20
|
+
SemanticVectorWrite,
|
|
21
|
+
SemanticVectorWriteResult,
|
|
22
|
+
)
|
|
23
|
+
from .store_transactions import query_store_transaction
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _indexed(item_kind: str, record, model: str) -> tuple[bool, str, str]:
|
|
27
|
+
text = semantic_text(item_kind, record)
|
|
28
|
+
text_hash = semantic_hash(text)
|
|
29
|
+
return record['semantic_model'] == model and record['semantic_hash'] == text_hash, text, text_hash
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
async def pending_semantic_items(store, actor, request: SemanticPendingRequest) -> SemanticPendingPage:
|
|
33
|
+
space = await personal_reader_space(store, actor, request.personal_space_id)
|
|
34
|
+
items = []
|
|
35
|
+
async for item_kind, record in indexable_from(store, space, request.after):
|
|
36
|
+
indexed, text, text_hash = _indexed(item_kind, record, request.model)
|
|
37
|
+
if indexed:
|
|
38
|
+
continue
|
|
39
|
+
if len(items) == request.limit:
|
|
40
|
+
last = items[-1]
|
|
41
|
+
return SemanticPendingPage(items=items, next=f'{last.item_kind}:{last.item_id}')
|
|
42
|
+
items.append(SemanticPendingItem(
|
|
43
|
+
item_kind=item_kind, item_id=record['id'], personal_project_id=record['personal_project_id'],
|
|
44
|
+
text=text, hash=text_hash))
|
|
45
|
+
return SemanticPendingPage(items=items, next=None)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
async def semantic_status(store, actor, request: SemanticStatusRequest) -> SemanticStatus:
|
|
49
|
+
space = await personal_reader_space(store, actor, request.personal_space_id)
|
|
50
|
+
total = done = 0
|
|
51
|
+
for item_kind in ITEM_KINDS:
|
|
52
|
+
async for record in indexable_items(store, space, item_kind):
|
|
53
|
+
total += 1
|
|
54
|
+
done += _indexed(item_kind, record, request.model)[0]
|
|
55
|
+
return SemanticStatus(total=total, done=done)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
_STORE_VECTOR = {
|
|
59
|
+
'entity': '''
|
|
60
|
+
MATCH (item:Entity {uuid: $item_id, group_id: $group_id})
|
|
61
|
+
SET item.fuli_semantic_vector = $vector, item.fuli_semantic_model = $model,
|
|
62
|
+
item.fuli_semantic_hash = $hash''',
|
|
63
|
+
'relationship': '''
|
|
64
|
+
MATCH ()-[item:RELATES_TO {uuid: $item_id, group_id: $group_id}]->()
|
|
65
|
+
SET item.fuli_semantic_vector = $vector, item.fuli_semantic_model = $model,
|
|
66
|
+
item.fuli_semantic_hash = $hash''',
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
async def write_semantic_vectors(store, actor, request: SemanticVectorWrite) -> SemanticVectorWriteResult:
|
|
71
|
+
space = await personal_reader_space(store, actor, request.personal_space_id)
|
|
72
|
+
written, skipped = 0, []
|
|
73
|
+
# One transaction: a vector never lands on text other than its own.
|
|
74
|
+
async with query_store_transaction(store) as scoped:
|
|
75
|
+
for item in request.items:
|
|
76
|
+
record = await locked_item(scoped, space, item.item_kind, item.item_id)
|
|
77
|
+
if record is None or semantic_hash(semantic_text(item.item_kind, record)) != item.hash:
|
|
78
|
+
skipped.append(item.item_id)
|
|
79
|
+
continue
|
|
80
|
+
await scoped.runtime.driver.execute_query(
|
|
81
|
+
_STORE_VECTOR[item.item_kind], vector=item.vector, model=request.model, hash=item.hash,
|
|
82
|
+
item_id=item.item_id, group_id=space['group_id'])
|
|
83
|
+
written += 1
|
|
84
|
+
return SemanticVectorWriteResult(written=written, skipped=skipped)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def register_knowledge_semantic_routes(application, store, Actor) -> None:
|
|
88
|
+
@application.post('/v1/semantic/pending', response_model=SemanticPendingPage)
|
|
89
|
+
async def semantic_pending(request: SemanticPendingRequest, actor: Actor):
|
|
90
|
+
return await pending_semantic_items(store, actor, request)
|
|
91
|
+
|
|
92
|
+
@application.post('/v1/semantic/vectors', response_model=SemanticVectorWriteResult)
|
|
93
|
+
async def semantic_vectors(request: SemanticVectorWrite, actor: Actor):
|
|
94
|
+
return await write_semantic_vectors(store, actor, request)
|
|
95
|
+
|
|
96
|
+
@application.post('/v1/semantic/status', response_model=SemanticStatus)
|
|
97
|
+
async def semantic_index_status(request: SemanticStatusRequest, actor: Actor):
|
|
98
|
+
return await semantic_status(store, actor, request)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""Requests and answers of the meaning index (rec#88)."""
|
|
2
|
+
from typing import Annotated
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, model_validator
|
|
5
|
+
|
|
6
|
+
from .knowledge_audit_models import KnowledgeItemKind
|
|
7
|
+
from .model_base import StrictModel
|
|
8
|
+
from .knowledge_semantic_query import SemanticVectorValues
|
|
9
|
+
|
|
10
|
+
SEMANTIC_BATCH_LIMIT = 64
|
|
11
|
+
SemanticModelName = Annotated[str, Field(min_length=1, max_length=256)]
|
|
12
|
+
Sha256 = Annotated[str, Field(pattern=r'^[0-9a-f]{64}$')]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SemanticPendingRequest(StrictModel):
|
|
16
|
+
personal_space_id: str = Field(min_length=1, max_length=128)
|
|
17
|
+
model: SemanticModelName
|
|
18
|
+
limit: int = Field(default=SEMANTIC_BATCH_LIMIT, ge=1, le=SEMANTIC_BATCH_LIMIT)
|
|
19
|
+
# The `next` of the previous page; omitted for the first.
|
|
20
|
+
after: str | None = Field(default=None, min_length=1, max_length=320)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SemanticPendingItem(StrictModel):
|
|
24
|
+
item_kind: KnowledgeItemKind
|
|
25
|
+
item_id: str
|
|
26
|
+
# None for an item no project owns, so the caller applies the project approval.
|
|
27
|
+
personal_project_id: str | None
|
|
28
|
+
text: str
|
|
29
|
+
hash: str
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SemanticPendingPage(StrictModel):
|
|
33
|
+
items: list[SemanticPendingItem]
|
|
34
|
+
next: str | None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class SemanticVectorItem(StrictModel):
|
|
38
|
+
item_kind: KnowledgeItemKind
|
|
39
|
+
item_id: str = Field(min_length=1, max_length=256)
|
|
40
|
+
hash: Sha256
|
|
41
|
+
vector: SemanticVectorValues
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class SemanticVectorWrite(StrictModel):
|
|
45
|
+
personal_space_id: str = Field(min_length=1, max_length=128)
|
|
46
|
+
model: SemanticModelName
|
|
47
|
+
items: list[SemanticVectorItem] = Field(min_length=1, max_length=SEMANTIC_BATCH_LIMIT)
|
|
48
|
+
|
|
49
|
+
@model_validator(mode='after')
|
|
50
|
+
def validate_one_length(self):
|
|
51
|
+
if len({len(item.vector) for item in self.items}) != 1:
|
|
52
|
+
raise ValueError('every vector in one write must have the same length')
|
|
53
|
+
if len({(item.item_kind, item.item_id) for item in self.items}) != len(self.items):
|
|
54
|
+
raise ValueError('each item may appear once')
|
|
55
|
+
return self
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class SemanticVectorWriteResult(StrictModel):
|
|
59
|
+
written: int = Field(ge=0)
|
|
60
|
+
# The items whose text changed since their hash was computed, or that are gone.
|
|
61
|
+
skipped: list[str]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class SemanticStatusRequest(StrictModel):
|
|
65
|
+
personal_space_id: str = Field(min_length=1, max_length=128)
|
|
66
|
+
model: SemanticModelName
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class SemanticStatus(StrictModel):
|
|
70
|
+
total: int = Field(ge=0)
|
|
71
|
+
done: int = Field(ge=0)
|
|
72
|
+
|