bugx-cli 0.1.4 → 0.1.6

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 (127) hide show
  1. package/README.md +89 -210
  2. package/core/README.md +1 -1
  3. package/core/agent/agent_execution.py +7 -0
  4. package/core/agent/agent_targets.py +5 -1
  5. package/core/agent/agent_workspace.py +10 -2
  6. package/core/autonomous_cve/run_fault_matrix.py +692 -0
  7. package/core/autonomous_cve/run_oss_cve_exploit_verify.py +608 -0
  8. package/core/autonomous_cve/run_six_worker_penetration.py +382 -0
  9. package/core/autonomous_cve/verifier.py +5 -7
  10. package/core/bugx.md +1 -1
  11. package/core/bugx_paths.py +2 -2
  12. package/core/bundled_docs/OVERVIEW.md +70 -236
  13. package/core/bundled_docs/README.md +2 -2
  14. package/core/bundled_docs/README_EN.md +67 -211
  15. package/core/bundled_docs/ai/01_AI_REFERENCE.md +11 -6
  16. package/core/bundled_docs/ai/02_AI_USAGE.md +1 -1
  17. package/core/bundled_docs/ai/03_AI_COMMANDS.md +1 -1
  18. package/core/bundled_docs/guides/01_USER_GUIDE.md +5 -5
  19. package/core/bundled_docs/guides/02_COMMANDS.md +3 -3
  20. package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +4 -4
  21. package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +4 -2
  22. package/core/bundled_docs/hosts/bugx_SKILL.md +2 -2
  23. package/core/bundled_docs/hosts/platform_bugx_SKILL.md +2 -2
  24. package/core/bundled_docs/manifest.json +22 -22
  25. package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +1 -0
  26. package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +1 -1
  27. package/core/cloud_sync/flywheel_client.py +89 -0
  28. package/core/contracts/README.md +1 -1
  29. package/core/contracts/bugx-runtime-contract.md +1 -1
  30. package/core/contracts/bugx-worker.md +1 -1
  31. package/core/coverage/coverage_ai_review.py +15 -11
  32. package/core/coverage/coverage_bootstrap.py +18 -13
  33. package/core/coverage/coverage_discovery.py +1 -1
  34. package/core/coverage/coverage_gate.py +12 -2
  35. package/core/coverage/coverage_manifest.py +1 -1
  36. package/core/coverage/coverage_validate.py +5 -3
  37. package/core/dev_harness/interaction_preset.py +1 -1
  38. package/core/engine-integrity.json +183 -163
  39. package/core/host_acp/README.md +4 -0
  40. package/core/host_acp/agnescode.py +128 -0
  41. package/core/host_runtime/README.md +3 -0
  42. package/core/host_runtime/adapters.py +45 -6
  43. package/core/host_runtime/autonomous_runner.py +3 -2
  44. package/core/host_runtime/host_registry.py +7 -1
  45. package/core/hosts/README.md +4 -0
  46. package/core/hosts/__init__.py +1 -0
  47. package/core/hosts/agnescode.py +415 -0
  48. package/core/hosts/base.py +1 -0
  49. package/core/hosts/claude.py +6 -0
  50. package/core/hosts/cline.py +6 -0
  51. package/core/hosts/codex.py +10 -1
  52. package/core/hosts/kimi.py +6 -4
  53. package/core/hosts/opencode.py +12 -4
  54. package/core/hosts/zcode.py +6 -0
  55. package/core/infra/README.md +1 -1
  56. package/core/infra/build_info.py +2 -2
  57. package/core/infra/python_runtime.py +4 -1
  58. package/core/launch_phases/README.md +2 -2
  59. package/core/launch_phases/finding_confirm_phase.py +1 -1
  60. package/core/launch_phases/semantic_recon.py +3 -19
  61. package/core/launch_phases/startup_gates.py +10 -1
  62. package/core/launch_phases/startup_version_gate.py +2 -2
  63. package/core/launch_phases/verify_loop.py +3 -19
  64. package/core/ledger/README.md +1 -1
  65. package/core/ledger/finding_confirmation.py +1 -1
  66. package/core/ledger/finding_verification.py +2 -20
  67. package/core/ledger/fp_ledger.py +3 -19
  68. package/core/ledger/life_ledger.py +7 -33
  69. package/core/ledger/schema.py +1 -1
  70. package/core/locales/en-US.json +2 -0
  71. package/core/locales/zh-CN.json +2 -0
  72. package/core/mcp_handlers/supervisor_handlers.py +34 -2
  73. package/core/mcp_handlers/telemetry_handlers.py +32 -0
  74. package/core/mcp_handlers/tool_table.py +34 -0
  75. package/core/mcp_runtime_support/common.py +6 -0
  76. package/core/mcp_runtime_support/environment.py +82 -23
  77. package/core/metadata.txt +1 -1
  78. package/core/planning/README.md +1 -1
  79. package/core/planning/target_sandbox_manager.py +2 -0
  80. package/core/probes/mobile_probe.py +1 -0
  81. package/core/probes/sast_probe.py +1 -1
  82. package/core/probes/sca_scanner.py +1 -1
  83. package/core/project_profiler/constants.py +1 -1
  84. package/core/retrieval/README.md +1 -1
  85. package/core/retrieval/symbol_index.py +229 -53
  86. package/core/retrieval/universal_code_matcher.py +1 -0
  87. package/core/runtime/README.md +1 -1
  88. package/core/runtime/daemon_runner.py +3 -2
  89. package/core/runtime/mining_quality_framework.py +2 -1
  90. package/core/runtime/project_init.py +1 -1
  91. package/core/runtime/scenario_eval.py +5 -2
  92. package/core/skills/bugx_mcp_server.py +9 -0
  93. package/core/skills/mcp_session_proof.py +3 -31
  94. package/core/supervisor/README.md +1 -1
  95. package/core/supervisor/finding_commit.py +3 -24
  96. package/core/supervisor/task_scheduler.py +5 -2
  97. package/core/supervisor/worker_execution.py +5 -0
  98. package/core/supervisor/worker_handoff.py +2 -2
  99. package/docs/07_distribution/01_README_NPM.md +89 -210
  100. package/ecosystem/integrations/dsh/mcp/package.json +2 -2
  101. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  102. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +3 -3
  103. package/ecosystem/integrations/opencode/mcp-lock.json +1 -1
  104. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  105. package/ecosystem/integrations/qoder/connector-meta.json +1 -1
  106. package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
  107. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
  108. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
  109. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
  110. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
  111. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
  112. package/interfaces/cli/bugx_cli/__init__.py +1 -1
  113. package/interfaces/cli/bugx_cli/cli.py +15 -0
  114. package/interfaces/cli/bugx_cli/commands/agent.py +18 -0
  115. package/interfaces/cli/bugx_cli/commands/audit.py +5 -6
  116. package/interfaces/cli/bugx_cli/commands/doctor.py +1 -1
  117. package/interfaces/cli/bugx_cli/commands/lifecycle.py +1 -1
  118. package/interfaces/cli/bugx_cli/commands/patch.py +5 -1
  119. package/interfaces/cli/bugx_cli/commands/plugin.py +31 -2
  120. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +2 -2
  121. package/interfaces/cli/bugx_cli/host_adapters.py +167 -1
  122. package/interfaces/cli/bugx_cli/hosts/registry.py +33 -1
  123. package/interfaces/cli/bugx_cli/infra/engine_installer.py +4 -4
  124. package/interfaces/cli/bugx_cli/infra/host_sync.py +1 -1
  125. package/package.json +1 -1
  126. package/scripts/sync-version.mjs +1 -1
  127. package/skills/platform/bugx/SKILL.md +2 -2
