@compforge/harness-common 0.5.4 → 0.5.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.
package/README.md CHANGED
@@ -176,3 +176,10 @@ headings or code blocks in child output.
176
176
  Move `KnowledgeMarkdownOptions.renderEntry` or `dictionaryToMarkdown` renderer callbacks
177
177
  into each Entry's `markdown()` method. These callback arguments are removed in 0.5; a
178
178
  custom Entry now renders consistently when shown alone or through its Dictionary and Knowledge.
179
+
180
+ ## Resource inventory
181
+
182
+ `Resource` declares a collection held by a running Service; `ServiceResource` records manages/uses
183
+ relationships without duplicating identity. `ResourceSnapshot` retains typed instances, unit-bearing
184
+ measurements, independently known totals and complete/partial/unavailable coverage. Discovery and
185
+ rendering remain consumer-owned. See [the shared contract](../../../docs/resource.md).
package/dist/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export type { Product } from "./product.js";
15
15
  export * from "./knowledge.js";
16
16
  export type { Identity } from "./identity.js";
17
17
  export * from "./file.js";
18
+ export * from "./resource.js";
package/dist/index.js CHANGED
@@ -13,3 +13,4 @@ export * from "./service.js";
13
13
  export * from "./execution.js";
14
14
  export * from "./knowledge.js";
15
15
  export * from "./file.js";
16
+ export * from "./resource.js";
@@ -0,0 +1,62 @@
1
+ import type { Service } from "./service.js";
2
+ /** A category of resources persistently managed or used by a running Service.
3
+ * @spec A declaration describes what can be inventoried, not the current count or existence.
4
+ * @rule id identifies the same resource collection across Services; names are presentation only.
5
+ */
6
+ export interface Resource {
7
+ readonly id: string;
8
+ readonly kind: string;
9
+ readonly name: string;
10
+ readonly description?: string;
11
+ }
12
+ /** Association does not transfer exclusive ownership or duplicate the underlying resource. */
13
+ export interface ServiceResource<S extends Service = Service> {
14
+ readonly service: S;
15
+ readonly resource: Resource;
16
+ readonly relationship: "manages" | "uses";
17
+ }
18
+ /** Caller-owned environment and collection IDs disambiguate identical local instance IDs. */
19
+ export interface ResourceInstanceRef {
20
+ readonly environment: string;
21
+ readonly resource: string;
22
+ readonly id: string;
23
+ }
24
+ export interface ResourceInstance<Details = Readonly<Record<string, unknown>>> {
25
+ readonly ref: ResourceInstanceRef;
26
+ readonly name?: string;
27
+ /** Domain state, never an implicit health verdict. */
28
+ readonly state?: string;
29
+ readonly details?: Details;
30
+ }
31
+ /** Quantities retain their units and aggregation scope; different measures are not additive. */
32
+ export interface ResourceMeasurement {
33
+ readonly name: string;
34
+ readonly value: number;
35
+ readonly unit: string;
36
+ readonly scope: "observed" | "total";
37
+ }
38
+ export type ResourceCoverage = {
39
+ readonly status: "complete";
40
+ } | {
41
+ readonly status: "partial" | "unavailable";
42
+ readonly reason: string;
43
+ };
44
+ /**
45
+ * Read-only inventory evidence. Collection, access, pagination policy and rendering belong to consumers.
46
+ * @spec totalCount is an independently known count for scope, never inferred from a page of instances.
47
+ * @spec Unknown values are omitted; partial or unavailable acquisition is not a resource health verdict.
48
+ * @rule source, scope and details contain only safe serializable evidence, never access credentials.
49
+ */
50
+ export interface ResourceSnapshot<Details = Readonly<Record<string, unknown>>> {
51
+ readonly resource: Resource;
52
+ readonly environment: string;
53
+ readonly observedAt: string;
54
+ readonly source: string;
55
+ readonly scope: Readonly<Record<string, string>>;
56
+ readonly coverage: ResourceCoverage;
57
+ readonly totalCount?: number;
58
+ readonly measurements?: readonly ResourceMeasurement[];
59
+ readonly instances?: readonly ResourceInstance<Details>[];
60
+ readonly nextCursor?: string;
61
+ }
62
+ export declare function sameResourceInstance(left: ResourceInstanceRef, right: ResourceInstanceRef): boolean;
@@ -0,0 +1,3 @@
1
+ export function sameResourceInstance(left, right) {
2
+ return left.environment === right.environment && left.resource === right.resource && left.id === right.id;
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compforge/harness-common",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Execution-neutral client lifecycle and datasource contracts for harnesses",
5
5
  "type": "module",
6
6
  "scripts": {