fuli-context 0.20.0-beta.9 → 0.20.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-Dy3drTbS.css → AboutPage-Bxm7RJZg.css} +1 -1
- package/dist/web/assets/{AboutPage-BybzKsx-.js → AboutPage-CjDenGS_.js} +1 -1
- package/dist/web/assets/{AgentName-CXf8heW-.js → AgentName-DdlJlpT3.js} +1 -1
- package/dist/web/assets/{AgentProfilePage-D0YyiAA6.js → AgentProfilePage-Cx_Uf5Vf.js} +1 -1
- package/dist/web/assets/{AgentProfilePage-B2yMnmQP.css → AgentProfilePage-DXvLQu-C.css} +1 -1
- package/dist/web/assets/{AgentsDirectoryPage-DvPJNJm-.css → AgentsDirectoryPage-BwF-0nFO.css} +1 -1
- package/dist/web/assets/{AgentsDirectoryPage-LU-bRYPw.js → AgentsDirectoryPage-DylT-GSW.js} +1 -1
- package/dist/web/assets/{BackLink-Dgc1V1EN.js → BackLink-D7oAvDG5.js} +1 -1
- package/dist/web/assets/{BoardMoveMenu-XrAiFzGj.js → BoardMoveMenu-B0pA7LLx.js} +1 -1
- package/dist/web/assets/CaptureChangePage-Cch3mT4b.css +1 -0
- package/dist/web/assets/{CaptureChangePage-DcJKvaGf.js → CaptureChangePage-DEuqPb14.js} +1 -1
- package/dist/web/assets/{Card-96u8qomm.js → Card-BZFLZ_2I.js} +1 -1
- package/dist/web/assets/{CardHeader-4je7E12I.js → CardHeader-C_c0keQn.js} +1 -1
- package/dist/web/assets/{CardTitle-bjMusOR6.js → CardTitle-yXOhV577.js} +1 -1
- package/dist/web/assets/ConnectionsPage-DlnHdtwn.js +1 -0
- package/dist/web/assets/{CreateProjectDialog-BDwT_wZd.js → CreateProjectDialog-BVJqWdlT.js} +1 -1
- package/dist/web/assets/{DataFormatPage-PxwqDWeZ.js → DataFormatPage-BdcjcyhZ.js} +1 -1
- package/dist/web/assets/DataFormatPage-Dp7mePUw.css +1 -0
- package/dist/web/assets/{DialogFooter-DwgFgHdH.js → DialogFooter-DYawfDCD.js} +1 -1
- package/dist/web/assets/{EmployeeRecruitDialog-DjX_wOWx.js → EmployeeRecruitDialog-CB4ARFkM.js} +1 -1
- package/dist/web/assets/{EmployeeWorkbenchPage-DWhBevwY.js → EmployeeWorkbenchPage-BUMfMBc8.js} +2 -2
- package/dist/web/assets/{EmployeeWorkbenchPage-l_LYqBnr.css → EmployeeWorkbenchPage-BenZP7De.css} +1 -1
- package/dist/web/assets/{GrowthLoading-DssogOkP.js → GrowthLoading-smW3-Gfp.js} +1 -1
- package/dist/web/assets/{InboxPage-fFg4gETv.css → InboxPage-CbbiHgTr.css} +1 -1
- package/dist/web/assets/{InboxPage-BF38gnSV.js → InboxPage-Crn1UU7s.js} +2 -2
- package/dist/web/assets/{Input-DHF3Ivr3.js → Input-F1oftPWh.js} +1 -1
- package/dist/web/assets/{KnowledgeEditDialog-uAzeQbMB.js → KnowledgeEditDialog-VdQwbX4E.js} +1 -1
- package/dist/web/assets/{KnowledgeHardDeleteSection-qGeE1YrK.js → KnowledgeHardDeleteSection-CXRmNnZF.js} +1 -1
- package/dist/web/assets/{KnowledgeItemEditPage-Cj5uNVo6.js → KnowledgeItemEditPage-CQo3TbCJ.js} +1 -1
- package/dist/web/assets/{KnowledgeItemSummaryCard-CeOSN36n.js → KnowledgeItemSummaryCard-Dd2McM-d.js} +1 -1
- package/dist/web/assets/{KnowledgeOrganizerPage-7VC_JAWQ.css → KnowledgeOrganizerPage-BIOaMzgQ.css} +1 -1
- package/dist/web/assets/{KnowledgeOrganizerPage-BVLMc2jL.js → KnowledgeOrganizerPage-BVgAyu6U.js} +1 -1
- package/dist/web/assets/KnowledgePage-Bfbfz_Z8.js +1 -0
- package/dist/web/assets/{KnowledgePeek-BD2zoQqA.js → KnowledgePeek-BNBkh1ey.js} +1 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-Ckw_olrt.js +1 -0
- package/dist/web/assets/{KnowledgeWorkspace-CgFI31jK.js → KnowledgeWorkspace-pH2tAFld.js} +1 -1
- package/dist/web/assets/{Label-DM1yZ2CL.js → Label-yDCtlpkb.js} +1 -1
- package/dist/web/assets/ModelSettingsPage-C3eBDWRL.js +1 -0
- package/dist/web/assets/ModelSettingsPage-DZkrJw7R.css +1 -0
- package/dist/web/assets/NotFoundPage-8gVVukRR.js +1 -0
- package/dist/web/assets/OccupationsPage-BTormZIO.css +1 -0
- package/dist/web/assets/{OccupationsPage-CHgGGvDu.js → OccupationsPage-PNoqE21Y.js} +1 -1
- package/dist/web/assets/{OverviewPage-E0tfzQRr.js → OverviewPage-DiwYSnhh.js} +2 -2
- package/dist/web/assets/{OverviewPage-CpHmwB7u.css → OverviewPage-YBQHyU7s.css} +1 -1
- package/dist/web/assets/{PersonalProfilePage-CfqsnB1K.css → PersonalProfilePage-CGW50MHm.css} +1 -1
- package/dist/web/assets/{PersonalProfilePage-o5Gpo9nJ.js → PersonalProfilePage-C_v2BFee.js} +1 -1
- package/dist/web/assets/PersonalProjectsPage-Cf5mrQmy.css +1 -0
- package/dist/web/assets/{PersonalProjectsPage-Boj9kG6I.js → PersonalProjectsPage-DGRV8cM5.js} +1 -1
- package/dist/web/assets/{PopperContent-BDOio_9z.js → PopperContent-5zqbtnYr.js} +1 -1
- package/dist/web/assets/{Presence-Bk6m9rvx.js → Presence-BYfYJNMD.js} +1 -1
- package/dist/web/assets/{ProjectAgentDetailPage-Cyl3ZPBO.js → ProjectAgentDetailPage-BQ9ffaCX.js} +2 -2
- package/dist/web/assets/{ProjectAgentDetailPage-Ns2ATys8.css → ProjectAgentDetailPage-CRFE6n-s.css} +1 -1
- package/dist/web/assets/{ProjectAgentDialog-C1_KluEx.js → ProjectAgentDialog-BGckQDTq.js} +1 -1
- package/dist/web/assets/{ProjectAgentFirstTask-CXKvWwhZ.js → ProjectAgentFirstTask-DrSd3nR-.js} +1 -1
- package/dist/web/assets/{ProjectAgentsPage-DKNDXWow.css → ProjectAgentsPage-BBzKAhZx.css} +1 -1
- package/dist/web/assets/{ProjectAgentsPage-DHTo0uNy.js → ProjectAgentsPage-U4Om3EPu.js} +1 -1
- package/dist/web/assets/{ProjectScopePicker-GjK7Hm4N.js → ProjectScopePicker-D0oxbwOd.js} +1 -1
- package/dist/web/assets/{PublicProjectsPage-BuJo0ReR.js → PublicProjectsPage-CvkQ3E8I.js} +1 -1
- package/dist/web/assets/{PublicProjectsPage-yA6Md4oM.css → PublicProjectsPage-Ditr0SY-.css} +1 -1
- package/dist/web/assets/{RadioGroupItem-DxktHt0c.js → RadioGroupItem-CBpbQlHx.js} +1 -1
- package/dist/web/assets/{RoundtablesPage-Bd3XCn7B.js → RoundtablesPage-BEUaKOjI.js} +1 -1
- package/dist/web/assets/RoundtablesPage-BMYSDYH8.css +1 -0
- package/dist/web/assets/{RovingFocusGroup-DyZDm-Bn.js → RovingFocusGroup-X9U-ufYr.js} +1 -1
- package/dist/web/assets/{RovingFocusItem-BKyXKG9n.js → RovingFocusItem-_uA_OCLT.js} +1 -1
- package/dist/web/assets/SessionMigrationPage-WVFSDcUO.js +1 -0
- package/dist/web/assets/{SessionRecordsPage-CvGaB3h3.js → SessionRecordsPage-Bs2eLXEi.js} +1 -1
- package/dist/web/assets/{SettingsPage-DG3ialW3.css → SettingsPage-BbX9ysTX.css} +1 -1
- package/dist/web/assets/{SettingsPage-OasIZiIz.js → SettingsPage-DlIwICIz.js} +1 -1
- package/dist/web/assets/{SharedJefaReportPage-_f2bnFY-.js → SharedJefaReportPage-B_rreEep.js} +1 -1
- package/dist/web/assets/{TabsContent-CTM6GBGk.js → TabsContent-8pXwYJPz.js} +1 -1
- package/dist/web/assets/{TabsTrigger-BFj6S2XJ.js → TabsTrigger-Cd6SI2yI.js} +1 -1
- package/dist/web/assets/{TagVocabularyPage-Cp1UVDoe.js → TagVocabularyPage-BQiuKG-4.js} +1 -1
- package/dist/web/assets/{TaskExecutionPlan-D_MbMVvj.js → TaskExecutionPlan-CupxJeyo.js} +1 -1
- package/dist/web/assets/TaskSchedulesPage-DcmDdY10.css +1 -0
- package/dist/web/assets/{TaskSchedulesPage-Dd38ntqQ.js → TaskSchedulesPage-zYQs7s6T.js} +1 -1
- package/dist/web/assets/{Teleport-D5d1fEVm.js → Teleport-BZX1Eb7R.js} +1 -1
- package/dist/web/assets/{TextField-DUZTbKVz.js → TextField-CielK4l3.js} +1 -1
- package/dist/web/assets/{UiDialog-CU8nqGKC.js → UiDialog-BSDblUpR.js} +1 -1
- package/dist/web/assets/{UiDisclosure-DbxNZe0B.js → UiDisclosure-DLmVwmy1.js} +1 -1
- package/dist/web/assets/{UiIcon-DSkB5Juh.js → UiIcon-B8eZeuGI.js} +1 -1
- package/dist/web/assets/{UiIconButton-Bgy8Hoy4.js → UiIconButton-e754Tmnq.js} +1 -1
- package/dist/web/assets/{UiSegmented-BwkPHeLK.js → UiSegmented-D1HD-qin.js} +1 -1
- package/dist/web/assets/{UiSelect-CW3HNsRZ.js → UiSelect-CbkTsi2e.js} +1 -1
- package/dist/web/assets/{UiToggle--Z_LpW41.js → UiToggle-Dz93aXFK.js} +1 -1
- package/dist/web/assets/{UiWeight-D8U0orbz.js → UiWeight-CUvyApSB.js} +1 -1
- package/dist/web/assets/{UnassignedConversationsPanel-BeWzhuBr.js → UnassignedConversationsPanel-xY7gsFot.js} +1 -1
- package/dist/web/assets/{VirtualDirectoryList-BT099Zuk.js → VirtualDirectoryList-Dv6PwLjU.js} +1 -1
- package/dist/web/assets/{Workbench3D-BAb5m-Qk.js → Workbench3D--4N_uKzp.js} +1 -1
- package/dist/web/assets/WritingTastePage-B7KojA4r.js +1 -0
- package/dist/web/assets/{WritingTastePage-Dh1qW6bK.css → WritingTastePage-asIa-2U5.css} +1 -1
- package/dist/web/assets/{_plugin-vue_export-helper-Crd8aFkh.js → _plugin-vue_export-helper-BmfQlfI8.js} +1 -1
- package/dist/web/assets/{accordion-C-pFa1cg.js → accordion-gXElbGP_.js} +1 -1
- package/dist/web/assets/{agent-occupation-BooDHzf0.js → agent-occupation-ChN-1QjC.js} +1 -1
- package/dist/web/assets/{agent-pins-CFO-xYmz.js → agent-pins-Chh_rdBi.js} +1 -1
- package/dist/web/assets/{agent-profile-Bi--2zRQ.css → agent-profile-LzhgJINr.css} +1 -1
- package/dist/web/assets/{agent-profile.css_vue_type_style_index_0_src_true_lang-BKk2RVxy.js → agent-profile.css_vue_type_style_index_0_src_true_lang-DWlz7UoN.js} +1 -1
- package/dist/web/assets/{agent-work-summary-BIZoVGaT.js → agent-work-summary-C9yMf019.js} +1 -1
- package/dist/web/assets/{attention-store-dDH6VA6Z.js → attention-store-CG9cF6DX.js} +1 -1
- package/dist/web/assets/{badge-BnU2j9Nh.js → badge-DvvDq2Wb.js} +1 -1
- package/dist/web/assets/{button-B4gCj85U.js → button-CFEnxtio.js} +1 -1
- package/dist/web/assets/{checkbox-CzVOT2cF.js → checkbox-DovdRz8u.js} +1 -1
- package/dist/web/assets/{client-Cg0bLxrO.js → client-lh80ewvs.js} +1 -1
- package/dist/web/assets/{console-k05BnLkZ.js → console-CQMgYkk9.js} +1 -1
- package/dist/web/assets/{conversation-launcher-settings-C745vZJa.js → conversation-launcher-settings-B1QM-wZB.js} +1 -1
- package/dist/web/assets/{design-lab-CJiqHzsm.js → design-lab-BDKwIbI8.js} +1 -1
- package/dist/web/assets/{dialog-DQaUWk4W.js → dialog-D2mO6m3B.js} +1 -1
- package/dist/web/assets/{dist-2CLFk118.js → dist-PmK0PfVA.js} +1 -1
- package/dist/web/assets/{dropdown-menu-CN5wjWUD.js → dropdown-menu-YzCnvjAb.js} +1 -1
- package/dist/web/assets/{field-6gOLsuT_.js → field-BMEFEyVC.js} +1 -1
- package/dist/web/assets/{identity-NbL1GGSB.js → identity-bK-fJdnj.js} +1 -1
- package/dist/web/assets/index-BhekqRSJ.js +2 -0
- package/dist/web/assets/index-DedvhyS3.css +1 -0
- package/dist/web/assets/{judgment-types-DfSuVLnV.js → judgment-types-DJnAr9c0.js} +1 -1
- package/dist/web/assets/{model-BjNAHvfb.js → model-BwNZZZNP.js} +1 -1
- package/dist/web/assets/{model-DrZFCNN6.js → model-CPMYnu3S.js} +1 -1
- package/dist/web/assets/{model-DPykou4S.js → model-Cengn9fg.js} +1 -1
- package/dist/web/assets/{model-YYqd0CSe.js → model-CuY1vtEy.js} +1 -1
- package/dist/web/assets/{model-2BvryZbU.js → model-DpVrfbnj.js} +1 -1
- package/dist/web/assets/{model-BsfqK9w_.js → model-rumuELTi.js} +1 -1
- package/dist/web/assets/{motion-preference-CxKthhLy.js → motion-preference-A1AMssSH.js} +1 -1
- package/dist/web/assets/{occupation-catalog-JHFMVvBn.js → occupation-catalog-DxwlYD1L.js} +1 -1
- package/dist/web/assets/{orchestration-filters-B7ZbjZKo.js → orchestration-filters-DZpJ0FN3.js} +1 -1
- package/dist/web/assets/{page-title-BawJ25Bw.js → page-title-Bg-mVyrS.js} +1 -1
- package/dist/web/assets/{personal-profile-graph-BEjSAQMe.js → personal-profile-graph-tMneNj_m.js} +1 -1
- package/dist/web/assets/{project-capture-BUtkhbr1.js → project-capture-QgMw6qvo.js} +1 -1
- package/dist/web/assets/{project-origin-DI7ft7I8.js → project-origin-ppsYHpYL.js} +1 -1
- package/dist/web/assets/project-team-api-DwP0O3rn.js +1 -0
- package/dist/web/assets/{quick-edit-api-CTMfc9uz.js → quick-edit-api-BiyK3ih-.js} +1 -1
- package/dist/web/assets/{shared-report-o1Tvfyn-.js → shared-report-D3Hem1t5.js} +3 -3
- package/dist/web/assets/{task-labels-dW28Ybet.js → task-labels-7KyNw9id.js} +1 -1
- package/dist/web/assets/{ui-BkbPVq3y.js → ui-Ck58paqr.js} +1 -1
- package/dist/web/assets/{useAgentRecords-D6BTApmV.js → useAgentRecords-C6RrZwwv.js} +1 -1
- package/dist/web/assets/{useApi-CROJJdhE-BMswzZdS.js → useApi-CROJJdhE-BujjnKN_.js} +1 -1
- package/dist/web/assets/{useFocusReturn-DQOtrYO8.js → useFocusReturn-D9IOIg17.js} +1 -1
- package/dist/web/assets/{useKnowledgeItemPeek-CGzVMWJz.js → useKnowledgeItemPeek-C6nAzvDL.js} +1 -1
- package/dist/web/assets/{useMinimumLoadingDisplay-DEBBYuGI.js → useMinimumLoadingDisplay-HnxkDut6.js} +1 -1
- package/dist/web/assets/{useRoutePeek-R9W605pr.js → useRoutePeek-BvYFc1BA.js} +1 -1
- package/dist/web/assets/{vue-router-BUjBh_Iw.js → vue-router-Bl55c88B.js} +1 -1
- package/dist/web/index.html +33 -33
- package/docs/agent-apps.md +5 -0
- package/graph-provider/fuli_graph/app.py +16 -11
- package/graph-provider/fuli_graph/graph_query.py +30 -2
- package/graph-provider/fuli_graph/knowledge_audit.py +9 -1
- package/graph-provider/fuli_graph/knowledge_item_routes.py +10 -6
- package/graph-provider/fuli_graph/knowledge_item_view.py +41 -12
- package/graph-provider/fuli_graph/knowledge_item_view_models.py +3 -3
- package/graph-provider/fuli_graph/knowledge_review.py +47 -10
- package/graph-provider/fuli_graph/knowledge_search.py +18 -22
- package/graph-provider/fuli_graph/knowledge_session_migration.py +14 -4
- package/graph-provider/fuli_graph/knowledge_session_migration_models.py +2 -2
- package/graph-provider/fuli_graph/knowledge_tag_routes.py +7 -5
- package/graph-provider/fuli_graph/knowledge_tags.py +8 -4
- package/graph-provider/fuli_graph/knowledge_visibility.py +195 -0
- package/graph-provider/fuli_graph/models.py +12 -2
- package/graph-provider/fuli_graph/preference_conflicts.py +50 -4
- package/graph-provider/fuli_graph/publication_source_copies.py +36 -0
- package/graph-provider/fuli_graph/session_records.py +33 -13
- package/graph-provider/fuli_graph/session_records_models.py +4 -2
- package/graph-provider/fuli_graph/store_knowledge.py +5 -1
- package/graph-provider/fuli_graph/store_publication.py +70 -12
- package/graph-provider/fuli_graph/task_context_models.py +2 -0
- package/graph-provider/fuli_graph/task_session_hints.py +7 -3
- package/graph-provider/pyproject.toml +1 -1
- package/native/win32/fuli-win-helper.exe +0 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/skills/capturing-session-knowledge/references/retrieval.md +6 -0
- package/src/agent-apps/instances.js +85 -26
- package/src/agent-apps/service.js +5 -4
- package/src/agent-tools/graph-definitions.js +4 -4
- package/src/agent-tools/interface-definitions.js +2 -1
- package/src/agent-tools/session-fuli-gate.js +55 -26
- package/src/agent-tools.js +2 -4
- package/src/agents/claude-code/lifecycle-hook.js +29 -12
- package/src/agents/codex/lifecycle-hook.js +25 -10
- package/src/agents/lifecycle-message.js +18 -0
- package/src/agents/turn-receipt.js +15 -8
- package/src/app/agent-request-context.js +18 -0
- package/src/cli/remote-mcp-command.js +6 -2
- package/src/cli/setup-command.js +6 -0
- package/src/cli/update-command.js +14 -1
- package/src/cli/update-installation.js +46 -2
- package/src/conversations/entry-budget.js +116 -0
- package/src/conversations/preference-evidence.js +6 -2
- package/src/conversations/task-context-view.js +13 -8
- package/src/data-format/local-stores.js +2 -0
- package/src/graphiti/agent-conversations.js +24 -3
- package/src/graphiti/assistant-project-candidate.js +5 -2
- package/src/graphiti/capture-notice.js +4 -1
- package/src/graphiti/entry-hint-claim.js +13 -0
- package/src/graphiti/federated-application.js +54 -61
- package/src/graphiti/human-review-channel.js +9 -5
- package/src/graphiti/jefa-board-match.js +4 -1
- package/src/graphiti/knowledge-item-edit.js +7 -4
- package/src/graphiti/knowledge-reader.js +46 -0
- package/src/graphiti/knowledge-result-budget.js +63 -12
- package/src/graphiti/knowledge-tags.js +12 -1
- package/src/graphiti/provider-client.js +18 -25
- package/src/graphiti/publication-draft-capture.js +28 -0
- package/src/graphiti/session-knowledge-migration.js +7 -3
- package/src/graphiti/session-layer-decision.js +28 -6
- package/src/graphiti/session-records.js +26 -15
- package/src/graphiti/shared-project-list.js +36 -0
- package/src/graphiti/task-entry-preferences.js +87 -46
- package/src/graphiti/turn-receipt-delivery.js +5 -2
- package/src/graphiti/writing-taste-profile-workflow.js +13 -7
- package/src/http/api-router.js +2 -1
- package/src/http/graph-api-router.js +13 -10
- package/src/http/knowledge-item-api-router.js +17 -4
- package/src/http/knowledge-tags-api-router.js +21 -9
- package/src/http/request-policy.js +18 -2
- package/src/http/session-records-api-router.js +7 -3
- package/src/judgment/review-prompt.js +21 -1
- package/src/knowledge-owner-reads/console-port.js +51 -0
- package/src/knowledge-tags/console-port.js +3 -2
- package/src/mcp/preference-delivery.js +7 -4
- package/src/mcp/provider-task-context-registry.js +23 -0
- package/src/mcp/tool-result.js +3 -3
- package/src/presence/windows-helper-pin.js +1 -1
- package/src/server.js +14 -2
- package/src/standing-assignments/port.js +146 -0
- package/src/standing-assignments/store.js +151 -0
- package/src/standing-assignments/term-match.js +28 -0
- package/src/text/name-identity.js +33 -0
- package/dist/web/assets/CaptureChangePage-C833Eiqu.css +0 -1
- package/dist/web/assets/ConnectionsPage-EFMP-UeV.js +0 -1
- package/dist/web/assets/DataFormatPage-DERqhmng.css +0 -1
- package/dist/web/assets/KnowledgePage-8ct5iO0F.js +0 -1
- package/dist/web/assets/KnowledgeTurnReceiptPage-Yn3jhDyx.js +0 -1
- package/dist/web/assets/ModelSettingsPage-5RkvgNYN.js +0 -1
- package/dist/web/assets/ModelSettingsPage-BqtWIKEA.css +0 -1
- package/dist/web/assets/NotFoundPage-BUUf2-MZ.js +0 -1
- package/dist/web/assets/OccupationsPage-B55DftFp.css +0 -1
- package/dist/web/assets/PersonalProjectsPage-aU1rApzX.css +0 -1
- package/dist/web/assets/RoundtablesPage-BmmsB1mW.css +0 -1
- package/dist/web/assets/SessionMigrationPage-CQhrJ1OQ.js +0 -1
- package/dist/web/assets/TaskSchedulesPage-CDalUfNj.css +0 -1
- package/dist/web/assets/WritingTastePage-BsekLhC3.js +0 -1
- package/dist/web/assets/index-C2rHjaT6.css +0 -1
- package/dist/web/assets/index-DYEE8nDj.js +0 -2
- package/dist/web/assets/project-team-api-BZMMPuUd.js +0 -1
|
@@ -22,6 +22,7 @@ from .search_projection import (
|
|
|
22
22
|
)
|
|
23
23
|
from .knowledge_weight import knowledge_weight
|
|
24
24
|
from .knowledge_tag_ranking import TagRanking
|
|
25
|
+
from .knowledge_visibility import AgentReader, fla_endpoints_visible_cypher, fla_visible, reader_parameter
|
|
25
26
|
|
|
26
27
|
MIN_TERM_COVERAGE = 0.25
|
|
27
28
|
LATIN_QUERY_FILLERS = {
|
|
@@ -182,23 +183,24 @@ async def personal_edge_scopes(
|
|
|
182
183
|
return {}
|
|
183
184
|
records, _, _ = await store.runtime.driver.execute_query(
|
|
184
185
|
'''
|
|
185
|
-
MATCH ()-[edge:RELATES_TO {group_id: $group_id}]->()
|
|
186
|
+
MATCH (source)-[edge:RELATES_TO {group_id: $group_id}]->(target)
|
|
186
187
|
WHERE edge.uuid IN $edge_ids
|
|
187
188
|
AND size(coalesce(edge.fuli_unresolved_bases, [])) = 0
|
|
189
|
+
WITH edge, ''' + fla_endpoints_visible_cypher('source', 'target') + ''' AS endpoints_visible
|
|
188
190
|
OPTIONAL MATCH (assignment:FuliKnowledgeAssignment {
|
|
189
191
|
space_id: $space_id,
|
|
190
192
|
item_kind: 'relationship',
|
|
191
193
|
item_id: edge.uuid
|
|
192
194
|
})
|
|
193
|
-
WITH edge, assignment
|
|
195
|
+
WITH edge, endpoints_visible, assignment
|
|
194
196
|
OPTIONAL MATCH (episode:Episodic {group_id: $group_id})
|
|
195
197
|
WHERE episode.uuid IN coalesce(edge.episodes, [])
|
|
196
|
-
WITH edge, assignment, collect(DISTINCT episode) AS episodes
|
|
198
|
+
WITH edge, endpoints_visible, assignment, collect(DISTINCT episode) AS episodes
|
|
197
199
|
OPTIONAL MATCH (:FuliSpace {id: $space_id})-[:HAS_KNOWLEDGE_REFERENCE]->
|
|
198
200
|
(reference:FuliKnowledgeProjectReference {
|
|
199
201
|
item_kind: 'relationship', item_id: edge.uuid, status: 'active'
|
|
200
202
|
})
|
|
201
|
-
RETURN edge.uuid AS id,
|
|
203
|
+
RETURN edge.uuid AS id, endpoints_visible,
|
|
202
204
|
edge.fuli_profile_aspect AS profile_aspect,
|
|
203
205
|
coalesce(edge.fuli_preference_scope, 'global')
|
|
204
206
|
AS preference_scope,
|
|
@@ -226,6 +228,7 @@ async def personal_edge_scopes(
|
|
|
226
228
|
project_ids=list(project_scopes),
|
|
227
229
|
include_personal_global=include_personal_global,
|
|
228
230
|
edge_ids=edge_ids,
|
|
231
|
+
reader=reader_parameter(_search_reader(request)),
|
|
229
232
|
routing_='r',
|
|
230
233
|
)
|
|
231
234
|
return {
|
|
@@ -513,6 +516,8 @@ def _item_scope_metadata(
|
|
|
513
516
|
project_scopes: dict[str, dict],
|
|
514
517
|
include_personal_global: bool,
|
|
515
518
|
) -> dict | None:
|
|
519
|
+
if not fla_visible(record, _search_reader(request)):
|
|
520
|
+
return None
|
|
516
521
|
profile_aspect = record.get('profile_aspect')
|
|
517
522
|
if profile_aspect:
|
|
518
523
|
preference_scope = record.get('preference_scope') or 'global'
|
|
@@ -522,18 +527,12 @@ def _item_scope_metadata(
|
|
|
522
527
|
return _global_scope_metadata()
|
|
523
528
|
project_id = record.get('preference_project_id')
|
|
524
529
|
if preference_scope == 'agent':
|
|
525
|
-
|
|
526
|
-
if (
|
|
527
|
-
project_id not in request.personal_project_ids
|
|
528
|
-
or not request.project_agent_id
|
|
529
|
-
or agent_id != request.project_agent_id
|
|
530
|
-
or project_id != request.active_personal_project_id
|
|
531
|
-
):
|
|
530
|
+
if project_id not in request.personal_project_ids:
|
|
532
531
|
return None
|
|
533
532
|
return _agent_scope_metadata(
|
|
534
533
|
project_id,
|
|
535
534
|
project_scopes[project_id],
|
|
536
|
-
|
|
535
|
+
record.get('preference_agent_id'),
|
|
537
536
|
)
|
|
538
537
|
project_ids = record.get('preference_project_ids') or [project_id]
|
|
539
538
|
candidates = [pid for pid in project_ids if pid in request.personal_project_ids and pid in project_scopes]
|
|
@@ -544,16 +543,7 @@ def _item_scope_metadata(
|
|
|
544
543
|
|
|
545
544
|
assignment_project_id = record.get('assignment_project_id')
|
|
546
545
|
episode_project_ids = list(record.get('episode_project_ids') or [])
|
|
547
|
-
|
|
548
|
-
record.get('episode_project_agent_ids') or []
|
|
549
|
-
)
|
|
550
|
-
if episode_project_agent_ids:
|
|
551
|
-
if (
|
|
552
|
-
not request.project_agent_id
|
|
553
|
-
or request.project_agent_id not in episode_project_agent_ids
|
|
554
|
-
or request.active_personal_project_id not in episode_project_ids
|
|
555
|
-
):
|
|
556
|
-
return None
|
|
546
|
+
if record.get('episode_project_agent_ids'):
|
|
557
547
|
return _agent_scope_metadata(
|
|
558
548
|
request.active_personal_project_id,
|
|
559
549
|
project_scopes[request.active_personal_project_id],
|
|
@@ -610,6 +600,12 @@ def _item_scope_metadata(
|
|
|
610
600
|
return None
|
|
611
601
|
|
|
612
602
|
|
|
603
|
+
def _search_reader(request: SearchRequest) -> AgentReader:
|
|
604
|
+
# The FLA was authorized in _personal_search_space; search shows no
|
|
605
|
+
# FLA-scoped item to the person's console either unless it names the FLA.
|
|
606
|
+
return AgentReader(request.active_personal_project_id, request.project_agent_id)
|
|
607
|
+
|
|
608
|
+
|
|
613
609
|
def _global_scope_metadata() -> dict:
|
|
614
610
|
return {
|
|
615
611
|
'defined_project_id': None,
|
|
@@ -22,6 +22,7 @@ from .knowledge_item_view_models import KnowledgeScopeChange
|
|
|
22
22
|
from .knowledge_management import _read_item
|
|
23
23
|
from .knowledge_scope_edit import apply_scope_change, scope_editor_space
|
|
24
24
|
from .knowledge_versions import lock_knowledge
|
|
25
|
+
from .knowledge_visibility import fla_own_work_cypher, hidden_refs, reader_parameter, request_reader
|
|
25
26
|
from .knowledge_session_migration_models import (
|
|
26
27
|
SessionMigrationApply,
|
|
27
28
|
SessionMigrationMoved,
|
|
@@ -39,15 +40,20 @@ async def preview_session_migration(store, actor: dict, request: SessionMigratio
|
|
|
39
40
|
target = await _target_project(store, actor, space, request.target_project_id)
|
|
40
41
|
temporary_id = session_temporary_project_id(space['id'], request.source_application, request.session_id)
|
|
41
42
|
held = await held_items(store, space, temporary_id)
|
|
43
|
+
# An Agent's offer neither counts nor lists another FLA's held items, nor
|
|
44
|
+
# counts another FLA's words among a listed item's sources.
|
|
45
|
+
reader = await request_reader(store, actor, space, request)
|
|
46
|
+
hidden = await hidden_refs(store, space, reader, [(item_kind, item_id) for item_kind, item_id, _ in held])
|
|
47
|
+
held = [row for row in held if (row[0], row[1]) not in hidden]
|
|
42
48
|
items = []
|
|
43
49
|
end = request.offset + request.limit
|
|
44
50
|
if request.include_items:
|
|
45
51
|
for item_kind, item_id, current in held[request.offset:end]:
|
|
46
|
-
_, source_ids = await item_evidence(store, space, item_kind, item_id, limit=0)
|
|
52
|
+
_, source_ids = await item_evidence(store, space, item_kind, item_id, limit=0, reader=reader)
|
|
47
53
|
items.append(await item_summary(store, space, item_kind, item_id, current, source_ids=source_ids))
|
|
48
54
|
return SessionMigrationPreview(
|
|
49
55
|
temporary_project_id=temporary_id, target_project=target, held_count=len(held),
|
|
50
|
-
linked_task_count=await _linked_task_count(store, space, request), items=items,
|
|
56
|
+
linked_task_count=await _linked_task_count(store, space, request, reader), items=items,
|
|
51
57
|
next_offset=end if request.include_items and end < len(held) else None)
|
|
52
58
|
|
|
53
59
|
|
|
@@ -125,13 +131,17 @@ async def _target_project(store, actor, space, project_id):
|
|
|
125
131
|
return (await scope_projects(store, space, [project_id]))[0]
|
|
126
132
|
|
|
127
133
|
|
|
128
|
-
async def _linked_task_count(store, space, request) -> int:
|
|
134
|
+
async def _linked_task_count(store, space, request, reader) -> int:
|
|
135
|
+
"""This session's tasks in the project that the reader's own work holds:
|
|
136
|
+
an FLA counts its own, a plain session those under no FLA, the person all."""
|
|
129
137
|
records, _, _ = await store.runtime.driver.execute_query(
|
|
130
138
|
'''
|
|
131
139
|
MATCH (:FuliSpace {id: $space_id, kind: 'personal'})-[:HAS_TASK_CONTEXT_SESSION]->
|
|
132
140
|
(:FuliTaskContextSession {id: $session_node})-[:HAS_CONTEXT]->
|
|
133
141
|
(task:FuliTaskContext {personal_project_id: $project_id})
|
|
142
|
+
WHERE ''' + fla_own_work_cypher('task.project_agent_id', 'task.personal_project_id') + '''
|
|
134
143
|
RETURN count(task) AS linked
|
|
135
|
-
''', space_id=space['id'], project_id=request.target_project_id,
|
|
144
|
+
''', space_id=space['id'], project_id=request.target_project_id, reader=reader_parameter(reader),
|
|
145
|
+
routing_='r',
|
|
136
146
|
session_node=store._task_session_id(space['id'], request.source_application, request.session_id))
|
|
137
147
|
return int(records[0]['linked']) if records else 0
|
|
@@ -10,7 +10,7 @@ from pydantic import Field, model_validator
|
|
|
10
10
|
from .knowledge_audit_models import KnowledgeItemKind
|
|
11
11
|
from .knowledge_item_view_models import KnowledgeItemSummary, KnowledgeScopeProject
|
|
12
12
|
from .model_base import StrictModel
|
|
13
|
-
from .models import SourceApplication
|
|
13
|
+
from .models import AgentReaderRef, SourceApplication
|
|
14
14
|
|
|
15
15
|
# One page of the prompt lists at most this many held items, and one move
|
|
16
16
|
# takes at most this many; what can be chosen is not limited (dot P2-3).
|
|
@@ -24,7 +24,7 @@ class SessionMigrationTarget(StrictModel):
|
|
|
24
24
|
target_project_id: str = Field(min_length=1, max_length=128)
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
class SessionMigrationRead(SessionMigrationTarget):
|
|
27
|
+
class SessionMigrationRead(SessionMigrationTarget, AgentReaderRef):
|
|
28
28
|
# False: only how many are held and how often this session already worked
|
|
29
29
|
# in the project, for a task entry deciding whether to show its link.
|
|
30
30
|
include_items: bool = True
|
|
@@ -3,7 +3,9 @@ Provider queries; every write names its actor and reason. A write claimed as
|
|
|
3
3
|
the person's own needs the human-review proof (ReviewAwareActor), and the
|
|
4
4
|
person's governance (approve, merge, split, retire, relations, undo) is applied
|
|
5
5
|
only on the human-review channel (HumanReviewer): an Agent can preview it,
|
|
6
|
-
never apply it (rec#11 D-07 part 2, D-22).
|
|
6
|
+
never apply it (rec#11 D-07 part 2, D-22). The owner's view across every
|
|
7
|
+
project (include_all_projects) lists and counts other FLAs' links, so it too
|
|
8
|
+
needs that proof; without it a read is scoped, and a claimed one is refused."""
|
|
7
9
|
|
|
8
10
|
from typing import Any
|
|
9
11
|
|
|
@@ -57,19 +59,19 @@ def register_knowledge_tag_routes(application, store, Actor: Any, ReviewAwareAct
|
|
|
57
59
|
return await detach_tag(store, actor, request)
|
|
58
60
|
|
|
59
61
|
@application.post('/v1/knowledge-tags/metrics', response_model=KnowledgeTagMetrics)
|
|
60
|
-
async def metrics(request: KnowledgeTagMetricsQuery, actor:
|
|
62
|
+
async def metrics(request: KnowledgeTagMetricsQuery, actor: ReviewAwareActor):
|
|
61
63
|
return await tag_metrics(store, actor, request)
|
|
62
64
|
|
|
63
65
|
@application.post('/v1/knowledge-tags/vocabulary', response_model=KnowledgeTagVocabulary)
|
|
64
|
-
async def vocabulary(request: KnowledgeTagVocabularyQuery, actor:
|
|
66
|
+
async def vocabulary(request: KnowledgeTagVocabularyQuery, actor: ReviewAwareActor):
|
|
65
67
|
return await list_vocabulary(store, actor, request)
|
|
66
68
|
|
|
67
69
|
@application.post('/v1/knowledge-tags/detail', response_model=KnowledgeTagDetail)
|
|
68
|
-
async def detail(request: KnowledgeTagDetailQuery, actor:
|
|
70
|
+
async def detail(request: KnowledgeTagDetailQuery, actor: ReviewAwareActor):
|
|
69
71
|
return await read_tag_detail(store, actor, request)
|
|
70
72
|
|
|
71
73
|
@application.post('/v1/knowledge-tags/governance/preview', response_model=KnowledgeTagGovernancePreview)
|
|
72
|
-
async def governance_preview(request: KnowledgeTagGovernanceRequest, actor:
|
|
74
|
+
async def governance_preview(request: KnowledgeTagGovernanceRequest, actor: ReviewAwareActor):
|
|
73
75
|
return await preview_governance(store, actor, request)
|
|
74
76
|
|
|
75
77
|
@application.post('/v1/knowledge-tags/governance/apply', response_model=KnowledgeTagGovernanceResult)
|
|
@@ -242,10 +242,10 @@ def new_link(space_id: str, tag_id: str, item_kind: str, item_id: str, at, actor
|
|
|
242
242
|
|
|
243
243
|
|
|
244
244
|
async def tag_metrics(store, actor: dict, request: KnowledgeTagMetricsQuery) -> KnowledgeTagMetrics:
|
|
245
|
-
space, namespaces = await visible_tag_scope(store, actor, request, 'reader'
|
|
245
|
+
space, namespaces = await visible_tag_scope(store, actor, request, 'reader',
|
|
246
|
+
all_projects=request.include_all_projects)
|
|
246
247
|
since = datetime.now(timezone.utc) - timedelta(days=request.days)
|
|
247
|
-
counts, created = await store.knowledge_tag_vocabulary().metrics(
|
|
248
|
-
space['id'], None if request.include_all_projects else namespaces, since)
|
|
248
|
+
counts, created = await store.knowledge_tag_vocabulary().metrics(space['id'], namespaces, since)
|
|
249
249
|
return KnowledgeTagMetrics(scope='all' if request.include_all_projects else 'visible',
|
|
250
250
|
days=request.days, counts=counts, created_by_day=created)
|
|
251
251
|
|
|
@@ -327,8 +327,12 @@ def _held(tag: dict, key: str):
|
|
|
327
327
|
async def visible_tag_scope(store, actor: dict, request: KnowledgeTagScope, role: str, *,
|
|
328
328
|
all_projects: bool = False):
|
|
329
329
|
"""The caller's space and the namespaces it sees; None means every namespace
|
|
330
|
-
(the owner's console view across projects).
|
|
330
|
+
(the owner's console view across projects). That view lists and counts the
|
|
331
|
+
links of every FLA's own knowledge, so it is read only on the human-review
|
|
332
|
+
channel; an Agent asking for it is refused."""
|
|
331
333
|
store._require_personal()
|
|
334
|
+
if all_projects and actor.get('_human_review_verified') is not True:
|
|
335
|
+
raise HTTPException(status_code=403, detail='the all-project tag view is read on the human-review channel')
|
|
332
336
|
space = await store.authorize(actor, request.personal_space_id, role)
|
|
333
337
|
namespaces = [PERSONAL_NAMESPACE]
|
|
334
338
|
if request.personal_project_id:
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""Who may read FLA-scoped knowledge.
|
|
2
|
+
|
|
3
|
+
Knowledge an FLA's own episodes wrote, and a preference the person gave one
|
|
4
|
+
FLA, belong to that FLA in its project, and to the person. Search, the graph
|
|
5
|
+
read, item views, turn receipts, session records, the human-change search,
|
|
6
|
+
the AI review and its decisions, preference conflicts and a session's
|
|
7
|
+
migration preview all decide it here.
|
|
8
|
+
|
|
9
|
+
The person's console proves itself with the human-review channel and reads
|
|
10
|
+
everything. Any other reader is an Agent: one FLA in one project, or a plain
|
|
11
|
+
session that is no FLA. No proof means an Agent reader, never a full read; a
|
|
12
|
+
wrong proof is refused before any read (app.current_review_aware_actor), and
|
|
13
|
+
a reader naming an FLA that is not assigned to that project is refused here.
|
|
14
|
+
"""
|
|
15
|
+
from dataclasses import dataclass
|
|
16
|
+
|
|
17
|
+
from .project_agent_access import authorize_project_agent
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class AgentReader:
|
|
22
|
+
personal_project_id: str | None = None
|
|
23
|
+
project_agent_id: str | None = None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
PLAIN_SESSION = AgentReader()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async def knowledge_reader(store, actor: dict, space: dict, *, personal_project_id: str | None,
|
|
30
|
+
project_agent_id: str | None) -> AgentReader | None:
|
|
31
|
+
"""None for the person's console (full read), else the Agent reading."""
|
|
32
|
+
if actor.get('_human_review_verified') is True:
|
|
33
|
+
return None
|
|
34
|
+
if not project_agent_id:
|
|
35
|
+
return PLAIN_SESSION
|
|
36
|
+
agent = await authorize_project_agent(store, actor, space, personal_project_id, project_agent_id)
|
|
37
|
+
return AgentReader(personal_project_id, agent['agent_id'])
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
async def request_reader(store, actor: dict, space: dict, request) -> AgentReader | None:
|
|
41
|
+
"""knowledge_reader for a request with reader_project_id and reader_agent_id."""
|
|
42
|
+
return await knowledge_reader(store, actor, space, personal_project_id=request.reader_project_id,
|
|
43
|
+
project_agent_id=request.reader_agent_id)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def fla_visible(record: dict, reader: AgentReader) -> bool:
|
|
47
|
+
"""Whether this reader may see the item. record carries profile_aspect,
|
|
48
|
+
preference_scope, preference_project_id, preference_agent_id and, from
|
|
49
|
+
the item's own episodes, episode_project_ids and episode_project_agent_ids.
|
|
50
|
+
A preference follows its own scope only; other knowledge any FLA's
|
|
51
|
+
episode wrote belongs to that FLA in that project. A relationship's
|
|
52
|
+
record also carries endpoints_visible (fla_endpoints_visible_cypher): one
|
|
53
|
+
linking to an entity this reader may not see is hidden with it."""
|
|
54
|
+
if record.get('endpoints_visible') is False:
|
|
55
|
+
return False
|
|
56
|
+
if record.get('profile_aspect'):
|
|
57
|
+
if (record.get('preference_scope') or 'global') != 'agent':
|
|
58
|
+
return True
|
|
59
|
+
return (
|
|
60
|
+
bool(reader.project_agent_id)
|
|
61
|
+
and record.get('preference_agent_id') == reader.project_agent_id
|
|
62
|
+
and record.get('preference_project_id') == reader.personal_project_id
|
|
63
|
+
)
|
|
64
|
+
agent_ids = record.get('episode_project_agent_ids') or []
|
|
65
|
+
if not agent_ids:
|
|
66
|
+
return True
|
|
67
|
+
return (
|
|
68
|
+
bool(reader.project_agent_id)
|
|
69
|
+
and reader.project_agent_id in agent_ids
|
|
70
|
+
and reader.personal_project_id in (record.get('episode_project_ids') or [])
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def fla_visible_cypher(item: str, item_kind: str) -> str:
|
|
75
|
+
"""fla_visible as a Cypher predicate on the bound `item` (an Entity, or a
|
|
76
|
+
RELATES_TO edge), so a page is cut after hiding and shows no gap. Needs
|
|
77
|
+
$group_id and $reader (reader_parameter: null for the person)."""
|
|
78
|
+
def episodes(condition: str) -> str:
|
|
79
|
+
if item_kind == 'entity':
|
|
80
|
+
return (f'EXISTS {{ MATCH (fla_episode:Episodic {{group_id: $group_id}})-[:MENTIONS]->({item}) '
|
|
81
|
+
f'WHERE {condition} }}')
|
|
82
|
+
return (f'EXISTS {{ MATCH (fla_episode:Episodic {{group_id: $group_id}}) '
|
|
83
|
+
f'WHERE fla_episode.uuid IN coalesce({item}.episodes, []) AND {condition} }}')
|
|
84
|
+
|
|
85
|
+
return f'''($reader IS NULL OR coalesce(
|
|
86
|
+
CASE WHEN {item}.fuli_profile_aspect IS NOT NULL
|
|
87
|
+
THEN coalesce({item}.fuli_preference_scope, 'global') <> 'agent'
|
|
88
|
+
OR ({item}.fuli_preference_agent_id = $reader.project_agent_id
|
|
89
|
+
AND {item}.fuli_preference_project_id = $reader.personal_project_id)
|
|
90
|
+
ELSE NOT {episodes('fla_episode.fuli_project_agent_id IS NOT NULL')}
|
|
91
|
+
OR ({episodes('fla_episode.fuli_project_agent_id = $reader.project_agent_id')}
|
|
92
|
+
AND {episodes('fla_episode.fuli_personal_project_id = $reader.personal_project_id')})
|
|
93
|
+
END, false))'''
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def fla_relationship_visible_cypher(edge: str, source: str, target: str) -> str:
|
|
97
|
+
"""A relationship is visible only with both its endpoints: one that links
|
|
98
|
+
to another FLA's entity is hidden with it, wherever it is read (graph,
|
|
99
|
+
item view, receipt, session records; search and the AI review through
|
|
100
|
+
fla_endpoints_visible_cypher and fla_visible)."""
|
|
101
|
+
return f"({fla_visible_cypher(edge, 'relationship')} AND {fla_endpoints_visible_cypher(source, target)})"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def fla_endpoints_visible_cypher(source: str, target: str) -> str:
|
|
105
|
+
"""Whether this reader may see both endpoints of a relationship. Needs
|
|
106
|
+
$group_id and $reader."""
|
|
107
|
+
return f"({fla_visible_cypher(source, 'entity')} AND {fla_visible_cypher(target, 'entity')})"
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def fla_own_work_cypher(agent: str, project: str) -> str:
|
|
111
|
+
"""Work done under an FLA (a session's turn, or an episode it wrote) is
|
|
112
|
+
that FLA's conversation: an FLA reads its own in its project, a plain
|
|
113
|
+
session only work under no FLA, and only the person all of it. agent and
|
|
114
|
+
project are the Cypher expressions of that work's FLA and project. Needs
|
|
115
|
+
$reader."""
|
|
116
|
+
return f'''($reader IS NULL OR CASE WHEN $reader.project_agent_id IS NULL
|
|
117
|
+
THEN {agent} IS NULL
|
|
118
|
+
ELSE coalesce({agent} = $reader.project_agent_id
|
|
119
|
+
AND {project} = $reader.personal_project_id, false) END)'''
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def fla_visible_ids_cypher(item_ids: str) -> str:
|
|
123
|
+
"""True when no entity or relationship among item_ids (a Cypher list
|
|
124
|
+
expression) is hidden from $reader: a record naming another FLA's item
|
|
125
|
+
is left out with it. Needs $group_id and $reader."""
|
|
126
|
+
return (f'''($reader IS NULL OR (
|
|
127
|
+
NOT EXISTS {{ MATCH (fla_item:Entity {{group_id: $group_id}}) WHERE fla_item.uuid IN {item_ids}
|
|
128
|
+
AND NOT {fla_visible_cypher('fla_item', 'entity')} }}
|
|
129
|
+
AND NOT EXISTS {{ MATCH (fla_source:Entity)-[fla_item:RELATES_TO {{group_id: $group_id}}]->(fla_target:Entity)
|
|
130
|
+
WHERE fla_item.uuid IN {item_ids}
|
|
131
|
+
AND NOT {fla_relationship_visible_cypher('fla_item', 'fla_source', 'fla_target')} }}))''')
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def fla_episode_visible_cypher(episode: str) -> str:
|
|
135
|
+
"""An episode an FLA wrote, as evidence or as a session's source: only
|
|
136
|
+
that FLA in its project reads it. Needs $reader."""
|
|
137
|
+
return f'''($reader IS NULL OR {episode}.fuli_project_agent_id IS NULL
|
|
138
|
+
OR coalesce({episode}.fuli_project_agent_id = $reader.project_agent_id
|
|
139
|
+
AND {episode}.fuli_personal_project_id = $reader.personal_project_id, false))'''
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def reader_parameter(reader: AgentReader | None) -> dict | None:
|
|
143
|
+
if reader is None:
|
|
144
|
+
return None
|
|
145
|
+
return {'personal_project_id': reader.personal_project_id, 'project_agent_id': reader.project_agent_id}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
_HIDDEN_QUERIES = {
|
|
149
|
+
'entity': '''
|
|
150
|
+
MATCH (item:Entity {group_id: $group_id}) WHERE item.uuid IN $item_ids
|
|
151
|
+
AND NOT ''' + fla_visible_cypher('item', 'entity') + '''
|
|
152
|
+
RETURN item.uuid AS id''',
|
|
153
|
+
'relationship': '''
|
|
154
|
+
MATCH (source)-[item:RELATES_TO {group_id: $group_id}]->(target)
|
|
155
|
+
WHERE item.uuid IN $item_ids
|
|
156
|
+
AND NOT ''' + fla_relationship_visible_cypher('item', 'source', 'target') + '''
|
|
157
|
+
RETURN item.uuid AS id''',
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
async def _hidden_items(store, space: dict, reader: AgentReader | None, item_kind: str,
|
|
162
|
+
item_ids) -> set[str]:
|
|
163
|
+
"""The ids among these that this reader may not see."""
|
|
164
|
+
item_ids = list(dict.fromkeys(item_ids))
|
|
165
|
+
if reader is None or not item_ids:
|
|
166
|
+
return set()
|
|
167
|
+
records, _, _ = await store.runtime.driver.execute_query(
|
|
168
|
+
_HIDDEN_QUERIES[item_kind], group_id=space['group_id'], item_ids=item_ids,
|
|
169
|
+
reader=reader_parameter(reader), routing_='r')
|
|
170
|
+
return {record['id'] for record in records}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
async def hidden_refs(store, space: dict, reader: AgentReader | None, refs) -> set[tuple[str, str]]:
|
|
174
|
+
"""The (item_kind, item_id) pairs among these that this reader may not see."""
|
|
175
|
+
refs = list(refs)
|
|
176
|
+
hidden = set()
|
|
177
|
+
for item_kind in _HIDDEN_QUERIES:
|
|
178
|
+
ids = [item_id for kind, item_id in refs if kind == item_kind]
|
|
179
|
+
hidden |= {(item_kind, item_id) for item_id in await _hidden_items(store, space, reader, item_kind, ids)}
|
|
180
|
+
return hidden
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
async def visible_episode_ids(store, space: dict, reader: AgentReader | None, episode_ids) -> list[str]:
|
|
184
|
+
"""These episodes in order, without the ones another FLA wrote."""
|
|
185
|
+
episode_ids = list(episode_ids)
|
|
186
|
+
if reader is None or not episode_ids:
|
|
187
|
+
return episode_ids
|
|
188
|
+
records, _, _ = await store.runtime.driver.execute_query(
|
|
189
|
+
'''
|
|
190
|
+
MATCH (episode:Episodic {group_id: $group_id}) WHERE episode.uuid IN $episode_ids
|
|
191
|
+
AND NOT ''' + fla_episode_visible_cypher('episode') + '''
|
|
192
|
+
RETURN episode.uuid AS id
|
|
193
|
+
''', group_id=space['group_id'], episode_ids=episode_ids, reader=reader_parameter(reader), routing_='r')
|
|
194
|
+
hidden = {record['id'] for record in records}
|
|
195
|
+
return [episode_id for episode_id in episode_ids if episode_id not in hidden]
|
|
@@ -997,7 +997,17 @@ class CollaborationContextResult(StrictModel):
|
|
|
997
997
|
truncated: bool = False
|
|
998
998
|
|
|
999
999
|
|
|
1000
|
-
class
|
|
1000
|
+
class AgentReaderRef(StrictModel):
|
|
1001
|
+
"""The Agent reading: an FLA in its project, or neither for a plain
|
|
1002
|
+
session. The person's console names no reader; it proves itself with the
|
|
1003
|
+
human-review channel instead (knowledge_visibility)."""
|
|
1004
|
+
reader_project_id: str | None = Field(default=None, min_length=1, max_length=128)
|
|
1005
|
+
reader_agent_id: str | None = Field(default=None, min_length=1, max_length=128)
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
# A conflict's write names its reader too: one naming an item this reader may
|
|
1009
|
+
# not see answers as missing, before anything is written or returned (0.20.1).
|
|
1010
|
+
class PreferenceConflictDeferCreate(AgentReaderRef):
|
|
1001
1011
|
personal_space_id: str = Field(min_length=1, max_length=128)
|
|
1002
1012
|
conflict_id: str = Field(min_length=1, max_length=1024)
|
|
1003
1013
|
preference_key: str = Field(min_length=1, max_length=512)
|
|
@@ -1024,7 +1034,7 @@ class PreferenceConflictDeferCreate(StrictModel):
|
|
|
1024
1034
|
return self
|
|
1025
1035
|
|
|
1026
1036
|
|
|
1027
|
-
class PreferenceConflictResolveCreate(
|
|
1037
|
+
class PreferenceConflictResolveCreate(AgentReaderRef):
|
|
1028
1038
|
personal_space_id: str = Field(min_length=1, max_length=128)
|
|
1029
1039
|
resolution: PreferenceConflictResolutionAction
|
|
1030
1040
|
reason: str = Field(min_length=1, max_length=2000)
|
|
@@ -16,6 +16,13 @@ from .models import (
|
|
|
16
16
|
PreferenceConflictResolveCreate,
|
|
17
17
|
PreferenceScopeChange,
|
|
18
18
|
)
|
|
19
|
+
from .knowledge_visibility import (
|
|
20
|
+
fla_visible_ids_cypher,
|
|
21
|
+
hidden_refs,
|
|
22
|
+
knowledge_reader,
|
|
23
|
+
reader_parameter,
|
|
24
|
+
request_reader,
|
|
25
|
+
)
|
|
19
26
|
from .provider_values import native_datetime as _native_datetime
|
|
20
27
|
|
|
21
28
|
|
|
@@ -42,6 +49,14 @@ async def defer_preference_conflict(
|
|
|
42
49
|
request.personal_space_id,
|
|
43
50
|
'maintainer',
|
|
44
51
|
)
|
|
52
|
+
# Neither the items it names nor a conflict already kept under this id
|
|
53
|
+
# may be another FLA's: that answers as missing, and nothing is written.
|
|
54
|
+
reader = await request_reader(store, actor, space, request)
|
|
55
|
+
if reader is not None:
|
|
56
|
+
existing = await _stored_conflict(store, space['id'], request.conflict_id)
|
|
57
|
+
await _require_visible(store, space, reader, [
|
|
58
|
+
(request.left_item_kind, request.left_item_id), (request.right_item_kind, request.right_item_id),
|
|
59
|
+
*(_conflict_items(existing) if existing else [])])
|
|
45
60
|
left = await _active_preference_item(
|
|
46
61
|
store,
|
|
47
62
|
space,
|
|
@@ -140,23 +155,30 @@ async def list_preference_conflicts(
|
|
|
140
155
|
limit: int = 500,
|
|
141
156
|
offset: int = 0,
|
|
142
157
|
) -> list[PreferenceConflictRecord]:
|
|
143
|
-
await _authorize_personal_space(
|
|
158
|
+
space = await _authorize_personal_space(
|
|
144
159
|
store,
|
|
145
160
|
actor,
|
|
146
161
|
personal_space_id,
|
|
147
162
|
'reader',
|
|
148
163
|
)
|
|
164
|
+
# An Agent reads as a plain session: no conflict naming any FLA's own
|
|
165
|
+
# item (an FLA meets those over its own preferences in its task context).
|
|
166
|
+
# The console reads them all with the human-review proof. Cut before the page.
|
|
167
|
+
reader = await knowledge_reader(store, actor, space, personal_project_id=None, project_agent_id=None)
|
|
149
168
|
records, _, _ = await store.runtime.driver.execute_query(
|
|
150
169
|
'''
|
|
151
170
|
MATCH (:FuliSpace {id: $space_id, kind: 'personal'})-
|
|
152
171
|
[:HAS_PREFERENCE_CONFLICT]->(conflict:FuliPreferenceConflict)
|
|
153
|
-
WHERE $status IS NULL OR conflict.status = $status
|
|
172
|
+
WHERE ($status IS NULL OR conflict.status = $status)
|
|
173
|
+
AND ''' + fla_visible_ids_cypher('[conflict.left_item_id, conflict.right_item_id]') + '''
|
|
154
174
|
RETURN conflict
|
|
155
175
|
ORDER BY conflict.updated_at DESC, conflict.id ASC
|
|
156
176
|
SKIP $offset
|
|
157
177
|
LIMIT $limit
|
|
158
178
|
''',
|
|
159
179
|
space_id=personal_space_id,
|
|
180
|
+
group_id=space['group_id'],
|
|
181
|
+
reader=reader_parameter(reader),
|
|
160
182
|
status=status,
|
|
161
183
|
limit=min(max(limit, 1), 1000),
|
|
162
184
|
offset=max(offset, 0),
|
|
@@ -216,6 +238,10 @@ async def resolve_preference_conflict(
|
|
|
216
238
|
'maintainer',
|
|
217
239
|
)
|
|
218
240
|
conflict = await _read_conflict(store, space['id'], conflict_id)
|
|
241
|
+
# Before anything is returned, a resolved retry included: a conflict
|
|
242
|
+
# naming another FLA's item answers as missing.
|
|
243
|
+
await _require_visible(store, space, await request_reader(store, actor, space, request),
|
|
244
|
+
_conflict_items(conflict))
|
|
219
245
|
if conflict.status == 'resolved':
|
|
220
246
|
return conflict
|
|
221
247
|
if conflict.status != 'ai_pending':
|
|
@@ -266,6 +292,10 @@ async def complete_preference_conflict(
|
|
|
266
292
|
'maintainer',
|
|
267
293
|
)
|
|
268
294
|
conflict = await _read_conflict(store, space['id'], conflict_id)
|
|
295
|
+
# The person completes any conflict with the console's proof; without it
|
|
296
|
+
# the caller reads as a plain session.
|
|
297
|
+
await _require_visible(store, space, await knowledge_reader(
|
|
298
|
+
store, actor, space, personal_project_id=None, project_agent_id=None), _conflict_items(conflict))
|
|
269
299
|
return await _complete(
|
|
270
300
|
store,
|
|
271
301
|
space['id'],
|
|
@@ -467,6 +497,13 @@ async def _complete(
|
|
|
467
497
|
|
|
468
498
|
|
|
469
499
|
async def _read_conflict(store, space_id, conflict_id):
|
|
500
|
+
conflict = await _stored_conflict(store, space_id, conflict_id)
|
|
501
|
+
if conflict is None:
|
|
502
|
+
raise HTTPException(status_code=404, detail='preference conflict not found')
|
|
503
|
+
return conflict
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
async def _stored_conflict(store, space_id, conflict_id):
|
|
470
507
|
records, _, _ = await store.runtime.driver.execute_query(
|
|
471
508
|
'''
|
|
472
509
|
MATCH (:FuliSpace {id: $space_id, kind: 'personal'})-
|
|
@@ -478,9 +515,18 @@ async def _read_conflict(store, space_id, conflict_id):
|
|
|
478
515
|
conflict_id=conflict_id,
|
|
479
516
|
routing_='r',
|
|
480
517
|
)
|
|
481
|
-
if
|
|
518
|
+
return _record(records[0]['conflict']) if records else None
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
def _conflict_items(conflict) -> list[tuple[str, str]]:
|
|
522
|
+
return [(conflict.left_item_kind, conflict.left_item_id),
|
|
523
|
+
(conflict.right_item_kind, conflict.right_item_id)]
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
async def _require_visible(store, space, reader, items) -> None:
|
|
527
|
+
"""A conflict naming an item this reader may not see is, to it, missing."""
|
|
528
|
+
if await hidden_refs(store, space, reader, items):
|
|
482
529
|
raise HTTPException(status_code=404, detail='preference conflict not found')
|
|
483
|
-
return _record(records[0]['conflict'])
|
|
484
530
|
|
|
485
531
|
|
|
486
532
|
async def _active_preference_item(store, space, item_id, item_kind):
|
|
@@ -21,6 +21,42 @@ def publication_source_identity(group_id, episode):
|
|
|
21
21
|
return identity
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
PROJECT_AGENT, PLAIN, UNRESOLVED = 'project_agent', 'plain', 'unresolved'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def draft_sources(store, space, identities) -> list[str]:
|
|
28
|
+
"""Whose work each of these draft source identities is, from the personal
|
|
29
|
+
episode it names and the session turn it came from (0.20.1):
|
|
30
|
+
PROJECT_AGENT when either is an FLA's, PLAIN only when one of them is
|
|
31
|
+
found and neither is, and UNRESOLVED when neither is found (erased, or
|
|
32
|
+
never recorded, as for a capture made only for a team project). Nothing
|
|
33
|
+
is ever taken as plain for want of a source."""
|
|
34
|
+
sources = [{'index': index, 'episode_id': identity.get('episode_id'),
|
|
35
|
+
'turn_id': identity.get('source_turn_id'),
|
|
36
|
+
'session_node': store._task_session_id(space['id'], identity['source_application'],
|
|
37
|
+
identity['session_id'])
|
|
38
|
+
if identity.get('source_application') and identity.get('session_id') else None}
|
|
39
|
+
for index, identity in enumerate(identities)]
|
|
40
|
+
if not sources:
|
|
41
|
+
return []
|
|
42
|
+
records, _, _ = await store.runtime.driver.execute_query(
|
|
43
|
+
'''
|
|
44
|
+
UNWIND $sources AS source
|
|
45
|
+
OPTIONAL MATCH (episode:Episodic {group_id: $group_id, uuid: source.episode_id})
|
|
46
|
+
OPTIONAL MATCH (:FuliSpace {id: $space_id, kind: 'personal'})-[:HAS_TASK_CONTEXT_SESSION]->
|
|
47
|
+
(:FuliTaskContextSession {id: source.session_node})-[:HAS_CONTEXT]->
|
|
48
|
+
(task:FuliTaskContext {turn_id: source.turn_id})
|
|
49
|
+
WITH source, collect(DISTINCT episode) AS episodes, collect(DISTINCT task) AS tasks
|
|
50
|
+
RETURN source.index AS index,
|
|
51
|
+
any(episode IN episodes WHERE episode.fuli_project_agent_id IS NOT NULL)
|
|
52
|
+
OR any(task IN tasks WHERE task.project_agent_id IS NOT NULL) AS project_agent,
|
|
53
|
+
size(episodes) + size(tasks) > 0 AS found
|
|
54
|
+
''', sources=sources, group_id=space['group_id'], space_id=space['id'], routing_='r')
|
|
55
|
+
found = {record['index']: (PROJECT_AGENT if record['project_agent'] else PLAIN if record['found'] else UNRESOLVED)
|
|
56
|
+
for record in records}
|
|
57
|
+
return [found.get(index, UNRESOLVED) for index in range(len(sources))]
|
|
58
|
+
|
|
59
|
+
|
|
24
60
|
async def drafts_for_sources(store, space, sources, *, source_range=None):
|
|
25
61
|
"""Read copies by exact source identity; all statuses participate in erasure.
|
|
26
62
|
Legacy drafts derive their identity from payload until first scrubbed.
|