@company-semantics/contracts 86.0.0 → 86.1.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/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# mcp/\_\_tests\_\_/
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Locks the MCP vocabulary claims the compiler alone does not.
|
|
6
|
+
|
|
7
|
+
- `capability-graph.test.ts` — `buildCapabilityGraph` derives edges from
|
|
8
|
+
`produces`/`consumes` resource flow.
|
|
9
|
+
- `resource-types-fixture.ts` — a COMPILED module, not a `*.test.ts`:
|
|
10
|
+
`src/tsconfig.json` excludes test files and vitest does not typecheck, so a
|
|
11
|
+
`satisfies ResourceType[]` written in a test would never be checked. Here
|
|
12
|
+
`tsc -b` checks that the nine original members and the five agent-reference
|
|
13
|
+
members (`company_md.doc`, `company_md.thread`, `org.member`, `org.unit`,
|
|
14
|
+
`work.item`) are all `ResourceType` members, and that no union member is
|
|
15
|
+
left unlisted.
|
|
16
|
+
- `resources.test.ts` — the runtime half: fourteen distinct members, each
|
|
17
|
+
`<domain>.<kind>`.
|
|
18
|
+
|
|
19
|
+
## Invariants
|
|
20
|
+
|
|
21
|
+
- These assert VOCABULARY and SHAPE, never behavior.
|
|
22
|
+
|
|
23
|
+
## Public API
|
|
24
|
+
|
|
25
|
+
None — test-only.
|
|
26
|
+
|
|
27
|
+
## Dependencies
|
|
28
|
+
|
|
29
|
+
`vitest` and the sibling modules under test.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time fixture for the `ResourceType` union (ADR slug
|
|
3
|
+
* mcp-resource-types-cover-agent-references).
|
|
4
|
+
*
|
|
5
|
+
* WHY A COMPILED MODULE AND NOT `resources.test.ts`. `src/tsconfig.json`
|
|
6
|
+
* excludes every `*.test.ts` file and vitest does not typecheck, so a
|
|
7
|
+
* `satisfies` written inside a test file is never checked. This file is not a
|
|
8
|
+
* `*.test.ts`, so `tsc -b` compiles it: a literal that stops being a
|
|
9
|
+
* `ResourceType` member fails `pnpm typecheck`. `resources.test.ts` imports the
|
|
10
|
+
* arrays to prove the runtime half (count, uniqueness).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ResourceType } from "../resources";
|
|
14
|
+
|
|
15
|
+
/** The nine members the union carried before agent-reference kinds were added. */
|
|
16
|
+
export const ORIGINAL_RESOURCE_TYPES = [
|
|
17
|
+
"integration.connection",
|
|
18
|
+
"slack.channel",
|
|
19
|
+
"slack.channel_scope",
|
|
20
|
+
"slack.coverage",
|
|
21
|
+
"ingestion.job",
|
|
22
|
+
"knowledge.fingerprint",
|
|
23
|
+
"org.status",
|
|
24
|
+
"system.status",
|
|
25
|
+
"system.runtime",
|
|
26
|
+
] as const satisfies readonly ResourceType[];
|
|
27
|
+
|
|
28
|
+
/** The resource kinds the agent is handed a reference to (control INV-AGENT-GROUND-3). */
|
|
29
|
+
export const AGENT_REFERENCE_RESOURCE_TYPES = [
|
|
30
|
+
"company_md.doc",
|
|
31
|
+
"company_md.thread",
|
|
32
|
+
"org.member",
|
|
33
|
+
"org.unit",
|
|
34
|
+
"work.item",
|
|
35
|
+
] as const satisfies readonly ResourceType[];
|
|
36
|
+
|
|
37
|
+
/** All fourteen members. */
|
|
38
|
+
export const ALL_RESOURCE_TYPES = [
|
|
39
|
+
...ORIGINAL_RESOURCE_TYPES,
|
|
40
|
+
...AGENT_REFERENCE_RESOURCE_TYPES,
|
|
41
|
+
] as const satisfies readonly ResourceType[];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Exhaustiveness: every `ResourceType` member is listed above. If a member is
|
|
45
|
+
* added to the union without being listed here, this assignment fails.
|
|
46
|
+
*/
|
|
47
|
+
type Unlisted = Exclude<ResourceType, (typeof ALL_RESOURCE_TYPES)[number]>;
|
|
48
|
+
export const NO_UNLISTED_RESOURCE_TYPES: [Unlisted] extends [never]
|
|
49
|
+
? true
|
|
50
|
+
: never = true;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import type { ResourceType } from "../resources";
|
|
3
|
+
import {
|
|
4
|
+
AGENT_REFERENCE_RESOURCE_TYPES,
|
|
5
|
+
ALL_RESOURCE_TYPES,
|
|
6
|
+
NO_UNLISTED_RESOURCE_TYPES,
|
|
7
|
+
ORIGINAL_RESOURCE_TYPES,
|
|
8
|
+
} from "./resource-types-fixture";
|
|
9
|
+
|
|
10
|
+
describe("ResourceType", () => {
|
|
11
|
+
it("keeps the nine original members", () => {
|
|
12
|
+
expect(ORIGINAL_RESOURCE_TYPES).toHaveLength(9);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("covers every resource kind the agent is handed a reference to", () => {
|
|
16
|
+
// Checked by the editor only (test files are not typechecked); the
|
|
17
|
+
// compiled twin is AGENT_REFERENCE_RESOURCE_TYPES in the fixture.
|
|
18
|
+
const agentReferences = [
|
|
19
|
+
"company_md.doc",
|
|
20
|
+
"company_md.thread",
|
|
21
|
+
"org.member",
|
|
22
|
+
"org.unit",
|
|
23
|
+
"work.item",
|
|
24
|
+
] satisfies ResourceType[];
|
|
25
|
+
expect([...AGENT_REFERENCE_RESOURCE_TYPES]).toEqual(agentReferences);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("has fourteen distinct members, all listed", () => {
|
|
29
|
+
expect(ALL_RESOURCE_TYPES).toHaveLength(14);
|
|
30
|
+
expect(new Set(ALL_RESOURCE_TYPES).size).toBe(14);
|
|
31
|
+
expect(NO_UNLISTED_RESOURCE_TYPES).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("namespaces every member as <domain>.<kind>", () => {
|
|
35
|
+
for (const resource of ALL_RESOURCE_TYPES) {
|
|
36
|
+
expect(resource).toMatch(/^[a-z_]+\.[a-z_]+$/);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
package/src/mcp/resources.ts
CHANGED
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
* This is a CLOSED union — new resource types represent architectural
|
|
9
9
|
* additions that require a contracts release and downstream consumer updates.
|
|
10
10
|
* Unlike ToolIntegration, resource types are not extensible via (string & {}).
|
|
11
|
+
*
|
|
12
|
+
* Since the ADR with slug mcp-resource-types-cover-agent-references, a member
|
|
13
|
+
* also exists for every resource kind the agent is handed a reference to (page
|
|
14
|
+
* context entity, citation entityId), so backend tool meta `consumes` can serve
|
|
15
|
+
* as the dereference registry (control INV-AGENT-GROUND-3).
|
|
11
16
|
*/
|
|
12
17
|
export type ResourceType =
|
|
13
18
|
| "integration.connection"
|
|
@@ -18,4 +23,14 @@ export type ResourceType =
|
|
|
18
23
|
| "knowledge.fingerprint"
|
|
19
24
|
| "org.status"
|
|
20
25
|
| "system.status"
|
|
21
|
-
| "system.runtime"
|
|
26
|
+
| "system.runtime"
|
|
27
|
+
/** A company-md document; consumed by id (uuid), or by company-md path for page context. */
|
|
28
|
+
| "company_md.doc"
|
|
29
|
+
/** A company-md comment thread; consumed by id (uuid). */
|
|
30
|
+
| "company_md.thread"
|
|
31
|
+
/** An org member; consumed by users.id (uuid). */
|
|
32
|
+
| "org.member"
|
|
33
|
+
/** An org unit; consumed by org_units.id (uuid). */
|
|
34
|
+
| "org.unit"
|
|
35
|
+
/** A work item; consumed by id (uuid). */
|
|
36
|
+
| "work.item";
|