@carlonicora/nestjs-neo4jsonapi 2.14.4 → 2.14.5

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.
Files changed (74) hide show
  1. package/dist/agents/community.detector/services/community.detector.service.d.ts +22 -1
  2. package/dist/agents/community.detector/services/community.detector.service.d.ts.map +1 -1
  3. package/dist/agents/community.detector/services/community.detector.service.js +132 -24
  4. package/dist/agents/community.detector/services/community.detector.service.js.map +1 -1
  5. package/dist/agents/contextualiser/nodes/chunk.node.service.d.ts.map +1 -1
  6. package/dist/agents/contextualiser/nodes/chunk.node.service.js +1 -0
  7. package/dist/agents/contextualiser/nodes/chunk.node.service.js.map +1 -1
  8. package/dist/agents/graph/graph.module.d.ts +8 -0
  9. package/dist/agents/graph/graph.module.d.ts.map +1 -1
  10. package/dist/agents/graph/graph.module.js +15 -0
  11. package/dist/agents/graph/graph.module.js.map +1 -1
  12. package/dist/agents/graph/services/graph.catalog.service.d.ts +10 -0
  13. package/dist/agents/graph/services/graph.catalog.service.d.ts.map +1 -1
  14. package/dist/agents/graph/services/graph.catalog.service.js +12 -0
  15. package/dist/agents/graph/services/graph.catalog.service.js.map +1 -1
  16. package/dist/agents/graph/services/scope.guard.d.ts.map +1 -1
  17. package/dist/agents/graph/services/scope.guard.js +2 -7
  18. package/dist/agents/graph/services/scope.guard.js.map +1 -1
  19. package/dist/agents/graph/services/scope.pattern.d.ts +23 -0
  20. package/dist/agents/graph/services/scope.pattern.d.ts.map +1 -0
  21. package/dist/agents/graph/services/scope.pattern.js +26 -0
  22. package/dist/agents/graph/services/scope.pattern.js.map +1 -0
  23. package/dist/agents/graph/services/scope.predicate.service.d.ts +32 -0
  24. package/dist/agents/graph/services/scope.predicate.service.d.ts.map +1 -0
  25. package/dist/agents/graph/services/scope.predicate.service.js +71 -0
  26. package/dist/agents/graph/services/scope.predicate.service.js.map +1 -0
  27. package/dist/agents/index.d.ts +3 -0
  28. package/dist/agents/index.d.ts.map +1 -1
  29. package/dist/agents/index.js +8 -1
  30. package/dist/agents/index.js.map +1 -1
  31. package/dist/common/repositories/agent-scope.filter.d.ts +64 -0
  32. package/dist/common/repositories/agent-scope.filter.d.ts.map +1 -0
  33. package/dist/common/repositories/agent-scope.filter.js +96 -0
  34. package/dist/common/repositories/agent-scope.filter.js.map +1 -0
  35. package/dist/common/repositories/index.d.ts +2 -0
  36. package/dist/common/repositories/index.d.ts.map +1 -1
  37. package/dist/common/repositories/index.js +2 -0
  38. package/dist/common/repositories/index.js.map +1 -1
  39. package/dist/common/repositories/scope-predicate.source.d.ts +32 -0
  40. package/dist/common/repositories/scope-predicate.source.d.ts.map +1 -0
  41. package/dist/common/repositories/scope-predicate.source.js +5 -0
  42. package/dist/common/repositories/scope-predicate.source.js.map +1 -0
  43. package/dist/common/types/agent.scope.d.ts +32 -0
  44. package/dist/common/types/agent.scope.d.ts.map +1 -0
  45. package/dist/common/types/agent.scope.js +12 -0
  46. package/dist/common/types/agent.scope.js.map +1 -0
  47. package/dist/common/types/index.d.ts +1 -0
  48. package/dist/common/types/index.d.ts.map +1 -1
  49. package/dist/common/types/index.js +1 -0
  50. package/dist/common/types/index.js.map +1 -1
  51. package/dist/core/core.module.d.ts.map +1 -1
  52. package/dist/core/core.module.js +5 -1
  53. package/dist/core/core.module.js.map +1 -1
  54. package/dist/foundations/assistant/services/assistant.service.d.ts +11 -0
  55. package/dist/foundations/assistant/services/assistant.service.d.ts.map +1 -1
  56. package/dist/foundations/assistant/services/assistant.service.js +18 -1
  57. package/dist/foundations/assistant/services/assistant.service.js.map +1 -1
  58. package/dist/foundations/atomicfact/repositories/atomicfact.repository.d.ts +3 -1
  59. package/dist/foundations/atomicfact/repositories/atomicfact.repository.d.ts.map +1 -1
  60. package/dist/foundations/atomicfact/repositories/atomicfact.repository.js +11 -2
  61. package/dist/foundations/atomicfact/repositories/atomicfact.repository.js.map +1 -1
  62. package/dist/foundations/chunk/repositories/chunk.repository.d.ts +11 -1
  63. package/dist/foundations/chunk/repositories/chunk.repository.d.ts.map +1 -1
  64. package/dist/foundations/chunk/repositories/chunk.repository.js +19 -3
  65. package/dist/foundations/chunk/repositories/chunk.repository.js.map +1 -1
  66. package/dist/foundations/community/repositories/community.repository.d.ts +33 -2
  67. package/dist/foundations/community/repositories/community.repository.d.ts.map +1 -1
  68. package/dist/foundations/community/repositories/community.repository.js +41 -4
  69. package/dist/foundations/community/repositories/community.repository.js.map +1 -1
  70. package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts +3 -1
  71. package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts.map +1 -1
  72. package/dist/foundations/keyconcept/repositories/keyconcept.repository.js +24 -2
  73. package/dist/foundations/keyconcept/repositories/keyconcept.repository.js.map +1 -1
  74. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"scope.guard.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/services/scope.guard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;;;;;;;GASG;AACH,qBACa,UAAU;IAInB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;gBAGnC,OAAO,EAAE,mBAAmB,EAC5B,KAAK,EAAE,YAAY;IAGtC,gBAAgB,CAAC,MAAM,EAAE;QACvB,MAAM,EAAE,aAAa,CAAC;QACtB,GAAG,EAAE,WAAW,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,C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AE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAKnF,MAAM,CAAC,CAAC,SAAS;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAiC9G,mEAAmE;IACnE,OAAO,CAAC,YAAY;CAGrB"}