@@ -1,38 +1,38 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "contract_version": "0.1.4",
3
+ "contract_version": "0.1.6",
4
4
  "file_count": 22,
5
- "total_bytes": 485544,
5
+ "total_bytes": 457959,
6
6
  "files": [
7
7
  {
8
8
  "path": "OVERVIEW.md",
9
9
  "source": "README.md",
10
- "bytes": 23985,
11
- "sha256": "d454b2a01346bb88b08bdcf119919ee042861684ea4a80ee12ae902a1c58e045"
10
+ "bytes": 7511,
11
+ "sha256": "8a272498e1a5c41da161a865a81d1458e76cf845f1a5a21392a758bc38a7ace4"
12
12
  },
13
13
  {
14
14
  "path": "README_EN.md",
15
15
  "source": "README_EN.md",
16
- "bytes": 19675,
17
- "sha256": "badb439d333a4d2ab501e8a27af07fa852831b4bb9a215b29d09134f5b5ff2e1"
16
+ "bytes": 6978,
17
+ "sha256": "e529ac3f5566f138ce58b494ab07a716a05fefaff47c6f0fccdfe9bcd3842a63"
18
18
  },
19
19
  {
20
20
  "path": "reference/01_ENVIRONMENT_VARIABLES.md",
21
21
  "source": "docs/04_reference/01_ENVIRONMENT_VARIABLES.md",
22
- "bytes": 41736,
23
- "sha256": "6ff8979e950e8a53a5f59b4e371454a64831424a5025815d1af0ea658bdc95ec"
22
+ "bytes": 41844,
23
+ "sha256": "9b73afb3796c7b94e6ead62c7709ba498925fa9b3a70738ab3077a97236b4692"
24
24
  },
25
25
  {
26
26
  "path": "reference/04_REPOSITORY_TOPOLOGY.md",
27
27
  "source": "docs/02_architecture/04_REPOSITORY_TOPOLOGY.md",
28
28
  "bytes": 13055,
29
- "sha256": "898dde0828e6fcf9b7e86fe903ccdac33e41b5e3acda65faadfc8439b1e39626"
29
+ "sha256": "30ef807e28f9b488503425192f4ff19c2854467be0e62760d26bdfcb5cee5a4a"
30
30
  },
31
31
  {
32
32
  "path": "hosts/platform_bugx_SKILL.md",
33
33
  "source": "skills/platform/bugx/SKILL.md",
34
34
  "bytes": 3941,
35
- "sha256": "e9eca96de0c7fb0064fe6f7d5b151280885570d224d15c8111c3ec618fe0e31d"
35
+ "sha256": "655783b82196921de4f36e4ef07755ec5535cefb0f5fc26cffad8adb38147ba1"
36
36
  },
37
37
  {
38
38
  "path": "hosts/cline_bugx_SKILL.md",
@@ -43,20 +43,20 @@
43
43
  {
44
44
  "path": "guides/01_USER_GUIDE.md",
45
45
  "source": "docs/01_guides/01_USER_GUIDE.md",
46
- "bytes": 64792,
47
- "sha256": "9634550063c38c7ed7c13bb5cd86c937c4f45ecd8a0c214e3fc486260f275930"
46
+ "bytes": 64848,
47
+ "sha256": "2d860f682c10d09124238027581b7fafdaa16fc06c3e63daf15e9c0c9e828323"
48
48
  },
49
49
  {
50
50
  "path": "guides/02_COMMANDS.md",
51
51
  "source": "docs/01_guides/02_COMMANDS.md",
52
- "bytes": 59226,
53
- "sha256": "992433ffba270456dcdf04e29f3ec4aff7d3e50b1b7607f91e52f7bd4101eedb"
52
+ "bytes": 59296,
53
+ "sha256": "3c4bf27fe28465c5b8bd7eabb129ca6e7ee21649711fdc010722a9b679e424f1"
54
54
  },
55
55
  {
56
56
  "path": "guides/03_TROUBLESHOOTING.md",
57
57
  "source": "docs/01_guides/03_TROUBLESHOOTING.md",
58
- "bytes": 39091,
59
- "sha256": "dbb8028dc98ba692234d78cbabc9a6551c630d5e61ac9b31a8b7d1b0546b0a8e"
58
+ "bytes": 39154,
59
+ "sha256": "0a763dc6acf173232df1493b5d53ff5ec471916fab38a3b29e6d46275449b614"
60
60
  },
61
61
  {
62
62
  "path": "guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md",
@@ -67,8 +67,8 @@
67
67
  {
68
68
  "path": "guides/05_HOST_MATRIX_AND_DISPATCH.md",
69
69
  "source": "docs/01_guides/05_HOST_MATRIX_AND_DISPATCH.md",
70
- "bytes": 3358,
71
- "sha256": "0b5fe0c21168cff3d855d02f5be59743c4a88299c04642ed588da01eafd9e177"
70
+ "bytes": 3833,
71
+ "sha256": "ae860f14b19dd9cb69e2a27966c2a78449dc94c7efeb675a11ad585fb0bad8ae"
72
72
  },
73
73
  {
74
74
  "path": "guides/06_PROBES_AND_POC_COOKBOOK.md",
@@ -91,20 +91,20 @@
91
91
  {
92
92
  "path": "ai/01_AI_REFERENCE.md",
93
93
  "source": "docs/03_ai/01_AI_REFERENCE.md",
94
- "bytes": 57296,
95
- "sha256": "47b3e2d7807e208b588a130409e8ca7d10bd78d6e5cd1e20c68ffe56b915af8c"
94
+ "bytes": 58110,
95
+ "sha256": "77041b3fb6e04938199ee2596ef045806da45f860d2a4ef7f24b3cd636eb4a1a"
96
96
  },
97
97
  {
98
98
  "path": "ai/02_AI_USAGE.md",
99
99
  "source": "docs/03_ai/02_AI_USAGE.md",
100
100
  "bytes": 13575,
101
- "sha256": "f0c318720f6fc49ad58d4390878af44d424ecdb8cfca3a68f9b2c55bf2171da1"
101
+ "sha256": "d1255ced21937e92133b0a64f5cc858a93332c9e5e57be6d717808aae3b002ce"
102
102
  },
103
103
  {
104
104
  "path": "ai/03_AI_COMMANDS.md",
105
105
  "source": "docs/03_ai/03_AI_COMMANDS.md",
106
106
  "bytes": 46169,
107
- "sha256": "27578198252a6a3f3a39c0fc1f9716e1b927a1fb67fdde09dd86a27d3f8bb650"
107
+ "sha256": "c50a0c9690bb46e80daa56e511ea4d1b7d5f37f3b27a8c57822c0a1071159797"
108
108
  },
109
109
  {
110
110
  "path": "hosts/bugx_SKILL.md",
@@ -297,6 +297,7 @@ bugx update --check --root /path/to/project
297
297
  | `BUGX_CLAUDE_USER_AGENTS_DIR` | 绝对路径 | 覆盖 Claude Desktop/Code 用户级 agents 目录探测位置 | `无默认(None/空)` | `interfaces/cli/bugx_cli/commands/plugin_claude.py` |
298
298
  | `BUGX_CLAUDE_USER_SKILLS_DIR` | 绝对路径 | 覆盖 Claude 用户级 skills 目录探测位置 | `无默认(None/空)` | `interfaces/cli/bugx_cli/commands/plugin_claude.py` |
299
299
  | `BUGX_CLINE_USER_AGENTS_DIR` | 绝对路径 | 覆盖 Cline 用户级 agents 目录探测位置 | `无默认(None/空)` | `interfaces/cli/bugx_cli/commands/plugin_cline.py` |
300
+ | `BUGX_AGNESCODE_MODEL` | provider/model | Agnes Code 子进程模型 | `""` | `core/hosts/agnescode.py` |
300
301
  | `BUGX_CODEX_CONFIG` | 绝对路径 | 覆盖 Codex config.toml 探测位置 | `无默认(None/空)` | `interfaces/cli/bugx_cli/commands/plugin.py` |
301
302
  | `BUGX_FUNIDE_DATA_DIR` | 绝对路径 | 覆盖 FunIDE 数据目录 | `无默认(None/空)` | `interfaces/cli/bugx_cli/host_adapters.py` |
302
303
  | `BUGX_FUNIDE_PROFILE_DIR` | 绝对路径 | 覆盖 FunIDE profile 目录 | `无默认(None/空)` | `interfaces/cli/bugx_cli/host_adapters.py` |
@@ -1,6 +1,6 @@
1
1
  # 全域全景架构与权威目录拓扑 (System Architecture & Repository Topology)
2
2
 
3
- > **文档编号**: `DOC-TOPOLOGY` | **基线版本**: `0.1.4` | **更新日期**: 2026-11-25
3
+ > **文档编号**: `DOC-TOPOLOGY` | **基线版本**: `0.1.6` | **更新日期**: 2026-11-26
4
4
  > **文档定位**: Diátaxis - Explanation (工程拓扑、架构正交性与目录层级权威白皮书)
5
5
  > **关联规范**: ``docs/02_architecture/01_ARCHITECTURE.md`` (`docs/02_architecture/01_ARCHITECTURE.md`) (系统高层架构设计), ``docs/02_architecture/02_DESIGN_SPEC.md`` (`docs/02_architecture/02_DESIGN_SPEC.md`) (设计规约总账), ``AGENTS.md`` (`AGENTS.md`) (工程开发宪法)
6
6
 
@@ -572,6 +572,64 @@ class FlywheelUploader:
572
572
  payload["dpo_preference"] = dpo_pair.as_dict() if isinstance(dpo_pair, DPOPreferencePair) else dict(dpo_pair)
573
573
  return self.enqueue(payload, tier=quality)
574
574
 
575
+ def enqueue_review(
576
+ self,
577
+ review_summary: Mapping[str, Any],
578
+ *,
579
+ static_topology: Iterable[Any] | None = None,
580
+ quality: str | int = "tier-2",
581
+ metrics: Mapping[str, Any] | None = None,
582
+ event_type: str = "code_review",
583
+ ) -> int | None:
584
+ """Queue a lightweight code review or probe telemetry event."""
585
+ topology = list(static_topology or [])
586
+ clean_summary = dict(review_summary)
587
+ clean_metrics = dict(metrics or {})
588
+ normalized_event = str(event_type or "code_review").strip().lower()
589
+ payload: dict[str, Any] = {
590
+ "schema_version": 1,
591
+ "event_type": normalized_event,
592
+ "quality_tier": quality_tier_name(quality),
593
+ "topology_hash": merkle_root(topology),
594
+ "review_summary": clean_summary,
595
+ "metrics": clean_metrics,
596
+ }
597
+ return self.enqueue(payload, tier=quality)
598
+
599
+ def record_and_flush(
600
+ self,
601
+ review_summary: Mapping[str, Any],
602
+ *,
603
+ static_topology: Iterable[Any] | None = None,
604
+ quality: str | int = "tier-2",
605
+ metrics: Mapping[str, Any] | None = None,
606
+ event_type: str = "code_review",
607
+ flush: bool = True,
608
+ ) -> dict[str, Any]:
609
+ """Record a telemetry event and attempt immediate non-blocking flush."""
610
+ record_id = self.enqueue_review(
611
+ review_summary,
612
+ static_topology=static_topology,
613
+ quality=quality,
614
+ metrics=metrics,
615
+ event_type=event_type,
616
+ )
617
+ if record_id is None:
618
+ return {"enabled": False, "status": "disabled", "sent": 0}
619
+ sent = 0
620
+ if flush:
621
+ try:
622
+ res = self.flush(limit=20, batch_size=20)
623
+ sent = int(res.get("sent", 0)) if isinstance(res, dict) else 0
624
+ except Exception:
625
+ pass
626
+ return {
627
+ "enabled": True,
628
+ "status": "sent" if sent > 0 else "queued",
629
+ "record_id": record_id,
630
+ "sent": sent,
631
+ }
632
+
575
633
  def enqueue_installation(self, event: str = "heartbeat") -> int | None:
576
634
  """Queue an install/heartbeat identity event in the existing outbox.
577
635
 
@@ -890,6 +948,36 @@ def maybe_report_installation(*, force: bool = False) -> dict[str, Any]:
890
948
  return {"enabled": True, "status": "error", "error": str(exc), "sent": 0}
891
949
 
892
950
 
951
+ def record_review_telemetry(
952
+ review_summary: Mapping[str, Any],
953
+ *,
954
+ static_topology: Iterable[Any] | None = None,
955
+ quality: str | int = "tier-2",
956
+ metrics: Mapping[str, Any] | None = None,
957
+ event_type: str = "code_review",
958
+ flush: bool = True,
959
+ ) -> dict[str, Any]:
960
+ """Convenience helper to record lightweight review telemetry and optionally flush."""
961
+ try:
962
+ from core.cloud_sync.consent import telemetry_enabled
963
+
964
+ if not telemetry_enabled():
965
+ return {"enabled": False, "status": "disabled", "sent": 0}
966
+ with FlywheelUploader() as uploader:
967
+ if not uploader.data_sharing:
968
+ return {"enabled": False, "status": "disabled", "sent": 0}
969
+ return uploader.record_and_flush(
970
+ review_summary=review_summary,
971
+ static_topology=static_topology,
972
+ quality=quality,
973
+ metrics=metrics,
974
+ event_type=event_type,
975
+ flush=flush,
976
+ )
977
+ except Exception as exc: # noqa: BLE001 - telemetry must fail closed and quiet
978
+ return {"enabled": False, "status": "error", "error": str(exc), "sent": 0}
979
+
980
+
893
981
  def _encrypt(data: bytes, passphrase: str) -> bytes:
894
982
  try:
895
983
  from cryptography.hazmat.primitives.ciphers.aead import AESGCM
@@ -928,4 +1016,5 @@ __all__ = [
928
1016
  "MAX_AUDIT_BYTES", "MAX_OUTBOX_BYTES", "MAX_OUTBOX_RECORDS", "OutboxFullError",
929
1017
  "build_dpo_preference_pair", "default_audit_path", "default_outbox_path",
930
1018
  "maybe_report_installation", "merkle_root", "quality_tier", "quality_tier_name",
1019
+ "record_review_telemetry",
931
1020
  ]
@@ -1,6 +1,6 @@
1
1
  # BugX 智能体执行协议与交互契约子系统 (Agent Runtime Contracts & Protocols)
2
2
 
3
- > **版本契约**: `0.1.4` | **父系统**: `core/`
3
+ > **版本契约**: `0.1.6` | **父系统**: `core/`
4
4
  > **工程规范**: 参见 [`docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md`](../../docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md) 与 [`docs/02_architecture/06_MODULE_GOVERNANCE_SPEC.md`](../../docs/02_architecture/06_MODULE_GOVERNANCE_SPEC.md)
5
5
  > **守卫机制**: `scripts/verify_directory_indices.py` (100% 索引对齐防漂移)
6
6
 
@@ -1,4 +1,4 @@
1
- # BugX 运行时契约(0.1.4)
1
+ # BugX 运行时契约(0.1.6)
2
2
 
3
3
  这是部署到用户级全局引擎 `~/.bugx/core/` 的最小运行时契约。项目不再保存
4
4
  `.bugx/core` 可执行入口;需要定位本文件时使用 `bugx engine path --name bugx-runtime-contract.md`。
@@ -1,5 +1,5 @@
1
1
  ---
2
- # bugx_version: 0.1.4
2
+ # bugx_version: 0.1.6
3
3
  description: BugX 并发 worker。负责 Supervisor 分配的覆盖单元或亲和任务包(最多 5 单元):领取租约 → 确认真实启动 → 挖掘举证 → 提交 checkpoint。不写寿命、不结算、不生成最终报告。
4
4
  mode: subagent
5
5
  permissions:
@@ -1,14 +1,18 @@
1
- """AI 覆盖复核机制(DOC-AIREV):覆盖清单污染由宿主 AI 逐目录排查定案。
2
-
3
- 设计约束(2026-11-04 复盘固化,替代"白名单简单排除"):
4
-
5
- - 引擎只做确定性枚举与证据打包;"这个目录是不是产品代码"的判定权属于
6
- 宿主 AI(复核包内含内容摘录与 import 可达性信号,AI 必须基于证据判定)。
7
- - AI 裁决只能**移出**单元(排除),不能添加——发现层的确定性下限不被
8
- AI 放大;裁决持久化到 ``.bugx/knowledge/coverage-review.json``,带
9
- 裁决理由/时间/裁决者/证据包摘要,可审计可回滚(重审覆盖即可推翻)。
10
- - 硬排除(依赖/生成物/引擎自产物)保持确定性,不经 AI。
11
- - 换项目零迁移:候选组按当次发现结果动态生成,不携带任何项目名清单。
1
+ """AI 覆盖复核机制(DOC-AIREV):双轨目录排除架构——静态白名单打底 + AI 语义复核扫尾。
2
+
3
+ 设计约束(双轨互补契约):
4
+
5
+ 1. **Track 1(静态确定性白名单/基线)**:由引擎在文件系统遍历层自动硬排除公认的
6
+ 依赖、生成物、工具链与运行态目录(如 ``.git``、``node_modules``、``dist``、
7
+ ``build``、``.tools``、``artifacts`` 等),防止超大非源码目录在第一阶段拖死进程。
8
+ 2. **Track 2(AI 语义全量扫尾复核)**:静态白名单绝非万能——针对白名单放行的
9
+ **所有剩余顶层目录**,引擎打包结构特征、文件摘录与 import 可达性证据
10
+ (``candidate_groups``),由宿主 AI 逐一过一遍并做出 ``product`` / ``exclude``
11
+ 语义裁决,清洗自定义构建物、私有脚本库与非产品夹具。
12
+ 3. **单向权威与持久化**:AI 裁决只能**移出**单元(``exclude``),不能添加;
13
+ 裁决持久化到 ``.bugx/knowledge/coverage-review.json``,带裁决理由/时间/
14
+ 裁决者/证据包摘要,可审计可回滚(重审覆盖即可推翻)。
15
+ 4. **换项目零迁移**:候选组按当次发现结果动态生成,不携带任何项目名清单。
12
16
  """
13
17
 
14
18
  from __future__ import annotations
@@ -492,7 +492,7 @@ def write_inventory_diff(manifest: Path, changes: dict) -> None:
492
492
 
493
493
  def bootstrap(
494
494
  root: Path, *, confirmed: bool = False, inherit_coverage: bool = True,
495
- reconcile: bool = False,
495
+ reconcile: bool = False, symbols: bool = True,
496
496
  ) -> dict[str, object]:
497
497
  """Create the manifest after an explicit host/user confirmation.
498
498
 
@@ -616,7 +616,7 @@ def bootstrap(
616
616
  }
617
617
 
618
618
  try:
619
- discovered = module_coverage.discovery_rows(root)
619
+ discovered = module_coverage.discovery_rows(root, symbols=symbols)
620
620
  except (OSError, UnicodeError, ValueError, RuntimeError) as exc:
621
621
  strict_detail = str(exc)
622
622
  if not _is_partial_parse_failure(exc):
@@ -686,18 +686,23 @@ def bootstrap(
686
686
  discovered,
687
687
  historical_unit_verdicts(root, exclude_polling=current_polling),
688
688
  )
689
- discovery = build_discovery_metadata(status="complete", mode="symbols")
689
+ discovery = (
690
+ build_discovery_metadata(status="complete", mode="symbols")
691
+ if symbols
692
+ else build_discovery_metadata(status="complete", mode="files", confidence="medium")
693
+ )
690
694
  write_manifest(manifest, discovered, discovery_metadata=discovery)
691
- try:
692
- rows, _ = module_coverage.parse_manifest(manifest)
693
- if not any(r.phase == "业务" for r in rows):
694
- business_lines = module_coverage.business_discovery_rows(root, rows)
695
- if business_lines:
696
- with open(manifest, "a", encoding="utf-8") as f:
697
- for bl in business_lines:
698
- f.write(bl + "\n")
699
- except Exception:
700
- pass
695
+ if symbols:
696
+ try:
697
+ rows, _ = module_coverage.parse_manifest(manifest)
698
+ if not any(r.phase == "业务" for r in rows):
699
+ business_lines = module_coverage.business_discovery_rows(root, rows)
700
+ if business_lines:
701
+ with open(manifest, "a", encoding="utf-8") as f:
702
+ for bl in business_lines:
703
+ f.write(bl + "\n")
704
+ except Exception:
705
+ pass
701
706
  rows, _ = module_coverage.parse_manifest(manifest)
702
707
  return {
703
708
  "ready": True,
@@ -929,7 +929,7 @@ def discovery_row(number: str, unit: dict, *, reset: bool = True,
929
929
  note += f" platform:{unit_platform_name}"
930
930
  difficulty = "3"
931
931
  calc_risk: float | None = None
932
- if root is not None:
932
+ if root is not None and unit.get("parser") != "files-only":
933
933
  try:
934
934
  operation_cache = risk_cache if risk_cache is not None else {}
935
935
  calc_risk = cached_unit_risk_score(file_path, root, digest, operation_cache)
@@ -218,7 +218,11 @@ def manifest_gate_errors(path: Path) -> list[str]:
218
218
 
219
219
 
220
220
  def startup_gate_errors(
221
- root: Path, manifest: Path, *, allow_business_partial: bool = False,
221
+ root: Path,
222
+ manifest: Path,
223
+ *,
224
+ allow_business_partial: bool = False,
225
+ explicit_scope: bool = False,
222
226
  ) -> list[str]:
223
227
  """Return strict errors for the automatic Supervisor start gate.
224
228
 
@@ -247,10 +251,16 @@ def startup_gate_errors(
247
251
  if not rows:
248
252
  return errors + ["清单漏列全部最小单元"]
249
253
  discovery_mode = manifest_discovery_mode(manifest)
254
+ is_explicit = (
255
+ explicit_scope
256
+ or (discovery_mode in ("explicit", "scoped", "partial"))
257
+ or bool(os.environ.get("BUGX_COVERAGE_MANIFEST"))
258
+ )
250
259
  errors.extend(validate_rows(
251
260
  rows, root, require_symbols=True, require_graph=True,
252
261
  require_plan_fields=False, discovery_mode=discovery_mode,
253
- allow_business_partial=allow_business_partial, context=ctx,
262
+ allow_business_partial=allow_business_partial,
263
+ explicit_scope=is_explicit, context=ctx,
254
264
  ))
255
265
  return list(dict.fromkeys(errors))
256
266
 
@@ -132,7 +132,7 @@ MANIFEST = AGENT_DIR / "module-coverage.md"
132
132
  SOURCE_EXTS = {
133
133
  ".py", ".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx", ".java", ".kt", ".kts", ".go",
134
134
  ".rs", ".swift", ".c", ".h", ".cc", ".cpp", ".cxx", ".cs", ".rb",
135
- ".php", ".vue", ".svelte",
135
+ ".php", ".vue", ".svelte", ".dart",
136
136
  }
137
137
  EVIDENCE_EXTS = SOURCE_EXTS | symbol_index.AUDIT_ASSET_EXTS | {
138
138
  ".json", ".yaml", ".yml", ".toml", ".xml", ".html", ".md",
@@ -85,7 +85,8 @@ def validate_rows(rows: list[ModuleRow], root: Path = REPO_ROOT,
85
85
  discovery_mode: str | None = None,
86
86
  require_plan_fields: bool = True,
87
87
  allow_business_partial: bool = False,
88
- context: PassContext | None = None) -> list[str]:
88
+ context: PassContext | None = None,
89
+ explicit_scope: bool = False) -> list[str]:
89
90
  # 同一轮校验共享一个上下文:证据文件事实与全仓枚举结果只计算一次。
90
91
  ctx = context if context is not None else PassContext(root)
91
92
  errors: list[str] = []
@@ -141,7 +142,7 @@ def validate_rows(rows: list[ModuleRow], root: Path = REPO_ROOT,
141
142
  errors.append(f"源码枚举不完整,不能判定全覆盖: {exc}")
142
143
  discovered = set()
143
144
  omitted = sorted(p for p in discovered if p not in listed)
144
- if omitted:
145
+ if omitted and not explicit_scope:
145
146
  errors.append("最小单元清单漏列源码或行为资产: " + ", ".join(omitted))
146
147
  # A parser-partial manifest is an explicit, persisted file-level fallback.
147
148
  # It remains schedulable and honest, but cannot be forced back through the
@@ -163,7 +164,7 @@ def validate_rows(rows: list[ModuleRow], root: Path = REPO_ROOT,
163
164
  if row.phase == "内部"
164
165
  }
165
166
  omitted_scopes = sorted(required_scopes - listed_scopes)
166
- if omitted_scopes:
167
+ if omitted_scopes and not explicit_scope:
167
168
  errors.append("符号级最小单元漏列: " + ", ".join(omitted_scopes))
168
169
  known_scopes = {
169
170
  unit["scope"] for unit in units
@@ -175,6 +176,7 @@ def validate_rows(rows: list[ModuleRow], root: Path = REPO_ROOT,
175
176
  if unknown_scopes:
176
177
  errors.append("清单引用不存在的源码符号: " + ", ".join(unknown_scopes))
177
178
 
179
+ flows: list[Any] = []
178
180
  if require_graph and not partial_files:
179
181
  discovery = ctx.business(rows)
180
182
  if not discovery["complete"]:
@@ -58,7 +58,7 @@ def _read_preset_raw_payload(root: Path | None = None) -> dict[str, Any]:
58
58
 
59
59
  try:
60
60
  st = preset_file.stat()
61
- if bool(st.st_mode & 0o002): # world-writable 防御
61
+ if os.name == "posix" and bool(st.st_mode & 0o002): # world-writable 防御
62
62
  return {}
63
63
 
64
64
  payload = json.loads(preset_file.read_text(encoding="utf-8"))