@quolu/lattice 0.72.0 → 0.73.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.72.0",
3
+ "version": "0.73.0",
4
4
  "description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
5
5
  "author": {
6
6
  "name": "Quo / クオ at kitepon.dev",
@@ -45,6 +45,9 @@ const COMMAND_KIND = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)?$/;
45
45
  const COMMAND_KIND_MAX = 48;
46
46
  // Nodeが付けるerror code(ENOENT・ERR_MODULE_NOT_FOUND等)だけを通す。Lattice自身のcodeや任意文字列は`none`。
47
47
  const CAUSE_CODE = /^(?:E[A-Z0-9]{2,15}|ERR_[A-Z0-9_]{1,60})$/;
48
+ // 工場の`factory-reporter.json`が名乗る端末の種類。dotagentsの契約(lib/factory/contract.mjs)と同じ語を
49
+ // 受ける——ここに無い語の端末は設定全体が無効とみなされ、故障を1件も記録しない。
50
+ const HOST_PROFILES = Object.freeze(['server', 'mac', 'linux', 'wsl', 'windows-native']);
48
51
 
49
52
  const plain = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
50
53
  const exact = (value, keys) => Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
@@ -73,7 +76,14 @@ function canonicalReporting(value) {
73
76
  return !value.enabled || (value.endpoint !== undefined && value.credential_file !== undefined);
74
77
  }
75
78
 
79
+ // このOSで収集に対応するか。Windowsはstoreの所有者と権限をPOSIXの形で確かめられない(`ensureSafeDir`)ので
80
+ // 対応しない。設定が有効でも記録は作らず、工場へは`disabled`でなく`unsupported`と答える——設定は有効なのに
81
+ // 製品が黙って無効と答えると、受け側は故障と区別できない。
82
+ const collectionSupported = (options = {}) => (options.platform ?? hostPlatform()) !== 'win32';
83
+ const inactiveCollection = (options = {}) => (collectionSupported(options) ? 'disabled' : 'unsupported');
84
+
76
85
  function collectionEnabled(options = {}) {
86
+ if (!collectionSupported(options)) return false;
77
87
  const env = options.env ?? process.env;
78
88
  try {
79
89
  const path = options.configPath ?? defaultFactoryReporterConfigPath(env);
@@ -83,7 +93,7 @@ function collectionEnabled(options = {}) {
83
93
  return plain(config) && exact(config, ['schema_version', 'host', 'collection', 'reporting'])
84
94
  && config.schema_version === '1.0' && plain(config.host) && exact(config.host, ['id', 'profile'])
85
95
  && typeof config.host.id === 'string' && /^[a-z0-9][a-z0-9._-]{0,63}$/.test(config.host.id)
86
- && ['server', 'mac', 'wsl', 'windows-native'].includes(config.host.profile)
96
+ && HOST_PROFILES.includes(config.host.profile)
87
97
  && plain(config.collection) && exact(config.collection, ['enabled']) && config.collection.enabled === true
88
98
  && canonicalReporting(config.reporting);
89
99
  } catch {
@@ -261,7 +271,7 @@ function snapshot(options = {}) {
261
271
  runtime_errors: rows.filter((record) => record.status === 'open').map(({ product_version, error_code, component, status, severity, fingerprint, message_template, count, first_seen, last_seen, state_schema_version, safe_context }) => ({ product_version, error_code, component, status, severity, fingerprint, message_template, occurrence_count: count, first_seen, last_seen, state_schema_version, ...(safe_context === undefined ? {} : { safe_context }) })),
262
272
  resolutions: rows.filter((record) => record.status === 'resolved').map(({ fingerprint, resolved_at, reason_code }) => ({ fingerprint, resolved_at, reason_code })),
263
273
  diagnostics: {
264
- collection: enabled ? 'enabled' : 'disabled',
274
+ collection: enabled ? 'enabled' : inactiveCollection(options),
265
275
  status: enabled ? 'ready' : 'not_applicable',
266
276
  total_count: store.records.length,
267
277
  pending_count: store.records.filter((record) => record.sequence > store.acknowledged_through).length,
@@ -276,7 +286,7 @@ export function runtimeErrorsSnapshot(afterCursor = 0, limit = MAX_RECORDS, opti
276
286
 
277
287
  export function runtimeErrorsDiagnostics(options = {}) {
278
288
  if (!collectionEnabled(options)) {
279
- return { schema: DIAGNOSTICS_SCHEMA, collection: 'disabled', status: 'not_applicable', total_count: 0, open_count: 0, pending_count: 0, high_watermark: 0, acknowledged_through: 0 };
289
+ return { schema: DIAGNOSTICS_SCHEMA, collection: inactiveCollection(options), status: 'not_applicable', total_count: 0, open_count: 0, pending_count: 0, high_watermark: 0, acknowledged_through: 0 };
280
290
  }
281
291
  try {
282
292
  const { path } = optionsFor(options);
@@ -297,7 +307,7 @@ export function runtimeErrorsDiagnostics(options = {}) {
297
307
  }
298
308
 
299
309
  export function recordRuntimeError(code, options = {}) {
300
- if (!collectionEnabled(options)) return { status: 'disabled' };
310
+ if (!collectionEnabled(options)) return { status: inactiveCollection(options) };
301
311
  const definition = definitions[code];
302
312
  if (!definition) throw Error('unknown_runtime_code');
303
313
  const { path } = optionsFor(options);