@@ -14,6 +14,7 @@ exports.ScopeGuard = void 0;
14
14
  const common_1 = require("@nestjs/common");
15
15
  const neo4j_service_1 = require("../../../core/neo4j/services/neo4j.service");
16
16
  const graph_catalog_service_1 = require("./graph.catalog.service");
17
+ const scope_pattern_1 = require("./scope.pattern");
17
18
  /**
18
19
  * Single place a scope predicate is built or applied. Every agent data-access
19
20
  * point routes through here so "which campaign is this run confined to" has
@@ -73,13 +74,7 @@ let ScopeGuard = ScopeGuard_1 = class ScopeGuard {
73
74
  }
74
75
  /** `(alias)-[:REL]->(:Label)…-[:REL]->(:Root { id: $scopeId })` */
75
76
  buildPattern(scope, alias) {
76
- let pattern = `(${alias})`;
77
- scope.path.forEach((hop, index) => {
78
- const isLast = index === scope.path.length - 1;
79
- const node = isLast ? `(:${hop.targetLabel} { id: $scopeId })` : `(:${hop.targetLabel})`;
80
- pattern += hop.cypherDirection === "out" ? `-[:${hop.cypherLabel}]->${node}` : `<-[:${hop.cypherLabel}]-${node}`;
81
- });
82
- return pattern;
77
+ return (0, scope_pattern_1.buildScopePattern)({ scope, alias, paramName: "scopeId" });
83
78
  }
84
79
  };
85
80
  exports.ScopeGuard = ScopeGuard;
