@hasna/machines 0.0.23 → 0.0.25

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.
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.hasna.xyz/machines/consumer/v1/machines-consumer.schema.json",
4
+ "title": "@hasna/machines consumer contract schema bundle",
5
+ "type": "object",
6
+ "$defs": {
7
+ "cacheability": {
8
+ "type": "object",
9
+ "required": ["observed_at", "verified_at", "expires_at", "ttl_ms", "source_authority", "confidence", "cacheable", "stale", "reasons"],
10
+ "properties": {
11
+ "observed_at": { "type": "string", "format": "date-time" },
12
+ "verified_at": { "type": ["string", "null"], "format": "date-time" },
13
+ "expires_at": { "type": ["string", "null"], "format": "date-time" },
14
+ "ttl_ms": { "type": ["number", "null"] },
15
+ "source_authority": { "enum": ["open-machines", "manifest", "manifest_metadata", "live_topology", "argument", "inferred", "fallback", "unresolved", "mixed", "unknown"] },
16
+ "confidence": { "enum": ["exact", "high", "medium", "low", "none"] },
17
+ "cacheable": { "type": "boolean" },
18
+ "stale": { "type": "boolean" },
19
+ "reasons": { "type": "array", "items": { "type": "string" } }
20
+ }
21
+ },
22
+ "contract": {
23
+ "type": "object",
24
+ "required": ["schema_version", "package_name", "entrypoint", "schema_uri", "schema_artifact", "capabilities", "field_capabilities", "cacheability", "envelopes", "stable_exports"]
25
+ },
26
+ "topology": {
27
+ "type": "object",
28
+ "required": ["schema_version", "package", "capabilities", "generated_at", "local_machine_id", "machines", "warnings"]
29
+ },
30
+ "route": {
31
+ "type": "object",
32
+ "required": ["schema_version", "package", "ok", "machine_id", "requested_machine_id", "generated_at", "route", "source", "target", "command_target", "confidence", "local", "evidence", "cacheability", "warnings"]
33
+ },
34
+ "workspace": {
35
+ "type": "object",
36
+ "required": ["schema_version", "package", "ok", "requested_machine_id", "machine_id", "generated_at", "project", "machine", "paths", "diagnostics", "repair_hints", "evidence", "cacheability", "warnings"]
37
+ },
38
+ "compatibility": {
39
+ "type": "object",
40
+ "required": ["schema_version", "package", "capabilities", "ok", "machine_id", "source", "generated_at", "checks", "summary"]
41
+ },
42
+ "resolver_snapshot": {
43
+ "type": "object",
44
+ "required": ["schema_version", "package", "generated_at", "requested_machine_id", "machine_id", "route", "workspace", "cacheability", "warnings", "provenance"]
45
+ }
46
+ }
47
+ }
@@ -42,6 +42,7 @@ function parseArgs(argv) {
42
42
  "",
43
43
  "Verifies downstream app dependency shapes for @hasna/machines:",
44
44
  " sdk-local: @hasna/machines/consumer is importable and emits v1 envelopes",
45
+ " sdk-local also validates schema artifacts and builds resolver snapshots",
45
46
  " future-contract-sdk: fake v2 SDK is detected before route/workspace calls are trusted",
46
47
  " global-cli-only: machines CLI JSON can be used when SDK is absent",
47
48
  " no-sdk-no-cli: consumer can report graceful unavailable diagnostics",
@@ -161,8 +162,11 @@ function writeSdkProbe(appDir) {
161
162
  import {
162
163
  MACHINES_CONSUMER_CONTRACT,
163
164
  MACHINES_CONSUMER_CONTRACT_VERSION,
165
+ MACHINES_CONSUMER_SCHEMA_BUNDLE,
164
166
  checkMachineCompatibility,
167
+ createMachineResolverSnapshot,
165
168
  discoverMachineTopology,
169
+ validateMachinesConsumerEnvelope,
166
170
  resolveMachineRoute,
167
171
  resolveMachineWorkspace,
168
172
  } from '@hasna/machines/consumer';
@@ -186,18 +190,33 @@ function writeSdkProbe(appDir) {
186
190
  workspaces: [],
187
191
  now: new Date('2026-06-09T00:00:00.000Z'),
188
192
  });
193
+ const snapshot = createMachineResolverSnapshot({
194
+ route,
195
+ workspace,
196
+ now: new Date('2026-06-09T00:00:00.000Z'),
197
+ });
189
198
 
190
199
  console.log(JSON.stringify({
191
200
  source: 'sdk',
192
201
  supported: MACHINES_CONSUMER_CONTRACT_VERSION <= ${supportedContractVersion},
193
202
  contract_version: MACHINES_CONSUMER_CONTRACT_VERSION,
194
203
  entrypoint: MACHINES_CONSUMER_CONTRACT.entrypoint,
204
+ schema_id: MACHINES_CONSUMER_SCHEMA_BUNDLE.$id,
205
+ schema_artifact: MACHINES_CONSUMER_CONTRACT.schema_artifact,
195
206
  envelopes: MACHINES_CONSUMER_CONTRACT.envelopes,
196
207
  capabilities: MACHINES_CONSUMER_CONTRACT.capabilities,
208
+ validation: {
209
+ contract: validateMachinesConsumerEnvelope('contract', MACHINES_CONSUMER_CONTRACT).ok,
210
+ route: validateMachinesConsumerEnvelope('route', route).ok,
211
+ workspace: validateMachinesConsumerEnvelope('workspace', workspace).ok,
212
+ compatibility: validateMachinesConsumerEnvelope('compatibility', compatibility).ok,
213
+ resolver_snapshot: validateMachinesConsumerEnvelope('resolver_snapshot', snapshot).ok,
214
+ },
197
215
  topology: { schema_version: topology.schema_version, machines: topology.machines.length },
198
- route: { schema_version: route.schema_version, ok: route.ok, route: route.route, target: route.target },
199
- workspace: { schema_version: workspace.schema_version, ok: workspace.ok, project_root: workspace.paths.project_root.path },
216
+ route: { schema_version: route.schema_version, ok: route.ok, route: route.route, target: route.target, cacheable: route.cacheability.cacheable },
217
+ workspace: { schema_version: workspace.schema_version, ok: workspace.ok, project_root: workspace.paths.project_root.path, cacheable: workspace.cacheability.cacheable },
200
218
  compatibility: { schema_version: compatibility.schema_version, ok: compatibility.ok },
219
+ resolver_snapshot: { schema_version: snapshot.schema_version, cacheable: snapshot.cacheability.cacheable, authority: snapshot.cacheability.source_authority },
201
220
  }));
202
221
  `);
203
222
  return script;
@@ -302,6 +321,12 @@ function assertCase(name, output) {
302
321
  if (!output.envelopes.includes(envelope)) throw new Error(`${name}: missing envelope ${envelope}`);
303
322
  if (output[envelope].schema_version !== 1) throw new Error(`${name}: ${envelope} schema mismatch`);
304
323
  }
324
+ if (!output.envelopes.includes("resolver_snapshot") || output.resolver_snapshot.schema_version !== 1) {
325
+ throw new Error(`${name}: missing resolver snapshot envelope\n${JSON.stringify(output, null, 2)}`);
326
+ }
327
+ if (!output.schema_artifact || !output.schema_id || !Object.values(output.validation).every(Boolean)) {
328
+ throw new Error(`${name}: schema validation failed\n${JSON.stringify(output, null, 2)}`);
329
+ }
305
330
  }
306
331
  if (name === "future-contract-sdk") {
307
332
  if (output.supported !== false || output.error !== "unsupported_contract_version:2" || output.trusted_envelopes.length !== 0) {