pomaster 0.1.1 → 0.2.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.
Files changed (55) hide show
  1. package/README.md +14 -6
  2. package/TRADEMARKS.md +2 -2
  3. package/catalog/archetypes/archetype.api.error.json +55 -0
  4. package/catalog/archetypes/archetype.api.pagination.json +68 -0
  5. package/catalog/archetypes/archetype.api.resource.json +45 -0
  6. package/catalog/archetypes/archetype.backend.approval_workflow.json +63 -0
  7. package/catalog/archetypes/archetype.backend.audit.json +44 -0
  8. package/catalog/archetypes/archetype.backend.crud_resource.json +56 -0
  9. package/catalog/archetypes/archetype.backend.export.json +40 -0
  10. package/catalog/archetypes/archetype.backend.external_integration.json +89 -0
  11. package/catalog/archetypes/archetype.backend.idempotent_command.json +65 -0
  12. package/catalog/archetypes/archetype.backend.import.json +47 -0
  13. package/catalog/archetypes/archetype.backend.master_data.json +45 -0
  14. package/catalog/archetypes/archetype.backend.outbox_event.json +80 -0
  15. package/catalog/archetypes/archetype.backend.query_resource.json +40 -0
  16. package/catalog/archetypes/archetype.backend.scheduled_job.json +69 -0
  17. package/catalog/archetypes/archetype.backend.transactional_write.json +79 -0
  18. package/catalog/archetypes/archetype.component.button.json +53 -0
  19. package/catalog/archetypes/archetype.component.data_grid.json +78 -0
  20. package/catalog/archetypes/archetype.component.dialog.json +52 -0
  21. package/catalog/archetypes/archetype.component.search_input.json +34 -0
  22. package/catalog/archetypes/archetype.component.search_select.json +77 -0
  23. package/catalog/archetypes/archetype.data.hierarchy.json +71 -0
  24. package/catalog/archetypes/archetype.data.ledger.json +40 -0
  25. package/catalog/archetypes/archetype.data.master_data.json +43 -0
  26. package/catalog/archetypes/archetype.data.transaction.json +42 -0
  27. package/catalog/archetypes/archetype.data.versioned.json +43 -0
  28. package/catalog/archetypes/archetype.frontend.error_taxonomy.json +99 -0
  29. package/catalog/archetypes/archetype.frontend.feature_oriented.json +59 -0
  30. package/catalog/archetypes/archetype.frontend.modular.json +37 -0
  31. package/catalog/archetypes/archetype.frontend.spa_layered.json +48 -0
  32. package/catalog/archetypes/archetype.page.analysis.json +39 -0
  33. package/catalog/archetypes/archetype.page.master_data.json +63 -0
  34. package/catalog/archetypes/archetype.runtime.environment_parity.json +178 -0
  35. package/catalog/archetypes/archetype.runtime.observability_binding.json +93 -0
  36. package/catalog/archetypes/archetype.state.async_command.json +63 -0
  37. package/catalog/archetypes/archetype.state.background_refresh.json +45 -0
  38. package/catalog/archetypes/archetype.state.form_edit.json +45 -0
  39. package/catalog/archetypes/archetype.state.optimistic_mutation.json +48 -0
  40. package/catalog/archetypes/archetype.state.selection.json +35 -0
  41. package/catalog/archetypes/archetype.state.server_query.json +60 -0
  42. package/catalog/archetypes/archetype.state.url_filter.json +47 -0
  43. package/catalog/archetypes/archetype.state.wizard.json +46 -0
  44. package/catalog/catalog-lock.draft.json +349 -5
  45. package/catalog/gates/gate.new-entity.checks.json +106 -0
  46. package/catalog/knowledge/knowledge.web.browser.mcp_eyes.json +99 -0
  47. package/catalog/sensors/sensor.browser.deterministic.json +17 -6
  48. package/catalog/sensors/sensor.browser.interactive.json +16 -6
  49. package/catalog/tools/materialize_v06_relock.py +218 -0
  50. package/catalog/tools/seed_v06_archetypes.py +283 -0
  51. package/catalog/tools/seed_v06_batch2_materials.py +504 -0
  52. package/catalog/tools/seed_v06_batch3_materials.py +756 -0
  53. package/catalog/tools/seed_v06_batch4_materials.py +353 -0
  54. package/dist/bin.js +2431 -215
  55. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -5351,11 +5351,11 @@ var init_object_envelope_schema = __esm({
5351
5351
  "x-vocab-extra": {
5352
5352
  note: "\u975E vocab-lock \u679A\u4E3E\uFF1A\u6765\u81EA\u4EFB\u52A1\u4E66 02 \u6307\u4EE4\u6216 thread-A \u57FA\u7EBF\uFF0C\u9010\u9879\u6CE8\u660E\u51FA\u5904\u5E76\u63D0\u8BF7 vocab PR \u6536\u7F16\uFF1B\u540C\u6837\u7981\u6B62\u5728 $definitions \u4E4B\u5916\u624B\u6284\u5B57\u9762\u91CF\u3002",
5353
5353
  source_type: {
5354
- all: { const: ["bp_blueprint", "design_seed", "human_directive", "code_refactor", "prototype_walkthrough", "prototype_html_scrape", "research_evidence", "openapi_contract", "ai_invention"] },
5355
- allowed: { const: ["bp_blueprint", "design_seed", "human_directive", "code_refactor", "prototype_walkthrough", "research_evidence", "openapi_contract"] },
5354
+ all: { const: ["bp_blueprint", "design_seed", "human_directive", "owner_directive", "code_refactor", "prototype_walkthrough", "prototype_html_scrape", "research_evidence", "openapi_contract", "ai_invention"] },
5355
+ allowed: { const: ["bp_blueprint", "design_seed", "human_directive", "owner_directive", "code_refactor", "prototype_walkthrough", "research_evidence", "openapi_contract"] },
5356
5356
  forbidden: { const: ["prototype_html_scrape", "ai_invention"] },
5357
5357
  "x-source": "\u4EFB\u52A1\u4E66 02\uFF08object-envelope \u6307\u4EE4\uFF09\u663E\u5F0F\u7ED9\u5B9A\uFF1Bforbidden \u4E24\u503C schema \u53EA\u4FDD\u8BC1\u53EF\u5224\u522B\u3001\u4E0D\u505A\u786C\u62E6\uFF0CTransition/Gate \u5C42\u5224 FATAL \u5E76\u7559\u75D5",
5358
- "x-vocab-status": "registered_in_vocab_lock__source_types\uFF082026-08-27 \u968F FROZEN \u4E00\u6B21\u6536\u7F16\uFF0Callowed/forbidden \u4E24\u5B50\u96C6\u5207\u5206\u540C\u6784\uFF1B\u672C\u6CE8\u8BB0\u4FDD\u7559\u4F5C\u5BBF\u4E3B\u4FA7\u955C\u50CF\uFF09"
5358
+ "x-vocab-status": "registered_in_vocab_lock__source_types\uFF082026-08-27 \u968F FROZEN \u4E00\u6B21\u6536\u7F16\uFF0Callowed/forbidden \u4E24\u5B50\u96C6\u5207\u5206\u540C\u6784\uFF1B2026-09-03 PR-0007 append-only \u589E\u503C owner_directive\u2014\u2014Owner \u6709\u610F\u8BCD\u5F62\uFF08Owner \u660E\u4EE4\uFF0C\u533A\u522B\u4E8E human_directive \u6CDB\u5316\u4EBA\u7C7B\u6307\u4EE4\uFF09\uFF0Call/allowed \u540C\u6B65\u589E\u503C\u3001forbidden \u4E0D\u52A8\uFF1B\u672C\u6CE8\u8BB0\u4FDD\u7559\u4F5C\u5BBF\u4E3B\u4FA7\u955C\u50CF\uFF09"
5359
5359
  },
5360
5360
  origin: { const: ["natural", "derived", "ingested"], "x-source": "01-truth-index \u4EFB\u52A1\u6307\u6D3E\u5B9A\u6848\u8BCD\u5F62\uFF1Bthread-A-ir-schema.md \xA73.0 \u7684 human_curated/migrated \u4E3A legacy \u8BCD\u5F62\uFF0C\u6536\u7F16\u6620\u5C04 human_curated\u2192natural\u3001migrated\u2192ingested\uFF082026-08-27 \u4E0E 01 \u5BF9\u9F50\uFF09" },
5361
5361
  write_policy: { const: ["NONE", "AGENT_WITH_PERMIT", "CORRECTION_ONLY", "EVOLUTION_CHANNEL"], "x-source": "thread-A-ir-schema.md \xA73.4" },
@@ -5704,11 +5704,11 @@ var init_object_envelope_schema = __esm({
5704
5704
  description: "NONE=\u9501\u6B7B\uFF1BAGENT_WITH_PERMIT=Agent \u6301\u8BB8\u53EF\u53EF\u5199\uFF1BCORRECTION_ONLY=\u4EC5\u7EA0\u9519\u901A\u9053\uFF1BEVOLUTION_CHANNEL=\u6280\u672F\u8DEF\u7EBF\u53D8\u66F4\u8D70 ACR\u3002"
5705
5705
  },
5706
5706
  SourceTypeAllowed: {
5707
- title: "source.type \u5408\u6CD5\u6765\u6E90\uFF087 \u503C\uFF09",
5707
+ title: "source.type \u5408\u6CD5\u6765\u6E90\uFF088 \u503C\uFF09",
5708
5708
  type: "string",
5709
- enum: ["bp_blueprint", "design_seed", "human_directive", "code_refactor", "prototype_walkthrough", "research_evidence", "openapi_contract"],
5710
- "x-vocab-source": "x-vocab-extra.source_type.allowed\uFF08\u4EFB\u52A1\u4E66 02 \u6307\u4EE4\u7ED9\u5B9A\uFF09",
5711
- description: "\u5408\u6CD5\u6765\u6E90\u96C6\uFF0C\u4F9B Gate/Transition \u5C42\u5224\u522B\u5F15\u7528\u3002"
5709
+ enum: ["bp_blueprint", "design_seed", "human_directive", "owner_directive", "code_refactor", "prototype_walkthrough", "research_evidence", "openapi_contract"],
5710
+ "x-vocab-source": "x-vocab-extra.source_type.allowed\uFF08\u4EFB\u52A1\u4E66 02 \u6307\u4EE4\u7ED9\u5B9A\uFF1B2026-09-03 PR-0007 append-only \u589E\u503C owner_directive\u2014\u2014vocab-lock source_types \u6536\u7F16\uFF09",
5711
+ description: "\u5408\u6CD5\u6765\u6E90\u96C6\uFF0C\u4F9B Gate/Transition \u5C42\u5224\u522B\u5F15\u7528\u3002owner_directive=Owner \u660E\u4EE4\uFF08\u533A\u522B\u4E8E human_directive \u6CDB\u5316\u4EBA\u7C7B\u6307\u4EE4\u2014\u2014PR-0007 Owner \u6709\u610F\u8BCD\u5F62\u6536\u7F16\uFF0Cknowledge.web.browser.mcp_eyes \u7269\u6599 sources[].type \u5B9E\u5F55\uFF09\u3002"
5712
5712
  },
5713
5713
  SourceTypeForbidden: {
5714
5714
  title: "source.type forbidden \u4E24\u503C\uFF08\u53EF\u5224\u522B\xB7\u4E0D\u786C\u62E6\uFF09",
@@ -5718,12 +5718,12 @@ var init_object_envelope_schema = __esm({
5718
5718
  description: "provenance_check \u4F9D\u8D56\u5B57\u6BB5\uFF1A\u672C\u5B9A\u4E49\u4E0E SourceTypeAllowed \u5206\u79BB\uFF0C\u4F7F Gate \u5C42\u53EF\u7528 schema \u5224\u522B\u975E\u6CD5\u6765\u6E90\u3002D24 \u7CBE\u795E\uFF1A\u975E\u6CD5\u6765\u6E90\u5728 Transition \u5C42 FATAL \u5E76\u7559\u75D5\uFF0C\u672C\u4FE1\u5C01\u4E0D\u9760 schema \u9759\u9ED8\u62E6\u622A\u3001\u66F4\u4E0D\u9760\u54C8\u5E0C\u515C\u5E95\u3002"
5719
5719
  },
5720
5720
  SourceTypeAll: {
5721
- title: "source.type \u5168\u96C6\uFF08allowed \u222A forbidden = 9 \u503C\uFF09",
5721
+ title: "source.type \u5168\u96C6\uFF08allowed \u222A forbidden = 10 \u503C\uFF09",
5722
5722
  oneOf: [
5723
5723
  { $ref: "#/$definitions/SourceTypeAllowed" },
5724
5724
  { $ref: "#/$definitions/SourceTypeForbidden" }
5725
5725
  ],
5726
- "x-vocab-source": "x-vocab-extra.source_type.all = allowed + forbidden\uFF08\u4EFB\u52A1\u4E66 02 \u6307\u4EE4\u7ED9\u5B9A\uFF09",
5726
+ "x-vocab-source": "x-vocab-extra.source_type.all = allowed + forbidden\uFF08\u4EFB\u52A1\u4E66 02 \u6307\u4EE4\u7ED9\u5B9A\uFF1B2026-09-03 PR-0007 \u968F allowed \u589E\u503C owner_directive\uFF09",
5727
5727
  description: "\u5B57\u6BB5\u7EA6\u675F\u7528\u5168\u96C6\uFF08schema \u4E0D\u62E6\uFF09\uFF1B\u5224\u522B\u9700\u6C42\u7528\u4E24\u4E2A\u5B50\u96C6\u5B9A\u4E49\u3002"
5728
5728
  },
5729
5729
  Sha256Digest: {
@@ -5761,7 +5761,7 @@ var init_object_envelope_schema = __esm({
5761
5761
  properties: {
5762
5762
  type: {
5763
5763
  $ref: "#/$definitions/SourceTypeAll",
5764
- description: "9 \u503C\u5168\u96C6\uFF08\u542B forbidden \u4E24\u503C\uFF09\u3002provenance_check\uFF1Aforbidden \u4E24\u503C\u7ECF SourceTypeForbidden \u5B9A\u4E49\u53EF\u88AB Gate/Transition \u5C42\u5224\u522B\uFF1B\u672C schema \u4E0D\u62E6\uFF08FATAL \u8BED\u4E49\u5728 Transition \u5C42\uFF0CD24 \u7CBE\u795E\uFF09\u3002"
5764
+ description: "10 \u503C\u5168\u96C6\uFF08\u542B forbidden \u4E24\u503C\uFF1B2026-09-03 PR-0007 \u589E\u503C owner_directive\uFF09\u3002provenance_check\uFF1Aforbidden \u4E24\u503C\u7ECF SourceTypeForbidden \u5B9A\u4E49\u53EF\u88AB Gate/Transition \u5C42\u5224\u522B\uFF1B\u672C schema \u4E0D\u62E6\uFF08FATAL \u8BED\u4E49\u5728 Transition \u5C42\uFF0CD24 \u7CBE\u795E\uFF09\u3002"
5765
5765
  },
5766
5766
  ref: {
5767
5767
  type: "string",
@@ -11233,8 +11233,192 @@ var init_decision_graph_schema = __esm({
11233
11233
  }
11234
11234
  });
11235
11235
 
11236
+ // packages/schemas/dist/assets/19-software-graph-relations.schema.json
11237
+ var software_graph_relations_schema_default;
11238
+ var init_software_graph_relations_schema = __esm({
11239
+ "packages/schemas/dist/assets/19-software-graph-relations.schema.json"() {
11240
+ software_graph_relations_schema_default = {
11241
+ $schema: "http://json-schema.org/draft-07/schema#",
11242
+ $id: "https://pomaster.dev/schemas/software-graph-relations/v1-draft.json",
11243
+ title: "Software Graph Relations\uFF08Typed Relation sidecar \u53F0\u8D26 \xB7 P-v06 \u6279\u6B21 0 Model Constitution \xB7 PRD v0.6 \xA76-8 + Owner \u51B3\u8BAE D-3\uFF09",
11244
+ description: "Canonical Software Graph \u7684\u8FB9\u5E73\u9762\u843D\u5730\uFF08PRD v0.6 \xA76\u300CGraph \u4E0D\u662F\u7B2C\u516D\u539F\u8BED\uFF1BGraph \u662F Governed Object + Typed Relation \u7684\u4E3B\u8981\u5B9E\u73B0\u65B9\u5F0F\u300D\u9010\u5B57 + Owner \u88C1\u51B3 D-3 2026-09-02\u300Crelation sidecar + \u6D3E\u751F\u89C6\u56FE\u300D\uFF09\u3002\n\u5F62\u6001\u7EAA\u5F8B\uFF08\u7ED3\u6784\u6027\u4FDD\u4F4F\uFF09\uFF1A\u2460\u4E0D\u5EFA\u56FE\u6570\u636E\u5E93\u3001\u4E0D\u6539 01 truth-index\uFF08additionalProperties:false \u5C01\u6761\u4E0D\u52A8\uFF0CA8 \u5C01\u6B7B\u8FD0\u884C\u4EA7\u7269\u5165\u7D22\u5F15\uFF09\u2014\u2014\u8FB9\u4F4F .pomaster/state/relations.jsonl \u8FFD\u52A0\u6D41\u4FA7\u8F66\uFF08staged write \u540C\u65CF + journal RELATION_* \u4E8B\u4EF6\u6D41 + \u4E0D\u8FDB content_digest\uFF0Cequivalence-registry \u4FA7\u8F66\u5148\u4F8B\uFF09\uFF1B\u2461\u8FB9\u7AEF\u70B9\u53EF\u6307 governed id\uFF08truth \u9762\uFF0CA5 closed-world \u8FC7 parseGovernedId\uFF09\u6216 catalog \u6761\u76EE id\uFF08catalog \u9762\uFF0CD-2 \u88C1\u5B9A INSTANCE_OF \u8FB9\u7684 catalog \u4FA7\u7AEF\u70B9\uFF09\uFF1B\u2462\u8FB9 provenance \u6BCF\u8FB9\u5FC5\u7B54\u300C\u4E3A\u4EC0\u4E48\u5B58\u5728\u300D\uFF08PRD v0.6 \xA78 Graph Provenance\uFF1Aorigin/producer/locator/confidence/observed \u4E8B\u4EF6\u62CD\uFF1Bruntime_trace \u8FB9\u5FC5\u987B\u9644 OBS-n/POB-<12hex> observation_ref\u2014\u2014\u300CAgent \u5FC5\u987B\u8BC1\u660E\u6211\u770B\u8FC7\u300D\xA76.13 \u5C01\u6761\u7684\u8FB9\u4FA7\u955C\u50CF\uFF09\u3002",
11245
+ "x-pomaster-file-role": "19-software-graph-relations.schema.json \u2014\u2014 state/relations.jsonl \u4FA7\u8F66\u7684\u5F62\u6001\u5951\u7EA6\uFF08kernel relations.ts \u7EF4\u62A4\uFF0C\u5199\u5165\u552F\u4E00\u901A\u8DEF registerRelation\uFF1Bappend-only \u8FFD\u52A0\u6D41\uFF0CEDGE-<12hex> \u5185\u5BB9\u5BFB\u5740\u5E42\u7B49 dedupe\uFF09\u3002\u6D88\u8D39\u65B9 = Software Graph \u6D3E\u751F\u89C6\u56FE\uFF08dependencies/composition/runtime \u5168\u90E8\u4ECE\u672C\u9762\u6D3E\u751F\u2014\u2014projection \u7F1D3\uFF09\u3001Change Impact\uFF08\xA7106-108 reverse dependents\uFF09\u3001New Entity Gate\uFF08v0.6.1 \xA775 \u4E94\u5426\u8BC1\u660E\u7684\u56FE\u6D88\u8D39\u4F4D\uFF09\u3001ref-integrity \u540C\u65CF\u5B58\u5728\u6027\u6D88\u8D39 gate\u3002",
11246
+ "x-pomaster-vocab-source": "\u8BCD\u5F62\u8F74\u5DF2\u968F vocab-pr-0006 \u6536\u7F16 vocab-lock@v0.5-resolved \u4E3B\u8868 software_graph_vocab \u6BB5\uFF08Owner \u56DB\u51B3\u8BAE D-1~D-4 2026-09-02 \u6279\u51C6\uFF09\uFF1Arelation_type \u9996\u6279 8 \u503C\uFF08INSTANCE_OF/IMPLEMENTS/CONTAINS/CALLS/READS/WRITES/VERIFIED_BY/DERIVED_FROM\u2014\u2014PRD v0.6 \xA77 \u9010\u5B57 + D-2 \u8865\u4F4D\uFF1B\u300C\u53EA\u6536\u771F\u5B9E\u6D88\u8D39\u300D\uFF0C\u5176\u4F59 \xA77 \u8BCD\u5F62\u5F85\u771F\u5B9E\u6D88\u8D39\u8005\u9010\u6279 append-only \u589E\u8865\uFF09\uFF1Brelation_origin \u4E09\u503C\uFF08static_analysis/runtime_trace/human_declared\u2014\u2014PRD \xA78 source_type \u8BED\u4E49\u8FB9\u4FA7\u627F\u8F7D\uFF09\uFF1Brelation_endpoint_domain \u4E24\u503C\uFF08truth/catalog\u2014\u2014D-2\uFF09\uFF1Brelation_confidence \u4E09\u503C\uFF08deterministic/probable/declared\u2014\u2014PRD \xA78 confidence.deterministic \u4E09\u7EA7\u5316\uFF09\u3002EDGE-<12hex> \u662F\u901A\u8DEF\u7F16\u53F7\u8BCD\u5F62\uFF08EQG-/POB-/PBR- \u540C\u65CF\u5148\u4F8B\uFF1A\u5185\u5BB9\u5BFB\u5740 sha256 \u524D 12 hex\uFF0CA4 \u65E0\u5899\u949F\u65E0\u968F\u673A\uFF09\uFF0C\u975E governed \u524D\u7F00\uFF0C\u4E0D\u5165 id_namespace prefixes_v0 \u95ED\u5305\u3001\u4E0D\u8FC7 parseGovernedId\uFF08vocab-lock id_namespace.state_plane_refs PR-0006 \u6CE8\u8BB0\uFF09\u3002",
11247
+ "x-pomaster-contract": {
11248
+ not_a_sixth_primitive: "PRD v0.6 \xA76 \u9010\u5B57\uFF1AGraph \u4E0D\u662F\u7B2C\u516D\u539F\u8BED\u2014\u2014\u672C\u9762\u662F Governed Object + Typed Relation \u7684\u8FB9\u627F\u8F7D\u4FA7\u8F66\uFF1B\u8282\u70B9=\u65E2\u6709 truth-index \u5BF9\u8C61\u4E0E catalog \u6761\u76EE\uFF08\u96F6\u65B0\u8282\u70B9\u5B58\u50A8\uFF09\uFF0C\u8FB9=\u672C\u9762\u8FFD\u52A0\u6D41\uFF1Bdependencies/composition/runtime \u89C6\u56FE\u5168\u90E8\u6D3E\u751F\uFF08PRD \xA71.3 One Model Many Projections\uFF09\uFF0C\u4E0D\u5EFA\u7B2C\u4E8C\u5957\u8282\u70B9\u4E8B\u5B9E\u3002",
11249
+ derived_edges_stay_derived: "\u673A\u5668\u6D3E\u751F\u8FB9\uFF08origin=static_analysis/runtime_trace\uFF09\u662F Derived Facts\uFF08PRD \xA71.2\uFF09\u2014\u2014\u7531 analyzer/\u4F20\u611F\u5668\u7ECF kernel registerRelation \u8BED\u4E49\u5165\u53E3\u767B\u8BB0\uFF0C\u7981\u4EBA\u5DE5\u7EF4\u62A4 JSON \u590D\u5236\u4EE3\u7801\u4E8B\u5B9E\uFF08PRD \xA71.7 No JSON Hell\uFF09\uFF1B\u6765\u6E90\u4EE3\u7801\u53D8\u5316\u540E\u65E7\u8FB9\u4E0D\u81EA\u52A8\u5931\u6548\uFF08stale \u8BED\u4E49\u5F52\u6279\u6B21 2+ rebuild \u9762\uFF09\uFF0C\u4F46 provenance.recorded_at_seq + producer + locator \u4FDD\u8BC1\u6BCF\u8FB9\u53EF\u56DE\u6EAF\u91CD\u7B97\u3002",
11250
+ existence_judged_by_consumers: "\u300C\u672C\u9762\u53EA\u89E3\u6790\u547D\u540D\uFF0C\u5B58\u5728\u6027\u5F52\u6D88\u8D39\u9762\u300D\uFF08equivalence \u4E09\u817F\u94FE\u5148\u4F8B\uFF09\uFF1A\u88C5\u8F7D\u9762\u6821\u9A8C\u7AEF\u70B9\u8BCD\u5F62\u6587\u6CD5\uFF08truth \u7AEF\u70B9\u8FC7 governed id \u6587\u6CD5\uFF1Bcatalog \u7AEF\u70B9\u8BCD\u5F62\u6CD5\u5F0F\uFF09\uFF0C\u7AEF\u70B9\u5B58\u5728\u6027\u5224\u5377\u5F52\u6D88\u8D39 gate\uFF08ref-integrity \u540C\u65CF/\u65B0\u5B9E\u4F53\u95E8\u7981/loader \u5206\u6BCD\uFF09\u2014\u2014\u672C\u9762\u4E0D\u67E5\u518C\u3001\u4E0D\u731C\u6D4B\u3001\u4E0D\u88C1\u65AD\u3002",
11251
+ runtime_trace_seal: "origin=runtime_trace \u7684\u8FB9\u5FC5\u987B\u9644 observation_ref\uFF08allOf \u6761\u4EF6\u5F0F\u5C01\u6B7B\uFF09\uFF1AOBS-n\uFF08perception observation receipt \u901A\u8DEF\uFF09\u6216 POB-<12hex>\uFF08production observation \u53F0\u8D26\uFF09\u2014\u2014\u65E0\u89C2\u5BDF\u56DE\u6267\u7684\u300C\u8FD0\u884C\u65F6\u8FB9\u300D\u662F\u624B\u6539\u75D5\u8FF9\uFF08\u88C5\u8F7D\u9762 SCHEMA_INVALID\uFF09\u3002static_analysis/human_declared \u8FB9\u7981\u5E26 observation_ref\uFF08\u6765\u6E90\u9762\u4E92\u65A5\uFF09\u3002",
11252
+ append_only_idempotent: "EDGE-<12hex> = canonical \u5E8F\u5217\u5316 (source,type,target) \u7684 sha256 \u524D 12 hex\uFF08A4 \u65E0\u5899\u949F\u65E0\u968F\u673A\uFF1BPR-0004 POB- \u5185\u5BB9\u5BFB\u5740\u5148\u4F8B\uFF09\uFF1A\u540C (source,type,target) \u91CD\u767B\u8BB0 = \u540C id\uFF0CregisterRelation \u8BED\u4E49\u5165\u53E3 dedupe noop \u5E42\u7B49\uFF08analyzer \u91CD\u8DD1\u5B89\u5168\uFF09\uFF1B(source,type,target) \u76F8\u540C\u800C provenance \u76F8\u5F02\u7684\u91CD\u590D\u767B\u8BB0 = \u8C03\u7528\u65B9\u7F3A\u9677\uFF08SCHEMA_INVALID \u663E\u5F0F\u62D2\u7EDD\uFF0C\u7981\u9759\u9ED8\u8986\u76D6\uFF09\u3002",
11253
+ no_fake_green: "\u88C5\u8F7D\u9762\u9010\u884C fail-closed\uFF08\u7981\u9759\u9ED8\u8DF3\u8FC7\u574F\u884C\u2014\u2014\u574F\u884C=SCHEMA_INVALID \u6574\u4F53\u62D2\u7EDD\uFF09\uFF1Bconfidence=probable \u7684\u8FB9\u5FC5\u987B\u9644 uncertainty_note\uFF08\xA7148 Analyzer Output Contract\uFF1A\u975E\u786E\u5B9A\u6D3E\u751F\u5FC5\u987B\u62AB\u9732 unresolved/parse_failures \u4F4D\uFF09\uFF1B\u96F6\u8FB9\u662F\u5408\u6CD5\u72B6\u6001\uFF08\u7A7A\u56FE \u2260 \u76F2\u533A\u5192\u5145\u5168\u77E5\u2014\u2014\u5206\u6BCD\u62AB\u9732\u5F52\u6D88\u8D39\u9762\uFF09\u3002"
11254
+ },
11255
+ "x-pomaster-digest-ethics-policy": '\u672C\u5BF9\u8C61\u5F53\u524D\u4E0D\u542B sha256/digest \u5B57\u6BB5\uFF08EDGE-<12hex> \u662F\u5185\u5BB9\u5BFB\u5740 id \u8BCD\u5F62\uFF0C\u4E0D\u662F digest \u5B57\u6BB5\u2014\u2014D24 \u4F26\u7406\u540C\u6761\uFF1A\u57FA\u7840\u8BBE\u65BD\u8BA1\u7B97\u3001\u4EBA\u7C7B\u7981\u89E6\uFF09\u3002\u672A\u6765\u4EFB\u4F55 digest/sha256 \u5B57\u6BB5\u52A0\u5165\u65F6\u5FC5\u987B\u643A\u5E26 x-digest-ethics \u6CE8\u8BB0 {"write_blocking": false, "side": "read_only_service", "human_touch": "forbidden"}\uFF08D24 / vocab-lock digest_ethics\uFF09\u3002',
11256
+ type: "object",
11257
+ additionalProperties: false,
11258
+ required: ["version", "entries"],
11259
+ properties: {
11260
+ version: {
11261
+ type: "integer",
11262
+ const: 1,
11263
+ title: "\u53F0\u8D26\u6587\u4EF6\u7248\u672C\uFF08version\uFF09"
11264
+ },
11265
+ entries: {
11266
+ type: "array",
11267
+ items: { $ref: "#/definitions/relation_entry" },
11268
+ title: "\u5173\u7CFB\u8FB9\u6761\u76EE\u5217\u8868\uFF08entries\uFF1B.pomaster/state/relations.jsonl \u9010\u884C\u4E00\u6761\uFF09",
11269
+ description: "\u7A7A\u6570\u7EC4\u5408\u6CD5\uFF08\u96F6\u8FB9=\u5408\u6CD5\u72B6\u6001\uFF0C\u7981\u76F2\u533A\u5192\u5145\u5168\u77E5\uFF09\u3002edge_id \u5168\u57DF\u552F\u4E00\uFF08\u5185\u5BB9\u5BFB\u5740\u540C id \u5E42\u7B49\uFF09\uFF1B(source,type,target) \u4E09\u5143\u7EC4\u5168\u57DF\u552F\u4E00\u3002"
11270
+ }
11271
+ },
11272
+ definitions: {
11273
+ relation_entry: {
11274
+ type: "object",
11275
+ additionalProperties: false,
11276
+ required: ["edge_id", "type", "source", "target", "origin", "confidence", "producer", "provenance"],
11277
+ allOf: [
11278
+ {
11279
+ if: {
11280
+ properties: { origin: { const: "runtime_trace" } },
11281
+ required: ["origin"]
11282
+ },
11283
+ then: {
11284
+ properties: {
11285
+ provenance: {
11286
+ type: "object",
11287
+ properties: {
11288
+ observation_ref: { type: "string", minLength: 1 }
11289
+ },
11290
+ required: ["observation_ref"]
11291
+ }
11292
+ },
11293
+ description: "runtime_trace \u5C01\u6761\uFF1A\u8FD0\u884C\u65F6\u8FB9\u5FC5\u987B\u9644\u89C2\u5BDF\u56DE\u6267\u5F15\u7528\uFF08OBS-n / POB-<12hex> \u8BCD\u5F62\uFF0Ckernel \u88C5\u8F7D\u9762\u6821\u9A8C\uFF09\u2014\u2014\u300CAgent \u5FC5\u987B\u8BC1\u660E\u6211\u770B\u8FC7\u300D\uFF08\xA76.13\uFF09\u7684\u8FB9\u4FA7\u955C\u50CF\u3002"
11294
+ }
11295
+ },
11296
+ {
11297
+ if: {
11298
+ properties: { origin: { enum: ["static_analysis", "human_declared"] } },
11299
+ required: ["origin"]
11300
+ },
11301
+ then: {
11302
+ properties: {
11303
+ provenance: {
11304
+ type: "object",
11305
+ properties: { observation_ref: { type: "null" } }
11306
+ }
11307
+ },
11308
+ description: "\u6765\u6E90\u9762\u4E92\u65A5\uFF1Astatic_analysis/human_declared \u8FB9\u7981\u5E26 observation_ref\uFF08\u975E null \u5373\u624B\u6539\u75D5\u8FF9\uFF09\u3002"
11309
+ }
11310
+ },
11311
+ {
11312
+ if: {
11313
+ properties: { confidence: { const: "probable" } },
11314
+ required: ["confidence"]
11315
+ },
11316
+ then: {
11317
+ properties: {
11318
+ uncertainty_note: { type: "string", minLength: 1 }
11319
+ },
11320
+ required: ["uncertainty_note"],
11321
+ description: "probable \u5C01\u6761\uFF08\xA7148 Analyzer Output Contract\uFF09\uFF1A\u975E\u786E\u5B9A\u6D3E\u751F\u5FC5\u987B\u62AB\u9732\u4E0D\u786E\u5B9A\u6027\u6CE8\u8BB0\uFF08unresolved/parse_failures \u4F4D\uFF09\u2014\u2014\u7981\u628A\u63A8\u6D4B\u5305\u88C5\u6210\u786E\u5B9A\u3002"
11322
+ }
11323
+ }
11324
+ ],
11325
+ properties: {
11326
+ edge_id: {
11327
+ type: "string",
11328
+ pattern: "^EDGE-[0-9a-f]{12}$",
11329
+ title: "\u8FB9\u901A\u8DEF\u7F16\u53F7\uFF08EDGE-<12hex>\uFF1B\u5185\u5BB9\u5BFB\u5740 sha256 \u524D 12 hex\u2014\u2014canonical (source,type,target) \u5E8F\u5217\u5316\uFF0CA4 \u65E0\u5899\u949F\u65E0\u968F\u673A\uFF09",
11330
+ description: "EQG-/POB-/PBR- \u540C\u65CF\u901A\u8DEF\u8BCD\u5F62\uFF1A\u975E governed \u524D\u7F00\uFF0C\u4E0D\u5165 id_namespace prefixes_v0 \u95ED\u5305\u3001\u4E0D\u8FC7 parseGovernedId\uFF08vocab-lock id_namespace.state_plane_refs PR-0006 \u6CE8\u8BB0\uFF09\u3002\u5168\u57DF\u552F\u4E00\uFF1B\u540C\u4E09\u5143\u7EC4\u91CD\u767B\u8BB0\u540C id\uFF08\u5E42\u7B49 dedupe\uFF09\u3002"
11331
+ },
11332
+ type: {
11333
+ type: "string",
11334
+ enum: ["INSTANCE_OF", "IMPLEMENTS", "CONTAINS", "CALLS", "READS", "WRITES", "VERIFIED_BY", "DERIVED_FROM"],
11335
+ title: "\u5173\u7CFB\u7C7B\u578B\uFF08relation_type \u8BCD\u8868\u9996\u6279 8 \u503C\u2014\u2014vocab-lock software_graph_vocab.relation_type\uFF0CPR-0006 \u6536\u7F16\uFF1B\u6269\u503C\u8D70\u8BCD\u6C47\u8868 PR\uFF09",
11336
+ description: "MAPS_TO_SOURCE \u8BED\u4E49\u7531\u65E2\u6709 key_bindings \u627F\u8F7D\uFF08D15\uFF09\uFF1BSUPERSEDES \u8BED\u4E49\u7531\u4FE1\u5C01 supersedes/successor_ref \u627F\u8F7D\u2014\u2014\u65E2\u6709\u673A\u5236\u5DF2\u6709\u627F\u8F7D\u4F4D\u7684 PRD \xA77 \u8BCD\u5F62\u4E0D\u91CD\u590D\u767B\u8BB0\u3002"
11337
+ },
11338
+ source: { $ref: "#/definitions/relation_endpoint" },
11339
+ target: { $ref: "#/definitions/relation_endpoint" },
11340
+ origin: {
11341
+ type: "string",
11342
+ enum: ["static_analysis", "runtime_trace", "human_declared"],
11343
+ title: "\u8FB9\u6765\u6E90\uFF08relation_origin \u8BCD\u8868\u4E09\u503C\u2014\u2014PRD v0.6 \xA78 Graph Provenance source_type \u8BED\u4E49\u7684\u8FB9\u4FA7\u627F\u8F7D\uFF09"
11344
+ },
11345
+ confidence: {
11346
+ type: "string",
11347
+ enum: ["deterministic", "probable", "declared"],
11348
+ title: "\u8FB9\u7F6E\u4FE1\uFF08relation_confidence \u8BCD\u8868\u4E09\u7EA7\u2014\u2014PRD \xA78 confidence.deterministic \u4E09\u7EA7\u5316 + \xA7148 analyzer confidence \u4F4D\uFF09",
11349
+ description: "\u4E0E state_axes.confidence\uFF08\u5BF9\u8C61\u6CBB\u7406\u8F74\uFF09\u6B63\u4EA4\u3001\u503C\u57DF\u4E0D\u76F8\u4EA4\u7981\u6DF7\u7528\u3002"
11350
+ },
11351
+ producer: {
11352
+ type: "string",
11353
+ pattern: "^[A-Z][A-Z0-9_.\\-]{0,63}$",
11354
+ title: "\u4EA7\u51FA\u8005\u8BCD\u5F62\uFF08ANALYZER.* / SENSOR.* / AGENT.* / \u4EBA\u7C7B\u4E3B\u4F53\u8BCD\u5F62\u2014\u2014\u6BCF\u8FB9\u5FC5\u7B54\u300C\u8C01\u4EA7\u51FA\u7684\u300D\uFF0CPRD \xA78 provenance.producer\uFF09",
11355
+ examples: ["ANALYZER.TS.IMPORT_GRAPH", "SENSOR.OTEL.TRACE", "human:owner"]
11356
+ },
11357
+ uncertainty_note: {
11358
+ type: ["string", "null"],
11359
+ title: "\u4E0D\u786E\u5B9A\u6027\u6CE8\u8BB0\uFF08confidence=probable \u65F6\u5FC5\u586B\u2014\u2014\xA7148 \u62AB\u9732\u4F4D\uFF1B\u5176\u4F59\u6052 null\uFF09"
11360
+ },
11361
+ provenance: { $ref: "#/definitions/relation_provenance" },
11362
+ note: {
11363
+ type: ["string", "null"],
11364
+ title: "\u4EBA\u7C7B\u6563\u6587\u6CE8\u8BB0\uFF08\u53EA\u767B\u8BB0\u4E0D\u89E3\u6790\uFF1BP9 \u7EAA\u5F8B\uFF09"
11365
+ }
11366
+ }
11367
+ },
11368
+ relation_endpoint: {
11369
+ type: "object",
11370
+ additionalProperties: false,
11371
+ required: ["domain", "id"],
11372
+ properties: {
11373
+ domain: {
11374
+ type: "string",
11375
+ enum: ["truth", "catalog"],
11376
+ title: "\u7AEF\u70B9\u57DF\uFF08relation_endpoint_domain \u8BCD\u8868\u4E24\u503C\u2014\u2014D-2\uFF1Atruth \u9762 governed id / catalog \u9762\u6761\u76EE id\uFF09"
11377
+ },
11378
+ id: {
11379
+ type: "string",
11380
+ minLength: 1,
11381
+ title: "\u7AEF\u70B9 id\uFF08truth=PREFIX.SEGMENT(.SEGMENT)*[.SEQ] canonical governed id\uFF1Bcatalog=\u6761\u76EE id \u8BCD\u5F62\u5982 ARCHETYPE.BACKEND.CRUD_RESOURCE\uFF09",
11382
+ description: "truth \u7AEF\u70B9\u6587\u6CD5\u6821\u9A8C\u5F52 kernel \u88C5\u8F7D\u9762\uFF08parseGovernedId \u540C\u6CD5\uFF09\uFF1B\u5B58\u5728\u6027\uFF08truth-index \u67E5\u518C / catalog-lock \u5206\u6BCD\uFF09\u5F52\u6D88\u8D39 gate\u2014\u2014\u672C\u9762\u53EA\u89E3\u6790\u547D\u540D\u3002"
11383
+ }
11384
+ }
11385
+ },
11386
+ relation_provenance: {
11387
+ type: "object",
11388
+ additionalProperties: false,
11389
+ required: ["recorded_at_seq", "source_ref"],
11390
+ properties: {
11391
+ recorded_at_seq: {
11392
+ type: "integer",
11393
+ minimum: 0,
11394
+ title: "\u767B\u8BB0\u4E8B\u4EF6\u62CD\uFF08A4 \u7981\u5899\u949F\uFF1B11-exception-ledger recorded_at_seq \u5148\u4F8B\uFF09"
11395
+ },
11396
+ source_ref: {
11397
+ type: "string",
11398
+ minLength: 1,
11399
+ title: "\u767B\u8BB0\u51FA\u5904\u951A\uFF08\u6BCF\u6761\u88C1\u5B9A\u6CE8\u8BB0\u51FA\u5904\u951A\u7EAA\u5F8B\uFF1A\u6E90\u6587\u4EF6:\u884C / PRD \xA7\u53F7 / GRN \u5F15\u7528 / \u58F0\u660E\u51B3\u8BAE\u5F15\u7528\uFF09"
11400
+ },
11401
+ locator: {
11402
+ type: ["string", "null"],
11403
+ title: "\u6E90\u5B9A\u4F4D\uFF08static_analysis\uFF1Afile:line\uFF1Bruntime_trace\uFF1Aspan/trace \u951A\uFF1Bhuman_declared\uFF1A\u51B3\u8BAE\u951A\u2014\u2014PRD \xA78 source_location\uFF09"
11404
+ },
11405
+ observation_ref: {
11406
+ type: ["string", "null"],
11407
+ title: "\u89C2\u5BDF\u56DE\u6267\u5F15\u7528\uFF08runtime_trace \u5FC5\u586B\uFF1AOBS-n \u6216 POB-<12hex>\uFF1B\u5176\u4F59 origin \u6052 null\u2014\u2014\u6765\u6E90\u9762\u4E92\u65A5\u5C01\u6761\uFF09"
11408
+ },
11409
+ declared_by: {
11410
+ type: ["string", "null"],
11411
+ title: "\u58F0\u660E\u4E3B\u4F53\uFF08human_declared \u65F6\u767B\u8BB0\u8C01\u58F0\u660E\u2014\u2014C5 \u81EA\u62A5\u53EA\u767B\u8BB0\u4E8B\u5B9E\u4E0D\u5224\u771F\uFF1B\u5176\u4F59\u6052 null\uFF09"
11412
+ }
11413
+ }
11414
+ }
11415
+ }
11416
+ };
11417
+ }
11418
+ });
11419
+
11236
11420
  // packages/schemas/dist/src/vocab.js
11237
- var IR_SCHEMA_DIALECT, LIFECYCLE_VALUES, CONFIDENCE_VALUES, EVIDENCE_VALUES, CHANGE_VALUES, LIFECYCLE_TRANSITIONS, SOURCE_TYPE_ALL_VALUES, SOURCE_TYPE_FORBIDDEN_VALUES, GOVERNED_ID_PREFIXES, ALIASES_V0, TRUTH_BODY_KINDS, CATALOG_ENFORCEMENT_VALUES, CATALOG_CLASSIFICATION_VALUES, CATALOG_LANE_VALUES, CATALOG_CHANGE_CLASS_VALUES, CATALOG_GOVERNANCE_PROFILE_VALUES, RECONCILE_DELTA_KINDS, VERDICT_VALUES, ORIGIN_VALUES, VERIFICATION_VERDICT_VALUES, PRODUCER_KIND_VALUES, ACTOR_TYPE_VALUES, RUN_TRIGGER_VALUES, DENOMINATOR_STATUS_VALUES, DISCOVERY_CHAIN_VALUES, DISCOVERY_CHAIN_TRANSITIONS, DISCOVERY_PROMOTION_BASIS_VALUES, BLUEPRINT_ENVELOPE_STATUS_VALUES, RESEARCH_FINDING_CONFIDENCE_VALUES, RESEARCH_EVIDENCE_LEVEL_VALUES, RESEARCH_AUTHORITY_EFFECT_VALUES, RESEARCH_MODE_VALUES, EXCEPTION_CLASSIFICATION_VALUES, KNOWLEDGE_KIND_VALUES, KNOWLEDGE_STATUS_VALUES, KNOWLEDGE_TRANSITIONS, KNOWLEDGE_PROMOTION_AUTHORITY_VALUES, KNOWLEDGE_CONFIDENCE_VALUES, EXECUTION_RUNTIME_VALUES, EXECUTION_IDENTITY_KIND_VALUES, EXECUTION_ROLE_VALUES, LOCK_KIND_VALUES, AGENT_ROLE_POOL_VALUES, RUNTIME_CAPABILITY_VALUES, RUNTIME_DEGRADATION_RULE_IDS, WORD_FORM_DOMAIN_VALUES, EQUIVALENCE_STATUS_VALUES, PORTABILITY_CANONICAL_SET_VALUES, PORTABILITY_RUNTIME_REBUILD_VALUES, PORTABILITY_FORBIDDEN_DEPENDENCY_VALUES, MEMORY_DRIFT, HARVEST_BUCKET_VALUES, HARVEST_PRIMARY_BUCKETS, HARVEST_SPECIAL_EXIT_VALUES, MEMORY_CLASS_VALUES, REVIEW_STATE_VALUES, HARVEST_SOURCE_VALUES, HARVEST_CONFIDENCE_VALUES, MEMORY_CLI_ERROR_VALUES, OWNER_ESCALATION_REQUIRED, PHASE_TIMELINE_VALUES, PRODUCTION_SIGNAL_SOURCE_VALUES, DIAGNOSIS_KIND_VALUES, BAND_PREDICATE_OPERATOR_VALUES, CONTROL_BAND_EVALUATION_STATUS_VALUES, CAPABILITY_OUTCOME_METRIC_STATUS_VALUES, CAPABILITY_OUTCOME_METRIC_KEY_VALUES, SELF_IMPROVEMENT_SIGNAL_VALUES, SELF_IMPROVEMENT_SIGNAL_PRD_LABELS, POMASTER_SELF_IMPROVEMENT_CANDIDATE, DETECTED_BY_TOOL_SIGNAL, PRODUCTION_CLI_ERROR_VALUES;
11421
+ var IR_SCHEMA_DIALECT, LIFECYCLE_VALUES, CONFIDENCE_VALUES, EVIDENCE_VALUES, CHANGE_VALUES, LIFECYCLE_TRANSITIONS, SOURCE_TYPE_ALL_VALUES, SOURCE_TYPE_FORBIDDEN_VALUES, GOVERNED_ID_PREFIXES, ALIASES_V0, TRUTH_BODY_KINDS, CATALOG_ENFORCEMENT_VALUES, CATALOG_CLASSIFICATION_VALUES, CATALOG_LANE_VALUES, CATALOG_CHANGE_CLASS_VALUES, CATALOG_GOVERNANCE_PROFILE_VALUES, RECONCILE_DELTA_KINDS, VERDICT_VALUES, ORIGIN_VALUES, VERIFICATION_VERDICT_VALUES, PRODUCER_KIND_VALUES, ACTOR_TYPE_VALUES, RUN_TRIGGER_VALUES, DENOMINATOR_STATUS_VALUES, DISCOVERY_CHAIN_VALUES, DISCOVERY_CHAIN_TRANSITIONS, DISCOVERY_PROMOTION_BASIS_VALUES, BLUEPRINT_ENVELOPE_STATUS_VALUES, RESEARCH_FINDING_CONFIDENCE_VALUES, RESEARCH_EVIDENCE_LEVEL_VALUES, RESEARCH_AUTHORITY_EFFECT_VALUES, RESEARCH_MODE_VALUES, EXCEPTION_CLASSIFICATION_VALUES, KNOWLEDGE_KIND_VALUES, KNOWLEDGE_STATUS_VALUES, KNOWLEDGE_TRANSITIONS, KNOWLEDGE_PROMOTION_AUTHORITY_VALUES, KNOWLEDGE_CONFIDENCE_VALUES, EXECUTION_RUNTIME_VALUES, EXECUTION_IDENTITY_KIND_VALUES, EXECUTION_ROLE_VALUES, LOCK_KIND_VALUES, AGENT_ROLE_POOL_VALUES, RUNTIME_CAPABILITY_VALUES, RUNTIME_DEGRADATION_RULE_IDS, WORD_FORM_DOMAIN_VALUES, EQUIVALENCE_STATUS_VALUES, PORTABILITY_CANONICAL_SET_VALUES, PORTABILITY_RUNTIME_REBUILD_VALUES, PORTABILITY_FORBIDDEN_DEPENDENCY_VALUES, MEMORY_DRIFT, HARVEST_BUCKET_VALUES, HARVEST_PRIMARY_BUCKETS, HARVEST_SPECIAL_EXIT_VALUES, MEMORY_CLASS_VALUES, REVIEW_STATE_VALUES, HARVEST_SOURCE_VALUES, HARVEST_CONFIDENCE_VALUES, MEMORY_CLI_ERROR_VALUES, OWNER_ESCALATION_REQUIRED, PHASE_TIMELINE_VALUES, PRODUCTION_SIGNAL_SOURCE_VALUES, DIAGNOSIS_KIND_VALUES, BAND_PREDICATE_OPERATOR_VALUES, CONTROL_BAND_EVALUATION_STATUS_VALUES, CAPABILITY_OUTCOME_METRIC_STATUS_VALUES, CAPABILITY_OUTCOME_METRIC_KEY_VALUES, SELF_IMPROVEMENT_SIGNAL_VALUES, SELF_IMPROVEMENT_SIGNAL_PRD_LABELS, POMASTER_SELF_IMPROVEMENT_CANDIDATE, DETECTED_BY_TOOL_SIGNAL, PRODUCTION_CLI_ERROR_VALUES, RELATION_TYPE_VALUES, RELATION_ORIGIN_VALUES, RELATION_ENDPOINT_DOMAIN_VALUES, RELATION_CONFIDENCE_VALUES, SUBSTRATE_LAYER_VALUES, RESOLUTION_MATCH_CLASS_VALUES, OBJECT_FAMILY_VALUES, CATALOG_KIND_VALUES;
11238
11422
  var init_vocab = __esm({
11239
11423
  "packages/schemas/dist/src/vocab.js"() {
11240
11424
  "use strict";
@@ -11267,6 +11451,7 @@ var init_vocab = __esm({
11267
11451
  "bp_blueprint",
11268
11452
  "design_seed",
11269
11453
  "human_directive",
11454
+ "owner_directive",
11270
11455
  "code_refactor",
11271
11456
  "prototype_walkthrough",
11272
11457
  "prototype_html_scrape",
@@ -11669,6 +11854,65 @@ var init_vocab = __esm({
11669
11854
  "EVIDENCE_NOT_FOUND",
11670
11855
  "DIAGNOSIS_WITHOUT_BREACH_EVIDENCE"
11671
11856
  ];
11857
+ RELATION_TYPE_VALUES = [
11858
+ "INSTANCE_OF",
11859
+ "IMPLEMENTS",
11860
+ "CONTAINS",
11861
+ "CALLS",
11862
+ "READS",
11863
+ "WRITES",
11864
+ "VERIFIED_BY",
11865
+ "DERIVED_FROM"
11866
+ ];
11867
+ RELATION_ORIGIN_VALUES = [
11868
+ "static_analysis",
11869
+ "runtime_trace",
11870
+ "human_declared"
11871
+ ];
11872
+ RELATION_ENDPOINT_DOMAIN_VALUES = ["truth", "catalog"];
11873
+ RELATION_CONFIDENCE_VALUES = [
11874
+ "deterministic",
11875
+ "probable",
11876
+ "declared"
11877
+ ];
11878
+ SUBSTRATE_LAYER_VALUES = [
11879
+ "FOUNDATION",
11880
+ "PRIMITIVE",
11881
+ "PATTERN",
11882
+ "ARCHETYPE",
11883
+ "REFERENCE_SOLUTION",
11884
+ "PROJECT_BASELINE",
11885
+ "BUSINESS_DELTA"
11886
+ ];
11887
+ RESOLUTION_MATCH_CLASS_VALUES = [
11888
+ "EXACT_MATCH",
11889
+ "CONFIGURABLE_MATCH",
11890
+ "COMPOSABLE_MATCH",
11891
+ "EXTENSIBLE_MATCH",
11892
+ "REFERENCE_MATCH",
11893
+ "NO_MATCH"
11894
+ ];
11895
+ OBJECT_FAMILY_VALUES = [
11896
+ "PRODUCT",
11897
+ "UI",
11898
+ "INTERFACE",
11899
+ "CODE",
11900
+ "DATA",
11901
+ "RUNTIME",
11902
+ "RESOURCE",
11903
+ "RELIABILITY",
11904
+ "SECURITY",
11905
+ "DELIVERY",
11906
+ "GOVERNANCE",
11907
+ "EVIDENCE"
11908
+ ];
11909
+ CATALOG_KIND_VALUES = [
11910
+ "policy",
11911
+ "gate_recipe",
11912
+ "sensor_capability",
11913
+ "knowledge_entry",
11914
+ "archetype"
11915
+ ];
11672
11916
  }
11673
11917
  });
11674
11918
 
@@ -11698,7 +11942,7 @@ function performanceBudgetPropertyNames() {
11698
11942
  }
11699
11943
  return Object.keys(properties).sort();
11700
11944
  }
11701
- var TRUTH_INDEX_ID, OBJECT_ENVELOPE_ID, GATE_RESULT_ID, KEYBINDING_ID, DENOMINATOR_ID, PRODUCER_ID, EVIDENCE_RECORDS_ID, DISCOVERY_STATE_CHAIN_ID, MSD_UNCERTAINTY_ID, RESEARCH_ARTIFACT_ID, EXCEPTION_LEDGER_ID, KNOWLEDGE_ENTRY_ID, EQUIVALENCE_REGISTRY_ID, MEMORY_HARVEST_ID, PRODUCTION_BAND_ID, EXECUTION_TRACE_ID, PERCEPTION_RECEIPTS_ID, DECISION_GRAPH_ID, truthIndexSchema, objectEnvelopeSchema, gateResultSchema, keybindingSchema, denominatorSchema, producerSchema, evidenceRecordsSchema, discoveryStateChainSchema, msdUncertaintySchema, researchArtifactSchema, exceptionLedgerSchema, knowledgeEntrySchema, equivalenceRegistrySchema, memoryHarvestSchema, productionBandSchema, executionTraceSchema, perceptionReceiptsSchema, decisionGraphSchema, allSchemas, performanceBudgetDefinition, PERFORMANCE_BUDGET_FIELDS;
11945
+ var TRUTH_INDEX_ID, OBJECT_ENVELOPE_ID, GATE_RESULT_ID, KEYBINDING_ID, DENOMINATOR_ID, PRODUCER_ID, EVIDENCE_RECORDS_ID, DISCOVERY_STATE_CHAIN_ID, MSD_UNCERTAINTY_ID, RESEARCH_ARTIFACT_ID, EXCEPTION_LEDGER_ID, KNOWLEDGE_ENTRY_ID, EQUIVALENCE_REGISTRY_ID, MEMORY_HARVEST_ID, PRODUCTION_BAND_ID, EXECUTION_TRACE_ID, PERCEPTION_RECEIPTS_ID, DECISION_GRAPH_ID, SOFTWARE_GRAPH_RELATIONS_ID, truthIndexSchema, objectEnvelopeSchema, gateResultSchema, keybindingSchema, denominatorSchema, producerSchema, evidenceRecordsSchema, discoveryStateChainSchema, msdUncertaintySchema, researchArtifactSchema, exceptionLedgerSchema, knowledgeEntrySchema, equivalenceRegistrySchema, memoryHarvestSchema, productionBandSchema, executionTraceSchema, perceptionReceiptsSchema, decisionGraphSchema, softwareGraphRelationsSchema, allSchemas, performanceBudgetDefinition, PERFORMANCE_BUDGET_FIELDS;
11702
11946
  var init_src = __esm({
11703
11947
  "packages/schemas/dist/src/index.js"() {
11704
11948
  "use strict";
@@ -11720,6 +11964,7 @@ var init_src = __esm({
11720
11964
  init_execution_trace_schema();
11721
11965
  init_perception_receipts_schema();
11722
11966
  init_decision_graph_schema();
11967
+ init_software_graph_relations_schema();
11723
11968
  init_vocab();
11724
11969
  TRUTH_INDEX_ID = "https://pomaster.dev/schemas/truth-index/v1-draft.json";
11725
11970
  OBJECT_ENVELOPE_ID = "https://pomaster.dev/schemas/object-envelope/v1-draft.json";
@@ -11739,6 +11984,7 @@ var init_src = __esm({
11739
11984
  EXECUTION_TRACE_ID = "https://pomaster.dev/schemas/execution-trace/v1-draft.json";
11740
11985
  PERCEPTION_RECEIPTS_ID = "https://pomaster.dev/schemas/perception-receipts/v1-draft.json";
11741
11986
  DECISION_GRAPH_ID = "https://pomaster.dev/schemas/decision-graph/v1-draft.json";
11987
+ SOFTWARE_GRAPH_RELATIONS_ID = "https://pomaster.dev/schemas/software-graph-relations/v1-draft.json";
11742
11988
  truthIndexSchema = asSchema(truth_index_schema_default, TRUTH_INDEX_ID);
11743
11989
  objectEnvelopeSchema = asSchema(object_envelope_schema_default, OBJECT_ENVELOPE_ID);
11744
11990
  gateResultSchema = asSchema(gate_result_schema_default, GATE_RESULT_ID);
@@ -11757,6 +12003,7 @@ var init_src = __esm({
11757
12003
  executionTraceSchema = asSchema(execution_trace_schema_default, EXECUTION_TRACE_ID);
11758
12004
  perceptionReceiptsSchema = asSchema(perception_receipts_schema_default, PERCEPTION_RECEIPTS_ID);
11759
12005
  decisionGraphSchema = asSchema(decision_graph_schema_default, DECISION_GRAPH_ID);
12006
+ softwareGraphRelationsSchema = asSchema(software_graph_relations_schema_default, SOFTWARE_GRAPH_RELATIONS_ID);
11760
12007
  allSchemas = {
11761
12008
  truthIndex: truthIndexSchema,
11762
12009
  objectEnvelope: objectEnvelopeSchema,
@@ -11775,7 +12022,8 @@ var init_src = __esm({
11775
12022
  productionBand: productionBandSchema,
11776
12023
  executionTrace: executionTraceSchema,
11777
12024
  perceptionReceipts: perceptionReceiptsSchema,
11778
- decisionGraph: decisionGraphSchema
12025
+ decisionGraph: decisionGraphSchema,
12026
+ softwareGraphRelations: softwareGraphRelationsSchema
11779
12027
  };
11780
12028
  performanceBudgetDefinition = definitionOf(objectEnvelopeSchema, "PerformanceBudget");
11781
12029
  PERFORMANCE_BUDGET_FIELDS = performanceBudgetPropertyNames();
@@ -18869,6 +19117,7 @@ function buildStorePaths(rootDir) {
18869
19117
  knowledgeLibraryPath: `${stateDir}/knowledge-library.json`,
18870
19118
  equivalenceRegistryPath: `${stateDir}/equivalence-registry.json`,
18871
19119
  linkageCoveragePath: `${stateDir}/linkage-coverage.json`,
19120
+ relationsPath: `${stateDir}/relations.jsonl`,
18872
19121
  journalPath: `${stateDir}/journal.jsonl`,
18873
19122
  truthObjectsDir: `${pomasterDir}/truth/objects`,
18874
19123
  evidenceDir,
@@ -20902,7 +21151,7 @@ function applyUpsertObject(workspace, envelope, tx) {
20902
21151
  }
20903
21152
  for (const source of sources) {
20904
21153
  const entry = source;
20905
- assertVocabValue2(entry.type, SOURCE_TYPE_ALL_VALUES, "sources[].type", `9 \u503C\u5168\u96C6\uFF1A${SOURCE_TYPE_ALL_VALUES.join(" / ")}\uFF1Bforbidden \u4E24\u503C\u987B\u8D70\u5408\u6CD5\u901A\u9053\uFF08\u5982 Live Walkthrough\uFF09`);
21154
+ assertVocabValue2(entry.type, SOURCE_TYPE_ALL_VALUES, "sources[].type", `10 \u503C\u5168\u96C6\uFF1A${SOURCE_TYPE_ALL_VALUES.join(" / ")}\uFF1Bforbidden \u4E24\u503C\u987B\u8D70\u5408\u6CD5\u901A\u9053\uFF08\u5982 Live Walkthrough\uFF09`);
20906
21155
  if (SOURCE_TYPE_FORBIDDEN_VALUES.includes(entry.type)) {
20907
21156
  throw new GovernanceError("SOURCE_TYPE_FORBIDDEN", `sources[].type="${String(entry.type)}" \u5C5E forbidden \u6765\u6E90`, "prototype_html_scrape\u2192Live Walkthrough \u6D3B\u4F53\u8D70\u67E5\uFF08D23\uFF09\uFF1Bai_invention\u2192\u8865 bp_blueprint/research_evidence \u7B49\u5408\u6CD5\u6765\u6E90\u540E\u91CD\u63D0\uFF08GOLDEN-L3-SCRAPE-FATAL\uFF09", { type: entry.type, id });
20908
21157
  }
@@ -24310,13 +24559,13 @@ function readCatalogLock(catalogRoot) {
24310
24559
  const lockPath = join3(catalogRoot, LOCK_FILE_NAME);
24311
24560
  const raw = readText(lockPath);
24312
24561
  if (raw === null) {
24313
- throw new GovernanceError("NOT_CONFIGURED", `catalog-lock \u7F3A\u5931: ${LOCK_FILE_NAME}`, "catalog-lock \u662F catalog \u7269\u6599\u7684 read-side \u6307\u7EB9\uFF08D24\uFF09\uFF1B\u5148\u8DD1 catalog/tools/materialize_*.py \u7269\u5316\u5E76\u91CD\u9501\u3002", { lockPath });
24562
+ throw new GovernanceError("NOT_CONFIGURED", `catalog-lock \u7F3A\u5931: ${LOCK_FILE_NAME}`, "catalog-lock \u662F catalog \u7269\u6599\u7684 read-side \u6307\u7EB9\uFF08D24\uFF09\uFF1B\u6062\u590D\u952E = pomaster catalog relock \u5E42\u7B49\u91CD\u9501\uFF08lock \u7F3A\u5931\u5F62\u6001 relock \u62D2\u7EDD\u521D\u59CB\u5316\u2014\u2014\u9700\u5148\u91CD\u8DD1 catalog/tools/materialize_*.py \u7269\u5316\u91CD\u751F\u6210\uFF09\u3002", { lockPath });
24314
24563
  }
24315
24564
  let parsed;
24316
24565
  try {
24317
24566
  parsed = JSON.parse(raw);
24318
24567
  } catch (error) {
24319
- throw new GovernanceError("SCHEMA_INVALID", `catalog-lock \u4E0D\u53EF\u89E3\u6790\uFF08JSON \u574F\u5F62\uFF09: ${LOCK_FILE_NAME}`, "catalog-lock \u88AB\u624B\u6539\u574F\uFF1A\u91CD\u8DD1 catalog/tools/materialize_*.py \u5E42\u7B49\u91CD\u751F\u6210\u3002", { lockPath, cause: String(error) });
24568
+ throw new GovernanceError("SCHEMA_INVALID", `catalog-lock \u4E0D\u53EF\u89E3\u6790\uFF08JSON \u574F\u5F62\uFF09: ${LOCK_FILE_NAME}`, "catalog-lock \u88AB\u624B\u6539\u574F\uFF1A\u6062\u590D\u952E = pomaster catalog relock\uFF08\u5E42\u7B49\u91CD\u9501\u8981\u6C42\u5B8C\u6574 lock\u2014\u2014\u672C\u574F\u5F62\u5F62\u6001\u5148\u6062\u590D\u539F\u5B57\u8282\u6216\u91CD\u8DD1 catalog/tools/materialize_*.py \u5E42\u7B49\u91CD\u751F\u6210\uFF09\u3002", { lockPath, cause: String(error) });
24320
24569
  }
24321
24570
  const body = parsed;
24322
24571
  const entries = body["entries"];
@@ -24380,7 +24629,7 @@ function verifyCatalogLock(catalogRoot, lock) {
24380
24629
  drifts.push({
24381
24630
  kind: "content_drift",
24382
24631
  path: entry.path,
24383
- detail: `\u7269\u6599\u88AB\u6539\u800C lock \u672A\u91CD\u9501\uFF1A\u671F\u671B ${entry.content_sha256}\uFF0C\u5B9E\u7B97 ${actual}\uFF08id=${entry.id}\uFF1B\u91CD\u8DD1 catalog/tools/materialize_*.py \u5E42\u7B49\u91CD\u9501\uFF09`
24632
+ detail: `\u7269\u6599\u88AB\u6539\u800C lock \u672A\u91CD\u9501\uFF1A\u671F\u671B ${entry.content_sha256}\uFF0C\u5B9E\u7B97 ${actual}\uFF08id=${entry.id}\uFF1B\u6062\u590D\u952E = pomaster catalog relock \u5E42\u7B49\u91CD\u9501\uFF0C\u6216\u91CD\u8DD1 catalog/tools/materialize_*.py\uFF09`
24384
24633
  });
24385
24634
  }
24386
24635
  if (!document.controlled_children.allowed.includes(entry.path)) {
@@ -24419,6 +24668,62 @@ function verifyCatalogLock(catalogRoot, lock) {
24419
24668
  drifts.sort((a, b) => a.path === b.path ? a.kind < b.kind ? -1 : 1 : a.path < b.path ? -1 : 1);
24420
24669
  return { ok: drifts.length === 0, entries_checked: document.entries.length, drifts };
24421
24670
  }
24671
+ function relockCatalog(catalogRoot) {
24672
+ const previous = readCatalogLock(catalogRoot);
24673
+ const previousByPath = new Map(previous.entries.map((entry) => [entry.path, entry]));
24674
+ const scannedEntries = [];
24675
+ const scannedPaths = [];
24676
+ const seenIds = /* @__PURE__ */ new Set();
24677
+ for (const section of CATALOG_SECTIONS) {
24678
+ const dir = join3(catalogRoot, section);
24679
+ if (!existsSync2(dir))
24680
+ continue;
24681
+ for (const fileName of readdirSync3(dir).filter((name) => name.endsWith(".json")).sort()) {
24682
+ const path = `${section}/${fileName}`;
24683
+ const raw = readFileSync4(join3(dir, fileName), "utf8");
24684
+ let body;
24685
+ try {
24686
+ body = asRecord2(JSON.parse(raw));
24687
+ } catch (error) {
24688
+ throw new GovernanceError("SCHEMA_INVALID", `catalog \u7269\u6599\u4E0D\u53EF\u89E3\u6790\uFF08relock \u65E0\u6CD5\u91CD\u9501\u574F\u5F62\u7269\u6599\uFF09: ${path}`, "\u7269\u6599 JSON \u574F\u5F62\u5148\u6062\u590D\u539F\u5B57\u8282\uFF08Git\uFF09\u6216\u91CD\u8DD1 catalog/tools/materialize_*.py\uFF1Brelock \u53EA\u91CD\u9501\u53EF\u89E3\u6790\u7269\u6599\u3002", { file: path, cause: String(error) });
24689
+ }
24690
+ const id = body["id"];
24691
+ if (typeof id !== "string" || id.length === 0) {
24692
+ throw new GovernanceError("SCHEMA_INVALID", `catalog \u7269\u6599\u7F3A id \u5B57\u6BB5\uFF08relock \u4EE5\u7269\u6599 id \u91CD\u5EFA entries\uFF09: ${path}`, "id \u662F catalog \u7269\u6599\u8EAB\u4EFD\u5B57\u6BB5\uFF08\u4E94\u8282\u7269\u6599\u7EDF\u4E00\u8981\u6C42\uFF09\uFF1B\u5BF9\u7167\u540C\u76EE\u5F55\u5728\u518C\u6761\u76EE\u4FEE\u590D\u3002", { file: path });
24693
+ }
24694
+ if (seenIds.has(id)) {
24695
+ throw new GovernanceError("SCHEMA_INVALID", `catalog \u7269\u6599 id \u8DE8\u8282\u91CD\u590D\uFF08\u8EAB\u4EFD\u9762\u7981\u91CD\u590D\uFF09: ${id}`, "id \u662F lock entries \u7684\u8EAB\u4EFD\u5206\u6BCD\uFF1B\u91CD\u590D\u8BF4\u660E\u7269\u6599\u7BA1\u7406\u5931\u5E8F\uFF0C\u5220\u9664\u6216\u5408\u5E76\u91CD\u590D\u6587\u4EF6\u3002", { file: path, id });
24696
+ }
24697
+ seenIds.add(id);
24698
+ scannedPaths.push(path);
24699
+ scannedEntries.push({
24700
+ id,
24701
+ path,
24702
+ content_sha256: sha256OfUtf8(raw),
24703
+ source_ref: previousByPath.get(path)?.source_ref ?? `package://catalog/${path}`
24704
+ });
24705
+ }
24706
+ }
24707
+ scannedEntries.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
24708
+ scannedPaths.sort();
24709
+ const scannedPathSet = new Set(scannedPaths);
24710
+ const added = scannedPaths.filter((path) => !previousByPath.has(path));
24711
+ const removed = [...new Set(previous.entries.map((entry) => entry.path))].filter((path) => !scannedPathSet.has(path)).sort();
24712
+ const refreshed = scannedEntries.filter((entry) => previousByPath.has(entry.path) && previousByPath.get(entry.path)?.content_sha256 !== entry.content_sha256).map((entry) => entry.path);
24713
+ const lockPath = join3(catalogRoot, LOCK_FILE_NAME);
24714
+ const rawLock = JSON.parse(readFileSync4(lockPath, "utf8"));
24715
+ const rawGeneratedBy = rawLock["generated_by"];
24716
+ if (rawGeneratedBy !== void 0 && typeof rawGeneratedBy !== "string") {
24717
+ throw new GovernanceError("SCHEMA_INVALID", `catalog-lock generated_by \u5F62\u72B6\u975E\u6CD5\uFF08\u987B\u5B57\u7B26\u4E32\u6216\u7F3A\u5E2D\uFF09: ${LOCK_FILE_NAME}`, "generated_by \u662F lock \u7684 producer \u6CE8\u8BB0\u4F4D\uFF1B\u574F\u5F62\u5148\u6062\u590D\u539F\u5B57\u8282\u518D\u91CD\u9501\u3002", { lockPath });
24718
+ }
24719
+ const generatedBy = typeof rawGeneratedBy === "string" ? rawGeneratedBy.includes(CATALOG_RELOCK_GENERATED_BY_NOTE) ? rawGeneratedBy : `${rawGeneratedBy} + ${CATALOG_RELOCK_GENERATED_BY_NOTE}` : CATALOG_RELOCK_GENERATED_BY_NOTE;
24720
+ const next = Object.assign({}, rawLock, {
24721
+ controlled_children: { allowed: scannedPaths, required: [...scannedPaths] },
24722
+ entries: scannedEntries,
24723
+ generated_by: generatedBy
24724
+ });
24725
+ return { previous, next, added, removed, refreshed };
24726
+ }
24422
24727
  function asRecord2(value) {
24423
24728
  return typeof value === "object" && value !== null ? value : {};
24424
24729
  }
@@ -24653,7 +24958,134 @@ function loadCatalogSensors(catalogRoot) {
24653
24958
  }
24654
24959
  return [...materials.values()].sort((a, b) => a.id < b.id ? -1 : 1);
24655
24960
  }
24656
- var CATALOG_SECTIONS, LOCK_FILE_NAME, SENSOR_ID_PATTERN, OBSERVATION_SURFACE_VALUES, SENSOR_SIDE_EFFECT_CLASS_VALUES, SENSOR_AVAILABILITY_SURFACE_VALUES, SENSOR_KERNEL_SURFACE_KEYS;
24961
+ function loadCatalogArchetypes(catalogRoot) {
24962
+ const dir = join3(catalogRoot, "archetypes");
24963
+ if (!existsSync2(dir)) {
24964
+ return [];
24965
+ }
24966
+ const materials = /* @__PURE__ */ new Map();
24967
+ for (const fileName of readdirSync3(dir).filter((name) => name.endsWith(".json")).sort()) {
24968
+ const file = `archetypes/${fileName}`;
24969
+ const raw = readFileSync4(join3(dir, fileName), "utf8");
24970
+ let body;
24971
+ try {
24972
+ body = asRecord2(JSON.parse(raw));
24973
+ } catch (error) {
24974
+ throw new GovernanceError("SCHEMA_INVALID", `catalog \u7269\u6599\u4E0D\u53EF\u89E3\u6790: ${file}`, "\u7269\u6599 JSON \u574F\u5F62\uFF1Aarchetype \u6761\u76EE\u4E3A P-v06 D-2 \u88C1\u5B9A\u767B\u8BB0\u7269\u6599\uFF08catalog \u9762\uFF09\uFF0C\u5BF9\u7167 catalog_layer_vocab.catalog_kind \u4FEE\u590D\u3002", { file, cause: String(error) });
24975
+ }
24976
+ const id = body["id"];
24977
+ const kind = body["kind"];
24978
+ const layer = body["layer"];
24979
+ const titleZh = body["title_zh"];
24980
+ const summaryZh = body["summary_zh"];
24981
+ if (typeof id !== "string" || !CATALOG_ARCHETYPE_ID_PATTERN.test(id) || !CATALOG_KIND_VALUES.includes(kind) || !SUBSTRATE_LAYER_VALUES.includes(layer) || typeof titleZh !== "string" || titleZh.length === 0 || typeof summaryZh !== "string" || summaryZh.length === 0) {
24982
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype \u7F3A\u5FC5\u586B\u5B57\u6BB5\u6216\u8BCD\u5F62\u975E\u6CD5\uFF08id \u81F3\u5C11\u4E24\u6BB5 SCREAMING_SNAKE / kind \u2208 CATALOG_KIND_VALUES / layer \u2208 SUBSTRATE_LAYER_VALUES / title_zh / summary_zh\uFF09: ${file}`, "archetype \u6761\u76EE\u5F62\u72B6\u7531 P-v06 D-2 \u88C1\u5B9A + vocab-lock software_graph_vocab\uFF08PR-0006\uFF09\u5B9A\u4E49\uFF1B\u5BF9\u7167\u5728\u518C\u6761\u76EE\u4FEE\u590D\u3002", { file, id: String(id) });
24983
+ }
24984
+ const composition = validateComposition(body["composition"], file, id);
24985
+ const semantic = validateSemantic(body["semantic"], file, id);
24986
+ const referenceAnchors = validateReferenceAnchors(body["x-research-anchors"], file, id);
24987
+ if (materials.has(id)) {
24988
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype id \u91CD\u590D\uFF08\u8EAB\u4EFD\u9762\u7981\u91CD\u590D\uFF09: ${id}`, "archetype id \u662F Engineering Substrate \u6807\u51C6\u4EF6\u8EAB\u4EFD\uFF1B\u91CD\u590D\u8BF4\u660E\u7269\u6599\u7BA1\u7406\u5931\u5E8F\uFF0C\u5220\u9664\u6216\u5408\u5E76\u91CD\u590D\u6587\u4EF6\u3002", { file, id });
24989
+ }
24990
+ materials.set(id, {
24991
+ file,
24992
+ id,
24993
+ kind: String(kind),
24994
+ layer,
24995
+ titleZh,
24996
+ summaryZh,
24997
+ composition,
24998
+ semantic,
24999
+ referenceAnchors
25000
+ });
25001
+ }
25002
+ return [...materials.values()].sort((a, b) => a.id < b.id ? -1 : 1);
25003
+ }
25004
+ function validateComposition(value, file, id) {
25005
+ if (value === void 0 || value === null) {
25006
+ return { requires: [], optional: [], incompatible: [] };
25007
+ }
25008
+ const record = value;
25009
+ const slots = [
25010
+ ["requires", record["requires"]],
25011
+ ["optional", record["optional"]],
25012
+ ["incompatible", record["incompatible"]]
25013
+ ];
25014
+ const out = {};
25015
+ for (const [slot, list] of slots) {
25016
+ if (list === void 0 || list === null) {
25017
+ out[slot] = [];
25018
+ continue;
25019
+ }
25020
+ if (!Array.isArray(list) || !list.every((item) => typeof item === "string" && CATALOG_ARCHETYPE_ID_PATTERN.test(item))) {
25021
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype composition.${slot} \u5F62\u6001\u975E\u6CD5\uFF08\u987B catalog id \u8BCD\u5F62\u6570\u7EC4\uFF09: ${file}`, "\u7EC4\u5408\u7EA6\u675F\u5F15\u7528\u7684\u662F\u6807\u51C6\u4EF6 id\uFF08v0.6.1 \xA74 composition\uFF09\uFF1B\u81EA\u7531\u6587\u672C\u4E0D\u662F\u673A\u5668\u53EF\u5224\u5377\u7EA6\u675F\u3002", { file, id, slot });
25022
+ }
25023
+ out[slot] = list;
25024
+ }
25025
+ return {
25026
+ requires: out["requires"] ?? [],
25027
+ optional: out["optional"] ?? [],
25028
+ incompatible: out["incompatible"] ?? []
25029
+ };
25030
+ }
25031
+ function validateSemantic(value, file, id) {
25032
+ if (value === void 0 || value === null) {
25033
+ return { responsibility: null, whenToUse: null, whenNotToUse: null };
25034
+ }
25035
+ if (typeof value !== "object" || Array.isArray(value)) {
25036
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype semantic \u5F62\u6001\u975E\u6CD5\uFF08\u987B\u5BF9\u8C61\uFF09: ${file}`, "semantic \u662F v0.6.1 \xA74 \u4E09\u69FD\u8BED\u4E49\u9762\uFF1B\u574F\u5F62\u7269\u6599\u663E\u5F0F\u7206\u3002", { file, id });
25037
+ }
25038
+ const record = value;
25039
+ const pick3 = (key) => {
25040
+ const slot = record[key];
25041
+ if (slot === void 0 || slot === null)
25042
+ return null;
25043
+ if (typeof slot !== "string" || slot.length === 0) {
25044
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype semantic.${key} \u5F62\u6001\u975E\u6CD5\uFF08\u987B\u975E\u7A7A\u5B57\u7B26\u4E32\u6216\u7F3A\u5E2D\uFF09: ${file}`, "semantic \u4E09\u69FD\u662F resolver\u300Cwhy\u300D\u5448\u73B0\u4F4D\uFF1B\u574F\u5F62\u663E\u5F0F\u7206\u3002", { file, id, key });
25045
+ }
25046
+ return slot;
25047
+ };
25048
+ return {
25049
+ responsibility: pick3("responsibility"),
25050
+ whenToUse: pick3("when_to_use"),
25051
+ whenNotToUse: pick3("when_not_to_use")
25052
+ };
25053
+ }
25054
+ function validateReferenceAnchors(value, file, id) {
25055
+ if (value === void 0 || value === null) {
25056
+ return { note: null, urls: [] };
25057
+ }
25058
+ if (typeof value !== "object" || Array.isArray(value)) {
25059
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype x-research-anchors \u5F62\u6001\u975E\u6CD5\uFF08\u987B\u5BF9\u8C61\uFF09: ${file}`, "\u7814\u7A76\u951A\u4F4D\u662F P-v06 \u6279\u6B21 2 resolver \u53C2\u7167\u8BCD\u5F62\u6765\u6E90\uFF1B\u574F\u5F62\u7269\u6599\u663E\u5F0F\u7206\u3002", { file, id });
25060
+ }
25061
+ const record = value;
25062
+ const noteSlot = record["note"];
25063
+ if (noteSlot !== void 0 && noteSlot !== null && (typeof noteSlot !== "string" || noteSlot.length === 0)) {
25064
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype x-research-anchors.note \u5F62\u6001\u975E\u6CD5\uFF08\u987B\u975E\u7A7A\u5B57\u7B26\u4E32\u6216\u7F3A\u5E2D/null\uFF09: ${file}`, "note \u662F\u53C2\u7167\u7CFB\u8BCD\u5F62\u6765\u6E90\u4E4B\u4E00\uFF1B\u574F\u951A\u663E\u5F0F\u7206\u7981\u9759\u9ED8\u4E22\u3002", { file, id });
25065
+ }
25066
+ const sources = record["sources"];
25067
+ const urls = [];
25068
+ if (sources !== void 0 && sources !== null) {
25069
+ if (!Array.isArray(sources)) {
25070
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype x-research-anchors.sources \u5F62\u6001\u975E\u6CD5\uFF08\u987B\u6570\u7EC4\uFF09: ${file}`, "sources[].url \u662F\u53C2\u7167\u7CFB\u8BCD\u5F62\u6765\u6E90\u4E4B\u4E00\uFF1B\u574F\u951A\u663E\u5F0F\u7206\u7981\u9759\u9ED8\u4E22\u3002", { file, id });
25071
+ }
25072
+ for (const item of sources) {
25073
+ if (typeof item !== "object" || item === null || Array.isArray(item)) {
25074
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype x-research-anchors.sources \u5143\u7D20\u5F62\u6001\u975E\u6CD5\uFF08\u987B\u5BF9\u8C61\uFF09: ${file}`, "sources[].url \u662F\u53C2\u7167\u7CFB\u8BCD\u5F62\u6765\u6E90\u4E4B\u4E00\uFF1B\u574F\u951A\u663E\u5F0F\u7206\u7981\u9759\u9ED8\u4E22\u3002", { file, id });
25075
+ }
25076
+ const url = item["url"];
25077
+ if (typeof url !== "string" || url.length === 0) {
25078
+ throw new GovernanceError("SCHEMA_INVALID", `catalog archetype x-research-anchors.sources[].url \u7F3A\u5931\u6216\u975E\u975E\u7A7A\u5B57\u7B26\u4E32: ${file}`, "url \u662F\u53C2\u7167\u7CFB\u8BCD\u5F62\u6765\u6E90\uFF1B\u574F\u951A\u663E\u5F0F\u7206\u7981\u9759\u9ED8\u4E22\u3002", { file, id });
25079
+ }
25080
+ urls.push(url);
25081
+ }
25082
+ }
25083
+ return {
25084
+ note: typeof noteSlot === "string" ? noteSlot : null,
25085
+ urls
25086
+ };
25087
+ }
25088
+ var CATALOG_SECTIONS, LOCK_FILE_NAME, CATALOG_RELOCK_GENERATED_BY_NOTE, SENSOR_ID_PATTERN, OBSERVATION_SURFACE_VALUES, SENSOR_SIDE_EFFECT_CLASS_VALUES, SENSOR_AVAILABILITY_SURFACE_VALUES, SENSOR_KERNEL_SURFACE_KEYS, CATALOG_ARCHETYPE_ID_PATTERN;
24657
25089
  var init_catalog = __esm({
24658
25090
  "packages/kernel/dist/catalog.js"() {
24659
25091
  "use strict";
@@ -24661,8 +25093,9 @@ var init_catalog = __esm({
24661
25093
  init_errors();
24662
25094
  init_id();
24663
25095
  init_io();
24664
- CATALOG_SECTIONS = ["gates", "knowledge", "policies", "sensors"];
25096
+ CATALOG_SECTIONS = ["archetypes", "gates", "knowledge", "policies", "sensors"];
24665
25097
  LOCK_FILE_NAME = "catalog-lock.draft.json";
25098
+ CATALOG_RELOCK_GENERATED_BY_NOTE = "pomaster catalog relock\uFF08CLI \u6062\u590D\u952E\uFF1B\u5E42\u7B49\u91CD\u9501\u4E0D\u542B\u65F6\u6233\u2014\u2014A4\uFF09";
24666
25099
  SENSOR_ID_PATTERN = /^SENSOR\.[A-Z0-9_]+\.[A-Z0-9_]+$/;
24667
25100
  OBSERVATION_SURFACE_VALUES = [
24668
25101
  "USER_SURFACE",
@@ -24685,6 +25118,7 @@ var init_catalog = __esm({
24685
25118
  "kernel"
24686
25119
  ];
24687
25120
  SENSOR_KERNEL_SURFACE_KEYS = ["production_control_band"];
25121
+ CATALOG_ARCHETYPE_ID_PATTERN = /^[A-Z][A-Z0-9_]*(\.[A-Z][A-Z0-9_]+)+$/;
24688
25122
  }
24689
25123
  });
24690
25124
 
@@ -31029,17 +31463,1136 @@ var init_perception = __esm({
31029
31463
  }
31030
31464
  });
31031
31465
 
31466
+ // packages/kernel/dist/relations.js
31467
+ function normalizeRelationType(value) {
31468
+ const matched = RELATION_TYPE_VALUES.find((candidate) => candidate === value);
31469
+ if (matched === void 0) {
31470
+ throw new GovernanceError("SCHEMA_INVALID", `relation type \u8BCD\u8868\u5916\uFF1A${value}\uFF08software_graph_vocab.relation_type \u9996\u6279 8 \u503C\u95ED\u5305\uFF0CPR-0006\uFF09`, `\u5408\u6CD5\u8BCD\u5F62\uFF1A${RELATION_TYPE_VALUES.join(" | ")}\uFF1BPRD \xA77 \u5176\u4F59\u8BCD\u5F62\u5F85\u771F\u5B9E\u6D88\u8D39\u8005\u843D\u5730\u9010\u6279\u8BCD\u6C47\u8868 PR \u589E\u8865`, { type: value });
31471
+ }
31472
+ return matched;
31473
+ }
31474
+ function normalizeRelationOrigin(value) {
31475
+ const matched = RELATION_ORIGIN_VALUES.find((candidate) => candidate === value);
31476
+ if (matched === void 0) {
31477
+ throw new GovernanceError("SCHEMA_INVALID", `relation origin \u8BCD\u8868\u5916\uFF1A${value}\uFF08software_graph_vocab.relation_origin \u4E09\u503C\u95ED\u5305\uFF0CPR-0006\uFF09`, `\u5408\u6CD5\u8BCD\u5F62\uFF1A${RELATION_ORIGIN_VALUES.join(" | ")}`, { origin: value });
31478
+ }
31479
+ return matched;
31480
+ }
31481
+ function normalizeEndpointDomain(value) {
31482
+ const matched = RELATION_ENDPOINT_DOMAIN_VALUES.find((candidate) => candidate === value);
31483
+ if (matched === void 0) {
31484
+ throw new GovernanceError("SCHEMA_INVALID", `endpoint domain \u8BCD\u8868\u5916\uFF1A${value}\uFF08software_graph_vocab.relation_endpoint_domain \u4E24\u503C\u95ED\u5305\uFF0CPR-0006\uFF09`, `\u5408\u6CD5\u8BCD\u5F62\uFF1A${RELATION_ENDPOINT_DOMAIN_VALUES.join(" | ")}`, { domain: value });
31485
+ }
31486
+ return matched;
31487
+ }
31488
+ function normalizeRelationConfidence(value) {
31489
+ const matched = RELATION_CONFIDENCE_VALUES.find((candidate) => candidate === value);
31490
+ if (matched === void 0) {
31491
+ throw new GovernanceError("SCHEMA_INVALID", `relation confidence \u8BCD\u8868\u5916\uFF1A${value}\uFF08software_graph_vocab.relation_confidence \u4E09\u503C\u95ED\u5305\uFF0CPR-0006\uFF09`, `\u5408\u6CD5\u8BCD\u5F62\uFF1A${RELATION_CONFIDENCE_VALUES.join(" | ")}\uFF1B\u4E0E state_axes.confidence \u6B63\u4EA4\u7981\u6DF7\u7528`, { confidence: value });
31492
+ }
31493
+ return matched;
31494
+ }
31495
+ function readRelations(paths) {
31496
+ const text = readText(paths.relationsPath);
31497
+ if (text === null) {
31498
+ return [];
31499
+ }
31500
+ const entries = [];
31501
+ const idOwner = /* @__PURE__ */ new Map();
31502
+ const tripleOwner = /* @__PURE__ */ new Map();
31503
+ const lines = text.split("\n");
31504
+ for (let index = 0; index < lines.length; index += 1) {
31505
+ const trimmed = lines[index]?.trim() ?? "";
31506
+ if (trimmed.length === 0)
31507
+ continue;
31508
+ let parsed;
31509
+ try {
31510
+ parsed = JSON.parse(trimmed);
31511
+ } catch (error) {
31512
+ throw relationsInvalid(`\u7B2C ${index + 1} \u884C\u65E0\u6CD5\u89E3\u6790\uFF08\u635F\u574F\u6216\u624B\u6539\uFF09`, trimmed, error);
31513
+ }
31514
+ const entry = validateEntryShape2(parsed, index + 1);
31515
+ const previousIdOwner = idOwner.get(entry.edge_id);
31516
+ if (previousIdOwner !== void 0) {
31517
+ throw relationsInvalid(`edge_id \u91CD\u590D\u767B\u8BB0\uFF1A${entry.edge_id}\uFF08\u7B2C ${previousIdOwner} \u884C\u4E0E\u7B2C ${index + 1} \u884C\uFF1B\u5185\u5BB9\u5BFB\u5740 id \u5168\u57DF\u552F\u4E00\uFF09`, trimmed);
31518
+ }
31519
+ idOwner.set(entry.edge_id, String(index + 1));
31520
+ const triple = tripleKey(entry);
31521
+ const previousTripleOwner = tripleOwner.get(triple);
31522
+ if (previousTripleOwner !== void 0) {
31523
+ throw relationsInvalid(`(source,type,target) \u4E09\u5143\u7EC4\u91CD\u590D\u767B\u8BB0\uFF1A${triple}\uFF08\u7B2C ${previousTripleOwner} \u884C\u4E0E\u7B2C ${index + 1} \u884C\uFF1B\u540C\u4E09\u5143\u7EC4\u5FC5\u987B\u540C edge_id\u2014\u2014\u5206\u53C9=\u624B\u6539\u75D5\u8FF9\uFF09`, trimmed);
31524
+ }
31525
+ tripleOwner.set(triple, String(index + 1));
31526
+ entries.push(entry);
31527
+ }
31528
+ return entries;
31529
+ }
31530
+ function relationsInvalid(message, line, cause) {
31531
+ return new GovernanceError("SCHEMA_INVALID", `state/relations.jsonl ${message}`, "\u6062\u590D git \u7248\u672C\uFF1B\u5173\u7CFB\u53F0\u8D26\u7531 kernel relations.ts \u8BED\u4E49\u5165\u53E3\u7EF4\u62A4\uFF08registerRelation\uFF09\uFF0C\u7981\u6B62\u624B\u6539", { line: line?.slice(0, 120), cause: cause === void 0 ? void 0 : String(cause) });
31532
+ }
31533
+ function validateEntryShape2(value, lineNo) {
31534
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
31535
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C\u975E\u5BF9\u8C61`);
31536
+ }
31537
+ const e = value;
31538
+ const edgeId = e["edge_id"];
31539
+ if (typeof edgeId !== "string" || !EDGE_ID_PATTERN.test(edgeId)) {
31540
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C edge_id \u8BCD\u5F62\u975E\u6CD5\uFF08\u987B EDGE-<12hex> \u5185\u5BB9\u5BFB\u5740\uFF09`);
31541
+ }
31542
+ const type = normalizeRelationType(requireString(e, "type", lineNo));
31543
+ const origin = normalizeRelationOrigin(requireString(e, "origin", lineNo));
31544
+ const confidence = normalizeRelationConfidence(requireString(e, "confidence", lineNo));
31545
+ const producer = requireString(e, "producer", lineNo);
31546
+ if (!/^[A-Z][A-Z0-9_.\-]{0,63}$/.test(producer) && !producer.startsWith("human:")) {
31547
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C producer \u8BCD\u5F62\u975E\u6CD5\uFF08ANALYZER.*/SENSOR.*/human:<\u4E3B\u4F53>\uFF09`);
31548
+ }
31549
+ const source = validateEndpoint(e["source"], `\u7B2C ${lineNo} \u884C source`);
31550
+ const target = validateEndpoint(e["target"], `\u7B2C ${lineNo} \u884C target`);
31551
+ if (confidence === "probable" && !isNonEmptyString(e["uncertainty_note"])) {
31552
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C confidence=probable \u4F46\u7F3A uncertainty_note\uFF08\xA7148 Analyzer Output Contract\uFF1A\u975E\u786E\u5B9A\u6D3E\u751F\u5FC5\u987B\u62AB\u9732\u4E0D\u786E\u5B9A\u6027\uFF09`);
31553
+ }
31554
+ if (confidence !== "probable" && e["uncertainty_note"] !== null && e["uncertainty_note"] !== void 0) {
31555
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C confidence\u2260probable \u5374\u643A\u5E26 uncertainty_note\uFF08\u62AB\u9732\u4F4D\u4E0E\u7F6E\u4FE1\u7EA7\u4E92\u65A5\uFF09`);
31556
+ }
31557
+ const provenance = validateProvenance(e["provenance"], lineNo, origin);
31558
+ const note = e["note"];
31559
+ if (note !== null && note !== void 0 && !isNonEmptyString(note)) {
31560
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C note \u5F62\u6001\u975E\u6CD5`);
31561
+ }
31562
+ return {
31563
+ edge_id: edgeId,
31564
+ type,
31565
+ source,
31566
+ target,
31567
+ origin,
31568
+ confidence,
31569
+ producer,
31570
+ uncertainty_note: confidence === "probable" ? String(e["uncertainty_note"]) : null,
31571
+ provenance,
31572
+ note: isNonEmptyString(note) ? note : null
31573
+ };
31574
+ }
31575
+ function validateEndpoint(value, label) {
31576
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
31577
+ throw relationsInvalid(`${label} \u975E\u5BF9\u8C61`);
31578
+ }
31579
+ const record = value;
31580
+ const domain = normalizeEndpointDomain(requireString(record, "domain", -1, label));
31581
+ const id = record["id"];
31582
+ if (!isNonEmptyString(id)) {
31583
+ throw relationsInvalid(`${label}.id \u7F3A\u5931\u6216\u975E\u975E\u7A7A\u5B57\u7B26\u4E32`);
31584
+ }
31585
+ if (domain === "truth") {
31586
+ try {
31587
+ parseGovernedId(id);
31588
+ } catch (error) {
31589
+ if (error instanceof GovernedIdParseError) {
31590
+ throw relationsInvalid(`${label} truth \u7AEF\u70B9\u300C${id}\u300D\u4E0D\u8FC7 governed id \u6587\u6CD5\uFF08${error.message}\uFF09`);
31591
+ }
31592
+ throw error;
31593
+ }
31594
+ } else if (!CATALOG_ENDPOINT_ID_PATTERN.test(id)) {
31595
+ throw relationsInvalid(`${label} catalog \u7AEF\u70B9\u300C${id}\u300D\u8BCD\u5F62\u975E\u6CD5\uFF08\u81F3\u5C11\u4E24\u6BB5 SCREAMING_SNAKE\uFF1B\u5B58\u5728\u6027\u5F52\u6D88\u8D39\u9762 loader \u5206\u6BCD\uFF09`);
31596
+ }
31597
+ return { domain, id };
31598
+ }
31599
+ function validateProvenance(value, lineNo, origin) {
31600
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
31601
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C provenance \u975E\u5BF9\u8C61`);
31602
+ }
31603
+ const record = value;
31604
+ const seq = record["recorded_at_seq"];
31605
+ if (typeof seq !== "number" || !Number.isInteger(seq) || seq < 0) {
31606
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C provenance.recorded_at_seq \u975E\u6CD5\uFF08\u987B\u975E\u8D1F\u6574\u6570\u4E8B\u4EF6\u62CD\uFF0CA4 \u7981\u5899\u949F\uFF09`);
31607
+ }
31608
+ const sourceRef = record["source_ref"];
31609
+ if (!isNonEmptyString(sourceRef)) {
31610
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C provenance.source_ref \u7F3A\u5931\uFF08\u767B\u8BB0\u51FA\u5904\u951A\u5FC5\u586B\uFF09`);
31611
+ }
31612
+ const observationRef = record["observation_ref"];
31613
+ const locator = record["locator"];
31614
+ const declaredBy = record["declared_by"];
31615
+ if (origin === "runtime_trace") {
31616
+ if (!isNonEmptyString(observationRef) || !OBSERVATION_REF_PATTERN.test(observationRef)) {
31617
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C origin=runtime_trace \u4F46 observation_ref \u7F3A\u5931\u6216\u8BCD\u5F62\u975E\u6CD5\uFF08\u987B OBS-n / POB-<12hex>\u2014\u2014\u300CAgent \u5FC5\u987B\u8BC1\u660E\u6211\u770B\u8FC7\u300D\u8FB9\u4FA7\u5C01\u6761\uFF09`);
31618
+ }
31619
+ } else if (observationRef !== null && observationRef !== void 0) {
31620
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C origin=${origin} \u5374\u643A\u5E26 observation_ref\uFF08\u6765\u6E90\u9762\u4E92\u65A5\u5C01\u6761\uFF09`);
31621
+ }
31622
+ if (origin === "human_declared" && declaredBy !== null && declaredBy !== void 0 && !isNonEmptyString(declaredBy)) {
31623
+ throw relationsInvalid(`\u7B2C ${lineNo} \u884C declared_by \u5F62\u6001\u975E\u6CD5`);
31624
+ }
31625
+ return {
31626
+ recorded_at_seq: seq,
31627
+ source_ref: sourceRef,
31628
+ locator: isNonEmptyString(locator) ? locator : null,
31629
+ observation_ref: isNonEmptyString(observationRef) ? observationRef : null,
31630
+ declared_by: isNonEmptyString(declaredBy) ? declaredBy : null
31631
+ };
31632
+ }
31633
+ async function registerRelation(store, input) {
31634
+ const paths = pathsOf(store);
31635
+ const currentSeq = readCurrentSeq(paths);
31636
+ if (currentSeq === null) {
31637
+ throw notConfigured2(store);
31638
+ }
31639
+ const entry = buildEntry(input, currentSeq);
31640
+ const existing = readRelations(paths);
31641
+ const triple = tripleKeyOf(entry.source, entry.type, entry.target);
31642
+ const hit = existing.find((candidate) => tripleKey(candidate) === triple);
31643
+ if (hit !== void 0) {
31644
+ if (hit.edge_id !== entry.edge_id) {
31645
+ throw new GovernanceError("SCHEMA_INVALID", `\u4E09\u5143\u7EC4\u5DF2\u5165\u8D26\u4F46 edge_id \u5206\u53C9\uFF1A${hit.edge_id} \u2260 ${entry.edge_id}\uFF08\u5185\u5BB9\u5BFB\u5740\u4E0D\u53D8\u5F0F\u88AB\u7834\u574F\u2014\u2014\u540C\u4E09\u5143\u7EC4\u5FC5\u987B\u540C id\uFF09`, "\u6B64\u4E3A\u624B\u6539/\u5B9E\u73B0\u7F3A\u9677\u75D5\u8FF9\uFF1B\u6062\u590D git \u7248\u672C\u5E76\u6392\u67E5 sha256OfCanonical \u8EAB\u4EFD\u9762", { edge_id: entry.edge_id, existing: hit.edge_id });
31646
+ }
31647
+ return { registered: false, entry: hit };
31648
+ }
31649
+ appendLine(paths.relationsPath, `${JSON.stringify(entry)}
31650
+ `);
31651
+ appendLine(paths.journalPath, `${JSON.stringify({
31652
+ type: "RELATION_REGISTERED",
31653
+ seq: currentSeq,
31654
+ edge_id: entry.edge_id,
31655
+ relation_type: entry.type,
31656
+ source: entry.source,
31657
+ target: entry.target,
31658
+ origin: entry.origin,
31659
+ confidence: entry.confidence,
31660
+ producer: entry.producer
31661
+ })}
31662
+ `);
31663
+ return { registered: true, entry };
31664
+ }
31665
+ function edgeIdOf(source, type, target) {
31666
+ return `EDGE-${sha256OfCanonical({ source, type, target }).slice("sha256:".length, "sha256:".length + 12)}`;
31667
+ }
31668
+ function relationsTouching(entries, endpoint) {
31669
+ return entries.filter((entry) => entry.source.domain === endpoint.domain && entry.source.id === endpoint.id).concat(entries.filter((entry) => entry.target.domain === endpoint.domain && entry.target.id === endpoint.id));
31670
+ }
31671
+ function reverseDependents(entries, endpoint) {
31672
+ return entries.filter((entry) => entry.target.domain === endpoint.domain && entry.target.id === endpoint.id);
31673
+ }
31674
+ function impactClosure(entries, root, options) {
31675
+ const maxDepth = options?.maxDepth ?? 4;
31676
+ if (!Number.isInteger(maxDepth) || maxDepth < 1 || maxDepth > 16) {
31677
+ throw new GovernanceError("SCHEMA_INVALID", `maxDepth \u975E\u6CD5\uFF1A${String(maxDepth)}\uFF08\u987B 1..16\u2014\u2014\u9632\u5FA1\u5931\u63A7 BFS\uFF09`, "\u7ED9\u51FA\u6709\u754C\u6DF1\u5EA6\uFF1B\u8D85\u754C\u5F71\u54CD\u9762\u5E94\u8D70\u5168\u91CF\u56FE rebuild\uFF08\u6279\u6B21 2+\uFF09", { maxDepth });
31678
+ }
31679
+ const incoming = /* @__PURE__ */ new Map();
31680
+ for (const entry of entries) {
31681
+ const key = `${entry.target.domain}:${entry.target.id}`;
31682
+ const list = incoming.get(key) ?? [];
31683
+ list.push(entry);
31684
+ incoming.set(key, list);
31685
+ }
31686
+ const affected = [];
31687
+ const visited = /* @__PURE__ */ new Set([`${root.domain}:${root.id}`]);
31688
+ const frontier = [
31689
+ { domain: root.domain, id: root.id, depth: 0 }
31690
+ ];
31691
+ let maxDepthReached = false;
31692
+ while (frontier.length > 0) {
31693
+ const current = frontier.shift() ?? void 0;
31694
+ if (current.depth >= maxDepth) {
31695
+ maxDepthReached = true;
31696
+ continue;
31697
+ }
31698
+ const edges = incoming.get(`${current.domain}:${current.id}`) ?? [];
31699
+ for (const edge of edges) {
31700
+ const sourceKey = `${edge.source.domain}:${edge.source.id}`;
31701
+ if (visited.has(sourceKey))
31702
+ continue;
31703
+ visited.add(sourceKey);
31704
+ affected.push({
31705
+ endpoint: edge.source,
31706
+ depth: current.depth + 1,
31707
+ via_edge_id: edge.edge_id,
31708
+ via_edge_type: edge.type
31709
+ });
31710
+ frontier.push({ domain: edge.source.domain, id: edge.source.id, depth: current.depth + 1 });
31711
+ }
31712
+ }
31713
+ affected.sort((a, b) => a.depth - b.depth || (a.endpoint.domain < b.endpoint.domain ? -1 : a.endpoint.domain > b.endpoint.domain ? 1 : 0) || (a.endpoint.id < b.endpoint.id ? -1 : 1));
31714
+ return { root: { domain: root.domain, id: root.id }, affected, max_depth_reached: maxDepthReached };
31715
+ }
31716
+ function forwardDependencies(entries, endpoint) {
31717
+ return entries.filter((entry) => entry.source.domain === endpoint.domain && entry.source.id === endpoint.id);
31718
+ }
31719
+ function buildEntry(input, seq) {
31720
+ const type = normalizeRelationType(input.type);
31721
+ const origin = normalizeRelationOrigin(input.origin);
31722
+ const confidence = normalizeRelationConfidence(input.confidence);
31723
+ const source = buildEndpoint(input.source, "source");
31724
+ const target = buildEndpoint(input.target, "target");
31725
+ const sourceRef = requireTrimmed(input.sourceRef, "sourceRef", "\u767B\u8BB0\u51FA\u5904\u951A\u5FC5\u586B\uFF08\u6E90\u6587\u4EF6:\u884C / PRD \xA7\u53F7 / GRN \u5F15\u7528\uFF09");
31726
+ const producer = (input.producer ?? "").trim();
31727
+ if (producer.length === 0) {
31728
+ throw new GovernanceError("SCHEMA_INVALID", "producer \u4E3A\u7A7A\uFF08\u6BCF\u8FB9\u5FC5\u7B54\u300C\u8C01\u4EA7\u51FA\u300D\u2014\u2014PRD \xA78 provenance.producer\uFF09", "\u7ED9\u51FA ANALYZER.* / SENSOR.* / human:<\u4E3B\u4F53> \u8BCD\u5F62", {});
31729
+ }
31730
+ if (!/^[A-Z][A-Z0-9_.\-]{0,63}$/.test(producer) && !producer.startsWith("human:")) {
31731
+ throw new GovernanceError("SCHEMA_INVALID", `producer \u8BCD\u5F62\u975E\u6CD5\uFF1A${producer}\uFF08ANALYZER.* / SENSOR.* / human:<\u4E3B\u4F53>\uFF09`, "\u4EA7\u51FA\u8005\u8BCD\u5F62\u6BCF\u8FB9\u5FC5\u7B54\uFF1B\u81EA\u7531\u6587\u672C\u4E0D\u662F\u4EA7\u51FA\u8005\u8EAB\u4EFD", { producer });
31732
+ }
31733
+ const observationRef = origin === "runtime_trace" ? requireTrimmed(input.observationRef, "observationRef", "runtime_trace \u8FB9\u5FC5\u987B\u9644\u89C2\u5BDF\u56DE\u6267\u5F15\u7528\uFF08OBS-n / POB-<12hex>\u2014\u2014\u300CAgent \u5FC5\u987B\u8BC1\u660E\u6211\u770B\u8FC7\u300D\u8FB9\u4FA7\u5C01\u6761\uFF09") : input.observationRef !== void 0 && input.observationRef.trim().length > 0 ? throwOriginMismatch(origin) : null;
31734
+ if (observationRef !== null && !OBSERVATION_REF_PATTERN.test(observationRef)) {
31735
+ throw new GovernanceError("SCHEMA_INVALID", `observation_ref \u8BCD\u5F62\u975E\u6CD5\uFF1A${observationRef}\uFF08\u987B OBS-n / POB-<12hex>\uFF09`, "\u8FD0\u884C\u65F6\u8FB9\u53EA\u63A5\u53D7\u65E2\u6709\u89C2\u5BDF\u56DE\u6267\u901A\u8DEF\u8BCD\u5F62\u5F15\u7528\uFF0C\u7981\u624B\u9020 id", { observation_ref: observationRef });
31736
+ }
31737
+ const uncertaintyNote = confidence === "probable" ? requireTrimmed(input.uncertaintyNote, "uncertaintyNote", "confidence=probable \u5FC5\u987B\u62AB\u9732\u4E0D\u786E\u5B9A\u6027\u6CE8\u8BB0\uFF08\xA7148 Analyzer Output Contract\uFF09") : input.uncertaintyNote !== void 0 && input.uncertaintyNote.trim().length > 0 ? (() => {
31738
+ throw new GovernanceError("SCHEMA_INVALID", "confidence\u2260probable \u5374\u643A\u5E26 uncertaintyNote\uFF08\u62AB\u9732\u4F4D\u4E0E\u7F6E\u4FE1\u7EA7\u4E92\u65A5\uFF09", "\u786E\u5B9A\u6027/\u58F0\u660E\u8FB9\u65E0\u4E0D\u786E\u5B9A\u6027\u62AB\u9732\u4F4D", {});
31739
+ })() : null;
31740
+ const declaredBy = origin === "human_declared" ? input.declaredBy !== void 0 && input.declaredBy.trim().length > 0 ? input.declaredBy.trim() : null : input.declaredBy !== void 0 && input.declaredBy.trim().length > 0 ? (() => {
31741
+ throw new GovernanceError("SCHEMA_INVALID", `origin=${origin} \u5374\u643A\u5E26 declaredBy\uFF08\u58F0\u660E\u4E3B\u4F53\u4F4D\u4EC5 human_declared \u8FB9\u5408\u6CD5\uFF09`, "\u673A\u5668\u6D3E\u751F\u8FB9\u7684\u4E3B\u4F53\u5F52 producer \u8BCD\u5F62", { declared_by: input.declaredBy });
31742
+ })() : null;
31743
+ const note = input.note !== void 0 && input.note.trim().length > 0 ? input.note.trim() : null;
31744
+ const locator = input.locator !== void 0 && input.locator.trim().length > 0 ? input.locator.trim() : null;
31745
+ return {
31746
+ edge_id: edgeIdOf(source, type, target),
31747
+ type,
31748
+ source,
31749
+ target,
31750
+ origin,
31751
+ confidence,
31752
+ producer,
31753
+ uncertainty_note: uncertaintyNote,
31754
+ provenance: {
31755
+ recorded_at_seq: seq,
31756
+ source_ref: sourceRef,
31757
+ locator,
31758
+ observation_ref: observationRef,
31759
+ declared_by: declaredBy
31760
+ },
31761
+ note
31762
+ };
31763
+ }
31764
+ function throwOriginMismatch(origin) {
31765
+ throw new GovernanceError("SCHEMA_INVALID", `origin=${origin} \u5374\u643A\u5E26 observationRef\uFF08\u6765\u6E90\u9762\u4E92\u65A5\u5C01\u6761\u2014\u2014\u89C2\u5BDF\u56DE\u6267\u4F4D\u4EC5 runtime_trace \u8FB9\u5408\u6CD5\uFF09`, "static_analysis \u8FB9\u7684\u4F9D\u636E\u5F52 locator\uFF1Bhuman_declared \u8FB9\u7684\u4F9D\u636E\u5F52 sourceRef", { origin });
31766
+ }
31767
+ function buildEndpoint(input, label) {
31768
+ const domain = normalizeEndpointDomain(input?.domain ?? "");
31769
+ const id = (input?.id ?? "").trim();
31770
+ if (id.length === 0) {
31771
+ throw new GovernanceError("SCHEMA_INVALID", `${label}.id \u4E3A\u7A7A\uFF08\u7A7A\u7AEF\u70B9\u65E0\u4ECE\u5EFA\u8FB9\uFF09`, "\u7ED9\u51FA\u975E\u7A7A\u7AEF\u70B9 id\uFF08truth=governed id / catalog=\u6761\u76EE id\uFF09", {});
31772
+ }
31773
+ if (domain === "truth") {
31774
+ try {
31775
+ parseGovernedId(id);
31776
+ } catch (error) {
31777
+ if (error instanceof GovernedIdParseError) {
31778
+ throw new GovernanceError("SCHEMA_INVALID", `${label} truth \u7AEF\u70B9\u300C${id}\u300D\u4E0D\u8FC7 governed id \u6587\u6CD5\uFF1A${error.message}`, "truth \u7AEF\u70B9\u987B\u4E3A PREFIX.SEGMENT(.SEGMENT)*[.SEQ] canonical governed id\uFF08A5 closed-world\uFF09", { id });
31779
+ }
31780
+ throw error;
31781
+ }
31782
+ } else if (!CATALOG_ENDPOINT_ID_PATTERN.test(id)) {
31783
+ throw new GovernanceError("SCHEMA_INVALID", `${label} catalog \u7AEF\u70B9\u300C${id}\u300D\u8BCD\u5F62\u975E\u6CD5\uFF08\u81F3\u5C11\u4E24\u6BB5 SCREAMING_SNAKE\uFF09`, "catalog \u7AEF\u70B9\u987B\u547D\u4E2D catalog-lock entries \u5206\u6BCD\uFF08\u5B58\u5728\u6027\u5F52\u6D88\u8D39\u9762 loader \u5224\u5377\uFF09", { id });
31784
+ }
31785
+ return { domain, id };
31786
+ }
31787
+ function tripleKey(entry) {
31788
+ return tripleKeyOf(entry.source, entry.type, entry.target);
31789
+ }
31790
+ function tripleKeyOf(source, type, target) {
31791
+ return `${source.domain}:${source.id}|${type}|${target.domain}:${target.id}`;
31792
+ }
31793
+ function requireString(record, field, lineNo, label) {
31794
+ const value = record[field];
31795
+ if (!isNonEmptyString(value)) {
31796
+ throw relationsInvalid(`${label ?? `\u7B2C ${lineNo} \u884C`} ${field} \u7F3A\u5931\u6216\u975E\u975E\u7A7A\u5B57\u7B26\u4E32`);
31797
+ }
31798
+ return value;
31799
+ }
31800
+ function requireTrimmed(value, field, why) {
31801
+ const trimmed = (value ?? "").trim();
31802
+ if (trimmed.length === 0) {
31803
+ throw new GovernanceError("SCHEMA_INVALID", `${field} \u4E3A\u7A7A\uFF08${why}\uFF09`, why, { [field]: value ?? null });
31804
+ }
31805
+ return trimmed;
31806
+ }
31807
+ function isNonEmptyString(value) {
31808
+ return typeof value === "string" && value.length > 0;
31809
+ }
31810
+ function notConfigured2(store) {
31811
+ return new GovernanceError("NOT_CONFIGURED", "store \u672A\u521D\u59CB\u5316\uFF08state/truth-index.json \u7F3A\u5931\uFF09", "\u5148\u8DD1 createStore(rootDir) \u5B8C\u6210\u9AA8\u67B6\u521D\u59CB\u5316\uFF08No-op is elegant\uFF09", { rootDir: store.rootDir });
31812
+ }
31813
+ var RELATIONS_RELATIVE, EDGE_ID_PATTERN, CATALOG_ENDPOINT_ID_PATTERN, OBSERVATION_REF_PATTERN;
31814
+ var init_relations = __esm({
31815
+ "packages/kernel/dist/relations.js"() {
31816
+ "use strict";
31817
+ init_errors();
31818
+ init_id();
31819
+ init_digest();
31820
+ init_io();
31821
+ init_paths();
31822
+ init_vocab2();
31823
+ RELATIONS_RELATIVE = ".pomaster/state/relations.jsonl";
31824
+ EDGE_ID_PATTERN = /^EDGE-[0-9a-f]{12}$/;
31825
+ CATALOG_ENDPOINT_ID_PATTERN = /^[A-Z][A-Z0-9_]*(\.[A-Z][A-Z0-9_]+)+$/;
31826
+ OBSERVATION_REF_PATTERN = /^(OBS-[0-9]+|POB-[0-9a-f]{12})$/;
31827
+ }
31828
+ });
31829
+
31830
+ // packages/kernel/dist/family.js
31831
+ function deriveFamily(prefix) {
31832
+ const family = PREFIX_FAMILY_MAP[prefix];
31833
+ if (family === void 0) {
31834
+ throw new Error(`PREFIX_FAMILY_MAP \u6F0F\u524D\u7F00\uFF1A${prefix}\uFF08\u6620\u5C04\u5FC5\u987B\u5BF9 GOVERNED_ID_PREFIXES \u5168\u603B\uFF1B\u65B0\u524D\u7F00\u5165\u95ED\u5305\u987B\u540C\u6279\u8865\u6620\u5C04\u2014\u2014\u8BCD\u6C47\u8868 PR \u4E09\u955C\u50CF\u7EAA\u5F8B\uFF09`);
31835
+ }
31836
+ return family;
31837
+ }
31838
+ function familyOfId(id) {
31839
+ return deriveFamily(parseGovernedId(id).prefix);
31840
+ }
31841
+ var PREFIX_FAMILY_MAP, FAMILIES_WITHOUT_PREFIX, unmapped;
31842
+ var init_family = __esm({
31843
+ "packages/kernel/dist/family.js"() {
31844
+ "use strict";
31845
+ init_id();
31846
+ init_vocab2();
31847
+ PREFIX_FAMILY_MAP = {
31848
+ PAGE: "UI",
31849
+ COMPONENT: "UI",
31850
+ CAPABILITY: "PRODUCT",
31851
+ API_REQ: "INTERFACE",
31852
+ ERR: "INTERFACE",
31853
+ FIELD: "DATA",
31854
+ KEYBINDING: "CODE",
31855
+ KNOWLEDGE: "GOVERNANCE",
31856
+ CHANGE: "GOVERNANCE",
31857
+ TASK: "GOVERNANCE",
31858
+ DENOMINATOR: "GOVERNANCE",
31859
+ POLICY: "GOVERNANCE",
31860
+ PROFILE: "GOVERNANCE",
31861
+ AUTHORITY: "GOVERNANCE",
31862
+ TEST: "EVIDENCE"
31863
+ };
31864
+ FAMILIES_WITHOUT_PREFIX = OBJECT_FAMILY_VALUES.filter((family) => !Object.values(PREFIX_FAMILY_MAP).includes(family));
31865
+ unmapped = GOVERNED_ID_PREFIXES.filter((prefix) => PREFIX_FAMILY_MAP[prefix] === void 0);
31866
+ if (unmapped.length > 0) {
31867
+ throw new Error(`PREFIX_FAMILY_MAP \u6F0F\u524D\u7F00\uFF1A${unmapped.join(" / ")}\uFF08\u5168\u603B\u6027\u81EA\u68C0\u5931\u8D25\u2014\u2014\u8BCD\u6C47\u8868 PR \u589E\u524D\u7F00\u987B\u540C\u6279\u8865\u6620\u5C04\uFF09`);
31868
+ }
31869
+ }
31870
+ });
31871
+
31872
+ // packages/kernel/dist/resolver.js
31873
+ async function resolveNeed(store, catalogRoot, input) {
31874
+ const need = (input.need ?? "").trim();
31875
+ if (need.length === 0) {
31876
+ throw new GovernanceError("SCHEMA_INVALID", "need \u4E3A\u7A7A\uFF08\u7A7A\u9700\u6C42\u65E0\u4ECE\u89E3\u6790\uFF09", '\u7ED9\u51FA\u9700\u6C42\u8BCD\u5F62\u539F\u6587\uFF08pomaster resolve "<need>"\uFF09\uFF1B\u7A7A\u69FD\u4F4D\u662F\u4E0A\u6E38\u4EA7\u51FA\u7F3A\u9677', {});
31877
+ }
31878
+ const hints = (input.hints ?? []).map((hint) => hint.trim()).filter((hint) => hint.length > 0);
31879
+ const truthIndex = await loadTruthIndex(store);
31880
+ const registry = readEquivalenceRegistry(pathsOf(store));
31881
+ const archetypes = loadCatalogArchetypes(catalogRoot);
31882
+ const queryTokens = /* @__PURE__ */ new Set();
31883
+ for (const piece of [need, ...hints]) {
31884
+ for (const token of knowledgeQueryTokens(piece))
31885
+ queryTokens.add(token);
31886
+ }
31887
+ const exactHits = [];
31888
+ let exactVia = null;
31889
+ const candidate = need;
31890
+ let candidateId = candidate;
31891
+ let via = null;
31892
+ try {
31893
+ parseGovernedId(candidate);
31894
+ via = "exact_id";
31895
+ } catch (error) {
31896
+ if (!(error instanceof GovernedIdParseError))
31897
+ throw error;
31898
+ const alias = resolveAlias(candidate);
31899
+ if (alias.matchedRuleLegacy !== null && alias.canonical !== null && alias.canonical !== candidate) {
31900
+ try {
31901
+ parseGovernedId(alias.canonical);
31902
+ candidateId = alias.canonical;
31903
+ via = "exact_id_via_alias";
31904
+ } catch (aliasError) {
31905
+ if (!(aliasError instanceof GovernedIdParseError))
31906
+ throw aliasError;
31907
+ }
31908
+ }
31909
+ }
31910
+ if (via === null) {
31911
+ const resolved = readEquivalenceRegistryForResolve(registry, candidate);
31912
+ if (resolved !== null) {
31913
+ candidateId = resolved;
31914
+ via = "equivalence_active";
31915
+ }
31916
+ }
31917
+ if (via !== null) {
31918
+ const row2 = truthIndex.objects.find((object) => object.id === candidateId);
31919
+ if (row2 !== void 0) {
31920
+ exactVia = via;
31921
+ exactHits.push({
31922
+ domain: "truth",
31923
+ id: row2.id,
31924
+ kind: row2.kind,
31925
+ title_zh: row2.titleZh,
31926
+ via,
31927
+ matched_tokens: [],
31928
+ family: familyOfId(row2.id)
31929
+ });
31930
+ }
31931
+ }
31932
+ const truthTokenHits = [];
31933
+ for (const row2 of truthIndex.objects) {
31934
+ if (exactHits.some((hit) => hit.id === row2.id))
31935
+ continue;
31936
+ const keyTokens = new Set(knowledgeQueryTokens(`${row2.titleZh} ${row2.id}`));
31937
+ const matched = [...queryTokens].filter((token) => keyTokens.has(token)).sort();
31938
+ if (matched.length > 0) {
31939
+ truthTokenHits.push({
31940
+ domain: "truth",
31941
+ id: row2.id,
31942
+ kind: row2.kind,
31943
+ title_zh: row2.titleZh,
31944
+ via: "token_match",
31945
+ matched_tokens: matched,
31946
+ family: familyOfId(row2.id)
31947
+ });
31948
+ }
31949
+ }
31950
+ truthTokenHits.sort(resolverMatchOrder);
31951
+ const catalogHits = [];
31952
+ for (const archetype of archetypes) {
31953
+ const coreKeyTokens = new Set(knowledgeQueryTokens([
31954
+ archetype.titleZh,
31955
+ archetype.id,
31956
+ archetype.summaryZh,
31957
+ archetype.semantic.responsibility ?? "",
31958
+ archetype.semantic.whenToUse ?? "",
31959
+ archetype.semantic.whenNotToUse ?? ""
31960
+ ].join(" ")));
31961
+ const referenceRaw = knowledgeQueryTokens([archetype.referenceAnchors.note ?? "", ...archetype.referenceAnchors.urls].join(" "));
31962
+ const referenceKeyTokens = new Set(referenceRaw.filter((token) => !coreKeyTokens.has(token)));
31963
+ const matched = [...queryTokens].filter((token) => coreKeyTokens.has(token) || referenceKeyTokens.has(token)).sort();
31964
+ if (matched.length === 0)
31965
+ continue;
31966
+ const coreMatched = matched.filter((token) => coreKeyTokens.has(token));
31967
+ catalogHits.push({
31968
+ match: {
31969
+ domain: "catalog",
31970
+ id: archetype.id,
31971
+ kind: archetype.kind,
31972
+ title_zh: archetype.titleZh,
31973
+ via: "token_match",
31974
+ matched_tokens: matched,
31975
+ family: null
31976
+ },
31977
+ coreMatched
31978
+ });
31979
+ }
31980
+ const coreHits = catalogHits.filter((hit) => hit.coreMatched.length > 0).map((hit) => hit.match).sort(resolverMatchOrder);
31981
+ const referenceOnlyHits = catalogHits.filter((hit) => hit.coreMatched.length === 0).map((hit) => hit.match).sort(resolverMatchOrder);
31982
+ const archetypeById = new Map(archetypes.map((entry) => [entry.id, entry]));
31983
+ const compositionLinked = (a, b) => {
31984
+ const materialA = archetypeById.get(a);
31985
+ const materialB = archetypeById.get(b);
31986
+ if (materialA === void 0 || materialB === void 0)
31987
+ return false;
31988
+ return materialA.composition.requires.includes(b) || materialA.composition.optional.includes(b) || materialB.composition.requires.includes(a) || materialB.composition.optional.includes(a);
31989
+ };
31990
+ const coreIds = coreHits.map((hit) => hit.id);
31991
+ const adjacency = /* @__PURE__ */ new Map();
31992
+ let composableLinks = 0;
31993
+ for (let i = 0; i < coreIds.length; i += 1) {
31994
+ for (let j = i + 1; j < coreIds.length; j += 1) {
31995
+ const idA = coreIds[i];
31996
+ const idB = coreIds[j];
31997
+ if (!compositionLinked(idA, idB))
31998
+ continue;
31999
+ composableLinks += 1;
32000
+ if (!adjacency.has(idA))
32001
+ adjacency.set(idA, []);
32002
+ if (!adjacency.has(idB))
32003
+ adjacency.set(idB, []);
32004
+ adjacency.get(idA).push(idB);
32005
+ adjacency.get(idB).push(idA);
32006
+ }
32007
+ }
32008
+ const chainVisited = /* @__PURE__ */ new Set();
32009
+ const participating = /* @__PURE__ */ new Set();
32010
+ for (const root of coreIds) {
32011
+ if (chainVisited.has(root))
32012
+ continue;
32013
+ const component = [];
32014
+ const queue = [root];
32015
+ chainVisited.add(root);
32016
+ while (queue.length > 0) {
32017
+ const current = queue.shift();
32018
+ component.push(current);
32019
+ for (const next of adjacency.get(current) ?? []) {
32020
+ if (!chainVisited.has(next)) {
32021
+ chainVisited.add(next);
32022
+ queue.push(next);
32023
+ }
32024
+ }
32025
+ }
32026
+ if (component.length >= 2) {
32027
+ for (const id of component)
32028
+ participating.add(id);
32029
+ }
32030
+ }
32031
+ const chainHits = coreHits.filter((hit) => participating.has(hit.id));
32032
+ const nonChainCoreHits = coreHits.filter((hit) => !participating.has(hit.id));
32033
+ let matchClass;
32034
+ let matches;
32035
+ let alternatives;
32036
+ if (exactHits.length > 0) {
32037
+ matchClass = "EXACT_MATCH";
32038
+ matches = exactHits;
32039
+ alternatives = [...coreHits, ...referenceOnlyHits, ...truthTokenHits];
32040
+ } else if (participating.size >= 2) {
32041
+ matchClass = "COMPOSABLE_MATCH";
32042
+ matches = chainHits;
32043
+ alternatives = [...nonChainCoreHits, ...referenceOnlyHits, ...truthTokenHits];
32044
+ } else if (coreHits.length > 0) {
32045
+ matchClass = "CONFIGURABLE_MATCH";
32046
+ matches = coreHits;
32047
+ alternatives = [...referenceOnlyHits, ...truthTokenHits];
32048
+ } else if (truthTokenHits.length > 0) {
32049
+ matchClass = "EXTENSIBLE_MATCH";
32050
+ matches = truthTokenHits;
32051
+ alternatives = [...referenceOnlyHits];
32052
+ } else if (referenceOnlyHits.length > 0) {
32053
+ matchClass = "REFERENCE_MATCH";
32054
+ matches = referenceOnlyHits;
32055
+ alternatives = [];
32056
+ } else {
32057
+ matchClass = "NO_MATCH";
32058
+ matches = [];
32059
+ alternatives = [];
32060
+ }
32061
+ const requiredBindings = /* @__PURE__ */ new Set();
32062
+ for (const hit of matches) {
32063
+ if (hit.domain !== "catalog")
32064
+ continue;
32065
+ const archetype = archetypes.find((candidate2) => candidate2.id === hit.id);
32066
+ for (const require2 of archetype?.composition.requires ?? []) {
32067
+ requiredBindings.add(require2);
32068
+ }
32069
+ }
32070
+ return {
32071
+ input: { need, hints },
32072
+ match_class: matchClass,
32073
+ matches,
32074
+ alternatives,
32075
+ required_bindings: [...requiredBindings].sort(),
32076
+ required_gates: [NEW_ENTITY_GATE_DEF],
32077
+ why: whyOf(matchClass, exactVia, exactHits.length > 0, need),
32078
+ sources_examined: {
32079
+ truth_rows: truthIndex.objects.length,
32080
+ catalog_archetypes: archetypes.length,
32081
+ equivalence_groups: registry.entries.filter((entry) => entry.status === "active").length,
32082
+ exact_hits: exactHits.length,
32083
+ token_match_hits: truthTokenHits.length + coreHits.length + referenceOnlyHits.length,
32084
+ composable_links: composableLinks,
32085
+ reference_hits: referenceOnlyHits.length
32086
+ }
32087
+ };
32088
+ }
32089
+ function newEntityVerdictFromResolution(matchClass) {
32090
+ switch (matchClass) {
32091
+ case "NO_MATCH":
32092
+ return { new_entity_allowed: true, denied_by: [] };
32093
+ case "EXACT_MATCH":
32094
+ case "CONFIGURABLE_MATCH":
32095
+ case "EXTENSIBLE_MATCH":
32096
+ case "COMPOSABLE_MATCH":
32097
+ case "REFERENCE_MATCH":
32098
+ return { new_entity_allowed: false, denied_by: [matchClass] };
32099
+ default:
32100
+ throw new GovernanceError("SCHEMA_INVALID", `match_class \u8BCD\u8868\u5916\uFF1A${String(matchClass)}\uFF08resolution_match_class \u516D\u503C\u95ED\u5305\uFF0CPR-0006\uFF09`, `\u5408\u6CD5\u8BCD\u5F62\uFF1AEXACT_MATCH | CONFIGURABLE_MATCH | COMPOSABLE_MATCH | EXTENSIBLE_MATCH | REFERENCE_MATCH | NO_MATCH`, { match_class: String(matchClass) });
32101
+ }
32102
+ }
32103
+ function readEquivalenceRegistryForResolve(registry, text) {
32104
+ for (const entry of registry.entries) {
32105
+ if (entry.status !== "active")
32106
+ continue;
32107
+ if (entry.word_forms.some((form) => form.text === text)) {
32108
+ const canonical = entry.word_forms.find((form) => form.domain === "canonical");
32109
+ return canonical?.text ?? null;
32110
+ }
32111
+ }
32112
+ return null;
32113
+ }
32114
+ function whyOf(matchClass, exactVia, exactInStore, need) {
32115
+ switch (matchClass) {
32116
+ case "EXACT_MATCH":
32117
+ return `\u7CBE\u786E\u817F\u547D\u4E2D\uFF08via=${exactVia ?? "unknown"}\uFF09\u2014\u2014\u9700\u6C42\u8BCD\u5F62\u6307\u5411\u5728\u518C\u9879\u76EE\u5BF9\u8C61\u300C${need}\u300D\uFF08EXACT_MATCH\uFF1A\u590D\u7528\u65E2\u6709\u5BF9\u8C61\uFF0C\u7981\u518D\u5EFA\u7B49\u4EF7\u65B0\u5B9E\u4F53\uFF09`;
32118
+ case "CONFIGURABLE_MATCH":
32119
+ return "Engineering Substrate \u6807\u51C6\u4EF6\u547D\u4E2D\uFF08CONFIGURABLE_MATCH\uFF1Aarchetype \u5B9A\u4E49\u4F4F catalog \u9762\uFF0C\u5B9E\u4F8B\u5316\u65F6\u7531\u4E1A\u52A1\u51B3\u5B9A\u5B57\u6BB5/\u53D8\u4F53/\u6743\u9650\u2014\u2014v0.6.1 \xA770 \u7528\u6237\u7BA1\u7406\u5224\u4F8B\uFF1B\u5B9E\u4F8B\u91C7\u7528\u8D70 INSTANCE_OF \u8FB9\u663E\u5F0F\u767B\u8BB0\uFF0C\u89E3\u6790\u2260\u91C7\u7528\uFF09";
32120
+ case "COMPOSABLE_MATCH":
32121
+ return "\u591A\u6807\u51C6\u4EF6\u7EC4\u5408\u53EF\u6EE1\u8DB3\uFF08COMPOSABLE_MATCH\uFF1A\u547D\u4E2D\u6807\u51C6\u4EF6\u7ECF composition.requires/optional \u6784\u6210\u7EC4\u5408\u94FE\u2014\u2014v0.6.1 \xA769\uFF1B\u7EC4\u5408\u53EF\u6EE1\u8DB3\u5373\u7EC4\u5408\u5426\u4E0D\u6210\u7ACB\uFF0C\u7981\u7ED5\u8FC7\u6807\u51C6\u4EF6\u5E73\u884C\u81EA\u9020\uFF1Bmatches=\u53C2\u4E0E\u94FE\u7684 archetype\uFF0C\u94FE\u4E0A\u8FB9\u6570\u89C1 sources_examined.composable_links\uFF09";
32122
+ case "EXTENSIBLE_MATCH":
32123
+ return "\u9879\u76EE\u5BF9\u8C61\u8BCD\u5F62\u547D\u4E2D\uFF08EXTENSIBLE_MATCH\uFF1A\u73B0\u6709\u5BF9\u8C61\u53EF\u6269\u5C55\u627F\u8F7D\u9700\u6C42\u2014\u2014\u5148\u67E5\u6269\u5C55\u4F4D\uFF0C\u7981\u5E73\u884C\u65B0\u5EFA\uFF09";
32124
+ case "REFERENCE_MATCH":
32125
+ return "\u5916\u90E8\u53C2\u7167\u4F53\u7CFB\u547D\u4E2D\uFF08REFERENCE_MATCH\uFF1A\u9700\u6C42\u63CF\u8FF0\u7684\u662F\u53C2\u7167\u5B9E\u73B0\u800C\u975E\u672C\u9879\u76EE\u5BF9\u8C61\u2014\u2014\u53C2\u7167\u7CFB\u5DF2\u6709\u843D\u70B9\uFF0Cadapter/\u53C2\u7167\u5426\u4E0D\u6210\u7ACB\uFF1B\u53C2\u7167\u8BCD\u5F62\u6765\u81EA\u7269\u6599 x-research-anchors\uFF0C\u547D\u4E2D\u6570\u89C1 sources_examined.reference_hits\uFF09";
32126
+ case "NO_MATCH":
32127
+ return "\u4E24\u5206\u6BCD\uFF08truth \u5BF9\u8C61 + catalog \u6807\u51C6\u4EF6\uFF09\u96F6\u547D\u4E2D\uFF08NO_MATCH\uFF1A\u663E\u5F0F\u7F3A\u5E2D\u2014\u2014\u5141\u8BB8\u8FDB\u5165 Design Synthesis\uFF0C\u4F46\u65B0\u5B9E\u4F53\u5FC5\u8FC7 New Entity Gate \u4E94\u5426\u8BC1\u660E\uFF1B\u5206\u6BCD\u8BA1\u6570\u89C1 sources_examined\uFF0Cadvisory \u9762\u547D\u4E2D\u4E0D\u6539\u53D8\u672C\u5224\u5B9A\u2014\u2014advisory \u2260 match\uFF0C\xA787\uFF09";
32128
+ default:
32129
+ return `match_class=${matchClass}\uFF08\u8BCD\u8868\u5916\u503C\u2014\u2014\u516D\u5206\u7C7B\u95ED\u5305\u5916\u6D3E\u751F\u4E0D\u5E94\u51FA\u73B0\uFF0C\u663E\u5F0F\u5448\u73B0\u7981\u9759\u9ED8\uFF09`;
32130
+ }
32131
+ }
32132
+ function resolverMatchOrder(a, b) {
32133
+ return b.matched_tokens.length - a.matched_tokens.length || (a.id < b.id ? -1 : 1);
32134
+ }
32135
+ var NEW_ENTITY_GATE_DEF;
32136
+ var init_resolver = __esm({
32137
+ "packages/kernel/dist/resolver.js"() {
32138
+ "use strict";
32139
+ init_catalog();
32140
+ init_errors();
32141
+ init_errors();
32142
+ init_id();
32143
+ init_knowledge();
32144
+ init_equivalence();
32145
+ init_paths();
32146
+ init_store();
32147
+ init_family();
32148
+ NEW_ENTITY_GATE_DEF = "POLICY.GATE.NEW_ENTITY.CHECKS@0.1.0";
32149
+ }
32150
+ });
32151
+
32152
+ // packages/kernel/dist/new-entity.js
32153
+ async function runNewEntityGate(store, catalogRoot, input) {
32154
+ const paths = pathsOf(store);
32155
+ const currentSeq = readCurrentSeq(paths);
32156
+ if (currentSeq === null) {
32157
+ throw new GovernanceError("NOT_CONFIGURED", "store \u672A\u521D\u59CB\u5316\uFF08state/truth-index.json \u7F3A\u5931\uFF09", "\u5148\u8DD1 createStore(rootDir) \u5B8C\u6210\u9AA8\u67B6\u521D\u59CB\u5316\uFF08No-op is elegant\uFF09", { rootDir: store.rootDir });
32158
+ }
32159
+ if (!Array.isArray(input.candidates)) {
32160
+ throw new GovernanceError("SCHEMA_INVALID", "candidates \u7F3A\u5931\uFF08\u5224\u5377\u5206\u6BCD\u5FC5\u7B54\u2014\u2014\u7A7A\u6570\u7EC4\u662F\u5408\u6CD5\u503C\uFF0C\u7F3A\u4F4D\u4E0D\u662F\uFF09", "\u7ED9\u5019\u9009\u6E05\u5355\uFF08\u53EF\u4E3A\u7A7A\uFF1B\u7A7A\u6570\u7EC4 \u2192 not_run \u96F6\u5206\u6BCD\u663E\u5F0F\uFF09", {});
32161
+ }
32162
+ const truthIndex = await loadTruthIndex(store);
32163
+ const knownIds = new Set(truthIndex.objects.map((object) => object.id));
32164
+ const archetypes = loadCatalogArchetypes(catalogRoot);
32165
+ const judgements = [];
32166
+ for (const candidate of input.candidates) {
32167
+ const wordForm = (candidate?.wordForm ?? "").trim();
32168
+ const need = (candidate?.need ?? "").trim() || wordForm;
32169
+ if (wordForm.length === 0) {
32170
+ throw new GovernanceError("SCHEMA_INVALID", "\u5019\u9009 wordForm \u4E3A\u7A7A\uFF08\u7A7A\u8BCD\u5F62\u65E0\u4ECE\u5224\u5377\uFF09", "\u7ED9\u51FA\u62DF\u65B0\u5EFA\u5B9E\u4F53\u7684\u975E\u7A7A\u8BCD\u5F62", {});
32171
+ }
32172
+ let grammarOk = true;
32173
+ try {
32174
+ parseGovernedId(wordForm);
32175
+ } catch (error) {
32176
+ if (!(error instanceof GovernedIdParseError))
32177
+ throw error;
32178
+ grammarOk = false;
32179
+ }
32180
+ if (!grammarOk) {
32181
+ judgements.push({
32182
+ word_form: wordForm,
32183
+ need,
32184
+ disposition: "blindspot",
32185
+ denied_by: ["grammar_invalid"],
32186
+ match_class: null,
32187
+ matches: [],
32188
+ sources_examined: {
32189
+ truth_rows: truthIndex.objects.length,
32190
+ catalog_archetypes: archetypes.length
32191
+ },
32192
+ rationale: "\u62DF\u7528\u8BCD\u5F62\u4E0D\u8FC7 governed id \u6587\u6CD5\uFF08A5 closed-world\uFF09\u2014\u2014\u6587\u6CD5\u5916\u8BCD\u5F62\u4E0D\u53EF\u5224\u5377\uFF08\u76F2\u533A\u663E\u5F0F\uFF1A\u4FEE\u590D\u8BCD\u5F62\u540E\u91CD\u8DD1\uFF0C\u7981\u731C\u6D4B\u653E\u884C\uFF09"
32193
+ });
32194
+ continue;
32195
+ }
32196
+ if (knownIds.has(wordForm)) {
32197
+ judgements.push({
32198
+ word_form: wordForm,
32199
+ need,
32200
+ disposition: "denied",
32201
+ denied_by: ["word_form_exists"],
32202
+ match_class: "EXACT_MATCH",
32203
+ matches: [],
32204
+ sources_examined: {
32205
+ truth_rows: truthIndex.objects.length,
32206
+ catalog_archetypes: archetypes.length
32207
+ },
32208
+ rationale: `\u8BCD\u5F62 ${wordForm} \u5DF2\u5728\u518C\uFF08\u540C id \u91CD\u590D\u767B\u8BB0=\u8C03\u7528\u65B9\u7F3A\u9677\uFF09`
32209
+ });
32210
+ continue;
32211
+ }
32212
+ const alias = resolveAlias(wordForm);
32213
+ if (alias.canonical !== null && alias.canonical !== wordForm && knownIds.has(alias.canonical)) {
32214
+ judgements.push({
32215
+ word_form: wordForm,
32216
+ need,
32217
+ disposition: "denied",
32218
+ denied_by: ["word_form_exists_via_alias"],
32219
+ match_class: "EXACT_MATCH",
32220
+ matches: [{ domain: "truth", id: alias.canonical, kind: "existing", title_zh: alias.canonical, via: "exact_id_via_alias", matched_tokens: [], family: null }],
32221
+ sources_examined: {
32222
+ truth_rows: truthIndex.objects.length,
32223
+ catalog_archetypes: archetypes.length
32224
+ },
32225
+ rationale: `\u8BCD\u5F62\u7ECF A6 \u522B\u540D\u65CF\u6536\u7F16\u547D\u4E2D\u5728\u518C\u5BF9\u8C61 ${alias.canonical}\uFF08rule=${alias.matchedRuleLegacy}\uFF09\u2014\u2014\u590D\u7528\u65E2\u6709\u5BF9\u8C61`
32226
+ });
32227
+ continue;
32228
+ }
32229
+ const resolution = await resolveNeed(store, catalogRoot, { need });
32230
+ const verdict = newEntityVerdictFromResolution(resolution.match_class);
32231
+ if (verdict.new_entity_allowed) {
32232
+ const emptyDenominator = resolution.sources_examined.truth_rows === 0 && resolution.sources_examined.catalog_archetypes === 0;
32233
+ if (emptyDenominator) {
32234
+ judgements.push({
32235
+ word_form: wordForm,
32236
+ need,
32237
+ disposition: "blindspot",
32238
+ denied_by: ["empty_denominator"],
32239
+ match_class: resolution.match_class,
32240
+ matches: resolution.matches,
32241
+ sources_examined: {
32242
+ truth_rows: resolution.sources_examined.truth_rows,
32243
+ catalog_archetypes: resolution.sources_examined.catalog_archetypes
32244
+ },
32245
+ rationale: "NO_MATCH \u7684\u4E24\u5206\u6BCD\u5747\u4E3A\u7A7A\uFF08truth_rows=0 \u4E14 catalog_archetypes=0\uFF09\u2014\u2014\u300C\u6CA1\u67E5\u300D\u2260\u300C\u67E5\u4E86\u6CA1\u6709\u300D\uFF08skipped_blindspot\uFF1A\u5206\u6BCD\u5728\u573A\u540E\u91CD\u8DD1\uFF09"
32246
+ });
32247
+ continue;
32248
+ }
32249
+ judgements.push({
32250
+ word_form: wordForm,
32251
+ need,
32252
+ disposition: "allowed",
32253
+ denied_by: [],
32254
+ match_class: resolution.match_class,
32255
+ matches: resolution.matches,
32256
+ sources_examined: {
32257
+ truth_rows: resolution.sources_examined.truth_rows,
32258
+ catalog_archetypes: resolution.sources_examined.catalog_archetypes
32259
+ },
32260
+ rationale: "\u4E94\u5426\u8BC1\u660E\u6210\u7ACB\uFF08NO_MATCH\uFF1Aexact/configuration/composition/extension/adapter \u4E94\u5426\u5168\u7531 match_class \u673A\u5224\u95ED\u5408\u2014\u2014\u6279\u6B21 2 \u8D77\u516D\u5206\u7C7B\u6D3E\u751F\u9762\u5E76\u62E2\uFF09\uFF1B\u5141\u8BB8\u8FDB\u5165 Design Synthesis\uFF0C\u91C7\u7528\u52A8\u4F5C\u987B\u767B\u8BB0 INSTANCE_OF \u8FB9 + key_bindings"
32261
+ });
32262
+ continue;
32263
+ }
32264
+ judgements.push({
32265
+ word_form: wordForm,
32266
+ need,
32267
+ disposition: "denied",
32268
+ denied_by: verdict.denied_by,
32269
+ match_class: resolution.match_class,
32270
+ matches: resolution.matches,
32271
+ sources_examined: {
32272
+ truth_rows: resolution.sources_examined.truth_rows,
32273
+ catalog_archetypes: resolution.sources_examined.catalog_archetypes
32274
+ },
32275
+ rationale: `\u9700\u6C42\u8BCD\u5F62\u547D\u4E2D\u65E2\u6709\u9762\uFF08match_class=${resolution.match_class}\uFF1Bdenied_by=${verdict.denied_by.join("/")}\uFF09\u2014\u2014\u590D\u7528/\u914D\u7F6E/\u6269\u5C55\u65E2\u6709\u5B9E\u4F53\uFF0C\u7981\u5E73\u884C\u65B0\u5EFA`
32276
+ });
32277
+ }
32278
+ const denied = judgements.filter((j) => j.disposition === "denied").length;
32279
+ const blindspot = judgements.filter((j) => j.disposition === "blindspot").length;
32280
+ const allowed = judgements.filter((j) => j.disposition === "allowed").length;
32281
+ const total = judgements.length;
32282
+ let decision;
32283
+ if (total === 0) {
32284
+ decision = {
32285
+ verdict: "not_run",
32286
+ rationale: "\u96F6\u5206\u6BCD\u7981\u5F53\u6EE1\u5206\uFF08P26 \u540C\u6B3E\uFF09\uFF1A\u5019\u9009\u96C6\u4E3A\u7A7A\uFF0C\u672C run \u65E0\u53EF\u5224\u5377\u5BF9\u8C61\u2014\u2014\u663E\u5F0F not_run \u800C\u975E passed"
32287
+ };
32288
+ } else if (denied > 0) {
32289
+ decision = {
32290
+ verdict: "failed",
32291
+ rationale: `${denied}/${total} \u5019\u9009\u88AB\u62D2\uFF08\u5728\u518C\u649E\u540D/\u9700\u6C42\u547D\u4E2D\u65E2\u6709\u9762\u2014\u2014\u771F\u8FDD\u89C4\u4E0D\u88AB\u76F2\u533A\u6D17\u767D\uFF09\uFF1B\u660E\u7EC6\u89C1 judgements.denied_by`
32292
+ };
32293
+ } else if (blindspot > 0) {
32294
+ decision = {
32295
+ verdict: "skipped_blindspot",
32296
+ rationale: `${blindspot}/${total} \u5019\u9009\u4E0D\u53EF\u5224\u5377\uFF08\u6587\u6CD5\u5916\u8BCD\u5F62/\u7A7A\u5206\u6BCD NO_MATCH\u2014\u2014\u76F2\u533A\u663E\u5F0F\u8BA1\u6570\uFF0C\u975E\u5047\u7EFF\u975E\u5047\u7EA2\uFF1B\u4FEE\u590D\u540E\u91CD\u8DD1\uFF09`
32297
+ };
32298
+ } else {
32299
+ decision = {
32300
+ verdict: "passed",
32301
+ rationale: `${allowed}/${total} \u5019\u9009\u4E94\u5426\u8BC1\u660E\u6210\u7ACB\uFF08NO_MATCH \u5206\u6BCD\u5728\u573A\uFF09\uFF1BDesign Synthesis \u653E\u884C`
32302
+ };
32303
+ }
32304
+ return {
32305
+ gate: NEW_ENTITY_GATE,
32306
+ gate_def: "POLICY.GATE.NEW_ENTITY.CHECKS@0.1.0",
32307
+ ran_at_seq: currentSeq,
32308
+ judgements,
32309
+ counts: { total, denied, allowed, blindspot, notApplicable: 0 },
32310
+ result: decision
32311
+ };
32312
+ }
32313
+ function instanceOfEdgesPresent(entries, sourceId) {
32314
+ return entries.filter((entry) => entry.type === "INSTANCE_OF" && entry.source.domain === "truth" && entry.source.id === sourceId).map((entry) => entry.target.id);
32315
+ }
32316
+ var NEW_ENTITY_GATE;
32317
+ var init_new_entity = __esm({
32318
+ "packages/kernel/dist/new-entity.js"() {
32319
+ "use strict";
32320
+ init_catalog();
32321
+ init_errors();
32322
+ init_id();
32323
+ init_paths();
32324
+ init_relations();
32325
+ init_resolver();
32326
+ init_store();
32327
+ NEW_ENTITY_GATE = "NEW_ENTITY";
32328
+ }
32329
+ });
32330
+
32331
+ // packages/kernel/dist/analyzer-contract.js
32332
+ function normalizeAnalyzerReport(input) {
32333
+ const analyzer = (input.analyzer ?? "").trim();
32334
+ if (!ANALYZER_ID_PATTERN.test(analyzer)) {
32335
+ throw new GovernanceError("SCHEMA_INVALID", `analyzer \u8BCD\u5F62\u975E\u6CD5\uFF1A${analyzer}\uFF08\u987B ANALYZER.<DOMAIN>.<KIND>\u2014\u2014PRD \xA7103 Catalog \u8BCD\u5F62\u65CF\uFF09`, "analyzer \u81EA\u62A5\u8BCD\u5F62\u662F\u4EA7\u51FA\u8005\u8EAB\u4EFD\u4F4D\uFF1B\u81EA\u7531\u6587\u672C\u4E0D\u662F\u8EAB\u4EFD", { analyzer });
32336
+ }
32337
+ const scannedScope = (input.scannedScope ?? "").trim();
32338
+ if (scannedScope.length === 0) {
32339
+ throw new GovernanceError("SCHEMA_INVALID", "scannedScope \u4E3A\u7A7A\uFF08\u300C\u626B\u4E86\u4EC0\u4E48\u300D\u5FC5\u7B54\u2014\u2014\xA7148 \u907F\u514D\u53EA\u8FD4\u56DE\u6210\u529F\u9879\u7684\u5047\u7EFF\uFF09", "\u7ED9\u51FA\u626B\u63CF\u8303\u56F4\uFF08\u76EE\u5F55 glob / \u6587\u4EF6\u6E05\u5355\u951A / \u5206\u6BCD\u5F15\u7528\uFF09", {});
32340
+ }
32341
+ for (const [field, value] of [
32342
+ ["objectsResolved", input.objectsResolved],
32343
+ ["relationsResolved", input.relationsResolved]
32344
+ ]) {
32345
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
32346
+ throw new GovernanceError("SCHEMA_INVALID", `${field} \u975E\u6CD5\uFF08\u987B\u975E\u8D1F\u6574\u6570\uFF09`, "\xA7148 \u8BA1\u6570\u4F4D\u5FC5\u7B54\uFF080 \u662F\u5408\u6CD5\u503C\u2014\u2014\u96F6\u547D\u4E2D\u663E\u5F0F\u5448\u73B0\u4E0D\u7F3A\u5E2D\uFF09", { [field]: value });
32347
+ }
32348
+ }
32349
+ const unsupported = stringListOf(input.unsupportedConstructs, "unsupportedConstructs");
32350
+ const unresolved = stringListOf(input.unresolvedConstructs, "unresolvedConstructs");
32351
+ const parseFailures = stringListOf(input.parseFailures, "parseFailures");
32352
+ const confidence = normalizeConfidence(input.confidence);
32353
+ if (confidence === "deterministic" && (parseFailures.length > 0 || unresolved.length > 0)) {
32354
+ throw new GovernanceError("SCHEMA_INVALID", `confidence=deterministic \u5374\u643A\u5E26 parse_failures(${parseFailures.length})/unresolved_constructs(${unresolved.length})\uFF08\u786E\u5B9A\u6027\u5BA3\u79F0\u4E0E\u5931\u8D25\u6E05\u5355\u5E76\u5B58 = \u5047\u7EFF\u6D17\u767D\uFF0C\xA7148\uFF09`, "\u964D\u7EA7 confidence=probable \u5E76\u62AB\u9732\u4E0D\u786E\u5B9A\u6027\uFF1B\u6216\u4FEE\u590D\u89E3\u6790\u5931\u8D25\u540E\u518D\u5BA3\u79F0\u786E\u5B9A", { analyzer, parse_failures: parseFailures.length, unresolved: unresolved.length });
32355
+ }
32356
+ const sourceSha = (input.sourceSha ?? "").trim();
32357
+ if (!SOURCE_SHA_PATTERN.test(sourceSha)) {
32358
+ throw new GovernanceError("SCHEMA_INVALID", `source_sha \u8BCD\u5F62\u975E\u6CD5\uFF08\u987B sha256:<64hex>\u2014\u2014\u7ED3\u8BBA\u5BF9\u54EA\u4E2A\u6E90\u5FEB\u7167\u6210\u7ACB\u7684\u951A\u4F4D\uFF0C\xA7148/\xA7132\uFF09`, "\u6E90\u5FEB\u7167\u951A\u7531\u57FA\u7840\u8BBE\u65BD\u8BA1\u7B97\uFF08D24\uFF1A\u4EBA\u7C7B\u7981\u89E6\u54C8\u5E0C\uFF09\uFF1B\u7F3A\u951A\u7684\u62A5\u544A\u4E0D\u53EF\u5165\u8D26", { analyzer, source_sha: sourceSha.slice(0, 24) });
32359
+ }
32360
+ return {
32361
+ analyzer,
32362
+ scanned_scope: scannedScope,
32363
+ objects_resolved: input.objectsResolved,
32364
+ relations_resolved: input.relationsResolved,
32365
+ unsupported_constructs: unsupported,
32366
+ unresolved_constructs: unresolved,
32367
+ parse_failures: parseFailures,
32368
+ confidence,
32369
+ source_sha: sourceSha
32370
+ };
32371
+ }
32372
+ function partitionBlindSpotAttempts(attempts) {
32373
+ let observed = 0;
32374
+ let absent = 0;
32375
+ let unsupported = 0;
32376
+ let blindspot = 0;
32377
+ for (const attempt of attempts) {
32378
+ switch (attempt.prd_state) {
32379
+ case "SUPPORTED_AND_OBSERVED":
32380
+ observed += 1;
32381
+ break;
32382
+ case "SUPPORTED_NOT_FOUND":
32383
+ absent += 1;
32384
+ break;
32385
+ case "UNSUPPORTED":
32386
+ unsupported += 1;
32387
+ break;
32388
+ case "FAILED_TO_OBSERVE":
32389
+ blindspot += 1;
32390
+ break;
32391
+ default:
32392
+ throw new GovernanceError("SCHEMA_INVALID", `\u76F2\u533A\u56DB\u6001\u8BCD\u5F62\u975E\u6CD5\uFF1A${String(attempt.prd_state)}\uFF08PRD \xA7149 \u56DB\u6001\u6587\u6863\u955C\u50CF\u4F4D\uFF09`, `\u5408\u6CD5\u8BCD\u5F62\uFF1A${PRD_BLINDSPOT_STATES.join(" / ")}`, { input: attempt.input });
32393
+ }
32394
+ }
32395
+ const total = attempts.length;
32396
+ return {
32397
+ total,
32398
+ observed,
32399
+ absent,
32400
+ unsupported,
32401
+ blindspot,
32402
+ coverage_ratio: total > 0 ? observed / total : 0,
32403
+ zero_denominator: total === 0,
32404
+ unchecked_in_blindspot_estimated: blindspot
32405
+ };
32406
+ }
32407
+ function normalizeConfidence(value) {
32408
+ const trimmed = (value ?? "").trim();
32409
+ if (trimmed === "deterministic" || trimmed === "probable" || trimmed === "declared") {
32410
+ return trimmed;
32411
+ }
32412
+ throw new GovernanceError("SCHEMA_INVALID", `confidence \u8BCD\u8868\u5916\uFF1A${value}\uFF08software_graph_vocab.relation_confidence \u4E09\u503C\u95ED\u5305\uFF0CPR-0006\uFF09`, "\u5408\u6CD5\u8BCD\u5F62\uFF1Adeterministic | probable | declared", { confidence: value });
32413
+ }
32414
+ function stringListOf(value, field) {
32415
+ if (value === void 0)
32416
+ return [];
32417
+ if (!Array.isArray(value)) {
32418
+ throw new GovernanceError("SCHEMA_INVALID", `${field} \u975E\u6570\u7EC4\uFF08\xA7148 \u5FC5\u7B54\u4F4D\uFF1A\u7A7A\u6570\u7EC4\u662F\u5408\u6CD5\u503C\uFF0C\u7F3A\u4F4D\u4E0D\u662F\uFF09`, "\u7ED9\u6570\u7EC4\uFF08\u53EF\u4E3A\u7A7A\uFF09\uFF1B\u7F3A\u5E2D=\u300C\u53EA\u8FD4\u56DE\u6210\u529F\u9879\u300D\u5047\u7EFF\u901A\u9053", { field });
32419
+ }
32420
+ for (const item of value) {
32421
+ if (typeof item !== "string" || item.trim().length === 0) {
32422
+ throw new GovernanceError("SCHEMA_INVALID", `${field} \u5B58\u5728\u7A7A/\u975E\u5B57\u7B26\u4E32\u6761\u76EE`, "\u6BCF\u6761\u62AB\u9732\u4F4D\u987B\u4E3A\u975E\u7A7A\u8BCD\u5F62\uFF08\u6784\u9020\u951A / \u4F4D\u7F6E\u951A\uFF09", { field });
32423
+ }
32424
+ }
32425
+ return value;
32426
+ }
32427
+ var ANALYZER_ID_PATTERN, SOURCE_SHA_PATTERN, PRD_BLINDSPOT_STATES, BLINDSPOT_CANONICAL_OBSERVED, PRD_BLINDSPOT_STATE_MAPPING;
32428
+ var init_analyzer_contract = __esm({
32429
+ "packages/kernel/dist/analyzer-contract.js"() {
32430
+ "use strict";
32431
+ init_perception();
32432
+ init_errors();
32433
+ ANALYZER_ID_PATTERN = /^ANALYZER\.[A-Z][A-Z0-9_]*(\.[A-Z][A-Z0-9_]+)*$/;
32434
+ SOURCE_SHA_PATTERN = /^sha256:[0-9a-f]{64}$/;
32435
+ PRD_BLINDSPOT_STATES = [
32436
+ "SUPPORTED_AND_OBSERVED",
32437
+ "SUPPORTED_NOT_FOUND",
32438
+ "UNSUPPORTED",
32439
+ "FAILED_TO_OBSERVE"
32440
+ ];
32441
+ BLINDSPOT_CANONICAL_OBSERVED = "OBSERVED";
32442
+ PRD_BLINDSPOT_STATE_MAPPING = {
32443
+ SUPPORTED_AND_OBSERVED: ["OBSERVED"],
32444
+ // 「没看到≠不存在」:OBSERVED_ABSENT 有严格四前提(perception.ts OBSERVED_ABSENT 封条)。
32445
+ SUPPORTED_NOT_FOUND: ["OBSERVED_ABSENT"],
32446
+ UNSUPPORTED: ["NOT_OBSERVABLE", "SENSOR_UNAVAILABLE", "PERMISSION_DENIED", "ENVIRONMENT_INVALID"],
32447
+ FAILED_TO_OBSERVE: ["PROBE_FAILED", "INCONCLUSIVE"]
32448
+ };
32449
+ for (const state of PRD_BLINDSPOT_STATES) {
32450
+ for (const canonical of PRD_BLINDSPOT_STATE_MAPPING[state]) {
32451
+ if (canonical === BLINDSPOT_CANONICAL_OBSERVED)
32452
+ continue;
32453
+ if (!NEGATIVE_OBSERVATION_VALUES.includes(canonical)) {
32454
+ throw new Error(`PRD_BLINDSPOT_STATE_MAPPING[${state}] canonical\u300C${canonical}\u300D\u4E0D\u5728\u65E2\u6709 perception \u8BCD\u9762\uFF08\u96F6\u65B0\u8BCD\u4E0D\u53D8\u5F0F\u88AB\u7834\u574F\u2014\u2014\u7981\u6B62\u53D1\u660E\u76F2\u533A\u8BCD\u503C\uFF09`);
32455
+ }
32456
+ }
32457
+ }
32458
+ }
32459
+ });
32460
+
32461
+ // packages/kernel/dist/analyzer-import-graph.js
32462
+ function analyzeImportGraph(input) {
32463
+ for (const [path, id] of Object.entries(input.mapping)) {
32464
+ try {
32465
+ parseGovernedId(id);
32466
+ } catch (error) {
32467
+ if (error instanceof GovernedIdParseError) {
32468
+ throw new GovernanceError("SCHEMA_INVALID", `mapping \u503C\u4E0D\u8FC7 governed id \u6587\u6CD5\uFF08A5 closed-world\uFF09: ${path} \u2192 ${id}\uFF08${error.message}\uFF09`, "mapping \u503C\u662F\u8FB9\u63D0\u6848\u7AEF\u70B9\u8EAB\u4EFD\uFF1B\u574F\u6761\u76EE\u6574\u4F53\u62D2\u7EDD\uFF08\u7981\u9759\u9ED8\u8DF3\u8FC7\u2014\u2014\u9759\u9ED8 = \u8FB9\u7AEF\u70B9\u8EAB\u4EFD\u5931\u771F\uFF09", { path, id });
32469
+ }
32470
+ throw error;
32471
+ }
32472
+ }
32473
+ const sorted = [...input.files].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
32474
+ const edges = [];
32475
+ const edgeSeen = /* @__PURE__ */ new Set();
32476
+ const unmapped2 = [];
32477
+ let externalImports = 0;
32478
+ let objectsResolved = 0;
32479
+ for (const file of sorted) {
32480
+ const sourceId = hasOwn(input.mapping, file.path) ? input.mapping[file.path] : void 0;
32481
+ if (sourceId !== void 0)
32482
+ objectsResolved += 1;
32483
+ for (const specifier of scanImportSpecifiers(file.content)) {
32484
+ if (!isRelativeSpecifier(specifier)) {
32485
+ externalImports += 1;
32486
+ continue;
32487
+ }
32488
+ const targetKey = resolveRelativeCandidate(joinFromSourceDir(file.path, specifier), input.mapping);
32489
+ if (targetKey === null) {
32490
+ unmapped2.push({ source: file.path, specifier, reason: "target_unresolved" });
32491
+ continue;
32492
+ }
32493
+ if (sourceId === void 0) {
32494
+ unmapped2.push({ source: file.path, specifier, reason: "source_not_mapped" });
32495
+ continue;
32496
+ }
32497
+ const targetId = input.mapping[targetKey];
32498
+ const dedupeKey = `${sourceId}|${targetId}`;
32499
+ if (edgeSeen.has(dedupeKey))
32500
+ continue;
32501
+ edgeSeen.add(dedupeKey);
32502
+ edges.push({ source: sourceId, target: targetId, type: IMPORT_EDGE_TYPE, locator: file.path });
32503
+ }
32504
+ }
32505
+ edges.sort((a, b) => (a.source < b.source ? -1 : a.source > b.source ? 1 : 0) || (a.target < b.target ? -1 : a.target > b.target ? 1 : 0) || (a.locator < b.locator ? -1 : a.locator > b.locator ? 1 : 0));
32506
+ const report = normalizeAnalyzerReport({
32507
+ analyzer: ANALYZER_IMPORT_GRAPH_ID,
32508
+ scannedScope: `import-scan:${sorted.length}-files`,
32509
+ objectsResolved,
32510
+ relationsResolved: edges.length,
32511
+ unresolvedConstructs: unmapped2.map((row2) => `${row2.source} -> ${row2.specifier} (${row2.reason})`),
32512
+ parseFailures: [],
32513
+ confidence: unmapped2.length === 0 ? "deterministic" : "probable",
32514
+ sourceSha: input.sourceSha
32515
+ });
32516
+ return { report, edges, externalImports, unmapped: unmapped2 };
32517
+ }
32518
+ function scanImportSpecifiers(content) {
32519
+ const specifiers = [];
32520
+ for (const match of content.matchAll(STATIC_IMPORT_RE)) {
32521
+ specifiers.push(match[1] ?? "");
32522
+ }
32523
+ for (const match of content.matchAll(DYNAMIC_IMPORT_RE)) {
32524
+ specifiers.push(match[1] ?? "");
32525
+ }
32526
+ return specifiers;
32527
+ }
32528
+ function isRelativeSpecifier(specifier) {
32529
+ return specifier.startsWith("./") || specifier.startsWith("../");
32530
+ }
32531
+ function joinFromSourceDir(sourcePath, specifier) {
32532
+ const cut = sourcePath.lastIndexOf("/");
32533
+ const baseDir = cut >= 0 ? sourcePath.slice(0, cut) : "";
32534
+ const segments = baseDir === "" ? [] : baseDir.split("/");
32535
+ for (const segment of specifier.split("/")) {
32536
+ if (segment === "" || segment === ".")
32537
+ continue;
32538
+ if (segment === "..") {
32539
+ segments.pop();
32540
+ continue;
32541
+ }
32542
+ segments.push(segment);
32543
+ }
32544
+ return segments.join("/");
32545
+ }
32546
+ function resolveRelativeCandidate(repoRelative, mapping) {
32547
+ for (const suffix of RELATIVE_IMPORT_CANDIDATE_SUFFIXES) {
32548
+ const candidate = `${repoRelative}${suffix}`;
32549
+ if (hasOwn(mapping, candidate))
32550
+ return candidate;
32551
+ }
32552
+ return null;
32553
+ }
32554
+ function hasOwn(record, key) {
32555
+ return Object.prototype.hasOwnProperty.call(record, key);
32556
+ }
32557
+ var ANALYZER_IMPORT_GRAPH_ID, IMPORT_EDGE_TYPE, RELATIVE_IMPORT_CANDIDATE_SUFFIXES, STATIC_IMPORT_RE, DYNAMIC_IMPORT_RE;
32558
+ var init_analyzer_import_graph = __esm({
32559
+ "packages/kernel/dist/analyzer-import-graph.js"() {
32560
+ "use strict";
32561
+ init_errors();
32562
+ init_id();
32563
+ init_analyzer_contract();
32564
+ ANALYZER_IMPORT_GRAPH_ID = "ANALYZER.TS.IMPORT_GRAPH";
32565
+ IMPORT_EDGE_TYPE = "CALLS";
32566
+ RELATIVE_IMPORT_CANDIDATE_SUFFIXES = [
32567
+ "",
32568
+ ".ts",
32569
+ ".tsx",
32570
+ ".vue",
32571
+ ".js",
32572
+ "/index.ts"
32573
+ ];
32574
+ STATIC_IMPORT_RE = /\bimport\b\s+(?:type\s+)?(?:[\w*{},\s$]+?\s+from\s+)?["']([^"']+)["']/g;
32575
+ DYNAMIC_IMPORT_RE = /\bimport\b\s*\(\s*["']([^"']+)["']\s*\)/g;
32576
+ }
32577
+ });
32578
+
31032
32579
  // packages/kernel/dist/index.js
31033
32580
  var dist_exports = {};
31034
32581
  __export(dist_exports, {
31035
32582
  ACTIVATION_BEARING_CLASSIFICATIONS: () => ACTIVATION_BEARING_CLASSIFICATIONS,
32583
+ ANALYZER_ID_PATTERN: () => ANALYZER_ID_PATTERN,
32584
+ ANALYZER_IMPORT_GRAPH_ID: () => ANALYZER_IMPORT_GRAPH_ID,
31036
32585
  ASKABLE_CATEGORIES: () => ASKABLE_CATEGORIES,
31037
32586
  BAND_PREDICATE_OPERATOR_VALUES: () => BAND_PREDICATE_OPERATOR_VALUES,
32587
+ BLINDSPOT_CANONICAL_OBSERVED: () => BLINDSPOT_CANONICAL_OBSERVED,
31038
32588
  CANDIDATE_KIND_MAPPING: () => CANDIDATE_KIND_MAPPING,
31039
32589
  CAPABILITY_DEGRADED: () => CAPABILITY_DEGRADED,
31040
32590
  CAPABILITY_OUTCOME_METRICS: () => CAPABILITY_OUTCOME_METRICS,
31041
32591
  CAPABILITY_OUTCOME_METRIC_KEY_VALUES: () => CAPABILITY_OUTCOME_METRIC_KEY_VALUES,
31042
32592
  CAPABILITY_OUTCOME_METRIC_STATUS_VALUES: () => CAPABILITY_OUTCOME_METRIC_STATUS_VALUES,
32593
+ CATALOG_ENDPOINT_ID_PATTERN: () => CATALOG_ENDPOINT_ID_PATTERN,
32594
+ CATALOG_KIND_VALUES: () => CATALOG_KIND_VALUES,
32595
+ CATALOG_RELOCK_GENERATED_BY_NOTE: () => CATALOG_RELOCK_GENERATED_BY_NOTE,
31043
32596
  CONTRADICTION_SIMILARITY_THRESHOLD: () => CONTRADICTION_SIMILARITY_THRESHOLD,
31044
32597
  CONTROL_BAND_EVALUATION_STATUS_VALUES: () => CONTROL_BAND_EVALUATION_STATUS_VALUES,
31045
32598
  CONVERGENCE_ZONE_KEYS: () => CONVERGENCE_ZONE_KEYS,
@@ -31057,6 +32610,7 @@ __export(dist_exports, {
31057
32610
  DOCTOR_CONFIRM_FIELDS: () => DOCTOR_CONFIRM_FIELDS,
31058
32611
  DOCTOR_REQUIRED_EXPECTATION_FIELDS: () => DOCTOR_REQUIRED_EXPECTATION_FIELDS,
31059
32612
  DUPLICATE_SIMILARITY_THRESHOLD: () => DUPLICATE_SIMILARITY_THRESHOLD,
32613
+ EDGE_ID_PATTERN: () => EDGE_ID_PATTERN,
31060
32614
  ENVIRONMENT_DOCTOR_VERDICT_VALUES: () => ENVIRONMENT_DOCTOR_VERDICT_VALUES,
31061
32615
  ENVREC_ID_PATTERN: () => ENVREC_ID_PATTERN,
31062
32616
  EQUIVALENCE_GROUP_PATTERN: () => EQUIVALENCE_GROUP_PATTERN,
@@ -31070,6 +32624,7 @@ __export(dist_exports, {
31070
32624
  EXECUTION_SCHEMA: () => EXECUTION_SCHEMA,
31071
32625
  EXECUTION_TRACE_SCHEMA: () => EXECUTION_TRACE_SCHEMA,
31072
32626
  EXECUTION_TRACE_VERSION: () => EXECUTION_TRACE_VERSION,
32627
+ FAMILIES_WITHOUT_PREFIX: () => FAMILIES_WITHOUT_PREFIX,
31073
32628
  FINDING_ID_PATTERN: () => FINDING_ID_PATTERN,
31074
32629
  GATEKEEPER_THRESHOLD_DEFAULT: () => GATEKEEPER_THRESHOLD_DEFAULT,
31075
32630
  GATEKEEPER_WINDOW_DAYS_DEFAULT: () => GATEKEEPER_WINDOW_DAYS_DEFAULT,
@@ -31085,12 +32640,14 @@ __export(dist_exports, {
31085
32640
  HARVEST_RULES: () => HARVEST_RULES,
31086
32641
  HARVEST_SOURCE_VALUES: () => HARVEST_SOURCE_VALUES,
31087
32642
  HARVEST_SPECIAL_EXIT_VALUES: () => HARVEST_SPECIAL_EXIT_VALUES,
32643
+ IMPORT_EDGE_TYPE: () => IMPORT_EDGE_TYPE,
31088
32644
  INBOX_SCOPE_VALUES: () => INBOX_SCOPE_VALUES,
31089
32645
  KNOWLEDGE_INJECTABLE_STATUSES: () => KNOWLEDGE_INJECTABLE_STATUSES,
31090
32646
  KNOWLEDGE_LIBRARY_RELATIVE: () => KNOWLEDGE_LIBRARY_RELATIVE,
31091
32647
  LINKAGE_COVERAGE_RELATIVE: () => LINKAGE_COVERAGE_RELATIVE,
31092
32648
  LOCKS_RELATIVE: () => LOCKS_RELATIVE,
31093
32649
  LOCK_DEFAULT_TTL_SECONDS: () => LOCK_DEFAULT_TTL_SECONDS,
32650
+ LOCK_FILE_NAME: () => LOCK_FILE_NAME,
31094
32651
  MEMORY_CLASS_OF_BUCKET: () => MEMORY_CLASS_OF_BUCKET,
31095
32652
  MEMORY_CLASS_PRD_LABELS: () => MEMORY_CLASS_PRD_LABELS,
31096
32653
  MEMORY_CLASS_VALUES: () => MEMORY_CLASS_VALUES,
@@ -31101,6 +32658,10 @@ __export(dist_exports, {
31101
32658
  MISSING_FACT_REF_PATTERN: () => MISSING_FACT_REF_PATTERN,
31102
32659
  MISSING_FACT_ROUTE_VALUES: () => MISSING_FACT_ROUTE_VALUES,
31103
32660
  NEGATIVE_OBSERVATION_VALUES: () => NEGATIVE_OBSERVATION_VALUES,
32661
+ NEW_ENTITY_GATE: () => NEW_ENTITY_GATE,
32662
+ NEW_ENTITY_GATE_DEF: () => NEW_ENTITY_GATE_DEF,
32663
+ OBJECT_FAMILY_VALUES: () => OBJECT_FAMILY_VALUES,
32664
+ OBSERVATION_REF_PATTERN: () => OBSERVATION_REF_PATTERN,
31104
32665
  OBSERVATION_RESULT_VALUES: () => OBSERVATION_RESULT_VALUES,
31105
32666
  OBSERVATION_SURFACE_VALUES: () => OBSERVATION_SURFACE_VALUES,
31106
32667
  OBSOLETE_MARKERS: () => OBSOLETE_MARKERS,
@@ -31116,7 +32677,10 @@ __export(dist_exports, {
31116
32677
  PORTABILITY_FORBIDDEN_DEPENDENCY_VALUES: () => PORTABILITY_FORBIDDEN_DEPENDENCY_VALUES,
31117
32678
  PORTABILITY_MANIFEST_RELATIVE: () => PORTABILITY_MANIFEST_RELATIVE,
31118
32679
  PORTABILITY_RUNTIME_REBUILD_VALUES: () => PORTABILITY_RUNTIME_REBUILD_VALUES,
32680
+ PRD_BLINDSPOT_STATES: () => PRD_BLINDSPOT_STATES,
32681
+ PRD_BLINDSPOT_STATE_MAPPING: () => PRD_BLINDSPOT_STATE_MAPPING,
31119
32682
  PRECHECK_IDS: () => PRECHECK_IDS,
32683
+ PREFIX_FAMILY_MAP: () => PREFIX_FAMILY_MAP,
31120
32684
  PROBE_SIDE_EFFECT_RULES: () => PROBE_SIDE_EFFECT_RULES,
31121
32685
  PRODUCTION_BANDS_RELATIVE: () => PRODUCTION_BANDS_RELATIVE,
31122
32686
  PRODUCTION_BREACHES_RELATIVE: () => PRODUCTION_BREACHES_RELATIVE,
@@ -31138,10 +32702,17 @@ __export(dist_exports, {
31138
32702
  REF_DANGLING_RULE: () => REF_DANGLING_RULE,
31139
32703
  REF_INTEGRITY_GATE: () => REF_INTEGRITY_GATE,
31140
32704
  REF_INTEGRITY_GATE_DEF: () => REF_INTEGRITY_GATE_DEF,
32705
+ RELATIONS_RELATIVE: () => RELATIONS_RELATIVE,
32706
+ RELATION_CONFIDENCE_VALUES: () => RELATION_CONFIDENCE_VALUES,
32707
+ RELATION_ENDPOINT_DOMAIN_VALUES: () => RELATION_ENDPOINT_DOMAIN_VALUES,
32708
+ RELATION_ORIGIN_VALUES: () => RELATION_ORIGIN_VALUES,
32709
+ RELATION_TYPE_VALUES: () => RELATION_TYPE_VALUES,
32710
+ RELATIVE_IMPORT_CANDIDATE_SUFFIXES: () => RELATIVE_IMPORT_CANDIDATE_SUFFIXES,
31141
32711
  RESEARCH_ARTIFACT_FILES: () => RESEARCH_ARTIFACT_FILES,
31142
32712
  RESEARCH_FORBIDDEN_SURFACE_PREFIXES: () => RESEARCH_FORBIDDEN_SURFACE_PREFIXES,
31143
32713
  RESEARCH_MODE_ROUTE_HINTS: () => RESEARCH_MODE_ROUTE_HINTS,
31144
32714
  RESEARCH_REQUEST_ID_PATTERN: () => RESEARCH_REQUEST_ID_PATTERN,
32715
+ RESOLUTION_MATCH_CLASS_VALUES: () => RESOLUTION_MATCH_CLASS_VALUES,
31145
32716
  REVIEW_STATE_VALUES: () => REVIEW_STATE_VALUES,
31146
32717
  RUNTIME_CONCURRENCY_MASQUERADE: () => RUNTIME_CONCURRENCY_MASQUERADE,
31147
32718
  SELF_IMPROVEMENT_SIGNAL_PRD_LABELS: () => SELF_IMPROVEMENT_SIGNAL_PRD_LABELS,
@@ -31154,7 +32725,9 @@ __export(dist_exports, {
31154
32725
  SESSION_DEFAULT_TTL_SECONDS: () => SESSION_DEFAULT_TTL_SECONDS,
31155
32726
  SESSION_KEY_PATTERN: () => SESSION_KEY_PATTERN,
31156
32727
  SIDE_EFFECT_CLASS_VALUES: () => SIDE_EFFECT_CLASS_VALUES,
32728
+ SOURCE_SHA_PATTERN: () => SOURCE_SHA_PATTERN,
31157
32729
  SPEC_ANALYZER_REPORT_DIALECT: () => SPEC_ANALYZER_REPORT_DIALECT,
32730
+ SUBSTRATE_LAYER_VALUES: () => SUBSTRATE_LAYER_VALUES,
31158
32731
  SUFFICIENCY_DIMENSIONS: () => SUFFICIENCY_DIMENSIONS,
31159
32732
  SUFFICIENCY_RESIDUAL_CLASSIFICATIONS: () => SUFFICIENCY_RESIDUAL_CLASSIFICATIONS,
31160
32733
  SUPERVISOR_CHAIN_MIN_LENGTH_DEFAULT: () => SUPERVISOR_CHAIN_MIN_LENGTH_DEFAULT,
@@ -31169,6 +32742,7 @@ __export(dist_exports, {
31169
32742
  acquireLock: () => acquireLock,
31170
32743
  adjudicateResearchFindings: () => adjudicateResearchFindings,
31171
32744
  allocateExecutionId: () => allocateExecutionId,
32745
+ analyzeImportGraph: () => analyzeImportGraph,
31172
32746
  analyzeSpecDir: () => analyzeSpecDir,
31173
32747
  analyzeSpecFiles: () => analyzeSpecFiles,
31174
32748
  applyKnowledgeTransition: () => applyKnowledgeTransition,
@@ -31211,9 +32785,11 @@ __export(dist_exports, {
31211
32785
  defaultUserMemoryRoot: () => defaultUserMemoryRoot,
31212
32786
  demoteKnowledge: () => demoteKnowledge,
31213
32787
  demoteSpecToKnowledge: () => demoteSpecToKnowledge,
32788
+ deriveFamily: () => deriveFamily,
31214
32789
  detectGatekeeperDrift: () => detectGatekeeperDrift,
31215
32790
  detectSupervisorTrigger: () => detectSupervisorTrigger,
31216
32791
  doctorProbes: () => doctorProbes,
32792
+ edgeIdOf: () => edgeIdOf,
31217
32793
  endExecution: () => endExecution,
31218
32794
  evaluateBlueprintEnvelope: () => evaluateBlueprintEnvelope,
31219
32795
  evaluateCapabilityDegradation: () => evaluateCapabilityDegradation,
@@ -31225,11 +32801,15 @@ __export(dist_exports, {
31225
32801
  executionRecordPath: () => executionRecordPath,
31226
32802
  executionTraceDerivedView: () => executionTraceDerivedView,
31227
32803
  explainCatalogProjection: () => explainCatalogProjection,
32804
+ familyOfId: () => familyOfId,
32805
+ forwardDependencies: () => forwardDependencies,
31228
32806
  gateResultToSnake: () => gateResultToSnake,
31229
32807
  governanceCodeForParseError: () => governanceCodeForParseError,
31230
32808
  harvestHarness: () => harvestHarness,
31231
32809
  heartbeatLock: () => heartbeatLock,
32810
+ impactClosure: () => impactClosure,
31232
32811
  inboxEntryIdOf: () => inboxEntryIdOf,
32812
+ instanceOfEdgesPresent: () => instanceOfEdgesPresent,
31233
32813
  isExceptionLedgerRef: () => isExceptionLedgerRef,
31234
32814
  isExecutionRef: () => isExecutionRef,
31235
32815
  isMultiAgentCapable: () => isMultiAgentCapable,
@@ -31248,6 +32828,7 @@ __export(dist_exports, {
31248
32828
  listSealedExecutionTraces: () => listSealedExecutionTraces,
31249
32829
  listSelfImprovementCandidates: () => listSelfImprovementCandidates,
31250
32830
  listSessionRecords: () => listSessionRecords,
32831
+ loadCatalogArchetypes: () => loadCatalogArchetypes,
31251
32832
  loadCatalogPolicies: () => loadCatalogPolicies,
31252
32833
  loadCatalogProjectionPresets: () => loadCatalogProjectionPresets,
31253
32834
  loadCatalogSensors: () => loadCatalogSensors,
@@ -31255,12 +32836,19 @@ __export(dist_exports, {
31255
32836
  loadStoreReadOnly: () => loadStoreReadOnly,
31256
32837
  loadTruthIndex: () => loadTruthIndex,
31257
32838
  lockRecordPath: () => lockRecordPath,
32839
+ newEntityVerdictFromResolution: () => newEntityVerdictFromResolution,
32840
+ normalizeAnalyzerReport: () => normalizeAnalyzerReport,
31258
32841
  normalizeClassificationValue: () => normalizeClassificationValue,
32842
+ normalizeEndpointDomain: () => normalizeEndpointDomain,
31259
32843
  normalizeGateResult: () => normalizeGateResult,
32844
+ normalizeRelationConfidence: () => normalizeRelationConfidence,
32845
+ normalizeRelationOrigin: () => normalizeRelationOrigin,
32846
+ normalizeRelationType: () => normalizeRelationType,
31260
32847
  normalizeWordFormDomain: () => normalizeWordFormDomain,
31261
32848
  parseFrontmatterMeta: () => parseFrontmatterMeta,
31262
32849
  parseGovernedId: () => parseGovernedId,
31263
32850
  parseSpecMarkdown: () => parseSpecMarkdown,
32851
+ partitionBlindSpotAttempts: () => partitionBlindSpotAttempts,
31264
32852
  pathsOf: () => pathsOf,
31265
32853
  persistEvidenceArtifact: () => persistEvidenceArtifact,
31266
32854
  planRoleExecution: () => planRoleExecution,
@@ -31283,6 +32871,7 @@ __export(dist_exports, {
31283
32871
  readLinkageCoverage: () => readLinkageCoverage,
31284
32872
  readLockRecord: () => readLockRecord,
31285
32873
  readPortabilityManifest: () => readPortabilityManifest,
32874
+ readRelations: () => readRelations,
31286
32875
  readSealedExecutionTrace: () => readSealedExecutionTrace,
31287
32876
  readSessionRecord: () => readSessionRecord,
31288
32877
  readUserMemoryLedger: () => readUserMemoryLedger,
@@ -31296,18 +32885,24 @@ __export(dist_exports, {
31296
32885
  refreshSession: () => refreshSession,
31297
32886
  registerControlBand: () => registerControlBand,
31298
32887
  registerEquivalence: () => registerEquivalence,
32888
+ registerRelation: () => registerRelation,
31299
32889
  registerSelfImprovementCandidate: () => registerSelfImprovementCandidate,
32890
+ relationsTouching: () => relationsTouching,
31300
32891
  releaseLock: () => releaseLock,
32892
+ relockCatalog: () => relockCatalog,
31301
32893
  resolveAlias: () => resolveAlias,
31302
32894
  resolveCatalogRoot: () => resolveCatalogRoot,
31303
32895
  resolveDecision: () => resolveDecision,
31304
32896
  resolveLinkageReadOnly: () => resolveLinkageReadOnly,
31305
32897
  resolveLinkageWordForm: () => resolveLinkageWordForm,
32898
+ resolveNeed: () => resolveNeed,
31306
32899
  resolveRefBatch: () => resolveRefBatch,
31307
32900
  resolveWordForm: () => resolveWordForm,
32901
+ reverseDependents: () => reverseDependents,
31308
32902
  reviewInbox: () => reviewInbox,
31309
32903
  runDeletabilityTest: () => runDeletabilityTest,
31310
32904
  runEnvironmentDoctor: () => runEnvironmentDoctor,
32905
+ runNewEntityGate: () => runNewEntityGate,
31311
32906
  runPortabilityChecks: () => runPortabilityChecks,
31312
32907
  runRefIntegrityGate: () => runRefIntegrityGate,
31313
32908
  sealExecutionTrace: () => sealExecutionTrace,
@@ -31393,6 +32988,14 @@ var init_dist = __esm({
31393
32988
  init_doctor();
31394
32989
  init_trace();
31395
32990
  init_perception();
32991
+ init_relations();
32992
+ init_new_entity();
32993
+ init_family();
32994
+ init_analyzer_contract();
32995
+ init_resolver();
32996
+ init_catalog();
32997
+ init_analyzer_import_graph();
32998
+ init_src();
31396
32999
  }
31397
33000
  });
31398
33001
 
@@ -40590,6 +42193,13 @@ var init_gate_recipe_runner = __esm({
40590
42193
  gateDef: "GATE.WEB.GRID.CHECKS@0.1.0",
40591
42194
  titleZh: "\u8868\u683C\u95E8\u7981\u68C0\u67E5\u5355",
40592
42195
  lane: "frontend"
42196
+ },
42197
+ {
42198
+ file: "gate.new-entity.checks.json",
42199
+ id: "GATE.NEW_ENTITY.CHECKS",
42200
+ gateDef: "GATE.NEW_ENTITY.CHECKS@0.1.0",
42201
+ titleZh: "\u65B0\u5B9E\u4F53\u95E8\u7981\u68C0\u67E5\u5355",
42202
+ lane: "any"
40593
42203
  }
40594
42204
  ];
40595
42205
  RECIPE_GATE_DISPATCH = {
@@ -40609,6 +42219,10 @@ var init_gate_recipe_runner = __esm({
40609
42219
  "GATE.WEB.GRID.CHECKS": {
40610
42220
  kind: "unbound",
40611
42221
  reason: "\u8868\u683C\u4E94\u9879\u4F9D\u8D56 interaction-contract-registry \u5BF9\u8D26\u4E0E\u5217 schema \u626B\u63CF\uFF0C\u626B\u63CF\u5668\u672A\u5EFA\uFF08check#5 registry \u5BF9\u8D26\u4E3A opt-in\uFF1Aregistry \u6587\u4EF6\u7F3A\u5E2D \u2192 not_configured \u8BED\u4E49\u9700\u4E13\u7528 adapter \u627F\u8F7D\uFF09\uFF1B\u9700 grid checklist adapter \u540E\u63A5\u7EBF"
42222
+ },
42223
+ "GATE.NEW_ENTITY.CHECKS": {
42224
+ kind: "unbound",
42225
+ reason: "\u4E94\u5426\u8BC1\u660E\u673A\u5224\u6838\u5FC3\u4F4F kernel runNewEntityGate\uFF08ref-integrity \u540C\u65CF kernel \u4FA7 gate\u2014\u2014resolveNeed/newEntityVerdictFromResolution \u5355\u4E00\u5B9E\u73B0\uFF09\uFF1B\u672C runner \u662F tool-adapter \u6D3E\u53D1\u9762\uFF0Ckernel \u4FA7 gate \u4E0D\u7ECF adapter \u7BA1\u7EBF\uFF08\u7F3A\u5E2D\u8BDA\u5B9E\uFF1Atool-adapter \u7ED1\u5B9A\u5F85\u6279\u6B21 2 architecture \u817F\uFF09"
40612
42226
  }
40613
42227
  };
40614
42228
  RECIPE_EXECUTORS = {
@@ -41479,6 +43093,75 @@ async function runInitInteractive(rootDir, interactive) {
41479
43093
  }
41480
43094
  return runInit(rootDir, { platforms: parse.platforms.join(",") });
41481
43095
  }
43096
+ var CHECKLIST_KEYS = {
43097
+ /** ↑ */
43098
+ up: "\x1B[A",
43099
+ /** ↓ */
43100
+ down: "\x1B[B",
43101
+ /** 空格(0x20):切换光标行选中态 */
43102
+ toggle: " ",
43103
+ /** 回车(\r;\n 亦收):确认 */
43104
+ confirm: "\r",
43105
+ /** Ctrl+C:中止(终端恢复后由调用方退出) */
43106
+ abort: ""
43107
+ };
43108
+ var CHECKLIST_HEADER = "? \u542F\u7528\u54EA\u4E9B\u5E73\u53F0\uFF1F\uFF08\u7A7A\u683C\u52FE\u9009 / \u2191\u2193\u79FB\u52A8 / \u56DE\u8F66\u786E\u8BA4\uFF09";
43109
+ var CHECKLIST_CODEX_NOTE = "\uFF08codex \u539F\u751F\u8BFB\u6839 AGENTS.md\uFF0C\u9009\u4E2D=\u5DF2\u8986\u76D6\uFF09";
43110
+ function checklistRow(platform, file, note, checked, isCursor) {
43111
+ const mark = checked ? "\u25C9" : "\u25EF";
43112
+ const prefix = isCursor ? "" : " ";
43113
+ return `${prefix}${mark} ${platform.padEnd(9)}\u2192 ${file}${note}`;
43114
+ }
43115
+ function renderChecklistFrame(checked, cursor) {
43116
+ const lines = [CHECKLIST_HEADER];
43117
+ PLATFORM_ADAPTERS.forEach((spec, index) => {
43118
+ const note = spec.coveredByAgentsMd ? CHECKLIST_CODEX_NOTE : "";
43119
+ lines.push(checklistRow(spec.name, spec.file, note, checked.has(spec.name), index === cursor));
43120
+ });
43121
+ return lines.join("\n");
43122
+ }
43123
+ function redrawFrame(frame) {
43124
+ const lines = frame.split("\n");
43125
+ return `\x1B[${lines.length - 1}A\r` + lines.map((line, i) => `\x1B[0K${line}${i < lines.length - 1 ? "\n" : ""}`).join("");
43126
+ }
43127
+ async function runChecklistPrompt(io) {
43128
+ let cursor = 0;
43129
+ const checked = /* @__PURE__ */ new Set(["claude"]);
43130
+ let done = null;
43131
+ io.write(renderChecklistFrame(checked, cursor));
43132
+ await io.pumpKeys((key) => {
43133
+ if (done !== null)
43134
+ return false;
43135
+ if (key === CHECKLIST_KEYS.up) {
43136
+ cursor = Math.max(0, cursor - 1);
43137
+ } else if (key === CHECKLIST_KEYS.down) {
43138
+ cursor = Math.min(PLATFORM_ADAPTERS.length - 1, cursor + 1);
43139
+ } else if (key === CHECKLIST_KEYS.toggle) {
43140
+ const platform = PLATFORM_ADAPTERS[cursor]?.name;
43141
+ if (platform !== void 0) {
43142
+ if (checked.has(platform)) {
43143
+ checked.delete(platform);
43144
+ } else {
43145
+ checked.add(platform);
43146
+ }
43147
+ }
43148
+ } else if (key === CHECKLIST_KEYS.confirm || key === "\n") {
43149
+ done = {
43150
+ kind: "confirmed",
43151
+ platforms: INIT_PLATFORMS.filter((platform) => checked.has(platform))
43152
+ };
43153
+ return false;
43154
+ } else if (key === CHECKLIST_KEYS.abort) {
43155
+ done = { kind: "aborted" };
43156
+ return false;
43157
+ } else {
43158
+ return true;
43159
+ }
43160
+ io.write(redrawFrame(renderChecklistFrame(checked, cursor)));
43161
+ return true;
43162
+ });
43163
+ return done ?? { kind: "aborted" };
43164
+ }
41482
43165
  function parseConfigProfile(configText) {
41483
43166
  const match = /^\s*profile:\s*([A-Za-z_-]+)/m.exec(configText);
41484
43167
  const value = match?.[1]?.toUpperCase();
@@ -41569,6 +43252,13 @@ ${stateSummary}
41569
43252
  - \`pomaster doctor --json\` \u2014 \u5185\u6838 / harness MCP \u63A2\u6D4B\uFF08\u7F3A\u4EC0\u4E48\u63D0\u793A\u88C5\u4EC0\u4E48\uFF09
41570
43253
  - \`pomaster check --fast --json\` \u2014 \u516B\u62CD\u2464\uFF1AFAST gate\uFF08BUILD\uFF09
41571
43254
 
43255
+ ## Browser Eyes\uFF08\u6D4F\u89C8\u5668\u53CC\u773C\uFF09
43256
+
43257
+ - chrome-devtools MCP = \u89C2\u6D4B\u773C\uFF1A\u8BCA\u65AD\u300C\u6162/\u62A5\u9519/\u5361\u4F4F\u300D\u5FC5\u987B\u5B9E\u6D4B\uFF08performance trace / network / console\uFF09\uFF0C\u7981\u53EA\u770B\u4EE3\u7801\u63A8\u65AD\u3002
43258
+ - playwright MCP = \u9A8C\u8BC1\u773C\uFF1AE2E smoke / \u4EA4\u4E92\u9A8C\u8BC1\u7528 playwright \u786E\u5B9A\u6027\u9A71\u52A8\uFF08\u5224\u5377\u951A = @playwright/test \u5B98\u65B9\u62A5\u544A\uFF09\u3002
43259
+ - \u4E24\u773C\u4EA7\u7269\uFF08\u5FEB\u7167/\u622A\u56FE/trace/console/network \u89C2\u6D4B/\u5B98\u65B9\u62A5\u544A\uFF09\u8FDB BROWSER gate \u53CC\u901A\u9053\u8BC1\u636E\u94FE\uFF08GRN / OBS receipt\uFF09\uFF0C\u4E0D\u505C\u7559\u5728\u804A\u5929\u8BB0\u5F55\u91CC\u3002
43260
+ - \u53EF\u7528\u6027\u81EA\u68C0\uFF1A\`pomaster doctor --json\` \u7684 chrome_devtools_mcp / playwright_mcp \u63A2\u9488\u884C\u3002
43261
+
41572
43262
  ## \u673A\u5668\u53EF\u8BFB\u8F93\u51FA
41573
43263
 
41574
43264
  \u4E00\u5207\u547D\u4EE4\u652F\u6301 \`--json\`\uFF08\xA745\uFF09\uFF1B\u7981\u6B62\u89E3\u6790\u5F69\u8272\u81EA\u7136\u8BED\u8A00\u5224\u65AD\u72B6\u6001\u2014\u2014\u673A\u8BFB\u552F\u4E00\u63A5\u53E3\u662F JSON \u4FE1\u5C01\u3002
@@ -41831,7 +43521,7 @@ function readCliPackageVersion() {
41831
43521
  }
41832
43522
  function resolveCliVersion() {
41833
43523
  if (true) {
41834
- return "0.1.1";
43524
+ return "0.2.0";
41835
43525
  }
41836
43526
  return readCliPackageVersion();
41837
43527
  }
@@ -44148,9 +45838,9 @@ ${lazy}
44148
45838
  `;
44149
45839
  }
44150
45840
  async function runContextCompile(rootDir, role, deps, inputs) {
44151
- const { readFile: readFile13 } = await import("node:fs/promises");
45841
+ const { readFile: readFile14 } = await import("node:fs/promises");
44152
45842
  try {
44153
- await readFile13(truthIndexPath(rootDir), "utf8");
45843
+ await readFile14(truthIndexPath(rootDir), "utf8");
44154
45844
  } catch {
44155
45845
  return failOutcome("context compile", {
44156
45846
  role,
@@ -44229,9 +45919,9 @@ async function runContextCompile(rootDir, role, deps, inputs) {
44229
45919
  }
44230
45920
  }
44231
45921
  async function runContextExplain(rootDir, role, deps, inputs) {
44232
- const { readFile: readFile13 } = await import("node:fs/promises");
45922
+ const { readFile: readFile14 } = await import("node:fs/promises");
44233
45923
  try {
44234
- await readFile13(truthIndexPath(rootDir), "utf8");
45924
+ await readFile14(truthIndexPath(rootDir), "utf8");
44235
45925
  } catch {
44236
45926
  return failOutcome("context explain", {
44237
45927
  role,
@@ -44305,8 +45995,10 @@ ${excluded.length > 0 ? excluded.map((d) => `- \`${d.ref}\` \u2014 why_excluded:
44305
45995
  // packages/cli/dist/doctor.js
44306
45996
  import { readFile as readFile6 } from "node:fs/promises";
44307
45997
  var CHROME_DEVTOOLS_MCP_HINT = '\u5728\u9879\u76EE\u6839 .mcp.json \u5199\u5165 {"mcpServers":{"chrome-devtools":{"command":"npx","args":["-y","chrome-devtools-mcp@latest"]}}} \uFF08\u5DF2\u5B58\u5728 .mcp.json \u65F6\u628A chrome-devtools \u6761\u76EE\u5E76\u5165 mcpServers\uFF09\uFF0C\u7136\u540E\u91CD\u542F harness\u3002';
45998
+ var PLAYWRIGHT_MCP_HINT = '\u5728\u9879\u76EE\u6839 .mcp.json \u5199\u5165 {"mcpServers":{"playwright":{"command":"npx","args":["-y","@playwright/mcp@latest"]}}} \uFF08\u5DF2\u5B58\u5728 .mcp.json \u65F6\u628A playwright \u6761\u76EE\u5E76\u5165 mcpServers\uFF09\uFF0C\u7136\u540E\u91CD\u542F harness\u3002';
44308
45999
  var KERNEL_PROBE_NAME = "kernel_doctor_probes";
44309
46000
  var MCP_PROBE_NAME = "chrome_devtools_mcp";
46001
+ var PLAYWRIGHT_MCP_PROBE_NAME = "playwright_mcp";
44310
46002
  var SENSOR_CATALOG_PROBE_NAME = "sensor_capability_catalog";
44311
46003
  var SENSOR_DETECTOR_TO_DOCTOR_PROBE = {
44312
46004
  chromeDevtoolsMcp: MCP_PROBE_NAME,
@@ -44316,17 +46008,17 @@ var SENSOR_DETECTOR_TO_DOCTOR_PROBE = {
44316
46008
  lighthouse: "lighthouse",
44317
46009
  webVitals: "web_vitals"
44318
46010
  };
44319
- async function probeChromeDevtoolsMcp(rootDir) {
46011
+ async function probeMcpServerConfigured(rootDir, spec) {
44320
46012
  const mcpJsonPath = `${rootDir}/.mcp.json`;
44321
46013
  let raw;
44322
46014
  try {
44323
46015
  raw = await readFile6(mcpJsonPath, "utf8");
44324
46016
  } catch {
44325
46017
  return {
44326
- probe: MCP_PROBE_NAME,
46018
+ probe: spec.probeName,
44327
46019
  status: "MISSING_CONFIGURATION",
44328
- detail: "no .mcp.json in project root; chrome-devtools MCP not configured",
44329
- hint: CHROME_DEVTOOLS_MCP_HINT
46020
+ detail: `no .mcp.json in project root; ${spec.toolLabel} MCP not configured`,
46021
+ hint: spec.hint
44330
46022
  };
44331
46023
  }
44332
46024
  let parsed;
@@ -44334,38 +46026,54 @@ async function probeChromeDevtoolsMcp(rootDir) {
44334
46026
  parsed = JSON.parse(raw);
44335
46027
  } catch (err) {
44336
46028
  return {
44337
- probe: MCP_PROBE_NAME,
46029
+ probe: spec.probeName,
44338
46030
  status: "DEFECT",
44339
46031
  detail: `.mcp.json is not valid JSON: ${err.message}`,
44340
- hint: `\u4FEE\u590D .mcp.json \u8BED\u6CD5\uFF08\u8BE5\u6587\u4EF6\u7531 harness \u89E3\u6790\uFF1B\u574F\u914D\u7F6E\u5C06\u9759\u9ED8\u5931\u6548\uFF09\u3002\u914D\u7F6E\u6837\u4F8B\uFF1A${CHROME_DEVTOOLS_MCP_HINT}`
46032
+ hint: `\u4FEE\u590D .mcp.json \u8BED\u6CD5\uFF08\u8BE5\u6587\u4EF6\u7531 harness \u89E3\u6790\uFF1B\u574F\u914D\u7F6E\u5C06\u9759\u9ED8\u5931\u6548\uFF09\u3002\u914D\u7F6E\u6837\u4F8B\uFF1A${spec.hint}`
44341
46033
  };
44342
46034
  }
44343
46035
  const servers = parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) && typeof parsed.mcpServers === "object" && parsed.mcpServers !== null ? parsed.mcpServers : null;
44344
46036
  if (servers === null) {
44345
46037
  return {
44346
- probe: MCP_PROBE_NAME,
46038
+ probe: spec.probeName,
44347
46039
  status: "MISSING_CONFIGURATION",
44348
- detail: ".mcp.json has no mcpServers section; chrome-devtools MCP not configured",
44349
- hint: CHROME_DEVTOOLS_MCP_HINT
46040
+ detail: `.mcp.json has no mcpServers section; ${spec.toolLabel} MCP not configured`,
46041
+ hint: spec.hint
44350
46042
  };
44351
46043
  }
44352
46044
  for (const [key, value] of Object.entries(servers)) {
44353
- if (key.toLowerCase().includes("chrome-devtools") || JSON.stringify(value).toLowerCase().includes("chrome-devtools")) {
46045
+ if (key.toLowerCase().includes(spec.serverKeyword) || JSON.stringify(value).toLowerCase().includes(spec.serverKeyword)) {
44354
46046
  return {
44355
- probe: MCP_PROBE_NAME,
46047
+ probe: spec.probeName,
44356
46048
  status: "READY",
44357
- detail: `chrome-devtools MCP configured (server key: ${key})`,
46049
+ detail: `${spec.toolLabel} MCP configured (server key: ${key})`,
44358
46050
  hint: null
44359
46051
  };
44360
46052
  }
44361
46053
  }
44362
46054
  return {
44363
- probe: MCP_PROBE_NAME,
46055
+ probe: spec.probeName,
44364
46056
  status: "MISSING_CONFIGURATION",
44365
- detail: "mcpServers present but no chrome-devtools entry",
44366
- hint: CHROME_DEVTOOLS_MCP_HINT
46057
+ detail: `mcpServers present but no ${spec.serverKeyword} entry`,
46058
+ hint: spec.hint
44367
46059
  };
44368
46060
  }
46061
+ async function probeChromeDevtoolsMcp(rootDir) {
46062
+ return probeMcpServerConfigured(rootDir, {
46063
+ probeName: MCP_PROBE_NAME,
46064
+ serverKeyword: "chrome-devtools",
46065
+ toolLabel: "chrome-devtools",
46066
+ hint: CHROME_DEVTOOLS_MCP_HINT
46067
+ });
46068
+ }
46069
+ async function probePlaywrightMcp(rootDir) {
46070
+ return probeMcpServerConfigured(rootDir, {
46071
+ probeName: PLAYWRIGHT_MCP_PROBE_NAME,
46072
+ serverKeyword: "playwright",
46073
+ toolLabel: "playwright",
46074
+ hint: PLAYWRIGHT_MCP_HINT
46075
+ });
46076
+ }
44369
46077
  function portabilityProbeToDoctorProbe(kernel) {
44370
46078
  switch (kernel.status) {
44371
46079
  case "READY":
@@ -44585,6 +46293,7 @@ async function runDoctor(rootDir, deps) {
44585
46293
  probes.push(...await runGauntletProbes(gauntletProbes, facts));
44586
46294
  }
44587
46295
  probes.push(await probeChromeDevtoolsMcp(rootDir));
46296
+ probes.push(await probePlaywrightMcp(rootDir));
44588
46297
  let sensors;
44589
46298
  try {
44590
46299
  const kernel = await Promise.resolve().then(() => (init_dist(), dist_exports));
@@ -44767,8 +46476,8 @@ function str(value) {
44767
46476
  }
44768
46477
  async function currentSeqForPolicy(rootDir) {
44769
46478
  try {
44770
- const { readFile: readFile13 } = await import("node:fs/promises");
44771
- const raw = await readFile13(`${rootDir}/${TRUTH_INDEX_RELATIVE}`, "utf8");
46479
+ const { readFile: readFile14 } = await import("node:fs/promises");
46480
+ const raw = await readFile14(`${rootDir}/${TRUTH_INDEX_RELATIVE}`, "utf8");
44772
46481
  const parsed = JSON.parse(raw);
44773
46482
  const generation = parsed.generation;
44774
46483
  return typeof generation?.seq === "number" ? generation.seq : 0;
@@ -46262,6 +47971,8 @@ function kernelErrorOf2(err) {
46262
47971
 
46263
47972
  // packages/cli/dist/catalog.js
46264
47973
  init_dist();
47974
+ import { writeFileSync as writeFileSync4 } from "node:fs";
47975
+ import { join as join8 } from "node:path";
46265
47976
  function emptyMaterial() {
46266
47977
  return {
46267
47978
  title_zh: null,
@@ -46295,7 +48006,7 @@ function driftError(drifts) {
46295
48006
  message: `catalog-lock \u6F02\u79FB ${drifts.length} \u5904\uFF08\u7269\u6599\u88AB\u6539\u800C lock \u672A\u91CD\u9501\uFF09\uFF1A
46296
48007
  ${head}` + (drifts.length > 5 ? `
46297
48008
  \u2026\u5171 ${drifts.length} \u5904` : ""),
46298
- hint: "\u91CD\u8DD1 catalog/tools/materialize_*.py \u5E42\u7B49\u91CD\u751F\u6210\u7269\u6599\u5E76\u91CD\u9501\uFF08content_sha256 = sha256(\u6587\u4EF6 utf-8 \u5B57\u8282)\uFF0Cproducer \u4E0E\u5BF9\u8D26\u7AEF\u540C\u53E3\u5F84\uFF09\u3002"
48009
+ hint: "\u6062\u590D\u952E\uFF1Apomaster catalog relock \u76F4\u63A5\u5E42\u7B49\u91CD\u9501\uFF08CLI \u4FA7\u6062\u590D\uFF0C\u96F6\u4F9D\u8D56 python\uFF09\uFF1B\u6216\u91CD\u8DD1 catalog/tools/materialize_*.py \u5E42\u7B49\u91CD\u751F\u6210\u7269\u6599\u5E76\u91CD\u9501\uFF08content_sha256 = sha256(\u6587\u4EF6 utf-8 \u5B57\u8282)\uFF0Cproducer \u4E0E\u5BF9\u8D26\u7AEF\u540C\u53E3\u5F84\uFF09\u3002"
46299
48010
  };
46300
48011
  }
46301
48012
  async function runCatalogStatus(deps) {
@@ -46312,6 +48023,7 @@ async function runCatalogStatus(deps) {
46312
48023
  gates: lock.entries.filter((entry) => entry.path.startsWith("gates/")).length,
46313
48024
  knowledge: lock.entries.filter((entry) => entry.path.startsWith("knowledge/")).length,
46314
48025
  sensors: loadCatalogSensors(catalogRoot).length,
48026
+ archetypes: loadCatalogArchetypes(catalogRoot).length,
46315
48027
  tools: loadCatalogTools(catalogRoot).length,
46316
48028
  projection_presets: loadCatalogProjectionPresets(catalogRoot).length
46317
48029
  };
@@ -46322,7 +48034,7 @@ async function runCatalogStatus(deps) {
46322
48034
  catalog_version: "",
46323
48035
  profile: "",
46324
48036
  entries_total: 0,
46325
- sections: { policies: 0, gates: 0, knowledge: 0, sensors: 0, tools: 0, projection_presets: 0 },
48037
+ sections: { policies: 0, gates: 0, knowledge: 0, sensors: 0, archetypes: 0, tools: 0, projection_presets: 0 },
46326
48038
  lock_verification: { ok: false, entries_checked: 0, drifts: [] }
46327
48039
  }, [
46328
48040
  {
@@ -46343,7 +48055,7 @@ async function runCatalogStatus(deps) {
46343
48055
  const human = [
46344
48056
  `catalog status: ${lock.catalog_version}\uFF08profile ${lock.profile}\uFF09`,
46345
48057
  ` root: ${catalogRoot}`,
46346
- ` entries: ${lock.entries.length}\uFF08policies ${sections.policies} / gates ${sections.gates} / knowledge ${sections.knowledge} / sensors ${sections.sensors}\uFF1Btools ${sections.tools} / projection-presets ${sections.projection_presets}\uFF09`,
48058
+ ` entries: ${lock.entries.length}\uFF08policies ${sections.policies} / gates ${sections.gates} / knowledge ${sections.knowledge} / sensors ${sections.sensors} / archetypes ${sections.archetypes}\uFF1Btools ${sections.tools} / projection-presets ${sections.projection_presets}\uFF09`,
46347
48059
  verification.ok ? ` catalog-lock: ok\uFF08${verification.entries_checked} entries \u54C8\u5E0C\u4E0E\u7BA1\u8F96\u9762\u5BF9\u8D26\u901A\u8FC7\uFF09` : ` catalog-lock: DRIFT\uFF08${verification.drifts.length} \u5904\u2014\u2014\u660E\u7EC6\u89C1 --json lock_verification.drifts\uFF09`
46348
48060
  ];
46349
48061
  if (verification.ok) {
@@ -46396,6 +48108,7 @@ async function runCatalogExplain(id, deps) {
46396
48108
  ], [`catalog explain: FAILED \u2014 CATALOG_ENTRY_NOT_FOUND\uFF08${id}\uFF09`]);
46397
48109
  }
46398
48110
  const policy = policies.find((candidate) => candidate.id === id);
48111
+ const archetype = policy === void 0 ? loadCatalogArchetypes(catalogRoot).find((candidate) => candidate.id === id) : void 0;
46399
48112
  const entryDrifts = verification.drifts.filter((drift) => drift.path === entry.path);
46400
48113
  const result2 = {
46401
48114
  id: entry.id,
@@ -46403,24 +48116,47 @@ async function runCatalogExplain(id, deps) {
46403
48116
  content_sha256: entry.content_sha256,
46404
48117
  source_ref: entry.source_ref,
46405
48118
  drifts: entryDrifts,
46406
- material: policy === void 0 ? emptyMaterial() : {
46407
- title_zh: policy.titleZh,
46408
- statement_zh: policy.statementZh,
46409
- classification: policy.classification,
46410
- lane: policy.lane,
46411
- condition: policy.appliesWhenCondition,
46412
- enforcement: policy.enforcement,
46413
- lifecycle: policy.lifecycle,
46414
- authority_owner: policy.authorityOwner,
46415
- lanes: [...policy.lanes],
46416
- capabilities: axisOrNull(policy.capabilities),
46417
- change_classes: axisOrNull(policy.changeClasses),
46418
- governance_profiles: axisOrNull(policy.governanceProfiles),
46419
- object_kinds: axisOrNull(policy.objectKinds),
46420
- applicability_note: policy.applicabilityNote,
46421
- risk_at_least: "not_configured",
46422
- technologies: "not_configured"
46423
- }
48119
+ material: (
48120
+ // 分支序重排(严格 tsc 清零;真值表等价改写——逐 case 对账:policy 有定义→
48121
+ // policy 物料;policy 缺席而 archetype 在场→archetype 物料;两者皆缺席→
48122
+ // emptyMaterial。与原「两者皆缺席 → policy 判 → archetype」分支序产值全等,
48123
+ // 重排使 archetype 在末支被前一判据真收窄,替代不可证的复合条件反推)。
48124
+ policy !== void 0 ? {
48125
+ title_zh: policy.titleZh,
48126
+ statement_zh: policy.statementZh,
48127
+ classification: policy.classification,
48128
+ lane: policy.lane,
48129
+ condition: policy.appliesWhenCondition,
48130
+ enforcement: policy.enforcement,
48131
+ lifecycle: policy.lifecycle,
48132
+ authority_owner: policy.authorityOwner,
48133
+ lanes: [...policy.lanes],
48134
+ capabilities: axisOrNull(policy.capabilities),
48135
+ change_classes: axisOrNull(policy.changeClasses),
48136
+ governance_profiles: axisOrNull(policy.governanceProfiles),
48137
+ object_kinds: axisOrNull(policy.objectKinds),
48138
+ applicability_note: policy.applicabilityNote,
48139
+ risk_at_least: "not_configured",
48140
+ technologies: "not_configured"
48141
+ } : archetype === void 0 ? emptyMaterial() : {
48142
+ title_zh: archetype.titleZh,
48143
+ statement_zh: archetype.summaryZh,
48144
+ classification: archetype.layer,
48145
+ lane: null,
48146
+ condition: archetype.semantic.whenToUse,
48147
+ enforcement: null,
48148
+ lifecycle: null,
48149
+ authority_owner: null,
48150
+ lanes: null,
48151
+ capabilities: null,
48152
+ change_classes: null,
48153
+ governance_profiles: null,
48154
+ object_kinds: null,
48155
+ applicability_note: null,
48156
+ risk_at_least: "not_configured",
48157
+ technologies: "not_configured"
48158
+ }
48159
+ )
46424
48160
  };
46425
48161
  const applicabilityLines = policy === void 0 ? [] : [
46426
48162
  ` applicability: \u6A21\u5F0F=${policy.hasMachineApplicability ? "\u673A\u5668\u5B57\u6BB5\u5168\u5224\u5B9A" : "lane \u56DE\u9000\uFF08\u672A\u58F0\u660E\u673A\u5668 applicability \u5B57\u6BB5\uFF0CO7\uFF09"}\uFF1Blanes=[${policy.lanes.join("/")}]\uFF1Bcapabilities=${axisOrNull(policy.capabilities)?.join("/") ?? "\u672A\u58F0\u660E"}\uFF1Bchange_classes=${axisOrNull(policy.changeClasses)?.join("/") ?? "\u672A\u58F0\u660E"}\uFF1Bgovernance_profiles=${axisOrNull(policy.governanceProfiles)?.join("/") ?? "\u672A\u58F0\u660E"}\uFF1Bobject_kinds=${axisOrNull(policy.objectKinds)?.join("/") ?? "\u672A\u58F0\u660E"}\uFF1Brisk_at_least=not_configured\uFF1Btechnologies=not_configured${policy.declaredUnregisteredAxes.length > 0 ? `\uFF08\u53E6\u58F0\u660E\u672A\u767B\u8BB0\u8BCD\u8F74 ${policy.declaredUnregisteredAxes.join("/")}\uFF09` : ""}`
@@ -46439,6 +48175,368 @@ async function runCatalogExplain(id, deps) {
46439
48175
  ].filter((line) => line !== null);
46440
48176
  return okOutcome("catalog explain", result2, human);
46441
48177
  }
48178
+ function diffLines(label, paths) {
48179
+ if (paths.length === 0)
48180
+ return [];
48181
+ const lines = paths.slice(0, 10).map((path) => ` ${label} ${path}`);
48182
+ if (paths.length > 10)
48183
+ lines.push(` \u2026\u5171 ${paths.length} \u6761\uFF08\u4EC5\u5217\u524D 10\uFF09`);
48184
+ return lines;
48185
+ }
48186
+ async function runCatalogRelock(deps) {
48187
+ let catalogRoot;
48188
+ let report;
48189
+ let verification;
48190
+ try {
48191
+ catalogRoot = catalogRootOf(deps);
48192
+ report = relockCatalog(catalogRoot);
48193
+ writeFileSync4(join8(catalogRoot, LOCK_FILE_NAME), `${JSON.stringify(report.next, null, 2)}
48194
+ `, "utf8");
48195
+ verification = verifyCatalogLock(catalogRoot);
48196
+ } catch (error) {
48197
+ const message = error instanceof Error ? error.message : String(error);
48198
+ return failOutcome("catalog relock", {
48199
+ catalog_root: "",
48200
+ entries_total: 0,
48201
+ added: [],
48202
+ removed: [],
48203
+ refreshed: []
48204
+ }, [
48205
+ {
48206
+ code: "CATALOG_NOT_AVAILABLE",
48207
+ message,
48208
+ hint: "relock \u4E0D\u662F\u521D\u59CB\u5316\u5DE5\u5177\uFF1Alock \u7F3A\u5931/\u574F\u5F62\u6216\u7269\u6599\u4E0D\u53EF\u89E3\u6790\u65F6\u663E\u5F0F\u62D2\u7EDD\uFF1B\u5148\u6062\u590D lock \u4E0E\u7269\u6599\u5B8C\u6574\u6027\uFF08Git \u539F\u5B57\u8282\u6216 catalog/tools/materialize_*.py\uFF09\u3002"
48209
+ }
48210
+ ], [`catalog relock: FAILED \u2014 ${message}`]);
48211
+ }
48212
+ const result2 = {
48213
+ catalog_root: catalogRoot,
48214
+ entries_total: verification.entries_checked,
48215
+ added: [...report.added],
48216
+ removed: [...report.removed],
48217
+ refreshed: [...report.refreshed]
48218
+ };
48219
+ const human = [
48220
+ `catalog relock: ${report.next.catalog_version}\uFF08profile ${report.next.profile}\uFF09`,
48221
+ ` root: ${catalogRoot}`,
48222
+ ` diff: added ${result2.added.length} / removed ${result2.removed.length} / refreshed ${result2.refreshed.length}\uFF08entries ${verification.entries_checked}\uFF09`,
48223
+ ...diffLines("+", result2.added),
48224
+ ...diffLines("-", result2.removed),
48225
+ ...diffLines("~", result2.refreshed),
48226
+ verification.ok ? ` catalog-lock: relocked & verified\uFF08${verification.entries_checked} entries\uFF09` : ` catalog-lock: RELOCK VERIFY FAILED\uFF08${verification.drifts.length} \u5904\u2014\u2014\u91CD\u9501\u4EA7\u7269\u5BF9\u8D26\u4E0D\u8FC7\uFF0C\u7EDD\u4E0D\u5047\u7EFF\uFF09`
48227
+ ];
48228
+ if (!verification.ok) {
48229
+ return failOutcome("catalog relock", result2, [driftError(verification.drifts)], human);
48230
+ }
48231
+ return okOutcome("catalog relock", result2, human);
48232
+ }
48233
+
48234
+ // packages/cli/dist/resolve.js
48235
+ init_dist();
48236
+ function renderResolve(outcome) {
48237
+ const lines = [];
48238
+ lines.push(`resolve: ${outcome.input.need}`);
48239
+ lines.push(`match_class: ${outcome.match_class}`);
48240
+ if (outcome.matches.length === 0) {
48241
+ lines.push("matches: (\u65E0\u2014\u2014NO_MATCH \u663E\u5F0F\u7F3A\u5E2D\uFF0C\u4E0D\u81C6\u9020\uFF1B\u5206\u6BCD\u89C1 sources_examined)");
48242
+ }
48243
+ for (const match of outcome.matches) {
48244
+ const tokens = match.matched_tokens.length > 0 ? ` [${match.matched_tokens.join(", ")}]` : "";
48245
+ lines.push(` - ${match.domain}:${match.id}\uFF08${match.kind}\uFF1Bvia=${match.via}${tokens}\uFF09`);
48246
+ }
48247
+ if (outcome.alternatives.length > 0) {
48248
+ lines.push("alternatives:");
48249
+ for (const alt of outcome.alternatives.slice(0, 8)) {
48250
+ lines.push(` - ${alt.domain}:${alt.id}\uFF08${alt.kind}\uFF09`);
48251
+ }
48252
+ }
48253
+ if (outcome.required_bindings.length > 0) {
48254
+ lines.push(`required_bindings: ${outcome.required_bindings.join(" / ")}`);
48255
+ }
48256
+ lines.push(`required_gates: ${outcome.required_gates.join(" / ")}`);
48257
+ lines.push(`sources_examined: ${JSON.stringify(outcome.sources_examined)}`);
48258
+ lines.push(`why: ${outcome.why}`);
48259
+ return lines;
48260
+ }
48261
+ async function runResolve(input) {
48262
+ try {
48263
+ const store = loadStoreReadOnly(input.rootDir);
48264
+ const catalogRoot = resolveCatalogRoot(input.catalogRoot);
48265
+ const outcome = await resolveNeed(store, catalogRoot, {
48266
+ need: input.need,
48267
+ hints: input.hints
48268
+ });
48269
+ const result2 = {
48270
+ need: outcome.input.need,
48271
+ match_class: outcome.match_class,
48272
+ matches: outcome.matches,
48273
+ alternatives: outcome.alternatives,
48274
+ required_bindings: outcome.required_bindings,
48275
+ required_gates: outcome.required_gates,
48276
+ why: outcome.why,
48277
+ sources_examined: outcome.sources_examined
48278
+ };
48279
+ return okOutcome("resolve", result2, renderResolve(outcome));
48280
+ } catch (error) {
48281
+ const cliError2 = {
48282
+ code: "RESOLVE_FAILED",
48283
+ message: error instanceof Error ? error.message : String(error),
48284
+ hint: error instanceof Error && error.message.includes("store \u672A\u521D\u59CB\u5316") ? "\u5148\u8DD1 pomaster init \u5EFA\u9AA8\u67B6\uFF08\u89E3\u6790\u9762\u53EA\u8BFB\u6D88\u8D39 .pomaster/state\uFF1BNOT_CONFIGURED \u662F\u72B6\u6001\u7F3A\u5E2D\u4E0D\u662F NO_MATCH\uFF09" : "\u68C0\u67E5 need \u8BCD\u5F62\u4E0E --catalog-root \u6CE8\u5165\uFF1B\u5224\u5377\u6743\u5A01\u5728 kernel resolveNeed\uFF08docs/kernel-api.md \xA729\uFF09"
48285
+ };
48286
+ return failOutcome("resolve", {}, [cliError2], []);
48287
+ }
48288
+ }
48289
+
48290
+ // packages/cli/dist/graph.js
48291
+ init_dist();
48292
+ import { readFile as readFile9 } from "node:fs/promises";
48293
+ var DEFAULT_IMPACT_DEPTH = 4;
48294
+ var RELATIONS_NOTE = `\u767B\u8BB0\u9762 ${RELATIONS_RELATIVE}`;
48295
+ function renderEdgeLine(edge, arrow) {
48296
+ return ` - ${edge.edge_id} ${arrow} ${edge.endpoint.domain}:${edge.endpoint.id}\uFF08origin=${edge.origin} confidence=${edge.confidence} producer=${edge.producer}\uFF09`;
48297
+ }
48298
+ function renderEdgeGroups(label, groups, arrow) {
48299
+ const total = groups.reduce((sum, group) => sum + group.edges.length, 0);
48300
+ if (total === 0) {
48301
+ return [` ${label}: (\u65E0\u8FB9\u767B\u8BB0\u2014\u2014\u96F6\u8FB9\u2260\u65E0\u4F9D\u8D56\uFF1B${RELATIONS_NOTE})`];
48302
+ }
48303
+ const lines = [` ${label}: ${total} \u6761`];
48304
+ for (const group of groups) {
48305
+ lines.push(` ${group.type}: ${group.edges.length} \u6761`);
48306
+ for (const edge of group.edges)
48307
+ lines.push(renderEdgeLine(edge, arrow));
48308
+ }
48309
+ return lines;
48310
+ }
48311
+ function renderGraph(result2) {
48312
+ const lines = [];
48313
+ if (result2.object !== null) {
48314
+ lines.push(`graph ${result2.object.id} \u2192 family=${result2.object.family} kind=${result2.object.kind ?? "?"}`);
48315
+ lines.push(` title: ${result2.object.title_zh ?? "(missing)"}`);
48316
+ if (result2.object.axes !== null) {
48317
+ lines.push(` axes: ${JSON.stringify(result2.object.axes)}`);
48318
+ }
48319
+ lines.push(result2.relations_touching === 0 ? ` relations: (\u65E0\u8FB9\u767B\u8BB0\u2014\u2014\u96F6\u8FB9\u2260\u65E0\u4F9D\u8D56\uFF1B${RELATIONS_NOTE})` : ` relations: ${result2.relations_touching} \u6761\u8FB9\u767B\u8BB0\uFF08touching \u672C\u5BF9\u8C61\uFF09`);
48320
+ } else {
48321
+ lines.push(`graph ${result2.id}\uFF08view=impact\uFF0C\u53EA\u51FA\u95ED\u5305\u6BB5\uFF09`);
48322
+ }
48323
+ if (result2.instance_of !== null) {
48324
+ if (result2.instance_of.length === 0) {
48325
+ lines.push(` instance_of: (\u65E0\u8FB9\u767B\u8BB0\u2014\u2014\u91C7\u7EB3\u8FB9\u7F3A\u5E2D\u2260\u672A\u91C7\u7528\u58F0\u660E\uFF1B${RELATIONS_NOTE})`);
48326
+ } else {
48327
+ lines.push(` instance_of: ${result2.instance_of.length} \u6761\u91C7\u7EB3\u8FB9`);
48328
+ for (const edge of result2.instance_of) {
48329
+ lines.push(` - ${edge.edge_id} \u2192 ${edge.endpoint.domain}:${edge.endpoint.id}\uFF08origin=${edge.origin} confidence=${edge.confidence} producer=${edge.producer}\uFF09`);
48330
+ }
48331
+ }
48332
+ }
48333
+ if (result2.forward_dependencies !== null) {
48334
+ lines.push(...renderEdgeGroups("forward dependencies\uFF08\u6B63\u5411\u4F9D\u8D56\uFF09", result2.forward_dependencies, "\u2192"));
48335
+ }
48336
+ if (result2.reverse_dependents !== null) {
48337
+ lines.push(...renderEdgeGroups("reverse dependents\uFF08\u53CD\u5411 dependents\uFF09", result2.reverse_dependents, "\u2190"));
48338
+ }
48339
+ if (result2.impact !== null) {
48340
+ if (result2.impact.affected.length === 0) {
48341
+ lines.push(` impact \u90BB\u57DF\uFF08max_depth=${result2.max_depth}\uFF09: (\u65E0\u8FB9\u767B\u8BB0\u2014\u2014\u96F6\u5165\u8FB9\u2260\u65E0\u5F71\u54CD\u9762\uFF1B${RELATIONS_NOTE})`);
48342
+ } else {
48343
+ lines.push(` impact \u90BB\u57DF\uFF08max_depth=${result2.max_depth}\uFF09: affected=${result2.impact.affected.length} max_depth_reached=${result2.impact.max_depth_reached}`);
48344
+ for (const node of result2.impact.affected) {
48345
+ lines.push(` - depth=${node.depth} ${node.domain}:${node.id} via ${node.via_edge_type} ${node.via_edge_id}`);
48346
+ }
48347
+ }
48348
+ }
48349
+ return lines;
48350
+ }
48351
+ function isRecord6(value) {
48352
+ return typeof value === "object" && value !== null && !Array.isArray(value);
48353
+ }
48354
+ function asString4(value) {
48355
+ return typeof value === "string" ? value : null;
48356
+ }
48357
+ function failGraph(error, skeleton) {
48358
+ return failOutcome("graph", skeleton, [error], [
48359
+ `graph: FAILED \u2014 ${error.code}
48360
+ hint: ${error.hint}`
48361
+ ]);
48362
+ }
48363
+ function kernelErrorToCliError(error) {
48364
+ if (error instanceof GovernanceError)
48365
+ return governanceErrorToCliError(error);
48366
+ return {
48367
+ code: "KERNEL_ERROR",
48368
+ message: error instanceof Error ? error.message : String(error),
48369
+ hint: "\u67E5\u770B docs/kernel-api.md \u5BF9\u5E94\u5951\u7EA6\uFF1B\u82E5\u4E3A\u73AF\u5883\u5F02\u5E38\u8BF7\u52FF\u9759\u9ED8\u964D\u7EA7\u3002"
48370
+ };
48371
+ }
48372
+ function emptyResult5(id, view, maxDepth) {
48373
+ return {
48374
+ id,
48375
+ view,
48376
+ max_depth: maxDepth,
48377
+ object: null,
48378
+ relations_touching: null,
48379
+ instance_of: null,
48380
+ forward_dependencies: null,
48381
+ reverse_dependents: null,
48382
+ impact: null
48383
+ };
48384
+ }
48385
+ function byEndpoint(a, b) {
48386
+ if (a.endpoint.domain !== b.endpoint.domain) {
48387
+ return a.endpoint.domain < b.endpoint.domain ? -1 : 1;
48388
+ }
48389
+ return a.endpoint.id < b.endpoint.id ? -1 : 1;
48390
+ }
48391
+ function groupEdgesByType(entries, otherEnd) {
48392
+ const groups = /* @__PURE__ */ new Map();
48393
+ for (const entry of entries) {
48394
+ const view = {
48395
+ edge_id: entry.edge_id,
48396
+ endpoint: otherEnd(entry),
48397
+ origin: entry.origin,
48398
+ confidence: entry.confidence,
48399
+ producer: entry.producer
48400
+ };
48401
+ const list = groups.get(entry.type);
48402
+ if (list === void 0)
48403
+ groups.set(entry.type, [view]);
48404
+ else
48405
+ list.push(view);
48406
+ }
48407
+ return [...groups.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([type, edges]) => ({ type, edges: edges.sort(byEndpoint) }));
48408
+ }
48409
+ async function runGraph(input) {
48410
+ const view = input.view ?? "all";
48411
+ if (view !== "all" && view !== "impact") {
48412
+ return failGraph({
48413
+ code: "SCHEMA_INVALID",
48414
+ message: `--view \u8BCD\u8868\u5916\uFF1A${view}\uFF08\u5408\u6CD5\u8BCD\u5F62\uFF1Aall | impact\uFF09`,
48415
+ hint: "all=\u5BF9\u8C61\u884C+\u91C7\u7EB3\u8FB9+\u6B63/\u53CD\u5411\u4F9D\u8D56+impact \u90BB\u57DF\uFF08\u7F3A\u7701\uFF09\uFF1Bimpact=\u53EA\u51FA\u95ED\u5305\u6BB5\u3002"
48416
+ }, emptyResult5(input.id, "all", DEFAULT_IMPACT_DEPTH));
48417
+ }
48418
+ let maxDepth = DEFAULT_IMPACT_DEPTH;
48419
+ if (input.maxDepth !== void 0) {
48420
+ const raw = input.maxDepth.trim();
48421
+ if (!/^[0-9]+$/.test(raw)) {
48422
+ return failGraph({
48423
+ code: "SCHEMA_INVALID",
48424
+ message: `--max-depth \u8BCD\u5F62\u975E\u6CD5\uFF1A${input.maxDepth}\uFF08\u987B\u975E\u8D1F\u6574\u6570\u5B57\u7B26\u4E32\uFF09`,
48425
+ hint: "\u6DF1\u5EA6\u57DF\u6821\u9A8C\uFF081..16\uFF09\u5F52 kernel impactClosure\u2014\u2014\u9632\u5FA1\u5931\u63A7 BFS\u3002"
48426
+ }, emptyResult5(input.id, view, DEFAULT_IMPACT_DEPTH));
48427
+ }
48428
+ maxDepth = Number.parseInt(raw, 10);
48429
+ }
48430
+ let store;
48431
+ try {
48432
+ store = loadStoreReadOnly(input.rootDir);
48433
+ } catch (error) {
48434
+ if (error instanceof GovernanceError && error.code === "NOT_CONFIGURED") {
48435
+ return failGraph({
48436
+ code: "NOT_CONFIGURED",
48437
+ message: error.message,
48438
+ hint: "\u5148\u8DD1 pomaster init \u5EFA\u9AA8\u67B6\uFF08graph \u7EAF\u8BFB\u6D88\u8D39 .pomaster/state\uFF1BNOT_CONFIGURED \u662F\u72B6\u6001\u7F3A\u5E2D\uFF0C\u4E0D\u662F\u7A7A\u56FE\u2014\u2014\u300C\u6CA1\u67E5\u300D\u2260\u300C\u67E5\u4E86\u6CA1\u6709\u300D\uFF09\u3002"
48439
+ }, emptyResult5(input.id, view, maxDepth));
48440
+ }
48441
+ return failGraph(governanceErrorToCliError(error), emptyResult5(input.id, view, maxDepth));
48442
+ }
48443
+ try {
48444
+ parseGovernedId(input.id);
48445
+ } catch (error) {
48446
+ if (!(error instanceof GovernedIdParseError))
48447
+ throw error;
48448
+ return failGraph(parseErrorToCliError(error), emptyResult5(input.id, view, maxDepth));
48449
+ }
48450
+ const target = input.id;
48451
+ let indexRaw;
48452
+ try {
48453
+ indexRaw = await readFile9(truthIndexPath(input.rootDir), "utf8");
48454
+ } catch {
48455
+ return failGraph({
48456
+ code: "NOT_INITIALIZED",
48457
+ message: `no pomaster state found at ${toPosix(TRUTH_INDEX_RELATIVE)}`,
48458
+ hint: "run: pomaster init\uFF08\u5728\u9879\u76EE\u6839\u521B\u5EFA\u6CBB\u7406\u9AA8\u67B6\u540E\u91CD\u8BD5\uFF09\u3002"
48459
+ }, emptyResult5(target, view, maxDepth));
48460
+ }
48461
+ let index;
48462
+ try {
48463
+ const parsed = JSON.parse(indexRaw);
48464
+ if (!isRecord6(parsed))
48465
+ throw new TypeError("truth-index is not an object");
48466
+ index = parsed;
48467
+ } catch (error) {
48468
+ return failGraph({
48469
+ code: "SCHEMA_INVALID",
48470
+ message: `truth-index \u65E0\u6CD5\u89E3\u6790\uFF1A${error.message}`,
48471
+ hint: `\u673A\u5668\u4E8B\u52A1\u7EF4\u62A4\u7684\u6587\u4EF6\uFF08${toPosix(TRUTH_INDEX_RELATIVE)}\uFF09\uFF1B\u624B\u6539\u5185\u5BB9\u8BF7\u8D70 kernel store \u4E8B\u52A1\u6062\u590D\u3002`
48472
+ }, emptyResult5(target, view, maxDepth));
48473
+ }
48474
+ const rows = Array.isArray(index.objects) ? index.objects : [];
48475
+ const row2 = rows.find((entry) => isRecord6(entry) && entry.id === target);
48476
+ if (row2 === void 0) {
48477
+ return failGraph({
48478
+ code: "OBJECT_NOT_FOUND",
48479
+ message: `\u5BF9\u8C61\u4E0D\u5728 truth-index\uFF1A${target}`,
48480
+ hint: "pomaster status --json \u67E5\u770B\u5BF9\u8C61\u6E05\u5355\uFF1Bid \u8BCD\u5F62\u89C1 vocab-lock id_namespace\uFF08A5\uFF09\u3002"
48481
+ }, emptyResult5(target, view, maxDepth));
48482
+ }
48483
+ const rowRecord = row2;
48484
+ let entries;
48485
+ try {
48486
+ entries = readRelations(pathsOf(store));
48487
+ } catch (error) {
48488
+ return failGraph(kernelErrorToCliError(error), emptyResult5(target, view, maxDepth));
48489
+ }
48490
+ let derived;
48491
+ try {
48492
+ const endpoint = { domain: "truth", id: target };
48493
+ const touching = relationsTouching(entries, endpoint);
48494
+ const forward = forwardDependencies(entries, endpoint);
48495
+ const reverse = reverseDependents(entries, endpoint);
48496
+ const instanceOfEdges = forward.filter((entry) => entry.type === "INSTANCE_OF").map((entry) => ({
48497
+ edge_id: entry.edge_id,
48498
+ endpoint: entry.target,
48499
+ origin: entry.origin,
48500
+ confidence: entry.confidence,
48501
+ producer: entry.producer
48502
+ })).sort(byEndpoint);
48503
+ const forwardGroups = groupEdgesByType(forward.filter((entry) => entry.type !== "INSTANCE_OF"), (entry) => entry.target);
48504
+ const reverseGroups = groupEdgesByType(reverse, (entry) => entry.source);
48505
+ const closure = impactClosure(entries, endpoint, { maxDepth });
48506
+ derived = { touching, instanceOfEdges, forwardGroups, reverseGroups, closure };
48507
+ } catch (error) {
48508
+ return failGraph(kernelErrorToCliError(error), emptyResult5(target, view, maxDepth));
48509
+ }
48510
+ const isAllView = view === "all";
48511
+ const result2 = {
48512
+ id: target,
48513
+ view,
48514
+ max_depth: maxDepth,
48515
+ object: isAllView ? {
48516
+ id: target,
48517
+ kind: asString4(rowRecord.kind),
48518
+ title_zh: asString4(rowRecord.title_zh),
48519
+ family: familyOfId(target),
48520
+ axes: isRecord6(rowRecord.axes) ? rowRecord.axes : null
48521
+ } : null,
48522
+ relations_touching: isAllView ? derived.touching.length : null,
48523
+ instance_of: isAllView ? derived.instanceOfEdges : null,
48524
+ forward_dependencies: isAllView ? derived.forwardGroups : null,
48525
+ reverse_dependents: isAllView ? derived.reverseGroups : null,
48526
+ impact: {
48527
+ root: derived.closure.root,
48528
+ affected: derived.closure.affected.map((node) => ({
48529
+ domain: node.endpoint.domain,
48530
+ id: node.endpoint.id,
48531
+ depth: node.depth,
48532
+ via_edge_id: node.via_edge_id,
48533
+ via_edge_type: node.via_edge_type
48534
+ })),
48535
+ max_depth_reached: derived.closure.max_depth_reached
48536
+ }
48537
+ };
48538
+ return okOutcome("graph", result2, renderGraph(result2));
48539
+ }
46442
48540
 
46443
48541
  // packages/cli/dist/eval.js
46444
48542
  import { existsSync as existsSync16, readFileSync as readFileSync20 } from "node:fs";
@@ -46918,18 +49016,18 @@ async function runEval(input) {
46918
49016
 
46919
49017
  // packages/cli/dist/projection-common.js
46920
49018
  init_dist();
46921
- import { readFile as readFile9 } from "node:fs/promises";
46922
- import { join as join8 } from "node:path";
46923
- function isRecord6(value) {
49019
+ import { readFile as readFile10 } from "node:fs/promises";
49020
+ import { join as join9 } from "node:path";
49021
+ function isRecord7(value) {
46924
49022
  return typeof value === "object" && value !== null && !Array.isArray(value);
46925
49023
  }
46926
- function asString4(value) {
49024
+ function asString5(value) {
46927
49025
  return typeof value === "string" ? value : null;
46928
49026
  }
46929
49027
  async function readRawIndexOrFail(rootDir) {
46930
49028
  let raw;
46931
49029
  try {
46932
- raw = await readFile9(truthIndexPath(rootDir), "utf8");
49030
+ raw = await readFile10(truthIndexPath(rootDir), "utf8");
46933
49031
  } catch {
46934
49032
  return {
46935
49033
  error: {
@@ -46941,7 +49039,7 @@ async function readRawIndexOrFail(rootDir) {
46941
49039
  }
46942
49040
  try {
46943
49041
  const parsed = JSON.parse(raw);
46944
- if (!isRecord6(parsed))
49042
+ if (!isRecord7(parsed))
46945
49043
  throw new TypeError("truth-index is not an object");
46946
49044
  return { index: parsed };
46947
49045
  } catch (err) {
@@ -46955,10 +49053,10 @@ async function readRawIndexOrFail(rootDir) {
46955
49053
  }
46956
49054
  }
46957
49055
  async function readLedgerEntries(rootDir) {
46958
- const path = join8(rootDir, POMASTER_DIR, "state", "exception-ledger.json");
49056
+ const path = join9(rootDir, POMASTER_DIR, "state", "exception-ledger.json");
46959
49057
  let raw;
46960
49058
  try {
46961
- raw = await readFile9(path, "utf8");
49059
+ raw = await readFile10(path, "utf8");
46962
49060
  } catch {
46963
49061
  return {
46964
49062
  entries: [],
@@ -46967,11 +49065,11 @@ async function readLedgerEntries(rootDir) {
46967
49065
  }
46968
49066
  try {
46969
49067
  const parsed = JSON.parse(raw);
46970
- if (!isRecord6(parsed) || !Array.isArray(parsed.entries)) {
49068
+ if (!isRecord7(parsed) || !Array.isArray(parsed.entries)) {
46971
49069
  throw new TypeError("entries is not an array");
46972
49070
  }
46973
49071
  return {
46974
- entries: parsed.entries.filter((entry) => isRecord6(entry)),
49072
+ entries: parsed.entries.filter((entry) => isRecord7(entry)),
46975
49073
  note: `exception-ledger \u5728\u518C ${parsed.entries.length} \u6761\uFF08${toPosix(".pomaster/state/exception-ledger.json")}\uFF09`
46976
49074
  };
46977
49075
  } catch (err) {
@@ -47006,23 +49104,23 @@ function resolveRowTargetId(raw) {
47006
49104
  }
47007
49105
  function findIndexRow(index, targetId) {
47008
49106
  const rows = Array.isArray(index.objects) ? index.objects : [];
47009
- return rows.find((entry) => isRecord6(entry) && entry.id === targetId) ?? null;
49107
+ return rows.find((entry) => isRecord7(entry) && entry.id === targetId) ?? null;
47010
49108
  }
47011
49109
  async function readBodyEnvelope(rootDir, row2) {
47012
- const bodyRef = asString4(row2.body_ref);
49110
+ const bodyRef = asString5(row2.body_ref);
47013
49111
  if (bodyRef === null) {
47014
49112
  return {
47015
49113
  error: {
47016
49114
  code: "SCHEMA_INVALID",
47017
- message: `\u7D22\u5F15\u884C\u7F3A body_ref\uFF08\u5BF9\u8C61 ${asString4(row2.id) ?? "?"}\uFF09`,
49115
+ message: `\u7D22\u5F15\u884C\u7F3A body_ref\uFF08\u5BF9\u8C61 ${asString5(row2.id) ?? "?"}\uFF09`,
47018
49116
  hint: "truth-index \u884C\u7531 kernel \u4E8B\u52A1\u7EF4\u62A4\uFF1B\u4ECE git \u6062\u590D\u540E\u91CD\u8BD5\u3002"
47019
49117
  }
47020
49118
  };
47021
49119
  }
47022
- const bodyPath = join8(rootDir, POMASTER_DIR, ...bodyRef.split("/"));
49120
+ const bodyPath = join9(rootDir, POMASTER_DIR, ...bodyRef.split("/"));
47023
49121
  let raw;
47024
49122
  try {
47025
- raw = await readFile9(bodyPath, "utf8");
49123
+ raw = await readFile10(bodyPath, "utf8");
47026
49124
  } catch {
47027
49125
  return {
47028
49126
  error: {
@@ -47034,34 +49132,34 @@ async function readBodyEnvelope(rootDir, row2) {
47034
49132
  }
47035
49133
  try {
47036
49134
  const parsed = JSON.parse(raw);
47037
- if (!isRecord6(parsed))
49135
+ if (!isRecord7(parsed))
47038
49136
  throw new TypeError("body is not an object");
47039
49137
  return { body: parsed };
47040
49138
  } catch (err) {
47041
49139
  return {
47042
49140
  error: {
47043
49141
  code: "SCHEMA_INVALID",
47044
- message: `\u6B63\u6587\u65E0\u6CD5\u89E3\u6790\uFF08\u5BF9\u8C61 ${asString4(row2.id) ?? "?"}\uFF09\uFF1A${err.message}`,
49142
+ message: `\u6B63\u6587\u65E0\u6CD5\u89E3\u6790\uFF08\u5BF9\u8C61 ${asString5(row2.id) ?? "?"}\uFF09\uFF1A${err.message}`,
47045
49143
  hint: "\u6B63\u6587\u6587\u4EF6\u7531 kernel \u4E8B\u52A1\u7EF4\u62A4\uFF08staged \u539F\u5B50\u5199\uFF09\uFF1B\u4ECE git \u6062\u590D\u8BE5\u6587\u4EF6\uFF0C\u7981\u624B\u6539\u6B63\u6587\u3002"
47046
49144
  }
47047
49145
  };
47048
49146
  }
47049
49147
  }
47050
49148
  async function readPermitFile(rootDir) {
47051
- const path = join8(rootDir, POMASTER_DIR, "state", "permits.json");
49149
+ const path = join9(rootDir, POMASTER_DIR, "state", "permits.json");
47052
49150
  let raw;
47053
49151
  try {
47054
- raw = await readFile9(path, "utf8");
49152
+ raw = await readFile10(path, "utf8");
47055
49153
  } catch {
47056
49154
  return { permits: [] };
47057
49155
  }
47058
49156
  try {
47059
49157
  const parsed = JSON.parse(raw);
47060
- if (!isRecord6(parsed) || !Array.isArray(parsed.permits)) {
49158
+ if (!isRecord7(parsed) || !Array.isArray(parsed.permits)) {
47061
49159
  throw new TypeError("permits is not an array");
47062
49160
  }
47063
49161
  return {
47064
- permits: parsed.permits.filter((entry) => isRecord6(entry))
49162
+ permits: parsed.permits.filter((entry) => isRecord7(entry))
47065
49163
  };
47066
49164
  } catch (err) {
47067
49165
  return {
@@ -47077,7 +49175,7 @@ async function readEvidencePlane(rootDir, warnings) {
47077
49175
  const { readFile: read } = await import("node:fs/promises");
47078
49176
  const runFieldOf3 = (record, field) => {
47079
49177
  const inline = record.gate_result;
47080
- if (isRecord6(inline) && isRecord6(inline.result)) {
49178
+ if (isRecord7(inline) && isRecord7(inline.result)) {
47081
49179
  const value = inline.result[field];
47082
49180
  if (value !== void 0)
47083
49181
  return value;
@@ -47085,7 +49183,7 @@ async function readEvidencePlane(rootDir, warnings) {
47085
49183
  return record[field];
47086
49184
  };
47087
49185
  const runs = [];
47088
- const runsDir = join8(rootDir, POMASTER_DIR, "evidence", "runs");
49186
+ const runsDir = join9(rootDir, POMASTER_DIR, "evidence", "runs");
47089
49187
  for (const fileName of listPlaneFiles(runsDir)) {
47090
49188
  if (!GRN_FILE_PATTERN.test(fileName)) {
47091
49189
  warnings.push({
@@ -47097,8 +49195,8 @@ async function readEvidencePlane(rootDir, warnings) {
47097
49195
  }
47098
49196
  let record;
47099
49197
  try {
47100
- const parsed = JSON.parse(await read(join8(runsDir, fileName), "utf8"));
47101
- if (!isRecord6(parsed))
49198
+ const parsed = JSON.parse(await read(join9(runsDir, fileName), "utf8"));
49199
+ if (!isRecord7(parsed))
47102
49200
  throw new TypeError("run record is not an object");
47103
49201
  record = parsed;
47104
49202
  } catch (err) {
@@ -47113,12 +49211,12 @@ async function readEvidencePlane(rootDir, warnings) {
47113
49211
  runs.push({
47114
49212
  grn: fileName.slice(0, -".json".length),
47115
49213
  subject_id: typeof subject === "string" ? subject : "(unbound)",
47116
- gate: asString4(runFieldOf3(record, "gate")),
47117
- verdict: asString4(runFieldOf3(record, "verdict"))
49214
+ gate: asString5(runFieldOf3(record, "gate")),
49215
+ verdict: asString5(runFieldOf3(record, "verdict"))
47118
49216
  });
47119
49217
  }
47120
49218
  const claims = [];
47121
- const claimsDir = join8(rootDir, POMASTER_DIR, "evidence", "claims");
49219
+ const claimsDir = join9(rootDir, POMASTER_DIR, "evidence", "claims");
47122
49220
  for (const fileName of listPlaneFiles(claimsDir)) {
47123
49221
  if (!CLM_FILE_PATTERN.test(fileName)) {
47124
49222
  warnings.push({
@@ -47130,8 +49228,8 @@ async function readEvidencePlane(rootDir, warnings) {
47130
49228
  }
47131
49229
  let record;
47132
49230
  try {
47133
- const parsed = JSON.parse(await read(join8(claimsDir, fileName), "utf8"));
47134
- if (!isRecord6(parsed))
49231
+ const parsed = JSON.parse(await read(join9(claimsDir, fileName), "utf8"));
49232
+ if (!isRecord7(parsed))
47135
49233
  throw new TypeError("claim record is not an object");
47136
49234
  record = parsed;
47137
49235
  } catch (err) {
@@ -47142,22 +49240,22 @@ async function readEvidencePlane(rootDir, warnings) {
47142
49240
  });
47143
49241
  continue;
47144
49242
  }
47145
- const subject = isRecord6(record.subject) ? record.subject.object_id : record.subject_id ?? record.subjectId;
47146
- const verification = isRecord6(record.verification) ? record.verification : void 0;
49243
+ const subject = isRecord7(record.subject) ? record.subject.object_id : record.subject_id ?? record.subjectId;
49244
+ const verification = isRecord7(record.verification) ? record.verification : void 0;
47147
49245
  claims.push({
47148
49246
  clm: fileName.slice(0, -".json".length),
47149
49247
  subject_id: typeof subject === "string" ? subject : "(unbound)",
47150
- verdict: verification === void 0 ? null : asString4(verification.verdict),
47151
- assertion: asString4(record.assertion)
49248
+ verdict: verification === void 0 ? null : asString5(verification.verdict),
49249
+ assertion: asString5(record.assertion)
47152
49250
  });
47153
49251
  }
47154
49252
  return { runs, claims };
47155
49253
  }
47156
49254
  async function readTransitionHistory(rootDir) {
47157
- const path = join8(rootDir, POMASTER_DIR, "state", "journal.jsonl");
49255
+ const path = join9(rootDir, POMASTER_DIR, "state", "journal.jsonl");
47158
49256
  let raw;
47159
49257
  try {
47160
- raw = await readFile9(path, "utf8");
49258
+ raw = await readFile10(path, "utf8");
47161
49259
  } catch {
47162
49260
  return { events: [] };
47163
49261
  }
@@ -47168,14 +49266,14 @@ async function readTransitionHistory(rootDir) {
47168
49266
  continue;
47169
49267
  try {
47170
49268
  const parsed = JSON.parse(trimmed);
47171
- if (!isRecord6(parsed) || parsed.type !== "TX_APPLIED")
49269
+ if (!isRecord7(parsed) || parsed.type !== "TX_APPLIED")
47172
49270
  continue;
47173
49271
  const seq = typeof parsed.seq === "number" ? parsed.seq : null;
47174
49272
  if (seq === null)
47175
49273
  throw new TypeError("TX_APPLIED \u7F3A seq");
47176
49274
  events.push({
47177
49275
  seq,
47178
- authority_ref: asString4(parsed.authority_ref),
49276
+ authority_ref: asString5(parsed.authority_ref),
47179
49277
  changed_object_ids: (Array.isArray(parsed.changed_object_ids) ? parsed.changed_object_ids : []).filter((id) => typeof id === "string")
47180
49278
  });
47181
49279
  } catch (err) {
@@ -47194,19 +49292,19 @@ function collectAffectedIds(input) {
47194
49292
  const ids = /* @__PURE__ */ new Set([input.taskId]);
47195
49293
  const taskPermitsActive = (Array.isArray(input.taskRow.permits_active) ? input.taskRow.permits_active : []).filter((id) => typeof id === "string");
47196
49294
  for (const permit of input.permits) {
47197
- const permitRef = asString4(permit.permit_ref);
47198
- const changeRef = asString4(permit.change_ref);
49295
+ const permitRef = asString5(permit.permit_ref);
49296
+ const changeRef = asString5(permit.change_ref);
47199
49297
  const relevant = permitRef !== null && taskPermitsActive.includes(permitRef) || changeRef !== null && (changeRef === input.taskId || input.changeRowId !== null && changeRef === input.changeRowId);
47200
49298
  if (!relevant)
47201
49299
  continue;
47202
- const scope = isRecord6(permit.scope) ? permit.scope : void 0;
49300
+ const scope = isRecord7(permit.scope) ? permit.scope : void 0;
47203
49301
  for (const subjectId of (Array.isArray(scope?.subject_ids) ? scope?.subject_ids : []) ?? []) {
47204
49302
  if (typeof subjectId === "string")
47205
49303
  ids.add(subjectId);
47206
49304
  }
47207
49305
  }
47208
49306
  if (input.changeBody !== null) {
47209
- const payload = isRecord6(input.changeBody.payload) ? input.changeBody.payload : {};
49307
+ const payload = isRecord7(input.changeBody.payload) ? input.changeBody.payload : {};
47210
49308
  for (const affected of (Array.isArray(payload.affected_objects) ? payload.affected_objects : []) ?? []) {
47211
49309
  if (typeof affected === "string")
47212
49310
  ids.add(affected);
@@ -47223,15 +49321,15 @@ var LEDGER_AGGREGATED_CLASSES = [
47223
49321
 
47224
49322
  // packages/cli/dist/view.js
47225
49323
  var NO_DATA_MARK = "\uFF08\u65E0\u2014\u2014\u8BE5\u6B65\u6682\u65E0\u673A\u5668\u53EF\u6C47\u7F16\u6570\u636E\uFF09";
47226
- function failView(command, error, emptyResult5) {
47227
- return failOutcome(command, emptyResult5, [error], [
49324
+ function failView(command, error, emptyResult6) {
49325
+ return failOutcome(command, emptyResult6, [error], [
47228
49326
  `${command}: FAILED \u2014 ${error.code}
47229
49327
  hint: ${error.hint}`
47230
49328
  ]);
47231
49329
  }
47232
49330
  function isStableCoreRow(row2) {
47233
- const axes = isRecord6(row2.axes) ? row2.axes : {};
47234
- return asString4(axes.lifecycle) === "CURRENT" && asString4(axes.change) === "STABLE";
49331
+ const axes = isRecord7(row2.axes) ? row2.axes : {};
49332
+ return asString5(axes.lifecycle) === "CURRENT" && asString5(axes.change) === "STABLE";
47235
49333
  }
47236
49334
  async function runViewBlueprint(rootDir, input) {
47237
49335
  const warnings = [];
@@ -47263,24 +49361,24 @@ async function runViewBlueprint(rootDir, input) {
47263
49361
  const envelopeRows = [];
47264
49362
  const rows = Array.isArray(index.objects) ? index.objects : [];
47265
49363
  for (const entry of rows) {
47266
- if (!isRecord6(entry))
49364
+ if (!isRecord7(entry))
47267
49365
  continue;
47268
- const id = asString4(entry.id);
49366
+ const id = asString5(entry.id);
47269
49367
  if (id === null)
47270
49368
  continue;
47271
49369
  if (scope !== null && !id.startsWith(scope))
47272
49370
  continue;
47273
- const kind = asString4(entry.kind) ?? "?";
47274
- const title = asString4(entry.title_zh) ?? "(missing title)";
49371
+ const kind = asString5(entry.kind) ?? "?";
49372
+ const title = asString5(entry.title_zh) ?? "(missing title)";
47275
49373
  if (isStableCoreRow(entry)) {
47276
49374
  stableCore.push({ id, kind, title });
47277
49375
  } else {
47278
- const axes = isRecord6(entry.axes) ? entry.axes : {};
49376
+ const axes = isRecord7(entry.axes) ? entry.axes : {};
47279
49377
  envelopeRows.push({
47280
49378
  id,
47281
49379
  kind,
47282
49380
  title,
47283
- axesLine: `lifecycle=${asString4(axes.lifecycle) ?? "?"} confidence=${asString4(axes.confidence) ?? "?"} evidence=${asString4(axes.evidence) ?? "?"} change=${asString4(axes.change) ?? "?"}`
49381
+ axesLine: `lifecycle=${asString5(axes.lifecycle) ?? "?"} confidence=${asString5(axes.confidence) ?? "?"} evidence=${asString5(axes.evidence) ?? "?"} change=${asString5(axes.change) ?? "?"}`
47284
49382
  });
47285
49383
  }
47286
49384
  }
@@ -47288,9 +49386,9 @@ async function runViewBlueprint(rootDir, input) {
47288
49386
  envelopeRows.sort((a, b) => a.id < b.id ? -1 : 1);
47289
49387
  const ledgerEntries = [];
47290
49388
  for (const entry of ledger.entries) {
47291
- const ref = asString4(entry.ledger_ref) ?? "EXC-?";
47292
- const classification = asString4(entry.classification) ?? "?";
47293
- const statement = asString4(entry.statement) ?? "(missing statement)";
49389
+ const ref = asString5(entry.ledger_ref) ?? "EXC-?";
49390
+ const classification = asString5(entry.classification) ?? "?";
49391
+ const statement = asString5(entry.statement) ?? "(missing statement)";
47294
49392
  ledgerEntries.push({ ledger_ref: ref, classification, statement });
47295
49393
  }
47296
49394
  const prominent = ledgerEntries.filter((entry) => LEDGER_PROMINENT_CLASSES.includes(entry.classification));
@@ -47369,12 +49467,12 @@ async function runViewBlueprint(rootDir, input) {
47369
49467
  return okOutcome("view blueprint", result2, result2.markdown.split("\n"), warnings);
47370
49468
  }
47371
49469
  function rowSummary(row2) {
47372
- const axes = isRecord6(row2.axes) ? row2.axes : {};
47373
- return `${asString4(row2.title_zh) ?? "(missing title)"}\uFF08kind=${asString4(row2.kind) ?? "?"} rev=${String(row2.rev ?? "?")} lifecycle=${asString4(axes.lifecycle) ?? "?"} evidence=${asString4(axes.evidence) ?? "?"} change=${asString4(axes.change) ?? "?"}\uFF09`;
49470
+ const axes = isRecord7(row2.axes) ? row2.axes : {};
49471
+ return `${asString5(row2.title_zh) ?? "(missing title)"}\uFF08kind=${asString5(row2.kind) ?? "?"} rev=${String(row2.rev ?? "?")} lifecycle=${asString5(axes.lifecycle) ?? "?"} evidence=${asString5(axes.evidence) ?? "?"} change=${asString5(axes.change) ?? "?"}\uFF09`;
47374
49472
  }
47375
49473
  async function runViewTask(rootDir, input) {
47376
49474
  const warnings = [];
47377
- const emptyResult5 = {
49475
+ const emptyResult6 = {
47378
49476
  view: "review",
47379
49477
  task: input.task,
47380
49478
  resolved_via_alias: null,
@@ -47384,25 +49482,25 @@ async function runViewTask(rootDir, input) {
47384
49482
  };
47385
49483
  const raw = await readRawIndexOrFail(rootDir);
47386
49484
  if ("error" in raw)
47387
- return failView("view task", raw.error, emptyResult5);
49485
+ return failView("view task", raw.error, emptyResult6);
47388
49486
  const index = raw.index;
47389
49487
  const resolved = resolveRowTargetId(input.task);
47390
49488
  if ("error" in resolved)
47391
- return failView("view task", resolved.error, emptyResult5);
49489
+ return failView("view task", resolved.error, emptyResult6);
47392
49490
  const taskRow = findIndexRow(index, resolved.target);
47393
49491
  if (taskRow === null) {
47394
49492
  return failView("view task", {
47395
49493
  code: "OBJECT_NOT_FOUND",
47396
49494
  message: `\u4EFB\u52A1\u4E0D\u5728 truth-index\uFF1A${resolved.target}${resolved.viaAlias === null ? "" : `\uFF08\u7531 ${resolved.viaAlias} \u6536\u7F16\u89E3\u6790\uFF09`}`,
47397
49495
  hint: "pomaster status --json \u67E5\u770B\u5BF9\u8C61\u6E05\u5355\uFF1Btask \u5BA1\u67E5\u89C6\u56FE\u53EA\u670D\u52A1 task_object \u5206\u6BCD\u3002"
47398
- }, emptyResult5);
49496
+ }, emptyResult6);
47399
49497
  }
47400
49498
  const taskBodyResult = await readBodyEnvelope(rootDir, taskRow);
47401
49499
  if ("error" in taskBodyResult)
47402
- return failView("view task", taskBodyResult.error, emptyResult5);
49500
+ return failView("view task", taskBodyResult.error, emptyResult6);
47403
49501
  const taskBody = taskBodyResult.body;
47404
- const taskPayload = isRecord6(taskBody.payload) ? taskBody.payload : {};
47405
- const implementsChange = asString4(taskPayload.implements_change);
49502
+ const taskPayload = isRecord7(taskBody.payload) ? taskBody.payload : {};
49503
+ const implementsChange = asString5(taskPayload.implements_change);
47406
49504
  let changeRow = null;
47407
49505
  let changeBody = null;
47408
49506
  if (implementsChange !== null) {
@@ -47429,13 +49527,13 @@ async function runViewTask(rootDir, input) {
47429
49527
  }
47430
49528
  const permits = await readPermitFile(rootDir);
47431
49529
  if ("error" in permits)
47432
- return failView("view task", permits.error, emptyResult5);
49530
+ return failView("view task", permits.error, emptyResult6);
47433
49531
  const affectedIds = collectAffectedIds({
47434
49532
  taskId: resolved.target,
47435
49533
  taskRow,
47436
49534
  taskBody,
47437
49535
  changeBody,
47438
- changeRowId: changeRow === null ? null : asString4(changeRow.id),
49536
+ changeRowId: changeRow === null ? null : asString5(changeRow.id),
47439
49537
  permits: permits.permits
47440
49538
  });
47441
49539
  const evidence = await readEvidencePlane(rootDir, warnings);
@@ -47454,7 +49552,7 @@ async function runViewTask(rootDir, input) {
47454
49552
  return entry;
47455
49553
  };
47456
49554
  step("Business Intent", [
47457
- ...asString4(taskPayload.intent) !== null ? [`- intent: ${asString4(taskPayload.intent)}`] : [],
49555
+ ...asString5(taskPayload.intent) !== null ? [`- intent: ${asString5(taskPayload.intent)}`] : [],
47458
49556
  ...implementsChange !== null ? [`- implements_change: ${implementsChange}`] : []
47459
49557
  ]);
47460
49558
  step("Change Localization", affectedIds.map((id) => {
@@ -47462,11 +49560,11 @@ async function runViewTask(rootDir, input) {
47462
49560
  return `- \`${id}\`${row2 === null ? "\uFF08\u4E0D\u5728 truth-index\u2014\u2014\u7531 permit/\u53D8\u66F4\u7533\u62A5\u5F15\u5165\uFF09" : ` \u2014 ${rowSummary(row2)}`}`;
47463
49561
  }));
47464
49562
  step("Architecture Impact", affectedRows.filter((row2) => {
47465
- const axes = isRecord6(row2.axes) ? row2.axes : {};
47466
- return asString4(axes.change) !== null && asString4(axes.change) !== "STABLE";
49563
+ const axes = isRecord7(row2.axes) ? row2.axes : {};
49564
+ return asString5(axes.change) !== null && asString5(axes.change) !== "STABLE";
47467
49565
  }).map((row2) => {
47468
- const axes = isRecord6(row2.axes) ? row2.axes : {};
47469
- return `- \`${asString4(row2.id)}\` \u2014 change=${asString4(axes.change)}\uFF08owner=${asString4(row2.authority_owner) ?? "?"}\uFF09`;
49566
+ const axes = isRecord7(row2.axes) ? row2.axes : {};
49567
+ return `- \`${asString5(row2.id)}\` \u2014 change=${asString5(axes.change)}\uFF08owner=${asString5(row2.authority_owner) ?? "?"}\uFF09`;
47470
49568
  }));
47471
49569
  step("FE/BE Boundary", (() => {
47472
49570
  const byPrefix = /* @__PURE__ */ new Map();
@@ -47479,23 +49577,23 @@ async function runViewTask(rootDir, input) {
47479
49577
  step("Layer Impact", (() => {
47480
49578
  const byKind = /* @__PURE__ */ new Map();
47481
49579
  for (const row2 of affectedRows) {
47482
- const kind = asString4(row2.kind) ?? "?";
49580
+ const kind = asString5(row2.kind) ?? "?";
47483
49581
  byKind.set(kind, (byKind.get(kind) ?? 0) + 1);
47484
49582
  }
47485
49583
  return [...byKind.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([kind, count]) => `- kind=${kind} \xD7 ${count}`);
47486
49584
  })());
47487
49585
  step("Code Unit Changes", affectedRows.map((row2) => {
47488
49586
  const hasBodySha = typeof row2.body_sha256 === "string";
47489
- return `- \`${asString4(row2.id)}\` \u2014 rev=${String(row2.rev ?? "?")}${hasBodySha ? ` body_sha256=${String(row2.body_sha256).slice(0, 12)}\u2026` : " body_sha256 \u7F3A\u5E2D"}`;
49587
+ return `- \`${asString5(row2.id)}\` \u2014 rev=${String(row2.rev ?? "?")}${hasBodySha ? ` body_sha256=${String(row2.body_sha256).slice(0, 12)}\u2026` : " body_sha256 \u7F3A\u5E2D"}`;
47490
49588
  }));
47491
- step("Public Contract Diff", affectedRows.filter((row2) => asString4(row2.kind) === "contract_operation").map((row2) => `- \`${asString4(row2.id)}\` \u2014 ${rowSummary(row2)}`));
49589
+ step("Public Contract Diff", affectedRows.filter((row2) => asString5(row2.kind) === "contract_operation").map((row2) => `- \`${asString5(row2.id)}\` \u2014 ${rowSummary(row2)}`));
47492
49590
  step("Dependency Diff", (() => {
47493
49591
  const lines2 = [];
47494
49592
  const currentVersion = /* @__PURE__ */ new Map();
47495
49593
  for (const denom of Array.isArray(index.denominators) ? index.denominators : []) {
47496
- if (!isRecord6(denom))
49594
+ if (!isRecord7(denom))
47497
49595
  continue;
47498
- const id = asString4(denom.id);
49596
+ const id = asString5(denom.id);
47499
49597
  const version = typeof denom.version === "number" ? denom.version : null;
47500
49598
  if (id === null || version === null)
47501
49599
  continue;
@@ -47503,14 +49601,14 @@ async function runViewTask(rootDir, input) {
47503
49601
  }
47504
49602
  for (const row2 of affectedRows) {
47505
49603
  for (const ref of Array.isArray(row2.denominator_refs) ? row2.denominator_refs : []) {
47506
- if (!isRecord6(ref))
49604
+ if (!isRecord7(ref))
47507
49605
  continue;
47508
- const id = asString4(ref.id);
49606
+ const id = asString5(ref.id);
47509
49607
  const versionSeen = typeof ref.version_seen === "number" ? ref.version_seen : null;
47510
49608
  if (id === null || versionSeen === null)
47511
49609
  continue;
47512
49610
  const current = currentVersion.get(id);
47513
- lines2.push(current === void 0 ? `- \`${asString4(row2.id)}\` \u2192 \u5206\u6BCD ${id}@${versionSeen}\uFF08\u672A\u5728\u7D22\u5F15\u767B\u8BB0\u2014\u2014\u8986\u76D6\u7F3A\u53E3\u5982\u5B9E\u5448\u73B0\uFF09` : current === versionSeen ? `- \`${asString4(row2.id)}\` \u2192 \u5206\u6BCD ${id}@${versionSeen}\uFF08\u73B0\u884C v${current}\uFF0C\u65E0\u6F02\u79FB\uFF09` : `- \`${asString4(row2.id)}\` \u2192 \u5206\u6BCD ${id}@${versionSeen}\uFF08\u73B0\u884C v${current}\u2014\u2014\u5F15\u7528\u5DF2\u843D\u540E\uFF0C\u6F02\u79FB\u5982\u5B9E\u5448\u73B0\uFF09`);
49611
+ lines2.push(current === void 0 ? `- \`${asString5(row2.id)}\` \u2192 \u5206\u6BCD ${id}@${versionSeen}\uFF08\u672A\u5728\u7D22\u5F15\u767B\u8BB0\u2014\u2014\u8986\u76D6\u7F3A\u53E3\u5982\u5B9E\u5448\u73B0\uFF09` : current === versionSeen ? `- \`${asString5(row2.id)}\` \u2192 \u5206\u6BCD ${id}@${versionSeen}\uFF08\u73B0\u884C v${current}\uFF0C\u65E0\u6F02\u79FB\uFF09` : `- \`${asString5(row2.id)}\` \u2192 \u5206\u6BCD ${id}@${versionSeen}\uFF08\u73B0\u884C v${current}\u2014\u2014\u5F15\u7528\u5DF2\u843D\u540E\uFF0C\u6F02\u79FB\u5982\u5B9E\u5448\u73B0\uFF09`);
47514
49612
  }
47515
49613
  }
47516
49614
  return lines2;
@@ -47522,17 +49620,17 @@ async function runViewTask(rootDir, input) {
47522
49620
  let unverified = 0;
47523
49621
  let rejected = 0;
47524
49622
  for (const row2 of affectedRows) {
47525
- const summary = isRecord6(row2.evidence_summary) ? row2.evidence_summary : {};
49623
+ const summary = isRecord7(row2.evidence_summary) ? row2.evidence_summary : {};
47526
49624
  claimsTotal += typeof summary.claims === "number" ? summary.claims : 0;
47527
49625
  verified += typeof summary.verified === "number" ? summary.verified : 0;
47528
49626
  unverified += typeof summary.unverified === "number" ? summary.unverified : 0;
47529
49627
  rejected += typeof summary.rejected === "number" ? summary.rejected : 0;
47530
49628
  }
47531
49629
  lines2.push(`- evidence_summary \u805A\u5408\uFF1Aclaims=${claimsTotal} verified=${verified} unverified=${unverified} rejected=${rejected}`);
47532
- const health = isRecord6(index.health) ? index.health : {};
47533
- const worst = isRecord6(health.worst_blindspot) ? health.worst_blindspot : null;
49630
+ const health = isRecord7(index.health) ? index.health : {};
49631
+ const worst = isRecord7(health.worst_blindspot) ? health.worst_blindspot : null;
47534
49632
  if (worst !== null) {
47535
- lines2.push(`- worst_blindspot: gate=${asString4(worst.gate) ?? "?"} escape_ratio=${String(worst.escape_ratio ?? "?")}`);
49633
+ lines2.push(`- worst_blindspot: gate=${asString5(worst.gate) ?? "?"} escape_ratio=${String(worst.escape_ratio ?? "?")}`);
47536
49634
  }
47537
49635
  return lines2;
47538
49636
  })());
@@ -47566,15 +49664,15 @@ async function runViewTask(rootDir, input) {
47566
49664
  }
47567
49665
 
47568
49666
  // packages/cli/dist/audit.js
47569
- function failAudit(error, emptyResult5) {
47570
- return failOutcome("audit", emptyResult5, [error], [
49667
+ function failAudit(error, emptyResult6) {
49668
+ return failOutcome("audit", emptyResult6, [error], [
47571
49669
  `audit: FAILED \u2014 ${error.code}
47572
49670
  hint: ${error.hint}`
47573
49671
  ]);
47574
49672
  }
47575
49673
  async function auditObject(rootDir, row2, index, runsAll, claimsAll, history, warnings) {
47576
- const objectId = asString4(row2.id) ?? "?";
47577
- const axes = isRecord6(row2.axes) ? row2.axes : null;
49674
+ const objectId = asString5(row2.id) ?? "?";
49675
+ const axes = isRecord7(row2.axes) ? row2.axes : null;
47578
49676
  const bodyResult = await readBodyEnvelope(rootDir, row2);
47579
49677
  let body = null;
47580
49678
  if ("error" in bodyResult) {
@@ -47586,17 +49684,17 @@ async function auditObject(rootDir, row2, index, runsAll, claimsAll, history, wa
47586
49684
  } else {
47587
49685
  body = bodyResult.body;
47588
49686
  }
47589
- const authorityBlock = body !== null && isRecord6(body.authority) ? body.authority : {};
49687
+ const authorityBlock = body !== null && isRecord7(body.authority) ? body.authority : {};
47590
49688
  const sourcesRaw = body !== null && Array.isArray(body.sources) ? body.sources : [];
47591
- const owner = asString4(row2.authority_owner);
49689
+ const owner = asString5(row2.authority_owner);
47592
49690
  const policies = [];
47593
49691
  for (const entry of Array.isArray(index.objects) ? index.objects : []) {
47594
- if (!isRecord6(entry))
49692
+ if (!isRecord7(entry))
47595
49693
  continue;
47596
- const id = asString4(entry.id);
49694
+ const id = asString5(entry.id);
47597
49695
  if (id === null || !id.startsWith("POLICY."))
47598
49696
  continue;
47599
- if (asString4(entry.authority_owner) === owner)
49697
+ if (asString5(entry.authority_owner) === owner)
47600
49698
  policies.push(id);
47601
49699
  }
47602
49700
  policies.sort();
@@ -47605,18 +49703,18 @@ async function auditObject(rootDir, row2, index, runsAll, claimsAll, history, wa
47605
49703
  state_axes: axes,
47606
49704
  authority: {
47607
49705
  owner,
47608
- write_policy: asString4(authorityBlock.write_policy)
49706
+ write_policy: asString5(authorityBlock.write_policy)
47609
49707
  },
47610
49708
  source: {
47611
- origin: asString4(row2.origin),
47612
- producer_id: asString4(row2.producer_id),
47613
- sources: sourcesRaw.filter((entry) => isRecord6(entry)).map((entry) => ({
47614
- type: asString4(entry.type) ?? "?",
47615
- ref: asString4(entry.ref) ?? "?"
49709
+ origin: asString5(row2.origin),
49710
+ producer_id: asString5(row2.producer_id),
49711
+ sources: sourcesRaw.filter((entry) => isRecord7(entry)).map((entry) => ({
49712
+ type: asString5(entry.type) ?? "?",
49713
+ ref: asString5(entry.ref) ?? "?"
47616
49714
  }))
47617
49715
  },
47618
49716
  evidence: {
47619
- summary: isRecord6(row2.evidence_summary) ? row2.evidence_summary : null,
49717
+ summary: isRecord7(row2.evidence_summary) ? row2.evidence_summary : null,
47620
49718
  permits_active: (Array.isArray(row2.permits_active) ? row2.permits_active : []).filter((id) => typeof id === "string"),
47621
49719
  runs: runsAll.filter((run) => run.subject_id === objectId).map(({ grn, gate, verdict }) => ({ grn, gate, verdict })),
47622
49720
  claims: claimsAll.filter((claim) => claim.subject_id === objectId).map(({ clm, verdict }) => ({ clm, verdict }))
@@ -47641,7 +49739,7 @@ function renderAuditMarkdown(subject, result2) {
47641
49739
  lines.push(" - \uFF08\u7D22\u5F15\u884C\u7F3A axes\u2014\u2014SCHEMA \u7834\u7F3A\uFF0C\u89C1 warnings\uFF09");
47642
49740
  } else {
47643
49741
  for (const axis of ["lifecycle", "confidence", "evidence", "change"]) {
47644
- lines.push(` - ${axis}: ${asString4(report.state_axes[axis]) ?? "?"}`);
49742
+ lines.push(` - ${axis}: ${asString5(report.state_axes[axis]) ?? "?"}`);
47645
49743
  }
47646
49744
  }
47647
49745
  lines.push("- Authority:");
@@ -47691,7 +49789,7 @@ function renderAuditMarkdown(subject, result2) {
47691
49789
  }
47692
49790
  async function runAuditCore(rootDir, subject, scope, resolvedViaAlias, objectIds, initialWarnings = []) {
47693
49791
  const warnings = [...initialWarnings];
47694
- const emptyResult5 = {
49792
+ const emptyResult6 = {
47695
49793
  view: "audit",
47696
49794
  subject,
47697
49795
  scope,
@@ -47702,12 +49800,12 @@ async function runAuditCore(rootDir, subject, scope, resolvedViaAlias, objectIds
47702
49800
  };
47703
49801
  const raw = await readRawIndexOrFail(rootDir);
47704
49802
  if ("error" in raw)
47705
- return failAudit(raw.error, emptyResult5);
49803
+ return failAudit(raw.error, emptyResult6);
47706
49804
  const index = raw.index;
47707
49805
  const evidence = await readEvidencePlane(rootDir, warnings);
47708
49806
  const history = await readTransitionHistory(rootDir);
47709
49807
  if ("error" in history)
47710
- return failAudit(history.error, emptyResult5);
49808
+ return failAudit(history.error, emptyResult6);
47711
49809
  const reports = [];
47712
49810
  for (const id of objectIds) {
47713
49811
  const row2 = findIndexRow(index, id);
@@ -47747,11 +49845,11 @@ async function runAuditBlueprint(rootDir, input) {
47747
49845
  });
47748
49846
  }
47749
49847
  const rows = Array.isArray(raw.index.objects) ? raw.index.objects : [];
47750
- const ids = rows.filter((entry) => isRecord6(entry)).map((entry) => asString4(entry.id)).filter((id) => id !== null).filter((id) => scope === null || id.startsWith(scope)).sort();
49848
+ const ids = rows.filter((entry) => isRecord7(entry)).map((entry) => asString5(entry.id)).filter((id) => id !== null).filter((id) => scope === null || id.startsWith(scope)).sort();
47751
49849
  return runAuditCore(rootDir, "blueprint", scope, null, ids);
47752
49850
  }
47753
49851
  async function runAuditTask(rootDir, input) {
47754
- const emptyResult5 = {
49852
+ const emptyResult6 = {
47755
49853
  view: "audit",
47756
49854
  subject: input.task,
47757
49855
  scope: null,
@@ -47762,29 +49860,29 @@ async function runAuditTask(rootDir, input) {
47762
49860
  };
47763
49861
  const raw = await readRawIndexOrFail(rootDir);
47764
49862
  if ("error" in raw)
47765
- return failAudit(raw.error, emptyResult5);
49863
+ return failAudit(raw.error, emptyResult6);
47766
49864
  const resolved = resolveRowTargetId(input.task);
47767
49865
  if ("error" in resolved)
47768
- return failAudit(resolved.error, emptyResult5);
49866
+ return failAudit(resolved.error, emptyResult6);
47769
49867
  const taskRow = findIndexRow(raw.index, resolved.target);
47770
49868
  if (taskRow === null) {
47771
49869
  return failAudit({
47772
49870
  code: "OBJECT_NOT_FOUND",
47773
49871
  message: `\u4EFB\u52A1\u4E0D\u5728 truth-index\uFF1A${resolved.target}${resolved.viaAlias === null ? "" : `\uFF08\u7531 ${resolved.viaAlias} \u6536\u7F16\u89E3\u6790\uFF09`}`,
47774
49872
  hint: "pomaster status --json \u67E5\u770B\u5BF9\u8C61\u6E05\u5355\uFF1Btask \u5BA1\u8BA1\u89C6\u56FE\u53EA\u670D\u52A1 task_object \u5206\u6BCD\u3002"
47775
- }, emptyResult5);
49873
+ }, emptyResult6);
47776
49874
  }
47777
49875
  const taskBodyResult = await readBodyEnvelope(rootDir, taskRow);
47778
49876
  if ("error" in taskBodyResult)
47779
- return failAudit(taskBodyResult.error, emptyResult5);
47780
- const implementsChange = asString4(isRecord6(taskBodyResult.body.payload) ? taskBodyResult.body.payload.implements_change : null);
49877
+ return failAudit(taskBodyResult.error, emptyResult6);
49878
+ const implementsChange = asString5(isRecord7(taskBodyResult.body.payload) ? taskBodyResult.body.payload.implements_change : null);
47781
49879
  let changeRowId = null;
47782
49880
  let changeBody = null;
47783
49881
  const denominatorWarnings = [];
47784
49882
  if (implementsChange !== null) {
47785
49883
  const changeRow = findIndexRow(raw.index, implementsChange);
47786
49884
  if (changeRow !== null) {
47787
- changeRowId = asString4(changeRow.id);
49885
+ changeRowId = asString5(changeRow.id);
47788
49886
  const changeBodyResult = await readBodyEnvelope(rootDir, changeRow);
47789
49887
  if ("error" in changeBodyResult) {
47790
49888
  denominatorWarnings.push({
@@ -47805,7 +49903,7 @@ async function runAuditTask(rootDir, input) {
47805
49903
  }
47806
49904
  const permits = await readPermitFile(rootDir);
47807
49905
  if ("error" in permits)
47808
- return failAudit(permits.error, emptyResult5);
49906
+ return failAudit(permits.error, emptyResult6);
47809
49907
  const affectedIds = collectAffectedIds({
47810
49908
  taskId: resolved.target,
47811
49909
  taskRow,
@@ -47820,10 +49918,10 @@ async function runAuditTask(rootDir, input) {
47820
49918
  // packages/cli/dist/ledger.js
47821
49919
  init_dist();
47822
49920
  init_src();
47823
- import { readFile as readFile10 } from "node:fs/promises";
47824
- import { join as join9 } from "node:path";
49921
+ import { readFile as readFile11 } from "node:fs/promises";
49922
+ import { join as join10 } from "node:path";
47825
49923
  async function runLedgerRecord(rootDir, input, deps) {
47826
- const emptyResult5 = {
49924
+ const emptyResult6 = {
47827
49925
  ledger_ref: "",
47828
49926
  classification: input.classification,
47829
49927
  statement: input.statement,
@@ -47833,20 +49931,20 @@ async function runLedgerRecord(rootDir, input, deps) {
47833
49931
  };
47834
49932
  const initialized = await requireInitialized(rootDir);
47835
49933
  if ("error" in initialized) {
47836
- return failOutcome("ledger record", emptyResult5, [initialized.error], [
49934
+ return failOutcome("ledger record", emptyResult6, [initialized.error], [
47837
49935
  `ledger record: FAILED \u2014 ${initialized.error.code}
47838
49936
  hint: ${initialized.error.hint}`
47839
49937
  ]);
47840
49938
  }
47841
49939
  const actor = parseActorArgv(input.actor);
47842
49940
  if ("error" in actor) {
47843
- return failOutcome("ledger record", emptyResult5, [actor.error], [
49941
+ return failOutcome("ledger record", emptyResult6, [actor.error], [
47844
49942
  `ledger record: FAILED \u2014 ${actor.error.code}
47845
49943
  hint: ${actor.error.hint}`
47846
49944
  ]);
47847
49945
  }
47848
49946
  if (input.statement.trim().length === 0) {
47849
- return failOutcome("ledger record", emptyResult5, [
49947
+ return failOutcome("ledger record", emptyResult6, [
47850
49948
  {
47851
49949
  code: "SCHEMA_INVALID",
47852
49950
  message: "--statement \u4E3A\u7A7A\uFF08\xA749.2 \u5F02\u5E38\u9648\u8FF0\u5FC5\u586B\uFF09",
@@ -47902,7 +50000,7 @@ async function runLedgerRecord(rootDir, input, deps) {
47902
50000
  message: err instanceof Error ? err.message : String(err),
47903
50001
  hint: "\u67E5\u770B docs/kernel-api.md \u5BF9\u5E94\u5951\u7EA6\uFF1B\u82E5\u4E3A\u73AF\u5883\u5F02\u5E38\u8BF7\u52FF\u9759\u9ED8\u964D\u7EA7\u3002"
47904
50002
  };
47905
- return failOutcome("ledger record", emptyResult5, [error], [
50003
+ return failOutcome("ledger record", emptyResult6, [error], [
47906
50004
  `ledger record: FAILED \u2014 ${error.code}
47907
50005
  hint: ${error.hint}`
47908
50006
  ]);
@@ -47910,10 +50008,10 @@ async function runLedgerRecord(rootDir, input, deps) {
47910
50008
  }
47911
50009
  async function runLedgerList(rootDir, input) {
47912
50010
  const classificationFilter = input.classification?.trim() ? input.classification.trim() : null;
47913
- const path = join9(rootDir, POMASTER_DIR, "state", "exception-ledger.json");
50011
+ const path = join10(rootDir, POMASTER_DIR, "state", "exception-ledger.json");
47914
50012
  let raw;
47915
50013
  try {
47916
- raw = await readFile10(path, "utf8");
50014
+ raw = await readFile11(path, "utf8");
47917
50015
  } catch {
47918
50016
  const result3 = {
47919
50017
  total: 0,
@@ -48000,13 +50098,13 @@ async function runLedgerList(rootDir, input) {
48000
50098
  // packages/cli/dist/knowledge.js
48001
50099
  init_dist();
48002
50100
  import { existsSync as existsSync18 } from "node:fs";
48003
- import { join as join11 } from "node:path";
50101
+ import { join as join12 } from "node:path";
48004
50102
 
48005
50103
  // packages/cli/dist/research.js
48006
50104
  init_dist();
48007
50105
  import { existsSync as existsSync17 } from "node:fs";
48008
- import { mkdir, readFile as readFile11, readdir, writeFile as writeFile2 } from "node:fs/promises";
48009
- import { join as join10 } from "node:path";
50106
+ import { mkdir, readFile as readFile12, readdir, writeFile as writeFile2 } from "node:fs/promises";
50107
+ import { join as join11 } from "node:path";
48010
50108
  var RESEARCH_MODE_ARGV_ALIASES = {
48011
50109
  internal: "INTERNAL",
48012
50110
  external: "EXTERNAL",
@@ -48065,7 +50163,7 @@ async function resolveResearchHost(rootDir, hostOption) {
48065
50163
  }
48066
50164
  };
48067
50165
  }
48068
- if (!existsSync17(join10(rootDir, ...host.split("/")))) {
50166
+ if (!existsSync17(join11(rootDir, ...host.split("/")))) {
48069
50167
  return {
48070
50168
  error: {
48071
50169
  code: "RESEARCH_HOST_NOT_FOUND",
@@ -48090,7 +50188,7 @@ async function resolveResearchHost(rootDir, hostOption) {
48090
50188
  const active = [];
48091
50189
  for (const id of entries) {
48092
50190
  try {
48093
- const raw = JSON.parse(await readFile11(join10(padsDir, id, "state.json"), "utf8"));
50191
+ const raw = JSON.parse(await readFile12(join11(padsDir, id, "state.json"), "utf8"));
48094
50192
  if (typeof raw.state === "string" && (raw.state === "DISCOVERY" || raw.state === "READY_TO_PROMOTE")) {
48095
50193
  active.push(id);
48096
50194
  }
@@ -48121,7 +50219,7 @@ async function readIndexYaml(indexPath) {
48121
50219
  if (!existsSync17(indexPath))
48122
50220
  return null;
48123
50221
  try {
48124
- return JSON.parse(await readFile11(indexPath, "utf8"));
50222
+ return JSON.parse(await readFile12(indexPath, "utf8"));
48125
50223
  } catch {
48126
50224
  return null;
48127
50225
  }
@@ -48205,10 +50303,10 @@ async function runResearchStart(rootDir, input) {
48205
50303
  const created = [];
48206
50304
  const skipped = [];
48207
50305
  try {
48208
- const researchDir = join10(rootDir, ...artifactRoot.split("/"));
50306
+ const researchDir = join11(rootDir, ...artifactRoot.split("/"));
48209
50307
  await mkdir(researchDir, { recursive: true });
48210
50308
  for (const fileName of RESEARCH_ARTIFACT_FILES) {
48211
- const filePath = join10(researchDir, fileName);
50309
+ const filePath = join11(researchDir, fileName);
48212
50310
  if (existsSync17(filePath)) {
48213
50311
  skipped.push(`${artifactRoot}${fileName}`);
48214
50312
  continue;
@@ -48280,7 +50378,7 @@ async function runResearchList(rootDir, hostArg) {
48280
50378
  ], [`research list: FAILED \u2014 SCHEMA_INVALID`]);
48281
50379
  }
48282
50380
  const hostRef = normalizeDir(hostArg);
48283
- const hostDir = join10(rootDir, ...hostRef.split("/"));
50381
+ const hostDir = join11(rootDir, ...hostRef.split("/"));
48284
50382
  if (!existsSync17(hostDir)) {
48285
50383
  return failOutcome("research list", { host_ref: hostRef, artifacts: [] }, [
48286
50384
  {
@@ -48290,7 +50388,7 @@ async function runResearchList(rootDir, hostArg) {
48290
50388
  }
48291
50389
  ], [`research list: FAILED \u2014 RESEARCH_HOST_NOT_FOUND (${hostRef})`]);
48292
50390
  }
48293
- const indexPath = join10(hostDir, "research", "index.yaml");
50391
+ const indexPath = join11(hostDir, "research", "index.yaml");
48294
50392
  const index = await readIndexYaml(indexPath);
48295
50393
  const artifacts = [];
48296
50394
  if (index !== null) {
@@ -48347,7 +50445,7 @@ async function runResearchInspect(rootDir, researchId) {
48347
50445
  }
48348
50446
  ], [`research inspect: FAILED \u2014 SCHEMA_INVALID`]);
48349
50447
  }
48350
- const hostDir = join10(rootDir, ...hostRef.split("/"));
50448
+ const hostDir = join11(rootDir, ...hostRef.split("/"));
48351
50449
  if (!existsSync17(hostDir)) {
48352
50450
  return failOutcome("research inspect", {
48353
50451
  research_id: researchId,
@@ -48365,8 +50463,8 @@ async function runResearchInspect(rootDir, researchId) {
48365
50463
  }
48366
50464
  ], [`research inspect: FAILED \u2014 RESEARCH_HOST_NOT_FOUND (${hostRef})`]);
48367
50465
  }
48368
- const researchDir = join10(hostDir, "research");
48369
- const indexPath = join10(researchDir, "index.yaml");
50466
+ const researchDir = join11(hostDir, "research");
50467
+ const indexPath = join11(researchDir, "index.yaml");
48370
50468
  if (!existsSync17(indexPath)) {
48371
50469
  return failOutcome("research inspect", {
48372
50470
  research_id: researchId,
@@ -48421,7 +50519,7 @@ async function runResearchInspect(rootDir, researchId) {
48421
50519
  }
48422
50520
  const files = RESEARCH_ARTIFACT_FILES.map((f) => ({
48423
50521
  file: f,
48424
- present: existsSync17(join10(researchDir, f))
50522
+ present: existsSync17(join11(researchDir, f))
48425
50523
  }));
48426
50524
  const missing = files.filter((f) => !f.present).map((f) => f.file);
48427
50525
  const rawFindings = Array.isArray(index.findings) ? index.findings : [];
@@ -48765,7 +50863,7 @@ async function loadResearchFinding(rootDir, researchId, findingNumber) {
48765
50863
  }
48766
50864
  };
48767
50865
  }
48768
- const indexPath = join11(rootDir, ...artifactRoot.split("/"), "index.yaml");
50866
+ const indexPath = join12(rootDir, ...artifactRoot.split("/"), "index.yaml");
48769
50867
  if (!existsSync18(indexPath)) {
48770
50868
  return {
48771
50869
  error: {
@@ -48982,17 +51080,17 @@ async function runKnowledgeDemote(rootDir, input, deps) {
48982
51080
  init_src();
48983
51081
  init_dist();
48984
51082
  import { existsSync as existsSync19 } from "node:fs";
48985
- import { mkdir as mkdir2, readdir as readdir2, readFile as readFile12, writeFile as writeFile3 } from "node:fs/promises";
48986
- import { isAbsolute, join as join12, relative as relative2, resolve as resolve2 } from "node:path";
51083
+ import { mkdir as mkdir2, readdir as readdir2, readFile as readFile13, writeFile as writeFile3 } from "node:fs/promises";
51084
+ import { isAbsolute, join as join13, relative as relative2, resolve as resolve2 } from "node:path";
48987
51085
  var PROMOTE_TARGETS = ["CHANGE", "TASK"];
48988
51086
  function scratchpadRefOf(id) {
48989
51087
  return `.pomaster/discovery/scratchpads/${id}/`;
48990
51088
  }
48991
51089
  function stateFilePath(rootDir, id) {
48992
- return join12(discoveryScratchpadDirPath(rootDir, id), "state.json");
51090
+ return join13(discoveryScratchpadDirPath(rootDir, id), "state.json");
48993
51091
  }
48994
51092
  function metaFilePath(rootDir, id) {
48995
- return join12(discoveryScratchpadDirPath(rootDir, id), "meta.json");
51093
+ return join13(discoveryScratchpadDirPath(rootDir, id), "meta.json");
48996
51094
  }
48997
51095
  function cliError(err) {
48998
51096
  if (err instanceof GovernedIdParseError) {
@@ -49012,7 +51110,7 @@ async function readJsonFile(path) {
49012
51110
  if (!existsSync19(path))
49013
51111
  return null;
49014
51112
  try {
49015
- return JSON.parse(await readFile12(path, "utf8"));
51113
+ return JSON.parse(await readFile13(path, "utf8"));
49016
51114
  } catch {
49017
51115
  return null;
49018
51116
  }
@@ -49200,7 +51298,7 @@ async function runBrainstormStatus(rootDir) {
49200
51298
  return okOutcome("brainstorm status", { scratchpads }, human, warnings);
49201
51299
  }
49202
51300
  async function runBrainstormPromote(rootDir, input) {
49203
- const emptyResult5 = {
51301
+ const emptyResult6 = {
49204
51302
  discovery_id: input.discoveryId,
49205
51303
  from_state: "",
49206
51304
  to_state: input.to ?? "",
@@ -49213,7 +51311,7 @@ async function runBrainstormPromote(rootDir, input) {
49213
51311
  suggested_command: null,
49214
51312
  scratchpad_state: ""
49215
51313
  };
49216
- const fail6 = (error, human) => failOutcome("brainstorm promote", emptyResult5, [error], human);
51314
+ const fail6 = (error, human) => failOutcome("brainstorm promote", emptyResult6, [error], human);
49217
51315
  if (!DISCOVERY_ID_PATTERN.test(input.discoveryId)) {
49218
51316
  return fail6({
49219
51317
  code: "SCHEMA_INVALID",
@@ -49391,7 +51489,7 @@ async function runBrainstormPromote(rootDir, input) {
49391
51489
  return fail6(txOutError, [`brainstorm promote: FAILED \u2014 SCHEMA_INVALID (--tx-out)`]);
49392
51490
  }
49393
51491
  if (txPath === null) {
49394
- txPath = join12(discoveryScratchpadDirPath(rootDir, input.discoveryId), "promote-tx.json");
51492
+ txPath = join13(discoveryScratchpadDirPath(rootDir, input.discoveryId), "promote-tx.json");
49395
51493
  }
49396
51494
  try {
49397
51495
  await mkdir2(discoveryScratchpadDirPath(rootDir, input.discoveryId), { recursive: true });
@@ -49403,7 +51501,7 @@ async function runBrainstormPromote(rootDir, input) {
49403
51501
  const maintainArgv = `pomaster maintain ${input.discoveryId} --ops ${toPosix(txPath)}`;
49404
51502
  if (input.apply !== true) {
49405
51503
  return okOutcome("brainstorm promote", {
49406
- ...emptyResult5,
51504
+ ...emptyResult6,
49407
51505
  from_state: fromState,
49408
51506
  to_state: target,
49409
51507
  promotion_basis: basisValue,
@@ -49428,7 +51526,7 @@ async function runBrainstormPromote(rootDir, input) {
49428
51526
  });
49429
51527
  if (!maintainOutcome.ok) {
49430
51528
  return failOutcome("brainstorm promote", {
49431
- ...emptyResult5,
51529
+ ...emptyResult6,
49432
51530
  from_state: fromState,
49433
51531
  to_state: target,
49434
51532
  promotion_basis: basisValue,
@@ -49459,7 +51557,7 @@ async function runBrainstormPromote(rootDir, input) {
49459
51557
  }
49460
51558
  } catch (err) {
49461
51559
  return failOutcome("brainstorm promote", {
49462
- ...emptyResult5,
51560
+ ...emptyResult6,
49463
51561
  from_state: fromState,
49464
51562
  to_state: target,
49465
51563
  promotion_basis: basisValue,
@@ -51794,13 +53892,10 @@ function createProgram(runs, io = defaultIo) {
51794
53892
  });
51795
53893
  program2.name(CLI_NAME).description("POMaster vNext \u2014 Governed Software State Control Plane\uFF08\u516B\u62CD Change Loop \u547D\u4EE4\u9762\uFF09").version(resolveCliVersion()).option("--dir <path>", "project root directory", process.cwd());
51796
53894
  program2.addHelpText("after", "\nContact / commercial licensing: allenxujianyang@outlook.com");
51797
- program2.command("init").description("\u521B\u5EFA .pomaster/ \u6700\u5C0F\u9AA8\u67B6 + AGENTS.md \u552F\u4E00\u4E8B\u5B9E\u6E90 + \u5E73\u53F0\u9002\u914D\u5668\uFF08F1\uFF1A--platforms \u9017\u53F7\u5217\u8868 claude,codex,cursor,qoder / none\uFF1B\u5E42\u7B49\uFF1B\u91CD\u590D\u6267\u884C NO_CHANGE\uFF09").option("--platforms <platforms>", "\u5E73\u53F0\u9002\u914D\u5668\u9017\u53F7\u5217\u8868\uFF08claude|codex|cursor|qoder|none\uFF1B\u7F3A\u7701 claude\uFF1BTTY \u4EBA\u8BFB\u6A21\u5F0F\u65E0\u65D7\u6807\u65F6\u51FA\u6E05\u5355\u4EA4\u4E92\uFF09").option("--json", "machine-readable JSON output (\xA745)").action(async (_opts, command) => {
53895
+ program2.command("init").description("\u521B\u5EFA .pomaster/ \u6700\u5C0F\u9AA8\u67B6 + AGENTS.md \u552F\u4E00\u4E8B\u5B9E\u6E90 + \u5E73\u53F0\u9002\u914D\u5668\uFF08F1\uFF1A--platforms \u9017\u53F7\u5217\u8868 claude,codex,cursor,qoder / none\uFF1B\u5E42\u7B49\uFF1B\u91CD\u590D\u6267\u884C NO_CHANGE\uFF09").option("--platforms <platforms>", "\u5E73\u53F0\u9002\u914D\u5668\u9017\u53F7\u5217\u8868\uFF08claude|codex|cursor|qoder|none\uFF1B\u7F3A\u7701 claude\uFF1BTTY \u4EBA\u8BFB\u6A21\u5F0F\u65E0\u65D7\u6807\u65F6\u51FA\u590D\u9009\u6E05\u5355\u4EA4\u4E92\uFF09").option("--json", "machine-readable JSON output (\xA745)").action(async (_opts, command) => {
51798
53896
  const platformsArg = command.opts().platforms;
51799
53897
  const asJson = command.opts().json === true;
51800
- const outcome = platformsArg === void 0 && !asJson && process.stdin.isTTY === true ? await runInitInteractive(resolveDir(command), {
51801
- write: (line) => io.stdout(line),
51802
- readLine: readLineFromStdin
51803
- }) : await runInit(resolveDir(command), { platforms: platformsArg });
53898
+ const outcome = platformsArg === void 0 && !asJson && process.stdin.isTTY === true ? await initInteractiveOutcome(resolveDir(command), io) : await runInit(resolveDir(command), { platforms: platformsArg });
51804
53899
  record({ command: "init", outcome, asJson });
51805
53900
  });
51806
53901
  program2.command("update").description("\u68C0\u67E5/\u6267\u884C CLI \u81EA\u66F4\u65B0\uFF1A\u7F3A\u7701 --check\uFF08npm view \u6BD4\u5BF9 semver\uFF0Cregistry \u4E0D\u53EF\u8FBE\u663E\u5F0F\u5448\u73B0\u7981\u5047\u7EFF\uFF09\uFF1B--yes = \u66F4\u65B0\u53EF\u7528\u65F6 npm install -g pomaster@latest\uFF08npm \u5931\u8D25\u900F\u4F20 exit 1\uFF1B\u5B8C\u6210\u540E\u91CD\u65B0 pomaster init \u5237\u65B0\u8F7B\u5165\u53E3\uFF09").option("--check", "\u68C0\u67E5\u66F4\u65B0\uFF08\u7F3A\u7701\u884C\u4E3A\uFF0C\u663E\u5F0F\u8BCD\u5F62\u517C\u5BB9\uFF09").option("--yes", "\u68C0\u67E5\u5230\u66F4\u65B0\u65F6\u6267\u884C npm install -g pomaster@latest").option("--json", "machine-readable JSON output (\xA745)").action(async (opts, command) => {
@@ -51839,6 +53934,32 @@ function createProgram(runs, io = defaultIo) {
51839
53934
  asJson: command.opts().json === true
51840
53935
  });
51841
53936
  });
53937
+ program2.command("resolve").description("\u7EDF\u4E00\u8BED\u4E49\u89E3\u6790\uFF1A\u9700\u6C42\u8BCD\u5F62 \u2192 \u65E2\u6709\u5BF9\u8C61/archetype \u6807\u51C6\u4EF6\u5339\u914D\uFF08EXACT/CONFIGURABLE/EXTENSIBLE/NO_MATCH \u786E\u5B9A\u6027\u5206\u7C7B\uFF1BNO_MATCH \u663E\u5F0F\u4E0D\u81C6\u9020\u2014\u2014Anti-Hallucination\uFF1B\u89E3\u6790\u2260\u91C7\u7528\uFF0CINSTANCE_OF \u8FB9\u5F52\u663E\u5F0F\u91C7\u7528\u52A8\u4F5C\uFF09").argument("<need>", "\u9700\u6C42\u8BCD\u5F62\uFF08\u81EA\u7136\u8BED\u8A00/\u610F\u56FE\u539F\u6587\uFF1B\u8BCD\u5F62\u5316\u8BCD\u7EA7\u7CBE\u786E\u7981\u5B50\u4E32\u731C\u6D4B\uFF09").option("--hints <words...>", "\u8865\u5145\u68C0\u7D22\u8BCD\uFF08\u53EF\u591A\u503C\uFF09").option("--catalog-root <path>", "\u6CE8\u5165 catalog \u6839\u76EE\u5F55\uFF08\u6D4B\u8BD5/\u5D4C\u5165\u9762\uFF1B\u7F3A\u7701 = \u5DE5\u5177\u4ED3\u5E93 catalog/\uFF09").option("--json", "machine-readable JSON output (\xA745)").action(async (need, opts, command) => {
53938
+ const outcome = await runResolve({
53939
+ need,
53940
+ hints: opts.hints,
53941
+ catalogRoot: opts.catalogRoot,
53942
+ rootDir: resolveDir(command)
53943
+ });
53944
+ record({
53945
+ command: "resolve",
53946
+ outcome,
53947
+ asJson: command.opts().json === true
53948
+ });
53949
+ });
53950
+ program2.command("graph").description("\u5BF9\u8C61\u56FE\u89C6\u56FE\uFF08\xA7104-113 Studio \u6700\u5C0F CLI \u6295\u5F71\uFF09\uFF1Afamily/\u6807\u9898 + INSTANCE_OF \u91C7\u7EB3\u8FB9 + \u6B63\u5411\u4F9D\u8D56/\u53CD\u5411 dependents + impact \u90BB\u57DF\uFF08\u95ED\u5305 maxDepth \u7F3A\u7701 4\uFF0C\u8D85\u6DF1\u663E\u5F0F\u5448\u73B0\uFF09\uFF1B--view impact \u53EA\u51FA\u95ED\u5305\u6BB5\uFF1B\u7EAF\u8BFB\u96F6\u5199\u5165\uFF08\u6240\u6709\u53EF\u89C6\u5316\u90FD\u662F Projection\u2014\u2014\xA71.6\uFF1B\u96F6\u8FB9=\u300C\u65E0\u8FB9\u767B\u8BB0\u300D\u4E0D\u5192\u5145\u65E0\u4F9D\u8D56\uFF09").argument("<governed-id>", "governed id\uFF08closed-world \u6587\u6CD5 A5\uFF1Bkernel parseGovernedId \u5224\u5377\uFF09").option("--view <view>", "\u89C6\u56FE\u8BCD\u5F62\uFF08all=\u5168\u6BB5\uFF08\u7F3A\u7701\uFF09| impact=\u53EA\u51FA impact \u95ED\u5305\u6BB5\uFF09").option("--max-depth <n>", "impact \u95ED\u5305\u6700\u5927\u6DF1\u5EA6\uFF081..16\uFF1B\u7F3A\u7701 4\u2014\u2014\u9632\u5FA1\u5931\u63A7 BFS\uFF09").option("--json", "machine-readable JSON output (\xA745)").action(async (id, opts, command) => {
53951
+ const outcome = await runGraph({
53952
+ id,
53953
+ view: opts.view,
53954
+ maxDepth: opts.maxDepth,
53955
+ rootDir: resolveDir(command)
53956
+ });
53957
+ record({
53958
+ command: "graph",
53959
+ outcome,
53960
+ asJson: command.opts().json === true
53961
+ });
53962
+ });
51842
53963
  const context = program2.command("context").description("\u4E0A\u4E0B\u6587\u6295\u5F71\uFF08\u516B\u62CD\u2462 PROJECTION\uFF09");
51843
53964
  context.command("compile").description("\u8F6C\u8C03 kernel compileProjection\uFF0C\u8F93\u51FA\u4E94\u5206\u533A markdown\uFF08MUST/ADVISORY/KNOWLEDGE/CATALOG/LAZY TOOLS\uFF09\uFF1Bcatalog \u5206\u533A\u6309\u7ED3\u6784\u5316 applicability \u786E\u5B9A\u6027\u8FC7\u6EE4\uFF08P0.5-1\uFF0CPRD \xA75.2/\xA75.3\uFF09").requiredOption("--role <role>", "role lane (frontend/backend/architect/designer/documenter ...)").option("--change <ref>", "CHANGE.*/TASK.* \u5F15\u7528\uFF08\u900F\u4F20 taskRef\uFF0C\u6FC0\u6D3B\u8BB8\u53EF\u901A\u9053\uFF09").option("--capability <governed-id>", "CAPABILITY.* governed id\uFF08\u53EF\u91CD\u590D\uFF1Bcatalog applicability \u5224\u5B9A\u8F93\u5165\uFF0CP0.5-1\uFF09", collectValues, []).option("--change-class <class>", "\u53D8\u66F4\u7C7B\u76EE\uFF08\u2208 CATALOG_CHANGE_CLASS_VALUES\uFF0Cvocab-pr-0005 \u8BCD\u8F74\uFF09").option("--profile <profile>", "\u6CBB\u7406\u6863\u4F4D\uFF08\u2208 CATALOG_GOVERNANCE_PROFILE_VALUES\uFF1B\u5BF9\u9F50 triage+STRICT\uFF09").option("--json", "machine-readable JSON output (\xA745)").action(async (opts, command) => {
51844
53965
  const outcome = await runContextCompile(resolveDir(command), opts.role, void 0, {
@@ -52066,7 +54187,7 @@ function createProgram(runs, io = defaultIo) {
52066
54187
  asJson: command.opts().json === true
52067
54188
  });
52068
54189
  });
52069
- const catalog = program2.command("catalog").description("Engineering Catalog \u547D\u4EE4\u9762\uFF08\xA744.10\uFF09\uFF1A\u67E5\u770B catalog \u6784\u6210\uFF08status\uFF09\u4E0E\u5355\u6761\u76EE\u89E3\u91CA\uFF08explain\uFF09\uFF1Bcatalog-lock \u6F02\u79FB\u663E\u5F0F\u68C0\u51FA");
54190
+ const catalog = program2.command("catalog").description("Engineering Catalog \u547D\u4EE4\u9762\uFF08\xA744.10\uFF09\uFF1A\u67E5\u770B catalog \u6784\u6210\uFF08status\uFF09/\u5355\u6761\u76EE\u89E3\u91CA\uFF08explain\uFF09/\u6F02\u79FB\u91CD\u9501\u6062\u590D\u952E\uFF08relock\uFF09\uFF1Bcatalog-lock \u6F02\u79FB\u663E\u5F0F\u68C0\u51FA");
52070
54191
  catalog.command("status").description("catalog \u6784\u6210\uFF1A\u7248\u672C/profile/\u5206\u533A\u8BA1\u6570\uFF08policies/gates/knowledge/tools/projection-presets\uFF09+ catalog-lock \u6821\u9A8C\uFF08\u6F02\u79FB = CATALOG_LOCK_DRIFT fail-closed\uFF09").option("--catalog-root <path>", "\u6CE8\u5165 catalog \u6839\u76EE\u5F55\uFF08\u6D4B\u8BD5/\u5D4C\u5165\u9762\uFF1B\u7F3A\u7701 = \u5DE5\u5177\u4ED3\u5E93 catalog/\uFF09").option("--json", "machine-readable JSON output (\xA745)").action(async (opts, command) => {
52071
54192
  const outcome = await runCatalogStatus({
52072
54193
  catalogRoot: opts.catalogRoot
@@ -52087,6 +54208,16 @@ function createProgram(runs, io = defaultIo) {
52087
54208
  asJson: command.opts().json === true
52088
54209
  });
52089
54210
  });
54211
+ catalog.command("relock").description("\u6F02\u79FB\u6062\u590D\u952E\uFF08P-v06 \u6279\u6B21 2.5\uFF09\uFF1A\u5E42\u7B49\u91CD\u7B97 sha256 \u91CD\u9501 catalog-lock\uFF08\u53D7\u63A7\u4E94\u8282\u5168\u626B\u63CF\u91CD\u5EFA entries/allowed/required\uFF0Cgenerated_by \u5E42\u7B49\u6CE8\u8BB0\uFF09+ \u5199\u540E\u590D\u9A8C\u56DE\u7EFF\u5448\u73B0 diff\uFF08added/removed/refreshed\uFF09\uFF1Block \u7F3A\u5931/\u574F\u5F62\u663E\u5F0F\u62D2\u7EDD\u2014\u2014relock \u4E0D\u662F\u521D\u59CB\u5316\u5DE5\u5177").option("--catalog-root <path>", "\u6CE8\u5165 catalog \u6839\u76EE\u5F55\uFF08\u6D4B\u8BD5/\u5D4C\u5165\u9762\uFF1B\u7F3A\u7701 = \u5DE5\u5177\u4ED3\u5E93 catalog/\uFF09").option("--json", "machine-readable JSON output (\xA745)").action(async (opts, command) => {
54212
+ const outcome = await runCatalogRelock({
54213
+ catalogRoot: opts.catalogRoot
54214
+ });
54215
+ record({
54216
+ command: "catalog relock",
54217
+ outcome,
54218
+ asJson: command.opts().json === true
54219
+ });
54220
+ });
52090
54221
  const migrate = program2.command("migrate").description("Trellis Spec \u8FC1\u79FB\u547D\u4EE4\u9762\uFF08\xA793.6/\xA796 \u7B2C 8 \u6B65\uFF09\uFF1Aanalyze-only \u9636\u6BB5\u53EA\u63A5\u7EBF --analyze\uFF08\u53EA\u8BFB\u5206\u6790\u96F6\u5199\u5165\uFF09");
52091
54222
  migrate.command("trellis-spec").description("Trellis Spec Analyzer\uFF08\xA796 \u7B2C 8 \u6B65\u300C\u53EA\u5206\u6790\uFF0C\u4E0D Apply\u300D\uFF09\uFF1A--analyze --spec-root <dir> \u8F93\u51FA\u8FC1\u79FB\u5206\u7C7B\u6E05\u5355\uFF08\xA793.3 \u516B\u7C7B\u5019\u9009 + \xA793.4 \u5341\u4E8C\u5206\u7C7B + \xA793.6 \u516D\u68C0 analyze \u7248\uFF1B\u5206\u6BCD\u5757\u6052\u5448\u73B0\uFF09\uFF1B--propose/--diff/--apply \u663E\u5F0F deferred\uFF08\u4F20\u5165\u5373\u63D0\u793A exit 1\uFF0C\u975E\u9759\u9ED8\u541E\u53C2\uFF09\uFF1B\u5176\u4F59\u672A\u77E5\u8BCD\u5F62\u663E\u5F0F\u62D2\u7EDD\uFF08SCHEMA_INVALID\uFF0C\u975E\u9759\u9ED8\u541E\u53C2\uFF09\uFF1B\u8FC1\u79FB\u7EAA\u5F8B\uFF08\xA796 \u7B2C 11 \u6B65\uFF09\uFF1A\u4E0D\u4EE5\u4E00\u6B21\u8FC1\u5B8C\u4E3A\u5B8C\u6210\u6761\u4EF6\u2014\u2014Tracer Bullet \u5148\u6253\u901A 3~5 \u4E2A\u4EE3\u8868\u4E3B\u9898\u5168\u94FE\u8DEF").option("--analyze", "\u8FD0\u884C\u5206\u6790\uFF08\u672C\u9636\u6BB5\u552F\u4E00\u63A5\u7EBF\u8BCD\u5F62\uFF1B\u53EA\u8BFB\u96F6\u5199\u5165\uFF09").option("--spec-root <dir>", "Analyzer \u8F93\u5165\u6E90 spec \u76EE\u5F55\uFF08\u7F3A\u5E2D = fail-closed \u663E\u5F0F\u62A5\u9519\uFF0C\u4E0D\u731C\u6D4B\u9ED8\u8BA4\u8DEF\u5F84\uFF09").allowUnknownOption(true).argument("[extras...]").option("--json", "machine-readable JSON output (\xA745)").action(async (extras, _opts, command) => {
52092
54223
  const deferredForms = extras.filter((form) => MIGRATE_DEFERRED_FORMS.includes(form));
@@ -52694,6 +54825,91 @@ function readLineFromStdin() {
52694
54825
  rl.once("close", () => resolve3(""));
52695
54826
  });
52696
54827
  }
54828
+ function takeKeyToken(buffer) {
54829
+ if (buffer.startsWith("\x1B[A") || buffer.startsWith("\x1B[B")) {
54830
+ return { token: buffer.slice(0, 3), rest: buffer.slice(3) };
54831
+ }
54832
+ if (buffer.startsWith("\x1B")) {
54833
+ if (buffer.length === 1)
54834
+ return null;
54835
+ if (buffer[1] === "[" && buffer.length === 2)
54836
+ return null;
54837
+ return { token: buffer.slice(0, 2), rest: buffer.slice(2) };
54838
+ }
54839
+ const head = buffer[0];
54840
+ return head === void 0 ? null : { token: head, rest: buffer.slice(1) };
54841
+ }
54842
+ function pumpStdinKeys(handler) {
54843
+ return new Promise((resolve3) => {
54844
+ let buffer = "";
54845
+ const cleanup = () => {
54846
+ process.stdin.removeListener("data", onData);
54847
+ process.stdin.removeListener("end", onDone);
54848
+ process.stdin.removeListener("close", onDone);
54849
+ };
54850
+ const onDone = () => {
54851
+ cleanup();
54852
+ resolve3();
54853
+ };
54854
+ const onData = (chunk) => {
54855
+ buffer += typeof chunk === "string" ? chunk : chunk.toString("utf8");
54856
+ while (buffer.length > 0) {
54857
+ const token = takeKeyToken(buffer);
54858
+ if (token === null)
54859
+ break;
54860
+ buffer = token.rest;
54861
+ if (!handler(token.token)) {
54862
+ cleanup();
54863
+ resolve3();
54864
+ return;
54865
+ }
54866
+ }
54867
+ };
54868
+ process.stdin.on("data", onData);
54869
+ process.stdin.once("end", onDone);
54870
+ process.stdin.once("close", onDone);
54871
+ });
54872
+ }
54873
+ async function initInteractiveOutcome(rootDir, io) {
54874
+ const stdin = process.stdin;
54875
+ const restoreRaw = () => {
54876
+ try {
54877
+ stdin.setRawMode(false);
54878
+ } catch {
54879
+ }
54880
+ process.stdout.write("\n");
54881
+ };
54882
+ if (typeof stdin.setRawMode === "function" && process.stdout.isTTY === true) {
54883
+ let rawEnabled = false;
54884
+ try {
54885
+ stdin.setRawMode(true);
54886
+ rawEnabled = true;
54887
+ } catch {
54888
+ rawEnabled = false;
54889
+ }
54890
+ if (rawEnabled) {
54891
+ let result2;
54892
+ try {
54893
+ result2 = await runChecklistPrompt({
54894
+ write: (chunk) => process.stdout.write(chunk),
54895
+ pumpKeys: (handler) => pumpStdinKeys(handler)
54896
+ });
54897
+ } catch (err) {
54898
+ restoreRaw();
54899
+ throw err;
54900
+ }
54901
+ restoreRaw();
54902
+ if (result2.kind === "aborted") {
54903
+ process.exit(130);
54904
+ }
54905
+ return runInit(rootDir, { platforms: result2.platforms.join(",") });
54906
+ }
54907
+ }
54908
+ return runInitInteractive(rootDir, {
54909
+ write: (line) => io.stdout(line),
54910
+ readLine: readLineFromStdin
54911
+ });
54912
+ }
52697
54913
  function isInformationalCommanderExit(err) {
52698
54914
  return err instanceof CommanderError && (err.code === "commander.helpDisplayed" || err.code === "commander.help" || err.code === "commander.version");
52699
54915
  }