@@ -1 +1 @@
1
- {"version":3,"file":"scope.guard.js","sourceRoot":"","sources":["../../../../src/agents/graph/services/scope.guard.ts"],"names":[],"mappings":";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AE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAChF,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,CAAE,MAAc,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClG,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,mEAAmE;IAC3D,YAAY,CAAC,KAA0C,EAAE,KAAa;QAC5E,OAAO,IAAA,iCAAiB,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AAlEY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAKiB,2CAAmB;QACrB,4BAAY;GAL3B,UAAU,CAkEtB"}
@@ -0,0 +1,23 @@
1
+ import { CatalogScope } from "../interfaces/graph.catalog.interface";
2
+ /**
3
+ * `(alias)-[:REL]->(:Label)…-[:REL]->(:Root { id: $<paramName> })`
4
+ *
5
+ * The single place a scope chain becomes Cypher. Both consumers — `ScopeGuard`
6
+ * (post-filtering records an agent already read) and `ScopePredicateService`
7
+ * (pre-filtering retrieval before it reads anything) — build their patterns
8
+ * here, so "is this node inside the run's scope root" cannot drift between
9
+ * the two.
10
+ */
11
+ export declare const buildScopePattern: (params: {
12
+ scope: CatalogScope;
13
+ alias: string;
14
+ /** Pins the root to a known id: `(:Root { id: $<paramName> })`. */
15
+ paramName?: string;
16
+ /**
17
+ * Binds the root to a variable instead of pinning it: `(<rootAlias>:Root)`.
18
+ * For the inverse question — "which root is this node under?" — where the id
19
+ * is the answer rather than the input. Ignored when `paramName` is given.
20
+ */
21
+ rootAlias?: string;
22
+ }) => string;
23
+ //# sourceMappingURL=scope.pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.pattern.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/services/scope.pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ;IACxC,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,KAAG,MAWH,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildScopePattern = void 0;
4
+ /**
5
+ * `(alias)-[:REL]->(:Label)…-[:REL]->(:Root { id: $<paramName> })`
6
+ *
7
+ * The single place a scope chain becomes Cypher. Both consumers — `ScopeGuard`
8
+ * (post-filtering records an agent already read) and `ScopePredicateService`
9
+ * (pre-filtering retrieval before it reads anything) — build their patterns
10
+ * here, so "is this node inside the run's scope root" cannot drift between
11
+ * the two.
12
+ */
13
+ const buildScopePattern = (params) => {
14
+ let pattern = `(${params.alias})`;
15
+ params.scope.path.forEach((hop, index) => {
16
+ const isLast = index === params.scope.path.length - 1;
17
+ const root = params.paramName
18
+ ? `(:${hop.targetLabel} { id: $${params.paramName} })`
19
+ : `(${params.rootAlias ?? "scopeRoot"}:${hop.targetLabel})`;
20
+ const node = isLast ? root : `(:${hop.targetLabel})`;
21
+ pattern += hop.cypherDirection === "out" ? `-[:${hop.cypherLabel}]->${node}` : `<-[:${hop.cypherLabel}]-${node}`;
22
+ });
23
+ return pattern;
24
+ };
25
+ exports.buildScopePattern = buildScopePattern;
26
+ //# sourceMappingURL=scope.pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.pattern.js","sourceRoot":"","sources":["../../../../src/agents/graph/services/scope.pattern.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;GAQG;AACI,MAAM,iBAAiB,GAAG,CAAC,MAWjC,EAAU,EAAE;IACX,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC;IAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS;YAC3B,CAAC,CAAC,KAAK,GAAG,CAAC,WAAW,WAAW,MAAM,CAAC,SAAS,KAAK;YACtD,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,IAAI,WAAW,IAAI,GAAG,CAAC,WAAW,GAAG,CAAC;QAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,WAAW,GAAG,CAAC;QACrD,OAAO,IAAI,GAAG,CAAC,eAAe,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,WAAW,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;IACnH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAtBW,QAAA,iBAAiB,qBAsB5B"}
@@ -0,0 +1,32 @@
1
+ import { ScopePredicateResult, ScopePredicateSource } from "../../../common/repositories/scope-predicate.source";
2
+ import { AgentScope } from "../../../common/types/agent.scope";
3
+ import { GraphCatalogService } from "./graph.catalog.service";
4
+ /**
5
+ * Turns the catalog's compiled scope chains into ONE boolean expression that
6
+ * confines a node alias to the run's scope root.
7
+ *
8
+ * The expression is a union over labels, because the alias it guards is
9
+ * untyped — retrieval binds `(data)` to any entity that owns chunks:
10
+ *
11
+ * (
12
+ * (data:Root AND data.id = $agentScopeId)
13
+ * OR (data:Child AND EXISTS { MATCH (data)-[:PART_OF]->(:Root { id: $agentScopeId }) })
14
+ * …
15
+ * )
16
+ *
17
+ * FAIL-CLOSED, twice over:
18
+ * - a type with no chain to THIS root contributes no branch, so it can never
19
+ * match — the same ruling `ScopeGuard` already applies when it post-filters;
20
+ * - if no type at all can reach the root, `build` returns null and the caller
21
+ * must retrieve nothing rather than fall back to company-wide retrieval.
22
+ */
23
+ export declare class ScopePredicateService implements ScopePredicateSource {
24
+ private readonly catalog;
25
+ private readonly logger;
26
+ constructor(catalog: GraphCatalogService);
27
+ build(params: {
28
+ alias: string;
29
+ scope: AgentScope;
30
+ }): ScopePredicateResult | null;
31
+ }
32
+ //# sourceMappingURL=scope.predicate.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.predicate.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/graph/services/scope.predicate.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AACjH,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBACa,qBAAsB,YAAW,oBAAoB;IAGpD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;gBAEpC,OAAO,EAAE,mBAAmB;IAEzD,KAAK,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,GAAG,oBAAoB,GAAG,IAAI;CA8BjF"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var ScopePredicateService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ScopePredicateService = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const graph_catalog_service_1 = require("./graph.catalog.service");
16
+ const scope_pattern_1 = require("./scope.pattern");
17
+ /**
18
+ * Turns the catalog's compiled scope chains into ONE boolean expression that
19
+ * confines a node alias to the run's scope root.
20
+ *
21
+ * The expression is a union over labels, because the alias it guards is
22
+ * untyped — retrieval binds `(data)` to any entity that owns chunks:
23
+ *
24
+ * (
25
+ * (data:Root AND data.id = $agentScopeId)
26
+ * OR (data:Child AND EXISTS { MATCH (data)-[:PART_OF]->(:Root { id: $agentScopeId }) })
27
+ * …
28
+ * )
29
+ *
30
+ * FAIL-CLOSED, twice over:
31
+ * - a type with no chain to THIS root contributes no branch, so it can never
32
+ * match — the same ruling `ScopeGuard` already applies when it post-filters;
33
+ * - if no type at all can reach the root, `build` returns null and the caller
34
+ * must retrieve nothing rather than fall back to company-wide retrieval.
35
+ */
36
+ let ScopePredicateService = ScopePredicateService_1 = class ScopePredicateService {
37
+ constructor(catalog) {
38
+ this.catalog = catalog;
39
+ this.logger = new common_1.Logger(ScopePredicateService_1.name);
40
+ }
41
+ build(params) {
42
+ const branches = [];
43
+ for (const entity of this.catalog.getAllEntities()) {
44
+ const scope = entity.scope;
45
+ if (!scope || scope.rootType !== params.scope.type)
46
+ continue;
47
+ if (scope.path.length === 0) {
48
+ // The entity IS the root: in scope iff it is that exact node.
49
+ branches.push(`(${params.alias}:${entity.labelName} AND ${params.alias}.id = $agentScopeId)`);
50
+ continue;
51
+ }
52
+ const pattern = (0, scope_pattern_1.buildScopePattern)({ scope, alias: params.alias, paramName: "agentScopeId" });
53
+ branches.push(`(${params.alias}:${entity.labelName} AND EXISTS { MATCH ${pattern} })`);
54
+ }
55
+ if (branches.length === 0) {
56
+ this.logger.warn(`build: no catalogued entity has a scope chain to root type "${params.scope.type}" — ` +
57
+ `retrieval in this run is confined to nothing.`);
58
+ return null;
59
+ }
60
+ return {
61
+ cypher: `(\n ${branches.join("\n OR ")}\n )`,
62
+ params: { agentScopeId: params.scope.id },
63
+ };
64
+ }
65
+ };
66
+ exports.ScopePredicateService = ScopePredicateService;
67
+ exports.ScopePredicateService = ScopePredicateService = ScopePredicateService_1 = __decorate([
68
+ (0, common_1.Injectable)(),
69
+ __metadata("design:paramtypes", [graph_catalog_service_1.GraphCatalogService])
70
+ ], ScopePredicateService);
71
+ //# sourceMappingURL=scope.predicate.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.predicate.service.js","sourceRoot":"","sources":["../../../../src/agents/graph/services/scope.predicate.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AAGpD,mEAA8D;AAC9D,mDAAoD;AAEpD;;;;;;;;;;;;;;;;;;GAkBG;AAEI,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAGhC,YAA6B,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAFxC,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAEL,CAAC;IAE7D,KAAK,CAAC,MAA4C;QAChD,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;YACnD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YAC3B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI;gBAAE,SAAS;YAE7D,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5B,8DAA8D;gBAC9D,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,QAAQ,MAAM,CAAC,KAAK,sBAAsB,CAAC,CAAC;gBAC9F,SAAS;YACX,CAAC;YAED,MAAM,OAAO,GAAG,IAAA,iCAAiB,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;YAC7F,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,uBAAuB,OAAO,KAAK,CAAC,CAAC;QACzF,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,+DAA+D,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM;gBACpF,+CAA+C,CAClD,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO;YACL,MAAM,EAAE,cAAc,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW;YAC/D,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;SAC1C,CAAC;IACJ,CAAC;CACF,CAAA;AAnCY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAI2B,2CAAmB;GAH9C,qBAAqB,CAmCjC"}
@@ -30,6 +30,9 @@ export { GraphSearchService } from "./graph/services/graph.search.service";
30
30
  export type { MatchMode, RunSearchParams } from "./graph/services/graph.search.service";
