@bevel-software/platform-core-backend 0.20.0 → 0.22.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/core/catalog-cache-invalidation.d.ts +7 -2
- package/dist/core/catalog-cache-invalidation.d.ts.map +1 -1
- package/dist/core/catalog-cache-invalidation.js +8 -9
- package/dist/core/catalog-cache-invalidation.js.map +1 -1
- package/dist/core/core-ports.d.ts +19 -0
- package/dist/core/core-ports.d.ts.map +1 -1
- package/dist/core/core-ports.js.map +1 -1
- package/dist/core/create-core-server.d.ts +2 -0
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +55 -107
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +41 -4
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +183 -82
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/core/lifecycle.d.ts +74 -28
- package/dist/core/lifecycle.d.ts.map +1 -1
- package/dist/core/lifecycle.js +157 -20
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/core/public-config.d.ts +5 -1
- package/dist/core/public-config.d.ts.map +1 -1
- package/dist/core/public-config.js +7 -5
- package/dist/core/public-config.js.map +1 -1
- package/dist/core-config.d.ts +95 -1
- package/dist/core-config.d.ts.map +1 -1
- package/dist/core-config.js +24 -8
- package/dist/core-config.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +18 -1
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +19 -8
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/access-requests.contract.d.ts +75 -0
- package/dist/modules/access/access-requests.contract.d.ts.map +1 -0
- package/dist/modules/access/access-requests.contract.js +20 -0
- package/dist/modules/access/access-requests.contract.js.map +1 -0
- package/dist/modules/access/access-requests.routes.d.ts +35 -0
- package/dist/modules/access/access-requests.routes.d.ts.map +1 -0
- package/dist/modules/access/access-requests.routes.js +237 -0
- package/dist/modules/access/access-requests.routes.js.map +1 -0
- package/dist/modules/access/access-requests.service.d.ts +123 -0
- package/dist/modules/access/access-requests.service.d.ts.map +1 -0
- package/dist/modules/access/access-requests.service.js +337 -0
- package/dist/modules/access/access-requests.service.js.map +1 -0
- package/dist/modules/access/access.routes.d.ts +2 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +10 -10
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access/change-read-gate.d.ts +6 -3
- package/dist/modules/access/change-read-gate.d.ts.map +1 -1
- package/dist/modules/access/change-read-gate.js +9 -6
- package/dist/modules/access/change-read-gate.js.map +1 -1
- package/dist/modules/access/creator-access.d.ts +4 -2
- package/dist/modules/access/creator-access.d.ts.map +1 -1
- package/dist/modules/access/creator-access.js +7 -4
- package/dist/modules/access/creator-access.js.map +1 -1
- package/dist/modules/access-model/access-grammar.d.ts +12 -0
- package/dist/modules/access-model/access-grammar.d.ts.map +1 -1
- package/dist/modules/access-model/access-grammar.js +24 -0
- package/dist/modules/access-model/access-grammar.js.map +1 -1
- package/dist/modules/agent-instructions/read-preamble.d.ts +2 -1
- package/dist/modules/agent-instructions/read-preamble.d.ts.map +1 -1
- package/dist/modules/agent-instructions/read-preamble.js +6 -9
- package/dist/modules/agent-instructions/read-preamble.js.map +1 -1
- package/dist/modules/auth/account-admission.d.ts +40 -0
- package/dist/modules/auth/account-admission.d.ts.map +1 -0
- package/dist/modules/auth/account-admission.js +17 -0
- package/dist/modules/auth/account-admission.js.map +1 -0
- package/dist/modules/auth/account.routes.d.ts.map +1 -1
- package/dist/modules/auth/account.routes.js +4 -1
- package/dist/modules/auth/account.routes.js.map +1 -1
- package/dist/modules/auth/auth.service.d.ts +45 -2
- package/dist/modules/auth/auth.service.d.ts.map +1 -1
- package/dist/modules/auth/auth.service.js +44 -3
- package/dist/modules/auth/auth.service.js.map +1 -1
- package/dist/modules/auth/oidc-auth-provider.d.ts.map +1 -1
- package/dist/modules/auth/oidc-auth-provider.js +9 -0
- package/dist/modules/auth/oidc-auth-provider.js.map +1 -1
- package/dist/modules/connection-probe/connection-probe.service.d.ts +13 -1
- package/dist/modules/connection-probe/connection-probe.service.d.ts.map +1 -1
- package/dist/modules/connection-probe/connection-probe.service.js +10 -2
- package/dist/modules/connection-probe/connection-probe.service.js.map +1 -1
- package/dist/modules/database/advisory-lock.d.ts +17 -0
- package/dist/modules/database/advisory-lock.d.ts.map +1 -1
- package/dist/modules/database/advisory-lock.js +24 -3
- package/dist/modules/database/advisory-lock.js.map +1 -1
- package/dist/modules/database/connection.d.ts +67 -2
- package/dist/modules/database/connection.d.ts.map +1 -1
- package/dist/modules/database/connection.js +118 -12
- package/dist/modules/database/connection.js.map +1 -1
- package/dist/modules/database/migrate.d.ts +1 -1
- package/dist/modules/database/migrate.d.ts.map +1 -1
- package/dist/modules/database/migrate.js +27 -3
- package/dist/modules/database/migrate.js.map +1 -1
- package/dist/modules/github-app/github-app.client.d.ts +101 -0
- package/dist/modules/github-app/github-app.client.d.ts.map +1 -0
- package/dist/modules/github-app/github-app.client.js +222 -0
- package/dist/modules/github-app/github-app.client.js.map +1 -0
- package/dist/modules/github-app/github-app.connection.d.ts +102 -0
- package/dist/modules/github-app/github-app.connection.d.ts.map +1 -0
- package/dist/modules/github-app/github-app.connection.js +185 -0
- package/dist/modules/github-app/github-app.connection.js.map +1 -0
- package/dist/modules/github-app/github-app.routes.d.ts +59 -0
- package/dist/modules/github-app/github-app.routes.d.ts.map +1 -0
- package/dist/modules/github-app/github-app.routes.js +323 -0
- package/dist/modules/github-app/github-app.routes.js.map +1 -0
- package/dist/modules/github-app/index.d.ts +4 -0
- package/dist/modules/github-app/index.d.ts.map +1 -0
- package/dist/modules/github-app/index.js +4 -0
- package/dist/modules/github-app/index.js.map +1 -0
- package/dist/modules/kb-fs/branch-name.d.ts +0 -1
- package/dist/modules/kb-fs/branch-name.d.ts.map +1 -1
- package/dist/modules/kb-fs/branch-name.js +3 -3
- package/dist/modules/kb-fs/branch-name.js.map +1 -1
- package/dist/modules/kb-fs/clone-config.d.ts +9 -8
- package/dist/modules/kb-fs/clone-config.d.ts.map +1 -1
- package/dist/modules/kb-fs/clone-config.js +14 -12
- package/dist/modules/kb-fs/clone-config.js.map +1 -1
- package/dist/modules/kb-fs/remote-url.d.ts +22 -0
- package/dist/modules/kb-fs/remote-url.d.ts.map +1 -0
- package/dist/modules/kb-fs/remote-url.js +35 -0
- package/dist/modules/kb-fs/remote-url.js.map +1 -0
- package/dist/modules/mcp/mcp.service.d.ts +7 -0
- package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
- package/dist/modules/mcp/mcp.service.js +4 -4
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts +4 -4
- package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts.map +1 -1
- package/dist/modules/plugins/compile/marketplace-compiler.service.js +7 -10
- package/dist/modules/plugins/compile/marketplace-compiler.service.js.map +1 -1
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts +4 -1
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts.map +1 -1
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js +5 -3
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js.map +1 -1
- package/dist/modules/plugins/discovery/kb-plugin-source.d.ts +6 -1
- package/dist/modules/plugins/discovery/kb-plugin-source.d.ts.map +1 -1
- package/dist/modules/plugins/discovery/kb-plugin-source.js +14 -9
- package/dist/modules/plugins/discovery/kb-plugin-source.js.map +1 -1
- package/dist/modules/plugins/discovery/native.source.d.ts +4 -1
- package/dist/modules/plugins/discovery/native.source.d.ts.map +1 -1
- package/dist/modules/plugins/discovery/native.source.js +4 -2
- package/dist/modules/plugins/discovery/native.source.js.map +1 -1
- package/dist/modules/plugins/index.d.ts +1 -1
- package/dist/modules/plugins/index.d.ts.map +1 -1
- package/dist/modules/plugins/index.js +1 -1
- package/dist/modules/plugins/index.js.map +1 -1
- package/dist/modules/plugins/join-proposals.d.ts +17 -5
- package/dist/modules/plugins/join-proposals.d.ts.map +1 -1
- package/dist/modules/plugins/join-proposals.js +76 -22
- package/dist/modules/plugins/join-proposals.js.map +1 -1
- package/dist/modules/plugins/join-request-jobs.service.d.ts +3 -1
- package/dist/modules/plugins/join-request-jobs.service.d.ts.map +1 -1
- package/dist/modules/plugins/join-request-jobs.service.js +6 -6
- package/dist/modules/plugins/join-request-jobs.service.js.map +1 -1
- package/dist/modules/plugins/join-requests.service.d.ts +113 -18
- package/dist/modules/plugins/join-requests.service.d.ts.map +1 -1
- package/dist/modules/plugins/join-requests.service.js +178 -33
- package/dist/modules/plugins/join-requests.service.js.map +1 -1
- package/dist/modules/plugins/plugin-links.d.ts +65 -10
- package/dist/modules/plugins/plugin-links.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-links.js +136 -31
- package/dist/modules/plugins/plugin-links.js.map +1 -1
- package/dist/modules/plugins/plugin-links.service.d.ts +107 -5
- package/dist/modules/plugins/plugin-links.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-links.service.js +151 -21
- package/dist/modules/plugins/plugin-links.service.js.map +1 -1
- package/dist/modules/plugins/plugin-provision.service.d.ts +10 -3
- package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-provision.service.js +33 -26
- package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
- package/dist/modules/plugins/plugin-rename.service.d.ts +4 -2
- package/dist/modules/plugins/plugin-rename.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-rename.service.js +10 -12
- package/dist/modules/plugins/plugin-rename.service.js.map +1 -1
- package/dist/modules/plugins/plugins.routes.d.ts +3 -0
- package/dist/modules/plugins/plugins.routes.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.routes.js +48 -17
- package/dist/modules/plugins/plugins.routes.js.map +1 -1
- package/dist/modules/plugins/plugins.service.d.ts +4 -4
- package/dist/modules/plugins/plugins.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.service.js +7 -10
- package/dist/modules/plugins/plugins.service.js.map +1 -1
- package/dist/modules/plugins/teams.routes.d.ts +4 -1
- package/dist/modules/plugins/teams.routes.d.ts.map +1 -1
- package/dist/modules/plugins/teams.routes.js +11 -9
- package/dist/modules/plugins/teams.routes.js.map +1 -1
- package/dist/modules/secrets-vault/index.d.ts +1 -1
- package/dist/modules/secrets-vault/index.d.ts.map +1 -1
- package/dist/modules/secrets-vault/index.js +1 -1
- package/dist/modules/secrets-vault/index.js.map +1 -1
- package/dist/modules/secrets-vault/secrets-variable-loader.d.ts +29 -11
- package/dist/modules/secrets-vault/secrets-variable-loader.d.ts.map +1 -1
- package/dist/modules/secrets-vault/secrets-variable-loader.js +46 -21
- package/dist/modules/secrets-vault/secrets-variable-loader.js.map +1 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts +3 -0
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts.map +1 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.js +4 -6
- package/dist/modules/secrets-vault/secrets-vault.routes.js.map +1 -1
- package/dist/modules/settings/deployment-settings.service.d.ts +34 -9
- package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
- package/dist/modules/settings/deployment-settings.service.js +113 -26
- package/dist/modules/settings/deployment-settings.service.js.map +1 -1
- package/dist/modules/settings/managed-repository.d.ts +43 -0
- package/dist/modules/settings/managed-repository.d.ts.map +1 -0
- package/dist/modules/settings/managed-repository.js +60 -0
- package/dist/modules/settings/managed-repository.js.map +1 -0
- package/dist/modules/settings/repository-source.d.ts +128 -0
- package/dist/modules/settings/repository-source.d.ts.map +1 -0
- package/dist/modules/settings/repository-source.js +150 -0
- package/dist/modules/settings/repository-source.js.map +1 -0
- package/dist/modules/settings/setup.routes.d.ts +34 -4
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +198 -18
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/skills/allowed-tools-check.d.ts +4 -3
- package/dist/modules/skills/allowed-tools-check.d.ts.map +1 -1
- package/dist/modules/skills/allowed-tools-check.js +8 -8
- package/dist/modules/skills/allowed-tools-check.js.map +1 -1
- package/dist/modules/skills/pending-skills.service.d.ts +3 -1
- package/dist/modules/skills/pending-skills.service.d.ts.map +1 -1
- package/dist/modules/skills/pending-skills.service.js +9 -6
- package/dist/modules/skills/pending-skills.service.js.map +1 -1
- package/dist/modules/skills/skill-access-requests.routes.d.ts +8 -9
- package/dist/modules/skills/skill-access-requests.routes.d.ts.map +1 -1
- package/dist/modules/skills/skill-access-requests.routes.js +26 -65
- package/dist/modules/skills/skill-access-requests.routes.js.map +1 -1
- package/dist/modules/skills/skills.routes.d.ts +4 -1
- package/dist/modules/skills/skills.routes.d.ts.map +1 -1
- package/dist/modules/skills/skills.routes.js +4 -4
- package/dist/modules/skills/skills.routes.js.map +1 -1
- package/dist/modules/skills/skills.service.d.ts +4 -2
- package/dist/modules/skills/skills.service.d.ts.map +1 -1
- package/dist/modules/skills/skills.service.js +13 -11
- package/dist/modules/skills/skills.service.js.map +1 -1
- package/dist/modules/tool-helpers/tool-context.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool-context.js +15 -0
- package/dist/modules/tool-helpers/tool-context.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts +2 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.js +6 -5
- package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts +4 -2
- package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.js +12 -10
- package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -1
- package/dist/modules/tool-manuals/pending-tools.service.d.ts +3 -1
- package/dist/modules/tool-manuals/pending-tools.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/pending-tools.service.js +19 -16
- package/dist/modules/tool-manuals/pending-tools.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-delete.service.d.ts +4 -2
- package/dist/modules/tool-manuals/tool-delete.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-delete.service.js +14 -12
- package/dist/modules/tool-manuals/tool-delete.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +3 -1
- package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.routes.js +7 -7
- package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts +4 -2
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.js +15 -12
- package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts +3 -0
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.js +4 -6
- package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts +3 -2
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.js +47 -11
- package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +14 -6
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +40 -18
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/git/node-git-runner.d.ts +26 -2
- package/dist/modules/workflow/git/node-git-runner.d.ts.map +1 -1
- package/dist/modules/workflow/git/node-git-runner.js +40 -5
- package/dist/modules/workflow/git/node-git-runner.js.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.d.ts +45 -0
- package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.js +99 -0
- package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.js +9 -4
- package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
- package/dist/modules/workflow/session-ontology.service.d.ts +6 -1
- package/dist/modules/workflow/session-ontology.service.d.ts.map +1 -1
- package/dist/modules/workflow/session-ontology.service.js +6 -2
- package/dist/modules/workflow/session-ontology.service.js.map +1 -1
- package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.routes.js +3 -1
- package/dist/modules/workflow/workflow.routes.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +42 -10
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +181 -71
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/session-ontology.gate.d.ts +3 -1
- package/dist/modules/workspace/session-ontology.gate.d.ts.map +1 -1
- package/dist/modules/workspace/session-ontology.gate.js +3 -3
- package/dist/modules/workspace/session-ontology.gate.js.map +1 -1
- package/dist/modules/workspace/startup/kb-git.d.ts +4 -3
- package/dist/modules/workspace/startup/kb-git.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-git.js +15 -13
- package/dist/modules/workspace/startup/kb-git.js.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts +70 -7
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.js +183 -38
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts +7 -1
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js +23 -16
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/personal-spaces.step.d.ts +7 -1
- package/dist/modules/workspace/startup/steps/personal-spaces.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/personal-spaces.step.js +12 -5
- package/dist/modules/workspace/startup/steps/personal-spaces.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-display-names.step.d.ts +7 -1
- package/dist/modules/workspace/startup/steps/plugin-display-names.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-display-names.step.js +12 -5
- package/dist/modules/workspace/startup/steps/plugin-display-names.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts +7 -1
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.js +12 -5
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts +4 -1
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.js +14 -11
- package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts +17 -3
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-files.step.js +36 -30
- package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.d.ts +6 -1
- package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.js +10 -6
- package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
- package/dist/modules/workspace/workspace.routes.d.ts +2 -1
- package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.routes.js +8 -7
- package/dist/modules/workspace/workspace.routes.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +18 -12
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +49 -29
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts +2 -1
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +48 -20
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- package/dist/modules/workspace/write-denial.d.ts +3 -2
- package/dist/modules/workspace/write-denial.d.ts.map +1 -1
- package/dist/modules/workspace/write-denial.js +6 -5
- package/dist/modules/workspace/write-denial.js.map +1 -1
- package/dist/shared/domain-errors.d.ts +39 -0
- package/dist/shared/domain-errors.d.ts.map +1 -1
- package/dist/shared/domain-errors.js +55 -0
- package/dist/shared/domain-errors.js.map +1 -1
- package/dist/shared/git.contract.d.ts +62 -7
- package/dist/shared/git.contract.d.ts.map +1 -1
- package/dist/shared/git.contract.js +30 -8
- package/dist/shared/git.contract.js.map +1 -1
- package/dist/shared/kb-context.d.ts +76 -0
- package/dist/shared/kb-context.d.ts.map +1 -0
- package/dist/shared/kb-context.js +108 -0
- package/dist/shared/kb-context.js.map +1 -0
- package/dist/shared/kb-layout.d.ts +3 -2
- package/dist/shared/kb-layout.d.ts.map +1 -1
- package/dist/shared/kb-layout.js +4 -3
- package/dist/shared/kb-layout.js.map +1 -1
- package/dist/shared/kb-layout.test.js +35 -27
- package/dist/shared/kb-layout.test.js.map +1 -1
- package/dist/shared/pending-proposals.d.ts +4 -1
- package/dist/shared/pending-proposals.d.ts.map +1 -1
- package/dist/shared/pending-proposals.js +3 -4
- package/dist/shared/pending-proposals.js.map +1 -1
- package/dist/shared/redact-secret.d.ts +5 -5
- package/dist/shared/redact-secret.js +5 -5
- package/dist/tenancy/index.d.ts +13 -0
- package/dist/tenancy/index.d.ts.map +1 -0
- package/dist/tenancy/index.js +13 -0
- package/dist/tenancy/index.js.map +1 -0
- package/dist/tenancy/static-tenant-source.d.ts +98 -0
- package/dist/tenancy/static-tenant-source.d.ts.map +1 -0
- package/dist/tenancy/static-tenant-source.js +220 -0
- package/dist/tenancy/static-tenant-source.js.map +1 -0
- package/dist/tenancy/tenant-host.d.ts +80 -0
- package/dist/tenancy/tenant-host.d.ts.map +1 -0
- package/dist/tenancy/tenant-host.js +217 -0
- package/dist/tenancy/tenant-host.js.map +1 -0
- package/dist/tenancy/tenant-runtime.d.ts +91 -0
- package/dist/tenancy/tenant-runtime.d.ts.map +1 -0
- package/dist/tenancy/tenant-runtime.js +174 -0
- package/dist/tenancy/tenant-runtime.js.map +1 -0
- package/dist/tenancy/tenant-secrets.d.ts +24 -0
- package/dist/tenancy/tenant-secrets.d.ts.map +1 -0
- package/dist/tenancy/tenant-secrets.js +30 -0
- package/dist/tenancy/tenant-secrets.js.map +1 -0
- package/dist/tenancy/tenant-source.contract.d.ts +45 -0
- package/dist/tenancy/tenant-source.contract.d.ts.map +1 -0
- package/dist/tenancy/tenant-source.contract.js +21 -0
- package/dist/tenancy/tenant-source.contract.js.map +1 -0
- package/migrations/0000_core_init.sql +14 -14
- package/migrations/0003_deployment_settings.sql +1 -1
- package/migrations/0005_github_facade.sql +1 -1
- package/migrations/0012_agent_audit.sql +6 -6
- package/package.json +3 -3
- package/src/__tests__/branch-model.test.ts +7 -6
- package/src/__tests__/kb-context.ts +30 -0
- package/src/__tests__/kb-layout-config.test.ts +35 -30
- package/src/core/__tests__/catalog-cache-invalidation.test.ts +2 -1
- package/src/core/__tests__/lifecycle.test.ts +78 -1
- package/src/core/__tests__/public-config.test.ts +5 -1
- package/src/core/catalog-cache-invalidation.ts +16 -11
- package/src/core/core-ports.ts +19 -0
- package/src/core/create-core-server.ts +64 -107
- package/src/core/create-core-services.ts +238 -96
- package/src/core/lifecycle.ts +214 -29
- package/src/core/public-config.ts +8 -5
- package/src/core-config.ts +107 -8
- package/src/index.ts +25 -2
- package/src/modules/access/__tests__/access-control.admin-root-floor.test.ts +2 -1
- package/src/modules/access/__tests__/access-requests.recut.test.ts +134 -0
- package/src/modules/access/__tests__/access-requests.routes.test.ts +610 -0
- package/src/modules/access/__tests__/access.routes.batch.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.folder-governs.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.group-grant.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.overrides.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.proposal-branch.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.prospective.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.revoke.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.unknown-email.test.ts +2 -1
- package/src/modules/access/__tests__/change-read-gate.test.ts +13 -11
- package/src/modules/access/__tests__/creator-access.test.ts +3 -2
- package/src/modules/access/__tests__/roles.routes.test.ts +2 -1
- package/src/modules/access/access-control.service.ts +20 -6
- package/src/modules/access/access-requests.contract.ts +93 -0
- package/src/modules/access/access-requests.routes.ts +286 -0
- package/src/modules/access/access-requests.service.ts +420 -0
- package/src/modules/access/access.routes.ts +10 -13
- package/src/modules/access/change-read-gate.ts +10 -4
- package/src/modules/access/creator-access.ts +7 -2
- package/src/modules/access-model/access-grammar.ts +22 -0
- package/src/modules/agent-instructions/__tests__/read-preamble.test.ts +13 -12
- package/src/modules/agent-instructions/read-preamble.ts +10 -12
- package/src/modules/auth/__tests__/account.routes.test.ts +15 -0
- package/src/modules/auth/__tests__/auth.service.test.ts +98 -0
- package/src/modules/auth/account-admission.ts +44 -0
- package/src/modules/auth/account.routes.ts +4 -1
- package/src/modules/auth/auth.service.ts +61 -2
- package/src/modules/auth/oidc-auth-provider.ts +9 -0
- package/src/modules/connection-probe/connection-probe.service.ts +7 -1
- package/src/modules/database/__tests__/advisory-lock.test.ts +23 -1
- package/src/modules/database/__tests__/connection.test.ts +98 -0
- package/src/modules/database/__tests__/migrations-unqualified.test.ts +32 -0
- package/src/modules/database/advisory-lock.ts +28 -4
- package/src/modules/database/connection.ts +143 -13
- package/src/modules/database/migrate.ts +48 -14
- package/src/modules/diff/__tests__/diff.service.seed-atomicity.test.ts +2 -1
- package/src/modules/diff/__tests__/diff.service.test.ts +2 -1
- package/src/modules/github-app/__tests__/github-app.test.ts +848 -0
- package/src/modules/github-app/github-app.client.ts +268 -0
- package/src/modules/github-app/github-app.connection.ts +204 -0
- package/src/modules/github-app/github-app.routes.ts +359 -0
- package/src/modules/github-app/index.ts +19 -0
- package/src/modules/kb-fs/__tests__/branch-name.test.ts +6 -6
- package/src/modules/kb-fs/__tests__/clone-config.test.ts +24 -20
- package/src/modules/kb-fs/__tests__/remote-url.test.ts +38 -0
- package/src/modules/kb-fs/branch-name.ts +3 -3
- package/src/modules/kb-fs/clone-config.ts +15 -12
- package/src/modules/kb-fs/remote-url.ts +35 -0
- package/src/modules/marketplace/__tests__/marketplace-repo.head.test.ts +2 -1
- package/src/modules/mcp/mcp.service.ts +11 -4
- package/src/modules/plugins/__tests__/bundle-dialect.e2e.test.ts +12 -11
- package/src/modules/plugins/__tests__/bundle-dialect.test.ts +2 -1
- package/src/modules/plugins/__tests__/compile-marketplace.test.ts +6 -4
- package/src/modules/plugins/__tests__/join-proposals.test.ts +100 -19
- package/src/modules/plugins/__tests__/join-request-jobs.service.test.ts +2 -1
- package/src/modules/plugins/__tests__/join-requests.service.test.ts +28 -11
- package/src/modules/plugins/__tests__/join-requests.settlement.test.ts +371 -0
- package/src/modules/plugins/__tests__/plugin-creation-display-name.test.ts +4 -3
- package/src/modules/plugins/__tests__/plugin-index.service.test.ts +6 -4
- package/src/modules/plugins/__tests__/plugin-links.service.test.ts +220 -5
- package/src/modules/plugins/__tests__/plugin-provision.service.test.ts +3 -1
- package/src/modules/plugins/__tests__/plugin-rename.service.test.ts +7 -6
- package/src/modules/plugins/__tests__/plugins.routes.test.ts +12 -3
- package/src/modules/plugins/__tests__/teams.routes.test.ts +2 -1
- package/src/modules/plugins/compile/marketplace-compiler.service.ts +7 -9
- package/src/modules/plugins/discovery/__tests__/kb-plugin-source.test.ts +20 -16
- package/src/modules/plugins/discovery/bundle-dialect/bundle.source.ts +9 -2
- package/src/modules/plugins/discovery/kb-plugin-source.ts +15 -8
- package/src/modules/plugins/discovery/native.source.ts +4 -1
- package/src/modules/plugins/index.ts +1 -1
- package/src/modules/plugins/join-proposals.ts +87 -19
- package/src/modules/plugins/join-request-jobs.service.ts +8 -7
- package/src/modules/plugins/join-requests.service.ts +203 -43
- package/src/modules/plugins/plugin-links.service.ts +192 -19
- package/src/modules/plugins/plugin-links.ts +147 -27
- package/src/modules/plugins/plugin-provision.service.ts +54 -27
- package/src/modules/plugins/plugin-rename.service.ts +10 -10
- package/src/modules/plugins/plugins.routes.ts +48 -17
- package/src/modules/plugins/plugins.service.ts +7 -11
- package/src/modules/plugins/teams.routes.ts +16 -8
- package/src/modules/secrets-vault/__tests__/connect-pending.route.test.ts +7 -0
- package/src/modules/secrets-vault/__tests__/secrets-variable-loader.test.ts +40 -0
- package/src/modules/secrets-vault/__tests__/tool-owner-gate.route.test.ts +2 -0
- package/src/modules/secrets-vault/index.ts +2 -0
- package/src/modules/secrets-vault/secrets-variable-loader.ts +51 -21
- package/src/modules/secrets-vault/secrets-vault.routes.ts +7 -6
- package/src/modules/settings/__tests__/deployment-settings.service.test.ts +24 -11
- package/src/modules/settings/__tests__/git-root-folders.test.ts +2 -1
- package/src/modules/settings/__tests__/repository-source.test.ts +191 -0
- package/src/modules/settings/__tests__/setup.routes.boot-failure.test.ts +2 -1
- package/src/modules/settings/__tests__/setup.routes.git-mode.test.ts +353 -0
- package/src/modules/settings/__tests__/setup.routes.github-app.test.ts +282 -0
- package/src/modules/settings/__tests__/setup.routes.layout-phase.test.ts +7 -4
- package/src/modules/settings/__tests__/setup.routes.managed-phase.test.ts +233 -0
- package/src/modules/settings/__tests__/setup.routes.oidc.test.ts +2 -0
- package/src/modules/settings/__tests__/setup.routes.sync-status.test.ts +2 -0
- package/src/modules/settings/__tests__/setup.routes.test.ts +33 -52
- package/src/modules/settings/deployment-settings.service.ts +130 -23
- package/src/modules/settings/managed-repository.ts +68 -0
- package/src/modules/settings/repository-source.ts +197 -0
- package/src/modules/settings/setup.routes.ts +233 -19
- package/src/modules/skills/__tests__/allowed-tools-check.test.ts +11 -10
- package/src/modules/skills/__tests__/allowed-tools-warn.tools.test.ts +4 -3
- package/src/modules/skills/__tests__/pending-skills.service.test.ts +3 -1
- package/src/modules/skills/__tests__/skill-access-requests.routes.test.ts +7 -2
- package/src/modules/skills/__tests__/skills.routes.warnings.test.ts +2 -1
- package/src/modules/skills/__tests__/skills.service.test.ts +3 -2
- package/src/modules/skills/allowed-tools-check.ts +7 -6
- package/src/modules/skills/pending-skills.service.ts +9 -8
- package/src/modules/skills/skill-access-requests.routes.ts +29 -79
- package/src/modules/skills/skills.routes.ts +4 -3
- package/src/modules/skills/skills.service.ts +13 -9
- package/src/modules/tool-helpers/__tests__/agent-roles-write.test.ts +3 -2
- package/src/modules/tool-helpers/__tests__/phase4-tools.test.ts +3 -2
- package/src/modules/tool-helpers/tool-context.ts +15 -0
- package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +17 -12
- package/src/modules/tool-manuals/__tests__/mcp-server-edit.service.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/pending-tools.service.test.ts +4 -1
- package/src/modules/tool-manuals/__tests__/tool-delete.service.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.archive.route.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.cli.test.ts +5 -4
- package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.invalid.routes.test.ts +4 -2
- package/src/modules/tool-manuals/__tests__/tool-manuals.invalid.test.ts +13 -5
- package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.restart.test.ts +9 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +3 -2
- package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +2 -0
- package/src/modules/tool-manuals/mcp-json-discovery.ts +6 -4
- package/src/modules/tool-manuals/mcp-server-edit.service.ts +13 -11
- package/src/modules/tool-manuals/pending-tools.service.ts +19 -16
- package/src/modules/tool-manuals/tool-delete.service.ts +13 -10
- package/src/modules/tool-manuals/tool-manuals.routes.ts +10 -8
- package/src/modules/tool-manuals/tool-manuals.service.ts +15 -13
- package/src/modules/tool-manuals/tool-manuals.tools.ts +7 -6
- package/src/modules/workflow/__tests__/apply-failure.test.ts +11 -2
- package/src/modules/workflow/__tests__/merge-announces-tree.test.ts +14 -26
- package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +2 -1
- package/src/modules/workflow/__tests__/session-ontology.service.test.ts +3 -2
- package/src/modules/workflow/__tests__/workflow.routes.lock-path.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.branch-in-use.test.ts +3 -10
- package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.deleted-branch-sweep.test.ts +3 -10
- package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +187 -35
- package/src/modules/workflow/__tests__/workflow.service.folder-proposals.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.platform-restore.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.read-gate.test.ts +3 -2
- package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.sync.test.ts +5 -4
- package/src/modules/workflow/__tests__/workflow.service.update-from-target.test.ts +148 -41
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +143 -2
- package/src/modules/workflow/agent-tools/workflow.tools.ts +60 -12
- package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +5 -4
- package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +12 -11
- package/src/modules/workflow/git/__tests__/git.service.commitChanges.test.ts +9 -8
- package/src/modules/workflow/git/__tests__/git.service.commitFile.strayPath.test.ts +8 -7
- package/src/modules/workflow/git/__tests__/git.service.commitFile.test.ts +6 -5
- package/src/modules/workflow/git/__tests__/git.service.createBranch.test.ts +3 -2
- package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +3 -2
- package/src/modules/workflow/git/__tests__/git.service.diffFileAtCommit.test.ts +7 -6
- package/src/modules/workflow/git/__tests__/git.service.diffFileBetweenBranches.test.ts +16 -15
- package/src/modules/workflow/git/__tests__/git.service.fileContentsAtCommit.test.ts +3 -2
- package/src/modules/workflow/git/__tests__/git.service.forkPoint.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.history-guards.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.list-branches.test.ts +10 -9
- package/src/modules/workflow/git/__tests__/git.service.listTrackedFiles.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.logForFile.test.ts +6 -5
- package/src/modules/workflow/git/__tests__/git.service.mergeChangeRequest.test.ts +9 -8
- package/src/modules/workflow/git/__tests__/git.service.pendingChanges.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.postMergePull.test.ts +4 -3
- package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +130 -8
- package/src/modules/workflow/git/__tests__/git.service.readFileAtRef.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.revertPathsAndPush.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.status.test.ts +4 -3
- package/src/modules/workflow/git/__tests__/git.service.syncFromRemote.test.ts +8 -7
- package/src/modules/workflow/git/__tests__/node-git-runner.test.ts +41 -3
- package/src/modules/workflow/git/__tests__/pull-request.service.getPrDetail.test.ts +145 -2
- package/src/modules/workflow/git/__tests__/pull-request.service.viewer-can-delete.test.ts +166 -0
- package/src/modules/workflow/git/git.service.ts +49 -17
- package/src/modules/workflow/git/node-git-runner.ts +43 -4
- package/src/modules/workflow/git/pull-request.service.ts +119 -0
- package/src/modules/workflow/review-workflow/review-workflow.service.ts +9 -6
- package/src/modules/workflow/session-ontology.service.ts +7 -2
- package/src/modules/workflow/workflow.routes.ts +3 -1
- package/src/modules/workflow/workflow.service.ts +201 -76
- package/src/modules/workspace/__tests__/file-stat-access.test.ts +3 -2
- package/src/modules/workspace/__tests__/git-internals.security.test.ts +10 -9
- package/src/modules/workspace/__tests__/session-ontology.gate.test.ts +4 -2
- package/src/modules/workspace/__tests__/workspace-paths-inside-the-repo.test.ts +3 -2
- package/src/modules/workspace/__tests__/workspace.routes.branch-errors.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.download-implies-read.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.file-writes.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.folders.test.ts +5 -4
- package/src/modules/workspace/__tests__/workspace.routes.move-platform-files.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.ensure-remotes-fetched.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.service.list-cloned.test.ts +6 -5
- package/src/modules/workspace/__tests__/workspace.service.move-never-overwrites.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.test.ts +84 -50
- package/src/modules/workspace/__tests__/workspace.service.unknown-branch.test.ts +45 -1
- package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +10 -7
- package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +237 -10
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +44 -11
- package/src/modules/workspace/__tests__/write-denial.test.ts +5 -4
- package/src/modules/workspace/session-ontology.gate.ts +6 -4
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.degraded.test.ts +6 -2
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +240 -21
- package/src/modules/workspace/startup/kb-git.ts +15 -22
- package/src/modules/workspace/startup/kb-startup-runner.ts +198 -45
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +104 -98
- package/src/modules/workspace/startup/steps/groups-to-plugins.step.ts +24 -16
- package/src/modules/workspace/startup/steps/personal-spaces.step.ts +14 -5
- package/src/modules/workspace/startup/steps/plugin-display-names.step.ts +13 -5
- package/src/modules/workspace/startup/steps/plugin-manifests.step.ts +14 -5
- package/src/modules/workspace/startup/steps/seed-tree.ts +11 -9
- package/src/modules/workspace/startup/steps/template-files.step.ts +43 -34
- package/src/modules/workspace/startup/steps/template-source.ts +8 -5
- package/src/modules/workspace/workspace.routes.ts +8 -7
- package/src/modules/workspace/workspace.service.ts +47 -28
- package/src/modules/workspace/workspace.tools.ts +56 -20
- package/src/modules/workspace/write-denial.ts +7 -5
- package/src/shared/__tests__/kb-layout.plugin.test.ts +19 -16
- package/src/shared/domain-errors.ts +58 -0
- package/src/shared/git.contract.ts +80 -8
- package/src/shared/kb-context.ts +130 -0
- package/src/shared/kb-layout.test.ts +37 -27
- package/src/shared/kb-layout.ts +4 -3
- package/src/shared/pending-proposals.ts +7 -4
- package/src/shared/redact-secret.ts +5 -5
- package/src/tenancy/__tests__/static-tenant-source.test.ts +177 -0
- package/src/tenancy/__tests__/tenant-host.test.ts +372 -0
- package/src/tenancy/__tests__/tenant-runtime.test.ts +221 -0
- package/src/tenancy/__tests__/tenant-secrets.test.ts +35 -0
- package/src/tenancy/index.ts +35 -0
- package/src/tenancy/static-tenant-source.ts +296 -0
- package/src/tenancy/tenant-host.ts +261 -0
- package/src/tenancy/tenant-runtime.ts +208 -0
- package/src/tenancy/tenant-secrets.ts +41 -0
- package/src/tenancy/tenant-source.contract.ts +59 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import {
|
|
3
|
+
joinBranchFor,
|
|
4
|
+
type AuthUser,
|
|
5
|
+
type IWorkflowService,
|
|
6
|
+
} from '@bevel-software/platform-shared';
|
|
7
|
+
import {
|
|
8
|
+
ChangeRequestConflictsError,
|
|
9
|
+
DuplicateChangeRequestError,
|
|
10
|
+
} from '../../shared/domain-errors.js';
|
|
11
|
+
import { isAbsence } from '../../shared/fs.contract.js';
|
|
12
|
+
import type { KbContext } from '../../shared/kb-context.js';
|
|
13
|
+
import { spliceGrant } from '../access-model/access-splice.js';
|
|
14
|
+
import type { WorkspaceService } from '../workspace/workspace.service.js';
|
|
15
|
+
import { logger } from '../../shared/logging.js';
|
|
16
|
+
import { AccessMutationError } from './access-mutation.service.js';
|
|
17
|
+
import {
|
|
18
|
+
rulesFileFor,
|
|
19
|
+
type AccessRequestTarget,
|
|
20
|
+
type IAccessRequestLifecycle,
|
|
21
|
+
type RequestLevel,
|
|
22
|
+
} from './access-requests.contract.js';
|
|
23
|
+
|
|
24
|
+
/** How the dialog spells each level — the same words the request is answered in. */
|
|
25
|
+
const log = logger('access.request');
|
|
26
|
+
|
|
27
|
+
export const LEVEL_LABEL: Record<RequestLevel, string> = {
|
|
28
|
+
write: 'Can edit',
|
|
29
|
+
owner: 'Owner',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** What the requester's own dialog shows in place of the control. */
|
|
33
|
+
export interface AccessRequestStatus {
|
|
34
|
+
/**
|
|
35
|
+
* - `none` nothing outstanding; show the control.
|
|
36
|
+
* - `pending` a request is open and still asking for something.
|
|
37
|
+
* - `not-accepted` their last request closed without the access landing.
|
|
38
|
+
*/
|
|
39
|
+
state: 'none' | 'pending' | 'not-accepted';
|
|
40
|
+
level?: RequestLevel;
|
|
41
|
+
number?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The name an item is called by in a title — the last path segment. */
|
|
45
|
+
export function itemNameOf(repoRelPath: string): string {
|
|
46
|
+
if (!repoRelPath) return 'the workspace';
|
|
47
|
+
return path.posix.basename(repoRelPath) || repoRelPath;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Neutralise every character a markdown renderer would read as structure.
|
|
52
|
+
*
|
|
53
|
+
* The note is somebody's free text and it lands in a change request's
|
|
54
|
+
* description, which IS rendered. Escaping it is what makes "plain text" true:
|
|
55
|
+
* without this a note can carry a heading, a link, or an image pointing at a
|
|
56
|
+
* URL that logs whoever opens the request.
|
|
57
|
+
*/
|
|
58
|
+
export function escapeMarkdown(text: string): string {
|
|
59
|
+
return text.replace(/[\\`*_{}[\]()#+\-.!|<>~]/g, (c) => `\\${c}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The exact inverse of {@link escapeMarkdown} — only our own backslashes go. */
|
|
63
|
+
function unescapeMarkdown(text: string): string {
|
|
64
|
+
return text.replace(/\\([\\`*_{}[\]()#+\-.!|<>~])/g, '$1');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The fence the note sits behind in a request's description.
|
|
69
|
+
*
|
|
70
|
+
* The description is the note's only home — there is no column for it — so the
|
|
71
|
+
* editors' banner has to read it back out of prose. Marking the block means
|
|
72
|
+
* that read is exact rather than a guess at which paragraph was the note, and
|
|
73
|
+
* an HTML comment is invisible in every surface that renders the description.
|
|
74
|
+
*/
|
|
75
|
+
const NOTE_OPEN = '<!--hexis:access-request-note-->';
|
|
76
|
+
const NOTE_CLOSE = '<!--/hexis:access-request-note-->';
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The level, recorded on the change request itself.
|
|
80
|
+
*
|
|
81
|
+
* The branch says what is proposed, but only while it can be read — and a
|
|
82
|
+
* clone whose refs are a few seconds stale cannot read a branch cut moments
|
|
83
|
+
* ago. The request's own row always can. "Requested: <level>" is a promise
|
|
84
|
+
* about a request, so it is answered from the request, not from a file at a
|
|
85
|
+
* ref that may not have arrived yet.
|
|
86
|
+
*/
|
|
87
|
+
const LEVEL_MARK = /<!--hexis:access-request-level:(write|owner)-->/;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The requester's own words, back out of a request's description, or
|
|
91
|
+
* undefined when they wrote none. Unescaped exactly as they were escaped, so
|
|
92
|
+
* what the banner shows is what was typed.
|
|
93
|
+
*/
|
|
94
|
+
/**
|
|
95
|
+
* The level a request asks for, off its own description. Undefined for a
|
|
96
|
+
* request opened before this marker existed — those are the skill route's,
|
|
97
|
+
* and the skill route only ever asked for `write`.
|
|
98
|
+
*/
|
|
99
|
+
export function extractRequestLevel(body: string | null | undefined): RequestLevel | undefined {
|
|
100
|
+
const hit = body ? LEVEL_MARK.exec(body) : null;
|
|
101
|
+
return hit ? (hit[1] as RequestLevel) : undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function extractRequestNote(body: string | null | undefined): string | undefined {
|
|
105
|
+
if (!body) return undefined;
|
|
106
|
+
const start = body.indexOf(NOTE_OPEN);
|
|
107
|
+
if (start < 0) return undefined;
|
|
108
|
+
const end = body.indexOf(NOTE_CLOSE, start);
|
|
109
|
+
if (end < 0) return undefined;
|
|
110
|
+
const note = body
|
|
111
|
+
.slice(start + NOTE_OPEN.length, end)
|
|
112
|
+
.split(/\r?\n/)
|
|
113
|
+
.filter((line) => line.startsWith('>'))
|
|
114
|
+
.map((line) => unescapeMarkdown(line.replace(/^>\s?/, '')))
|
|
115
|
+
.join('\n')
|
|
116
|
+
.trim();
|
|
117
|
+
return note || undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Asking for Can edit or Owner on ONE item, and reading back what came of it.
|
|
122
|
+
*
|
|
123
|
+
* A request is a change request whose branch proposes exactly one grant in the
|
|
124
|
+
* item's own rules — a folder's `access.md`, or a file's own frontmatter — and
|
|
125
|
+
* nothing else. There is no request table: the branch IS the request, named
|
|
126
|
+
* deterministically from (person, item), so a second click finds the first
|
|
127
|
+
* click's request instead of opening a rival. Editors answer it by granting
|
|
128
|
+
* through the ordinary access path, and it retires itself
|
|
129
|
+
* ({@link IAccessRequestLifecycle}) once the access has landed however it
|
|
130
|
+
* landed.
|
|
131
|
+
*
|
|
132
|
+
* Keyed on the ITEM'S PATH, which is what the skill page's "Request write
|
|
133
|
+
* access" keys on too — so a Can edit request on a skill's folder and that
|
|
134
|
+
* button open one request, shown on both surfaces.
|
|
135
|
+
*/
|
|
136
|
+
export class AccessRequestsService {
|
|
137
|
+
constructor(
|
|
138
|
+
private readonly deps: {
|
|
139
|
+
workflow: IWorkflowService;
|
|
140
|
+
workspaceService: WorkspaceService;
|
|
141
|
+
lifecycle: IAccessRequestLifecycle;
|
|
142
|
+
kb: Pick<KbContext, 'defaultBranch' | 'defaultWorkspaceId' | 'kbDirName'>;
|
|
143
|
+
},
|
|
144
|
+
) {}
|
|
145
|
+
|
|
146
|
+
/** The branch a request from `email` about `target` always lives on. */
|
|
147
|
+
branchFor(email: string, target: AccessRequestTarget): string {
|
|
148
|
+
return joinBranchFor(email, target.path);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Open `user`'s request for `level` on `target`, or answer with the one they
|
|
153
|
+
* already have open. Never opens a second request for the same pair.
|
|
154
|
+
*/
|
|
155
|
+
async open(input: {
|
|
156
|
+
user: AuthUser;
|
|
157
|
+
target: AccessRequestTarget;
|
|
158
|
+
itemName: string;
|
|
159
|
+
level: RequestLevel;
|
|
160
|
+
note?: string;
|
|
161
|
+
}): Promise<{ number: number; level: RequestLevel }> {
|
|
162
|
+
const { user, target, itemName, level } = input;
|
|
163
|
+
const note = (input.note ?? '').trim();
|
|
164
|
+
const { workflow, workspaceService, kb } = this.deps;
|
|
165
|
+
const wsId = kb.defaultWorkspaceId();
|
|
166
|
+
const branch = this.branchFor(user.email, target);
|
|
167
|
+
|
|
168
|
+
// FRESH, and matched on the BRANCH rather than on the author: a repeated
|
|
169
|
+
// click must find the request the previous one opened (the cached listing
|
|
170
|
+
// can trail it), and the same lookup has to prove the branch free before
|
|
171
|
+
// it is recut below. The branch name already carries the person, so
|
|
172
|
+
// matching it is matching them.
|
|
173
|
+
const openOnBranch = async () =>
|
|
174
|
+
(await workflow.listChangeRequests({ fresh: true })).find(
|
|
175
|
+
(cr) => cr.state === 'open' && cr.branch === branch,
|
|
176
|
+
);
|
|
177
|
+
const existing = await openOnBranch();
|
|
178
|
+
if (existing) return { number: existing.number, level: await this.levelOf(existing.number) };
|
|
179
|
+
|
|
180
|
+
// Existence is PROBED, before and — if creation fails — after: the race
|
|
181
|
+
// shows up as "already exists" locally or as a rejected push when origin
|
|
182
|
+
// got there first, and a message is not a contract. STRICT: the list
|
|
183
|
+
// proves absence, and a listing that could not fetch proves nothing.
|
|
184
|
+
const branchExists = async () =>
|
|
185
|
+
(await workflow.listBranches(wsId, { freshFetch: true, strictFetch: true })).some(
|
|
186
|
+
(b) => b.name === branch,
|
|
187
|
+
);
|
|
188
|
+
// A branch still standing here belonged to an ANSWERED request: it holds a
|
|
189
|
+
// dead proposal on a base that may be months old. It cannot simply be
|
|
190
|
+
// written to. `openChangeRequest` merges live INTO the source branch, and
|
|
191
|
+
// that merge conflicts the moment live has touched the same rules file —
|
|
192
|
+
// which an editor granting anyone anything on this item does. The person
|
|
193
|
+
// asking would be shown "resolve the conflicts on <an internal branch>",
|
|
194
|
+
// about a branch they cannot reach, for good.
|
|
195
|
+
//
|
|
196
|
+
// So the branch is CUT AGAIN from live. Live's tip is then the merge base,
|
|
197
|
+
// the auto-merge is a no-op, and the diff is exactly the one grant this
|
|
198
|
+
// request proposes. Deleting it also retires its clone, so the old content
|
|
199
|
+
// cannot come back (`deleteBranch`), and `deleteBranch` refuses a branch
|
|
200
|
+
// with an open request — the guard against recutting one under a request
|
|
201
|
+
// that opened in the meantime.
|
|
202
|
+
let present = await branchExists();
|
|
203
|
+
if (present) {
|
|
204
|
+
try {
|
|
205
|
+
await workflow.deleteBranch(wsId, branch, user);
|
|
206
|
+
// A delete that RETURNED is proof enough; re-probing here would let a
|
|
207
|
+
// ref list that has not caught up talk us out of cutting the branch we
|
|
208
|
+
// just removed, and the proposal would have nowhere to go.
|
|
209
|
+
present = false;
|
|
210
|
+
} catch (err) {
|
|
211
|
+
// It raced into an open request, or could not be removed. Answer with
|
|
212
|
+
// the request if there is one; otherwise carry on against the branch
|
|
213
|
+
// as it stands, which is what this did before and still works whenever
|
|
214
|
+
// the live rules have not moved.
|
|
215
|
+
const raced = await openOnBranch();
|
|
216
|
+
if (raced) return { number: raced.number, level: await this.levelOf(raced.number) };
|
|
217
|
+
log.warn(
|
|
218
|
+
`could not recut the request branch "${branch}": ${
|
|
219
|
+
err instanceof Error ? err.message : String(err)
|
|
220
|
+
}`,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (!present) {
|
|
225
|
+
try {
|
|
226
|
+
await workflow.createBranch(wsId, branch, kb.defaultBranch);
|
|
227
|
+
} catch (err) {
|
|
228
|
+
if (!(await branchExists())) throw err;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const rulesPath = rulesFileFor(target);
|
|
233
|
+
const wsRulesPath = `${kb.kbDirName}/${rulesPath}`;
|
|
234
|
+
// The proposal is spliced onto the LIVE copy, never onto whatever the
|
|
235
|
+
// branch holds. Belt and braces with the recut above: a branch that could
|
|
236
|
+
// not be recut still carries a declined proposal, and splicing onto it
|
|
237
|
+
// would ask for two levels at once. Starting from live means the request
|
|
238
|
+
// proposes exactly what was chosen this time.
|
|
239
|
+
const live = await this.readLive(target, wsRulesPath);
|
|
240
|
+
const spliced = spliceGrant(
|
|
241
|
+
live,
|
|
242
|
+
level,
|
|
243
|
+
{ kind: 'user', email: user.email, displayName: user.name },
|
|
244
|
+
{ allowScalar: target.kind === 'file', target: target.kind === 'folder' ? 'folder' : 'node' },
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
const ws = await workspaceService.getOrCreateForBranch(branch);
|
|
248
|
+
const onBranch = await workspaceService
|
|
249
|
+
.readFile(ws.id, wsRulesPath)
|
|
250
|
+
.catch((err: unknown) => {
|
|
251
|
+
if (!isAbsence(err)) throw err;
|
|
252
|
+
return null;
|
|
253
|
+
});
|
|
254
|
+
if (onBranch !== spliced.text) {
|
|
255
|
+
await workspaceService.writeFile(ws.id, wsRulesPath, spliced.text);
|
|
256
|
+
await workflow.commitChanges(
|
|
257
|
+
ws.id,
|
|
258
|
+
user,
|
|
259
|
+
`Request ${LEVEL_LABEL[level].toLowerCase()} access to ${itemName}`,
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
try {
|
|
264
|
+
const detail = await workflow.openChangeRequest(ws.id, user, {
|
|
265
|
+
sourceBranch: branch,
|
|
266
|
+
targetBranch: kb.defaultBranch,
|
|
267
|
+
title: `Access request: ${itemName}`,
|
|
268
|
+
description: this.describe({ user, target, level, note }),
|
|
269
|
+
});
|
|
270
|
+
return { number: detail.number, level };
|
|
271
|
+
} catch (err) {
|
|
272
|
+
// Two sends that raced past the listing above meet here, at the partial
|
|
273
|
+
// unique index on open (source, target). The loser answers with the
|
|
274
|
+
// winner's request rather than an error: the person asked once, and one
|
|
275
|
+
// request is what they get.
|
|
276
|
+
if (err instanceof DuplicateChangeRequestError) {
|
|
277
|
+
return { number: err.existingNumber, level: await this.levelOf(err.existingNumber) };
|
|
278
|
+
}
|
|
279
|
+
// The branch is recut from live above precisely so this cannot happen;
|
|
280
|
+
// reaching it means something raced. Whatever the cause, the person
|
|
281
|
+
// asking cannot act on "resolve the conflicts on
|
|
282
|
+
// reader2/join-artest3-04i7dr4" — they have never heard of that branch
|
|
283
|
+
// and could not reach it if they had. Say the one thing that IS theirs
|
|
284
|
+
// to do, and keep the detail where an operator will find it.
|
|
285
|
+
if (err instanceof ChangeRequestConflictsError) {
|
|
286
|
+
log.warn(
|
|
287
|
+
`request branch "${branch}" conflicted with live after being recut: ${err.message}`,
|
|
288
|
+
);
|
|
289
|
+
throw new AccessMutationError(
|
|
290
|
+
'The rules changed while your request was being sent. Try again.',
|
|
291
|
+
409,
|
|
292
|
+
{ kind: 'request-raced' },
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
throw err;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* What `user`'s dialog should say about `target`.
|
|
301
|
+
*
|
|
302
|
+
* The two states are answered from DIFFERENT sources, because different
|
|
303
|
+
* things prove them:
|
|
304
|
+
*
|
|
305
|
+
* pending an open request on this branch. That is the whole proof,
|
|
306
|
+
* and the level comes off the request itself — asking the
|
|
307
|
+
* branch would make "Requested: …" depend on whether this
|
|
308
|
+
* clone has fetched a ref that may be seconds old.
|
|
309
|
+
* not-accepted a closed request AND a branch that still carries an unmet
|
|
310
|
+
* proposal naming this person. A settled request has no
|
|
311
|
+
* branch left, so an accepted one can never read as
|
|
312
|
+
* declined; a branch that cannot be read proves nothing and
|
|
313
|
+
* reads as `none`, which shows the control rather than
|
|
314
|
+
* claiming a refusal nobody made.
|
|
315
|
+
*/
|
|
316
|
+
async status(user: AuthUser, target: AccessRequestTarget): Promise<AccessRequestStatus> {
|
|
317
|
+
const { workflow } = this.deps;
|
|
318
|
+
const branch = this.branchFor(user.email, target);
|
|
319
|
+
|
|
320
|
+
const open = (await workflow.listChangeRequests({ fresh: true })).find(
|
|
321
|
+
(cr) => cr.state === 'open' && cr.branch === branch,
|
|
322
|
+
);
|
|
323
|
+
if (open) {
|
|
324
|
+
return { state: 'pending', level: await this.levelOf(open.number), number: open.number };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const level = await this.levelAskedOn(branch, target, user.email);
|
|
328
|
+
if (!level) return { state: 'none' };
|
|
329
|
+
const last = await workflow.latestClosedChangeRequest(user.email, branch);
|
|
330
|
+
return last ? { state: 'not-accepted', level, number: last.number } : { state: 'none' };
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* The level change request `number` asks for, off its own description.
|
|
335
|
+
*
|
|
336
|
+
* `write` when the description does not say: every request that predates the
|
|
337
|
+
* marker came from the skill page's "Request write access", which asks for
|
|
338
|
+
* exactly that. A detail that cannot be fetched falls there too — the line
|
|
339
|
+
* it feeds says which level was asked for, and Can edit is the lesser claim.
|
|
340
|
+
*/
|
|
341
|
+
private async levelOf(number: number): Promise<RequestLevel> {
|
|
342
|
+
const detail = await this.deps.workflow
|
|
343
|
+
.getChangeRequestDetail(number, { patches: false })
|
|
344
|
+
.catch(() => null);
|
|
345
|
+
return extractRequestLevel(detail?.body) ?? 'write';
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* The level `email`'s branch still asks for on `target`, or null when it
|
|
350
|
+
* asks for nothing they do not already hold. Owner wins when a branch
|
|
351
|
+
* somehow carries both — it is the larger of the two, and it is the one the
|
|
352
|
+
* person is still waiting on.
|
|
353
|
+
*/
|
|
354
|
+
private async levelAskedOn(
|
|
355
|
+
branch: string,
|
|
356
|
+
target: AccessRequestTarget,
|
|
357
|
+
email: string,
|
|
358
|
+
): Promise<RequestLevel | null> {
|
|
359
|
+
const needle = email.trim().toLowerCase();
|
|
360
|
+
// null ⇒ the branch could not be read at all, which is not "asks for
|
|
361
|
+
// nothing". Saying nothing is outstanding shows the control, which is
|
|
362
|
+
// recoverable; claiming a refusal would not be.
|
|
363
|
+
const proposals = await this.deps.lifecycle.proposalsOn(branch, target);
|
|
364
|
+
if (proposals === null) return null;
|
|
365
|
+
const mine = proposals.filter(
|
|
366
|
+
(p) => p.principal.kind === 'user' && p.principal.email.trim().toLowerCase() === needle,
|
|
367
|
+
);
|
|
368
|
+
if (mine.some((p) => p.verb === 'owner')) return 'owner';
|
|
369
|
+
return mine.some((p) => p.verb === 'write') ? 'write' : null;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* The live rules text to splice onto. A folder with no `access.md` yet is
|
|
374
|
+
* normal and reads as empty; a FILE that is not there is not — a request
|
|
375
|
+
* must not conjure the file it asks about.
|
|
376
|
+
*/
|
|
377
|
+
private async readLive(target: AccessRequestTarget, wsRulesPath: string): Promise<string> {
|
|
378
|
+
const { workspaceService, kb } = this.deps;
|
|
379
|
+
await workspaceService.getOrCreateForBranch(kb.defaultBranch);
|
|
380
|
+
try {
|
|
381
|
+
return await workspaceService.readFile(kb.defaultWorkspaceId(), wsRulesPath);
|
|
382
|
+
} catch (err) {
|
|
383
|
+
if (target.kind === 'folder' && isAbsence(err)) return '';
|
|
384
|
+
if (isAbsence(err)) {
|
|
385
|
+
throw new AccessMutationError(`"${target.path}" is not there any more.`, 404, {
|
|
386
|
+
kind: 'unknown-target',
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
throw err;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** The description an editor reads: who, what, where, the note, and how to answer. */
|
|
394
|
+
private describe(input: {
|
|
395
|
+
user: AuthUser;
|
|
396
|
+
target: AccessRequestTarget;
|
|
397
|
+
level: RequestLevel;
|
|
398
|
+
note: string;
|
|
399
|
+
}): string {
|
|
400
|
+
const { user, target, level, note } = input;
|
|
401
|
+
const who = escapeMarkdown(user.name || user.email);
|
|
402
|
+
const lines = [
|
|
403
|
+
`<!--hexis:access-request-level:${level}-->`,
|
|
404
|
+
`${who} (${escapeMarkdown(user.email)}) asked for **${LEVEL_LABEL[level]}** on ` +
|
|
405
|
+
`${escapeMarkdown(target.path || 'the workspace')}.`,
|
|
406
|
+
];
|
|
407
|
+
if (note) {
|
|
408
|
+
lines.push('', `Note from ${who}:`, '', NOTE_OPEN);
|
|
409
|
+
for (const line of note.split(/\r?\n/)) lines.push(`> ${escapeMarkdown(line)}`);
|
|
410
|
+
lines.push(NOTE_CLOSE);
|
|
411
|
+
}
|
|
412
|
+
lines.push(
|
|
413
|
+
'',
|
|
414
|
+
`Anyone who can edit this ${target.kind}'s access answers it: Accept in the ` +
|
|
415
|
+
`${target.kind}'s Manage access dialog, or approve and merge this request. It closes ` +
|
|
416
|
+
`itself once ${who} holds that access, however it was given.`,
|
|
417
|
+
);
|
|
418
|
+
return lines.join('\n');
|
|
419
|
+
}
|
|
420
|
+
}
|
|
@@ -9,8 +9,6 @@ const grantLog = logger('access.grant');
|
|
|
9
9
|
const revokeLog = logger('access.revoke');
|
|
10
10
|
import type { AuthUser } from '@bevel-software/platform-shared';
|
|
11
11
|
import {
|
|
12
|
-
isProtectedBranch,
|
|
13
|
-
DEFAULT_BRANCH,
|
|
14
12
|
pluginManifestName,
|
|
15
13
|
FOLDER_GOVERNS_ACCESS_KIND,
|
|
16
14
|
} from '@bevel-software/platform-shared';
|
|
@@ -20,7 +18,8 @@ import type {
|
|
|
20
18
|
GrantSources,
|
|
21
19
|
} from './access-control.interface.js';
|
|
22
20
|
import type { WorkspaceService } from '../workspace/workspace.service.js';
|
|
23
|
-
import {
|
|
21
|
+
import type { KbContext } from '../../shared/kb-context.js';
|
|
22
|
+
import { branchForWorkspaceId } from '../../shared/workspace-id.js';
|
|
24
23
|
import type { AuthService } from '../auth/auth.service.js';
|
|
25
24
|
import type { WorkflowService } from '../workflow/workflow.service.js';
|
|
26
25
|
import type { WorkflowEventBus } from '../workflow/event-bus.js';
|
|
@@ -89,18 +88,19 @@ export function createAccessRoutes(
|
|
|
89
88
|
workflowService: WorkflowService,
|
|
90
89
|
eventBus: WorkflowEventBus,
|
|
91
90
|
db: Database,
|
|
92
|
-
|
|
91
|
+
kb: KbContext,
|
|
93
92
|
/** This deployment's configured admins — the break-glass recovery roster. */
|
|
94
93
|
recoveryAdmins: readonly string[] = [],
|
|
95
94
|
): express.Router {
|
|
96
95
|
const router = express.Router({ mergeParams: true });
|
|
96
|
+
const { kbDirName } = kb;
|
|
97
97
|
const mutation = new AccessMutationService(workspaceService, accessControl, kbDirName);
|
|
98
98
|
const rolesAdmin = new RolesAdminService(
|
|
99
99
|
workspaceService,
|
|
100
100
|
workflowService,
|
|
101
101
|
accessControl,
|
|
102
102
|
kbDirName,
|
|
103
|
-
() =>
|
|
103
|
+
() => kb.defaultBranch,
|
|
104
104
|
eventBus,
|
|
105
105
|
recoveryAdmins,
|
|
106
106
|
);
|
|
@@ -118,10 +118,8 @@ export function createAccessRoutes(
|
|
|
118
118
|
groups: string[];
|
|
119
119
|
plugins: { name: string; folder: string }[];
|
|
120
120
|
}> => {
|
|
121
|
-
await workspaceService.getOrCreateForBranch(
|
|
122
|
-
const { roles, groups, plugins } = await accessControl.kbPrincipals(
|
|
123
|
-
workspaceIdForBranch(DEFAULT_BRANCH),
|
|
124
|
-
);
|
|
121
|
+
await workspaceService.getOrCreateForBranch(kb.defaultBranch);
|
|
122
|
+
const { roles, groups, plugins } = await accessControl.kbPrincipals(kb.defaultWorkspaceId());
|
|
125
123
|
// `plugins` is defensive: an older resolver double may omit it.
|
|
126
124
|
return { roles, groups, plugins: plugins ?? [] };
|
|
127
125
|
};
|
|
@@ -139,7 +137,7 @@ export function createAccessRoutes(
|
|
|
139
137
|
): Promise<{ name: string; folder: string }[]> => {
|
|
140
138
|
if (plugins.length === 0) return [];
|
|
141
139
|
const verdicts = await accessControl.canReadBatch(
|
|
142
|
-
|
|
140
|
+
kb.defaultWorkspaceId(),
|
|
143
141
|
email,
|
|
144
142
|
plugins.map((p) => `${p.folder}/access.md`),
|
|
145
143
|
);
|
|
@@ -711,7 +709,6 @@ export function createAccessRoutes(
|
|
|
711
709
|
// resolves to false and is rejected above. Nothing extra needed here — but
|
|
712
710
|
// keep the branch check explicit so the intent is legible.
|
|
713
711
|
void branch;
|
|
714
|
-
void isProtectedBranch;
|
|
715
712
|
}
|
|
716
713
|
|
|
717
714
|
/**
|
|
@@ -1211,8 +1208,8 @@ export function createAccessRoutes(
|
|
|
1211
1208
|
|
|
1212
1209
|
/** Fail-fast admin gate for the roles routes. Throws AccessDeniedError. */
|
|
1213
1210
|
async function assertRolesAdmin(userEmail: string): Promise<void> {
|
|
1214
|
-
await workspaceService.getOrCreateForBranch(
|
|
1215
|
-
await assertCanMutate(
|
|
1211
|
+
await workspaceService.getOrCreateForBranch(kb.defaultBranch);
|
|
1212
|
+
await assertCanMutate(kb.defaultWorkspaceId(), kb.defaultBranch, userEmail, 'roles.yaml');
|
|
1216
1213
|
}
|
|
1217
1214
|
|
|
1218
1215
|
router.get('/access/roles', async (req, res) => {
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import path from 'node:path';
|
|
18
|
-
import { creatableRootDirNames } from '@bevel-software/platform-shared';
|
|
18
|
+
import { creatableRootDirNames, type KbLayout } from '@bevel-software/platform-shared';
|
|
19
19
|
import type { IFsProbe } from '../../shared/fs.contract.js';
|
|
20
|
+
import type { KbContext } from '../../shared/kb-context.js';
|
|
20
21
|
import type { WorkspaceService } from '../workspace/workspace.service.js';
|
|
21
22
|
import type { IAccessControl } from './access-control.interface.js';
|
|
22
23
|
import { AccessConfigError, AccessDeniedError } from '../access-model/access-errors.js';
|
|
@@ -39,10 +40,11 @@ export async function isNewTopLevelFolderPath(
|
|
|
39
40
|
kbRel: string,
|
|
40
41
|
kind: ChangeTargetKind,
|
|
41
42
|
exists: (kbRel: string) => Promise<boolean>,
|
|
43
|
+
layout: KbLayout,
|
|
42
44
|
): Promise<boolean> {
|
|
43
45
|
const segments = kbRel.split('/');
|
|
44
46
|
const root = segments[0];
|
|
45
|
-
if (root === undefined || !creatableRootDirNames().has(root)) return false;
|
|
47
|
+
if (root === undefined || !creatableRootDirNames(layout).has(root)) return false;
|
|
46
48
|
if (segments.length < (kind === 'dir' ? 2 : 3)) return false;
|
|
47
49
|
return !(await exists(`${root}/${segments[1]}`));
|
|
48
50
|
}
|
|
@@ -51,10 +53,14 @@ export class ChangeReadGate implements IChangeReadGate {
|
|
|
51
53
|
constructor(
|
|
52
54
|
private readonly workspaceService: Pick<WorkspaceService, 'getWorkspacePath'>,
|
|
53
55
|
private readonly accessControl: Pick<IAccessControl, 'canRead' | 'holdsAdminRootWrite'>,
|
|
54
|
-
private readonly
|
|
56
|
+
private readonly kb: KbContext,
|
|
55
57
|
private readonly disk: IFsProbe,
|
|
56
58
|
) {}
|
|
57
59
|
|
|
60
|
+
private get kbDirName(): string {
|
|
61
|
+
return this.kb.kbDirName;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
async judge(
|
|
59
65
|
workspaceId: string,
|
|
60
66
|
userEmail: string,
|
|
@@ -88,7 +94,7 @@ export class ChangeReadGate implements IChangeReadGate {
|
|
|
88
94
|
return { allowed: true, via: 'admin-rescue' };
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
|
-
if (await isNewTopLevelFolderPath(rel, kind, exists)) {
|
|
97
|
+
if (await isNewTopLevelFolderPath(rel, kind, exists, this.kb.layout)) {
|
|
92
98
|
return { allowed: true, via: 'new-top-level-folder' };
|
|
93
99
|
}
|
|
94
100
|
if (await this.accessControl.canRead(workspaceId, userEmail, rel)) {
|
|
@@ -33,6 +33,7 @@ import { printable } from '../../shared/printable.js';
|
|
|
33
33
|
const log = logger('creator-access');
|
|
34
34
|
|
|
35
35
|
import type { IFsProbe } from '../../shared/fs.contract.js';
|
|
36
|
+
import type { KbContext } from '../../shared/kb-context.js';
|
|
36
37
|
import type { WorkspaceService } from '../workspace/workspace.service.js';
|
|
37
38
|
import type { IAccessControl } from './access-control.interface.js';
|
|
38
39
|
import { spliceGrant, type Principal } from '../access-model/access-splice.js';
|
|
@@ -49,10 +50,14 @@ export class CreatorAccessService implements ICreatorAccess {
|
|
|
49
50
|
constructor(
|
|
50
51
|
private readonly workspaceService: WorkspaceService,
|
|
51
52
|
private readonly accessControl: IAccessControl,
|
|
52
|
-
private readonly
|
|
53
|
+
private readonly kb: KbContext,
|
|
53
54
|
private readonly disk: IFsProbe,
|
|
54
55
|
) {}
|
|
55
56
|
|
|
57
|
+
private get kbDirName(): string {
|
|
58
|
+
return this.kb.kbDirName;
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
/**
|
|
57
62
|
* Whether something is at `abs`. Links are NOT followed: a link, dangling
|
|
58
63
|
* or not, is something there — never a "new" folder to seed a grant under,
|
|
@@ -106,7 +111,7 @@ export class CreatorAccessService implements ICreatorAccess {
|
|
|
106
111
|
const segments = rel.split('/');
|
|
107
112
|
if (kind === 'file') segments.pop();
|
|
108
113
|
const root = segments[0];
|
|
109
|
-
if (root === undefined || segments.length < 2 || !creatableRootDirNames().has(root)) return null;
|
|
114
|
+
if (root === undefined || segments.length < 2 || !creatableRootDirNames(this.kb.layout).has(root)) return null;
|
|
110
115
|
const top = `${root}/${segments[1]}`;
|
|
111
116
|
try {
|
|
112
117
|
if (await this.exists(path.join(repoDir, top))) return null;
|
|
@@ -1042,3 +1042,25 @@ export function parseOwnAccessEntries(text: string): OwnEntries | null {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
return sawVerb ? entries : null;
|
|
1044
1044
|
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Whether a node file's frontmatter could be READ at all, which
|
|
1048
|
+
* {@link parseOwnAccessEntries} does not say: its null covers a file with no
|
|
1049
|
+
* frontmatter, one that names no access verb, and one whose frontmatter is
|
|
1050
|
+
* broken, and only the last of those is a failure to read.
|
|
1051
|
+
*
|
|
1052
|
+
* Readable: no frontmatter block at all (the file grants nothing), or a
|
|
1053
|
+
* block that parses to a mapping. Not readable: a block that is never
|
|
1054
|
+
* closed, or one that does not parse to a mapping. For a caller that must
|
|
1055
|
+
* not take "could not tell" for "grants nothing".
|
|
1056
|
+
*/
|
|
1057
|
+
export function ownAccessReadable(text: string): boolean {
|
|
1058
|
+
const scan = scanFrontmatter(text);
|
|
1059
|
+
if (scan.kind === 'none') return true;
|
|
1060
|
+
if (scan.kind === 'unterminated') return false;
|
|
1061
|
+
const block = scan.fm.join('\n');
|
|
1062
|
+
// An empty block says nothing, and says it readably.
|
|
1063
|
+
if (!block.trim()) return true;
|
|
1064
|
+
const root = ownEntriesRoot(block);
|
|
1065
|
+
return root != null && typeof root === 'object' && !Array.isArray(root);
|
|
1066
|
+
}
|