31
31
  export { GRAPH_EXACT_MAX_RESULTS, GRAPH_FUZZY_MAX_RESULTS, GRAPH_SEMANTIC_MAX_RESULTS, GRAPH_SEMANTIC_MIN_SCORE, } from "./graph/services/graph.search.service";
32
32
  export { GraphDescriptorRegistry } from "./graph/services/descriptor.source";
33
+ export { ScopeGuard } from "./graph/services/scope.guard";
34
+ export { ScopePredicateService } from "./graph/services/scope.predicate.service";
35
+ export { buildScopePattern } from "./graph/services/scope.pattern";
33
36
  export { UserModulesRepository } from "./graph/repositories/user-modules.repository";
34
37
  export { ResolveEntityTool } from "./graph/tools/resolve-entity.tool";
35
38
  export { DescribeEntityTool } from "./graph/tools/describe-entity.tool";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,cAAc,WAAW,CAAC;AAK1B,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AAGpG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oDAAoD,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,8DAA8D,CAAC;AAG1G,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAC3G,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AACzF,OAAO,EAAE,mCAAm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,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AACxH,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EACL,2BAA2B,EAC3B,kCAAkC,GACnC,MAAM,mDAAmD,CAAC;AAG3D,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAC/E,YAAY,EACV,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC"}
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.OperatorToolRegistry = exports.OperatorTestActionTool = exports.SearchCommunitiesTool = exports.SearchDocumentsTool = exports.OPERATOR_TOOLS = exports.OPERATOR_DEFAULT_APPROVAL_TTL_DAYS = exports.OperatorCheckpointerService = exports.defaultOperatorSystemPrompt = exports.OperatorContext = exports.OperatorService = exports.OperatorController = exports.operatorMeta = exports.OperatorModule = exports.TraverseTool = exports.ReadEntityTool = exports.SearchEntitiesTool = exports.DescribeEntityTool = exports.ResolveEntityTool = exports.UserModulesRepository = exports.GraphDescriptorRegistry = exports.GRAPH_SEMANTIC_MIN_SCORE = exports.GRAPH_SEMANTIC_MAX_RESULTS = exports.GRAPH_FUZZY_MAX_RESULTS = exports.GRAPH_EXACT_MAX_RESULTS = exports.GraphSearchService = exports.GraphModule = exports.SummariserService = exports.SummariserModule = exports.ResponderService = exports.ResponderModule = exports.isValidKeyConcept = exports.buildGraphCreatorOutputSchema = exports.graphCreatorOutputSchema = exports.GraphCreatorService = exports.GraphCreatorModule = exports.CONTEXTUALISER_TOOLS = exports.RETRIEVAL_SOURCES = exports.ContextualiserContextFactoryService = exports.ContextualiserService = exports.ContextualiserModule = exports.DriftMigrationService = exports.DriftSearchService = exports.DriftModule = exports.CommunitySummariserService = exports.CommunitySummariserModule = exports.CommunityDetectorService = exports.CommunityDetectorModule = exports.AgentsModule = void 0;
17
+ exports.OperatorTestActionTool = exports.SearchCommunitiesTool = exports.SearchDocumentsTool = exports.OPERATOR_TOOLS = exports.OPERATOR_DEFAULT_APPROVAL_TTL_DAYS = exports.OperatorCheckpointerService = exports.defaultOperatorSystemPrompt = exports.OperatorContext = exports.OperatorService = exports.OperatorController = exports.operatorMeta = exports.OperatorModule = exports.TraverseTool = exports.ReadEntityTool = exports.SearchEntitiesTool = exports.DescribeEntityTool = exports.ResolveEntityTool = exports.UserModulesRepository = exports.buildScopePattern = exports.ScopePredicateService = exports.ScopeGuard = exports.GraphDescriptorRegistry = exports.GRAPH_SEMANTIC_MIN_SCORE = exports.GRAPH_SEMANTIC_MAX_RESULTS = exports.GRAPH_FUZZY_MAX_RESULTS = exports.GRAPH_EXACT_MAX_RESULTS = exports.GraphSearchService = exports.GraphModule = exports.SummariserService = exports.SummariserModule = exports.ResponderService = exports.ResponderModule = exports.isValidKeyConcept = exports.buildGraphCreatorOutputSchema = exports.graphCreatorOutputSchema = exports.GraphCreatorService = exports.GraphCreatorModule = exports.CONTEXTUALISER_TOOLS = exports.RETRIEVAL_SOURCES = exports.ContextualiserContextFactoryService = exports.ContextualiserService = exports.ContextualiserModule = exports.DriftMigrationService = exports.DriftSearchService = exports.DriftModule = exports.CommunitySummariserService = exports.CommunitySummariserModule = exports.CommunityDetectorService = exports.CommunityDetectorModule = exports.AgentsModule = void 0;
18
+ exports.OperatorToolRegistry = void 0;
18
19
  // Centralized AgentsModule - prompts configured via baseConfig.prompts
19
20
  var agents_modules_1 = require("./agents.modules");
20
21
  Object.defineProperty(exports, "AgentsModule", { enumerable: true, get: function () { return agents_modules_1.AgentsModule; } });
@@ -80,6 +81,12 @@ Object.defineProperty(exports, "GRAPH_SEMANTIC_MAX_RESULTS", { enumerable: true,
80
81
  Object.defineProperty(exports, "GRAPH_SEMANTIC_MIN_SCORE", { enumerable: true, get: function () { return graph_search_service_2.GRAPH_SEMANTIC_MIN_SCORE; } });
81
82
  var descriptor_source_1 = require("./graph/services/descriptor.source");
82
83
  Object.defineProperty(exports, "GraphDescriptorRegistry", { enumerable: true, get: function () { return descriptor_source_1.GraphDescriptorRegistry; } });
84
+ var scope_guard_1 = require("./graph/services/scope.guard");
85
+ Object.defineProperty(exports, "ScopeGuard", { enumerable: true, get: function () { return scope_guard_1.ScopeGuard; } });
86
+ var scope_predicate_service_1 = require("./graph/services/scope.predicate.service");
87
+ Object.defineProperty(exports, "ScopePredicateService", { enumerable: true, get: function () { return scope_predicate_service_1.ScopePredicateService; } });
88
+ var scope_pattern_1 = require("./graph/services/scope.pattern");
89
+ Object.defineProperty(exports, "buildScopePattern", { enumerable: true, get: function () { return scope_pattern_1.buildScopePattern; } });
83
90
  var user_modules_repository_1 = require("./graph/repositories/user-modules.repository");
84
91
  Object.defineProperty(exports, "UserModulesRepository", { enumerable: true, get: function () { return user_modules_repository_1.UserModulesRepository; } });
85
92
  // The graph tool builders, for app-side agents that bind the catalog tools to
@@ -1 +1 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AA;AAE1B,wEAA6E;AAApE,4HAAA,uBAAuB,OAAA;AAChC,4DAA0D;AAAjD,yGAAA,UAAU,OAAA;AACnB,oFAAiF;AAAxE,gIAAA,qBAAqB,OAAA;AAC9B,gEAAmE;AAA1D,kHAAA,iBAAiB,OAAA;AAC1B,wFAAqF;AAA5E,gIAAA,qBAAqB,OAAA;AAC9B,8EAA8E;AAC9E,oFAAoF;AACpF,yEAAsE;AAA7D,wHAAA,iBAAiB,OAAA;AAC1B,2EAAwE;AAA/D,0HAAA,kBAAkB,OAAA;AAC3B,2EAAwE;AAA/D,0HAAA,kBAAkB,OAAA;AAC3B,mEAAgE;AAAvD,kHAAA,cAAc,OAAA;AACvB,6DAA2D;AAAlD,6GAAA,YAAY,OAAA;AAGrB,WAAW;AACX,8DAA4D;AAAnD,iHAAA,cAAc,OAAA;AACvB,mEAAiE;AAAxD,6GAAA,YAAY,OAAA;AACrB,kFAAgF;AAAvE,yHAAA,kBAAkB,OAAA;AAC3B,yEAAuE;AAA9D,mHAAA,eAAe,OAAA;AAExB,yEAAuE;AAA9D,mHAAA,eAAe,OAAA;AAExB,oFAAwF;AAA/E,qIAAA,2BAA2B,OAAA;AACpC,mGAG2D;AAFzD,4IAAA,2BAA2B,OAAA;AAC3B,mJAAA,kCAAkC,OAAA;AAGpC,wBAAwB;AACxB,yFAA+E;AAAtE,yHAAA,cAAc,OAAA;AAQvB,gFAA6E;AAApE,4HAAA,mBAAmB,OAAA;AAC5B,oFAAiF;AAAxE,gIAAA,qBAAqB,OAAA;AAC9B,wFAAoF;AAA3E,mIAAA,sBAAsB,OAAA;AAC/B,kFAA+E;AAAtE,8HAAA,oBAAoB,OAAA"}
@@ -0,0 +1,64 @@
1
+ import { ClsService } from "nestjs-cls";
2
+ import { ScopePredicateSource } from "./scope-predicate.source";
3
+ import { AgentScope } from "../types/agent.scope";
4
+ import { DataLimits } from "../types/data.limits";
5
+ /** A Cypher fragment to place immediately after the source query's `WITH <alias>`. */
6
+ export interface AgentScopeFilter {
7
+ /** `WHERE …`, or `""` when the run is deliberately unscoped. */
8
+ cypher: string;
9
+ params: Record<string, unknown>;
10
+ /** True when a scope was in force and the fragment narrows retrieval. */
11
+ applied: boolean;
12
+ }
13
+ /**
14
+ * The retrieval-side half of scope enforcement.
15
+ *
16
+ * WHY THIS IS NOT INSIDE `AiSourceQueryProvider`: that provider is an app
17
+ * override point (`CoreModule.forRoot({ aiSourceQuery })`). Putting the scope
18
+ * predicate inside the DEFAULT implementation would mean any app that
19
+ * customised its source query silently opted out of scope enforcement — a
20
+ * fail-OPEN seam guarding a security boundary. Applying the filter at the call
21
+ * sites, on top of whatever the provider returned, makes the guard impossible
22
+ * for an override to drop.
23
+ */
24
+ export declare class AgentScopeFilterService {
25
+ private readonly cls;
26
+ private readonly predicates?;
27
+ private readonly logger;
28
+ constructor(cls: ClsService, predicates?: ScopePredicateSource);
29
+ /** The scope published for this turn, if any. */
30
+ current(): AgentScope | undefined;
31
+ /**
32
+ * Builds the `WHERE` that confines `alias` to the run's scope root.
33
+ *
34
+ * Three outcomes, all deliberate:
35
+ * - no scope in CLS, or a HowTo run → `""`. HowTo content is global and has
36
+ * no scope root; help mode is scope-independent by design.
37
+ * - scope + a predicate → `WHERE (…)`, retrieval narrowed to that root.
38
+ * - scope + NO predicate (no `SCOPE_PREDICATE_SOURCE` registered, or no
39
+ * entity can reach the root) → `WHERE false`. FAIL CLOSED: a run that
40
+ * declares a scope it cannot enforce retrieves nothing. Returning `""`
41
+ * here would silently restore company-wide retrieval — a cross-scope leak,
42
+ * which is the whole failure this guard exists to prevent.
43
+ */
44
+ build(params: {
45
+ alias: string;
46
+ dataLimits?: DataLimits;
47
+ }): AgentScopeFilter;
48
+ /**
49
+ * The bare boolean expression, for callers that must embed it somewhere a
50
+ * standalone `WHERE` cannot go — inside an `EXISTS { … }`, or ANDed onto a
51
+ * clause that already has a `WHERE`.
52
+ *
53
+ * `null` means the run is unscoped and nothing should be filtered. It never
54
+ * means "could not work it out": that case returns the constant `false`.
55
+ */
56
+ predicate(params: {
57
+ alias: string;
58
+ dataLimits?: DataLimits;
59
+ }): {
60
+ cypher: string;
61
+ params: Record<string, unknown>;
62
+ } | null;
63
+ }
64
+ //# sourceMappingURL=agent-scope.filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-scope.filter.d.ts","sourceRoot":"","sources":["../../../src/common/repositories/agent-scope.filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAA0B,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAuB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,yEAAyE;IACzE,OAAO,EAAE,OAAO,CAAC;CAClB;AAID;;;;;;;;;;GAUG;AACH,qBACa,uBAAuB;IAIhC,OAAO,CAAC,QAAQ,CAAC,GAAG;IACwB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IAJ1E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;gBAGhD,GAAG,EAAE,UAAU,EAC6B,UAAU,CAAC,EAAE,oBAAoB;IAGhG,iDAAiD;IACjD,OAAO,IAAI,UAAU,GAAG,SAAS;IAOjC;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,gBAAgB;IAM3E;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,IAAI;CAkB/D"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var AgentScopeFilterService_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.AgentScopeFilterService = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const nestjs_cls_1 = require("nestjs-cls");
19
+ const scope_predicate_source_1 = require("./scope-predicate.source");
20
+ const agent_scope_1 = require("../types/agent.scope");
21
+ const UNSCOPED = { cypher: "", params: {}, applied: false };
22
+ /**
23
+ * The retrieval-side half of scope enforcement.
24
+ *
25
+ * WHY THIS IS NOT INSIDE `AiSourceQueryProvider`: that provider is an app
26
+ * override point (`CoreModule.forRoot({ aiSourceQuery })`). Putting the scope
27
+ * predicate inside the DEFAULT implementation would mean any app that
28
+ * customised its source query silently opted out of scope enforcement — a
29
+ * fail-OPEN seam guarding a security boundary. Applying the filter at the call
30
+ * sites, on top of whatever the provider returned, makes the guard impossible
31
+ * for an override to drop.
32
+ */
33
+ let AgentScopeFilterService = AgentScopeFilterService_1 = class AgentScopeFilterService {
34
+ constructor(cls, predicates) {
35
+ this.cls = cls;
36
+ this.predicates = predicates;
37
+ this.logger = new common_1.Logger(AgentScopeFilterService_1.name);
38
+ }
39
+ /** The scope published for this turn, if any. */
40
+ current() {
41
+ const scope = this.cls.has(agent_scope_1.AGENT_SCOPE_CLS_KEY)
42
+ ? this.cls.get(agent_scope_1.AGENT_SCOPE_CLS_KEY)
43
+ : undefined;
44
+ return scope?.id && scope?.type ? scope : undefined;
45
+ }
46
+ /**
47
+ * Builds the `WHERE` that confines `alias` to the run's scope root.
48
+ *
49
+ * Three outcomes, all deliberate:
50
+ * - no scope in CLS, or a HowTo run → `""`. HowTo content is global and has
51
+ * no scope root; help mode is scope-independent by design.
52
+ * - scope + a predicate → `WHERE (…)`, retrieval narrowed to that root.
53
+ * - scope + NO predicate (no `SCOPE_PREDICATE_SOURCE` registered, or no
54
+ * entity can reach the root) → `WHERE false`. FAIL CLOSED: a run that
55
+ * declares a scope it cannot enforce retrieves nothing. Returning `""`
56
+ * here would silently restore company-wide retrieval — a cross-scope leak,
57
+ * which is the whole failure this guard exists to prevent.
58
+ */
59
+ build(params) {
60
+ const predicate = this.predicate(params);
61
+ if (!predicate)
62
+ return UNSCOPED;
63
+ return { cypher: `WHERE ${predicate.cypher}`, params: predicate.params, applied: true };
64
+ }
65
+ /**
66
+ * The bare boolean expression, for callers that must embed it somewhere a
67
+ * standalone `WHERE` cannot go — inside an `EXISTS { … }`, or ANDed onto a
68
+ * clause that already has a `WHERE`.
69
+ *
70
+ * `null` means the run is unscoped and nothing should be filtered. It never
71
+ * means "could not work it out": that case returns the constant `false`.
72
+ */
73
+ predicate(params) {
74
+ if (params.dataLimits?.howToMode || params.dataLimits?.limitToHowToId)
75
+ return null;
76
+ const scope = this.current();
77
+ if (!scope)
78
+ return null;
79
+ const predicate = this.predicates?.build({ alias: params.alias, scope });
80
+ if (!predicate) {
81
+ this.logger.error(`predicate: run is scoped to ${scope.type}:${scope.id} but no scope predicate could be compiled ` +
82
+ `(${this.predicates ? "no entity reaches that root" : "no SCOPE_PREDICATE_SOURCE registered"}) — ` +
83
+ `failing closed, this retrieval returns nothing.`);
84
+ return { cypher: "false", params: {} };
85
+ }
86
+ return predicate;
87
+ }
88
+ };
89
+ exports.AgentScopeFilterService = AgentScopeFilterService;
90
+ exports.AgentScopeFilterService = AgentScopeFilterService = AgentScopeFilterService_1 = __decorate([
91
+ (0, common_1.Injectable)(),
92
+ __param(1, (0, common_1.Optional)()),
93
+ __param(1, (0, common_1.Inject)(scope_predicate_source_1.SCOPE_PREDICATE_SOURCE)),
94
+ __metadata("design:paramtypes", [nestjs_cls_1.ClsService, Object])
95
+ ], AgentScopeFilterService);
96
+ //# sourceMappingURL=agent-scope.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-scope.filter.js","sourceRoot":"","sources":["../../../src/common/repositories/agent-scope.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAsE;AACtE,2CAAwC;AACxC,qEAAwF;AACxF,sDAAuE;AAYvE,MAAM,QAAQ,GAAqB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAE9E;;;;;;;;;;GAUG;AAEI,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IAGlC,YACmB,GAAe,EACY,UAAkD;QAD7E,QAAG,GAAH,GAAG,CAAY;QAC6B,eAAU,GAAV,UAAU,CAAuB;QAJ/E,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IAKhE,CAAC;IAEJ,iDAAiD;IACjD,OAAO;QACL,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,iCAAmB,CAAC;YAC7C,CAAC,CAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,iCAAmB,CAA4B;YAC/D,CAAC,CAAC,SAAS,CAAC;QACd,OAAO,KAAK,EAAE,EAAE,I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AAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,+CAAsB,CAAC,CAAA;qCADrB,uBAAU;GAJvB,uBAAuB,CAgEnC"}
@@ -1,3 +1,5 @@
1
+ export * from "./agent-scope.filter";
2
+ export * from "./scope-predicate.source";
1
3
  export * from "./ai.source.query";
2
4
  export * from "./ai-source-query.provider";
3
5
  export * from "./default.ai-source-query.provider";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC"}
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./agent-scope.filter"), exports);
18
+ __exportStar(require("./scope-predicate.source"), exports);
17
19
  __exportStar(require("./ai.source.query"), exports);
18
20
  __exportStar(require("./ai-source-query.provider"), exports);
19
21
  __exportStar(require("./default.ai-source-query.provider"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/repositories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,6DAA2C;AAC3C,qEAAmD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/repositories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,2DAAyC;AACzC,oDAAkC;AAClC,6DAA2C;AAC3C,qEAAmD"}
@@ -0,0 +1,32 @@
1
+ import { AgentScope } from "../types/agent.scope";
2
+ export interface ScopePredicateResult {
3
+ /**
4
+ * A Cypher BOOLEAN EXPRESSION over `alias` — no `WHERE`, no `AND` prefix, so
5
+ * the caller decides how to join it. References `$agentScopeId` only.
6
+ */
7
+ cypher: string;
8
+ /** Parameters the expression references — bound, never interpolated. */
9
+ params: Record<string, unknown>;
10
+ }
11
+ /**
12
+ * Compiles "is this node inside the run's scope root?" into Cypher.
13
+ *
14
+ * The knowledge needed to answer that — every entity type's hop chain to the
15
+ * scope root — lives in the graph catalog, which sits ABOVE the core layer
16
+ * where retrieval repositories live. This token is the seam between the two:
17
+ * the graph layer registers an implementation, and core-layer retrieval asks
18
+ * for a predicate without depending on the catalog.
19
+ *
20
+ * FAIL-CLOSED CONTRACT: an implementation returns `null` only when it can
21
+ * prove nothing is in scope. A caller holding a scope that gets `null` MUST
22
+ * retrieve nothing — never fall back to unfiltered retrieval, which is the
23
+ * cross-scope leak this seam exists to prevent.
24
+ */
25
+ export interface ScopePredicateSource {
26
+ build(params: {
27
+ alias: string;
28
+ scope: AgentScope;
29
+ }): ScopePredicateResult | null;
30
+ }
31
+ export declare const SCOPE_PREDICATE_SOURCE: unique symbol;
32
+ //# sourceMappingURL=scope-predicate.source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-predicate.source.d.ts","sourceRoot":"","sources":["../../../src/common/repositories/scope-predicate.source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,GAAG,oBAAoB,GAAG,IAAI,CAAC;CAClF;AAED,eAAO,MAAM,sBAAsB,eAAmC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCOPE_PREDICATE_SOURCE = void 0;
4
+ exports.SCOPE_PREDICATE_SOURCE = Symbol("SCOPE_PREDICATE_SOURCE");
5
+ //# sourceMappingURL=scope-predicate.source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-predicate.source.js","sourceRoot":"","sources":["../../../src/common/repositories/scope-predicate.source.ts"],"names":[],"mappings":";;;AA8Ba,QAAA,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The scope ROOT one agent run is confined to.
3
+ *
4
+ * A scope root is a catalogued entity whose compiled scope chain is empty —
5
+ * every other entity reaches it through a chain of relationship hops. A run
6
+ * bound to one may read only content that reaches that root.
7
+ *
8
+ * WHY THIS IS AMBIENT (CLS) RATHER THAN A PARAMETER
9
+ * -------------------------------------------------
10
+ * Retrieval reads the run's scope from CLS for the same reason it reads
11
+ * `companyId` from CLS: a security boundary that every call site must REMEMBER
12
+ * to pass is a boundary that eventually is not passed. Publishing it once per
13
+ * turn, next to `companyId`, means a new retrieval path is confined by
14
+ * construction rather than by review.
15
+ */
16
+ export interface AgentScope {
17
+ /** Id of the scope-root node. */
18
+ id: string;
19
+ /** JSON:API type of the scope root, e.g. "campaigns". */
20
+ type: string;
21
+ /** Neo4j label of the scope root, e.g. "Campaign". */
22
+ label: string;
23
+ }
24
+ /**
25
+ * CLS key under which a turn publishes its `AgentScope`.
26
+ *
27
+ * Absent = the run is deliberately unscoped (company-wide MCP tools, a worker
28
+ * job, an app with no scope roots at all) and retrieval behaves as it always
29
+ * has. Present = every retrieval in the turn is confined to that root.
30
+ */
31
+ export declare const AGENT_SCOPE_CLS_KEY = "agentScope";
32
+ //# sourceMappingURL=agent.scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.scope.d.ts","sourceRoot":"","sources":["../../../src/common/types/agent.scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,UAAU;IACzB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,eAAe,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AGENT_SCOPE_CLS_KEY = void 0;
4
+ /**
5
+ * CLS key under which a turn publishes its `AgentScope`.
6
+ *
7
+ * Absent = the run is deliberately unscoped (company-wide MCP tools, a worker
8
+ * job, an app with no scope roots at all) and retrieval behaves as it always
9
+ * has. Present = every retrieval in the turn is confined to that root.
10
+ */
11
+ exports.AGENT_SCOPE_CLS_KEY = "agentScope";
12
+ //# sourceMappingURL=agent.scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.scope.js","sourceRoot":"","sources":["../../../src/common/types/agent.scope.ts"],"names":[],"mappings":";;;AAwBA;;;;;;GAMG;AACU,QAAA,mBAAmB,GAAG,YAAY,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from "./agent.scope";
1
2
  export * from "./data.limits";
2
3
  export * from "./reducers";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./agent.scope"), exports);
17
18
  __exportStar(require("./data.limits"), exports);
18
19
  __exportStar(require("./reducers"), exports);
19
20
  //# sourceMappingURL=index.js.map