Repository navigation
接通 Rust 默认生命周期、固定原生复检入口与 32-grammar 运行时候选 #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7bfb07a
feat: expose pinned 32-grammar Rust runtime candidate
loong10k 5ef4ea6
合并远端名称与 MCP 更新并保留 Rust 候选发布版本
loong10k dec5f9d
接通 Rust 默认生命周期和固定原生复检入口,准备 0.20.0 发布
loong10k 79af622
修复运行时恢复指引不可执行与损坏缓存无法自查
loong10k 0130198
同步镜像副本并转义含空格的恢复命令路径
loong10k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,32 +10,43 @@ | |
|
|
||
| CodeGuard provides native check evidence and guards supported Git commit/push calls from AI coding assistants. PostToolUse gives feedback, not blocking. Verified violations block the Git call; unavailable checks remain explicitly UNVERIFIED. Passing a configured check is not proof of complete code correctness. | ||
|
|
||
| ### Rust runtime candidate (macOS arm64) | ||
| ### Rust lifecycle runtime (macOS arm64) | ||
|
|
||
| The plugin now contains a **candidate**, explicit Rust runtime binding. It pins `@partme.ai/[email protected]`, its registry tarball and native binary hashes, candidate source commit, platform, and check protocol major in [`runtime/codeguard.lock.json`](runtime/codeguard.lock.json). Install only on Apple Silicon macOS: | ||
| Canonical [`hooks/hooks.json`](hooks/hooks.json) now routes SessionStart, UserPromptSubmit, PostToolUse, PostToolUseFailure and Stop through [`hooks/rust_runtime_dispatch.cjs`](hooks/rust_runtime_dispatch.cjs) to fixed `@partme.ai/[email protected]`. [`runtime/codeguard.lock.json`](runtime/codeguard.lock.json) pins the public tarball, binary, source commit and 32 grammar-license hashes. Node 18+ is the thin host binding; Rust performs discovery, native checks, WASM parsing and task synchronization. | ||
|
|
||
| Install explicitly on Apple Silicon macOS, then initialize the selected project: | ||
|
|
||
| ```bash | ||
| node runtime/codeguard_runtime.cjs install --download | ||
| node runtime/codeguard_runtime.cjs verify | ||
| node runtime/codeguard_runtime.cjs exec init /absolute/project --apply --format=json | ||
| node runtime/codeguard_runtime.cjs exec next /absolute/project --format=json | ||
| node runtime/codeguard_runtime.cjs exec grammar status --format=json | ||
| node runtime/codeguard_runtime.cjs exec check all /absolute/project --format=json | ||
| # Use the real ID returned by next: | ||
| node runtime/codeguard_runtime.cjs exec task show TASK_ID /absolute/project --format=json | ||
| node runtime/codeguard_runtime.cjs exec task verify TASK_ID /absolute/project --zig-tool /absolute/zig --format=json | ||
| ``` | ||
|
|
||
| For offline installation, use `install --tarball /absolute/path/to/partme.ai-codeguard-0.1.2.tgz`; the same lock hashes are enforced. Installation stages and verifies the package before switching the active receipt. [`hooks/rust_runtime_dispatch.cjs`](hooks/rust_runtime_dispatch.cjs) is a candidate Claude Code adapter for SessionStart, UserPromptSubmit, PostToolUse, PostToolUseFailure, and Stop. It rechecks the active binary before each call, never selects a random `codeguard` on `PATH`, and reports an incomplete runtime instead of falling back to Python. UserPromptSubmit returns fixed, non-blocking timing guidance; it does not run lint or treat prompt words as a Git gate. The current [`hooks/hooks.json`](hooks/hooks.json) still uses the legacy Python hooks; the Rust candidate has not been made the default, connected to a strict Git gate, or accepted on Codex/ZCode/Kimi. See the [candidate acceptance record](tests/rust-runtime-candidate.md) and [hook protocol](hooks/__protocol__.md). | ||
| Offline installation uses `install --tarball /absolute/path/to/codeguard-public-0.1.4-darwin-arm64.tgz` with the same digest checks. Hooks do not download packages. An unavailable or unsupported runtime returns visible incomplete/setup guidance, without PATH codeguard or Python fallback. Successful edits select only the changed file: supported native Ruff/ESLint checks precede bounded WASM; suspected syntax creates a stable native-confirmation task in an initialized workspace. Zero recovery nodes only recommend native checking and never close an old task. The program contains all 32 runnable but **unqualified** grammar candidates, including Dart and Zig. | ||
|
|
||
| Prompt events only give fixed timing guidance, failed edits do not scan source, and Stop gives bounded next-task guidance with reentry handling. Internal check budget is 5 seconds, child-process timeout 8 seconds, host timeout 10 seconds. This does not certify all filesystem I/O deadlines or installed-host latency. `auto_fix_on_save` and legacy timeout settings remain compatibility fields; Rust does not silently apply fixes. An uninitialized workspace needs explicit init before durable tasks exist. | ||
|
|
||
| The installed plugin version is recorded in its manifests. The architecture refactor keeps the existing 68 managed skills and focuses on reliable evidence, clear module ownership and Java project awareness. | ||
| The PreToolUse Git gate and legacy CLI/MCP remain Python compatibility surfaces; Copilot/OpenHands carry identical mirrors of the lifecycle binding for package consistency. Those mirrors are not installed-host acceptance. Installed Claude/Codex/ZCode/Kimi automation, trusted closure policy, full native-first coverage, other platforms and precision remain open. See [default lifecycle acceptance](tests/rust-lifecycle-default.md), [historical candidate evidence](tests/rust-runtime-candidate.md), [historical 32-grammar acceptance](tests/rust-wasm-runtime-candidate.md), and [hook protocol](hooks/__protocol__.md). | ||
|
|
||
| ### Runtime boundaries | ||
|
|
||
| | Surface | What it checks | Result | | ||
| |---|---|---| | ||
| | PostToolUse | Edited file, for file-scoped tools | Feedback, exit 0; project-level checks deferred | | ||
| | UserPromptSubmit | Working-tree changes relevant to commit intent | Advisory, never blocks the user message | | ||
| | UserPromptSubmit | Fixed checking-time guidance; no source scan | Advisory, never blocks the user message | | ||
| | PreToolUse Git gate | Proposed index snapshot or HEAD snapshot for push | Verified violations exit 2; uncertain checks report UNVERIFIED and fail open | | ||
| | CLI check / MCP check_code_style | Project checks, including Java build verification | Explicit status, reason, raw exit code, ordered execution trace and output log | | ||
| | pre-commit / CI | Independently configured checks | Separate acceptance; not replaced by hook success | | ||
|
|
||
| Hooks do not run in every host command surface automatically. Historical V0.5.4 installation evidence is not acceptance of this version in Codex, ZCode or Kimi. | ||
|
|
||
| Claude Code does not support a matcher on `UserPromptSubmit`: it starts the legacy Python Hook for every submitted prompt. The Hook returns before environment or repository work when its own intent filter does not match. A commit-intent prompt may still run the legacy soft check; only the actual Git command reaches the PreToolUse gate. The manifest cannot avoid per-prompt process startup, and installed-host latency has not been measured. | ||
| Claude Code invokes the canonical Rust prompt binding on every UserPromptSubmit; no keyword matcher or prompt-triggered lint is used. Copilot/OpenHands carry the same mirror; their actual host protocol compatibility still needs separate acceptance. Actual Git commands still reach PreToolUse. Installed-host latency has not been measured. | ||
|
|
||
| ### Verdict contract | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,32 +10,43 @@ | |
|
|
||
| CodeGuard 为 AI 编程助手提供原生检查证据,守护已支持的 Git 提交/推送调用。PostToolUse 只反馈、不阻断;确定违规会拦截 Git 调用;检查无法完成时明确 UNVERIFIED。某项检查通过,不等于代码完全正确。 | ||
|
|
||
| ### Rust 运行时候选(macOS arm64) | ||
| ### Rust 生命周期运行时(macOS arm64) | ||
|
|
||
| 插件新增**显式候选** Rust 运行时绑定。[`runtime/codeguard.lock.json`](runtime/codeguard.lock.json) 固定 `@partme.ai/[email protected]`、注册表 tarball 和原生二进制摘要、候选源码提交、平台及检查协议主版本。仅在 Apple Silicon macOS 上安装: | ||
| Canonical [`hooks/hooks.json`](hooks/hooks.json) 现将 SessionStart、UserPromptSubmit、PostToolUse、PostToolUseFailure、Stop 经 [`hooks/rust_runtime_dispatch.cjs`](hooks/rust_runtime_dispatch.cjs) 接到固定 `@partme.ai/[email protected]`。[`runtime/codeguard.lock.json`](runtime/codeguard.lock.json) 锁定公开 tarball、程序、源码提交和 32 份 grammar 许可证摘要。Node 18+ 仅绑定宿主;发现、原生检查、WASM 解析和任务同步由 Rust 执行。 | ||
|
|
||
| 在 Apple Silicon macOS 上显式安装,再初始化指定项目: | ||
|
|
||
| ```bash | ||
| node runtime/codeguard_runtime.cjs install --download | ||
| node runtime/codeguard_runtime.cjs verify | ||
| node runtime/codeguard_runtime.cjs exec init /absolute/project --apply --format=json | ||
| node runtime/codeguard_runtime.cjs exec next /absolute/project --format=json | ||
| node runtime/codeguard_runtime.cjs exec grammar status --format=json | ||
| node runtime/codeguard_runtime.cjs exec check all /absolute/project --format=json | ||
| # TASK_ID 使用 next 返回的真实 ID: | ||
| node runtime/codeguard_runtime.cjs exec task show TASK_ID /absolute/project --format=json | ||
| node runtime/codeguard_runtime.cjs exec task verify TASK_ID /absolute/project --zig-tool /absolute/zig --format=json | ||
| ``` | ||
|
|
||
| 离线安装可执行 `install --tarball /absolute/path/to/partme.ai-codeguard-0.1.2.tgz`,仍须满足同一锁定摘要。安装器先在暂存目录核验包,再切换活动收据。[`hooks/rust_runtime_dispatch.cjs`](hooks/rust_runtime_dispatch.cjs) 是 Claude Code 的 SessionStart、UserPromptSubmit、PostToolUse、PostToolUseFailure、Stop 候选适配器;每次调用前复核活动二进制,不从 PATH 随机选择 `codeguard`,缺运行时时报告未完成而不回退 Python。UserPromptSubmit 仅返回固定、非阻断的检查时机建议,不运行 lint,也不把提示词当作 Git 门禁。当前 [`hooks/hooks.json`](hooks/hooks.json) 仍使用旧 Python 钩子;Rust 候选尚未成为默认入口,未接严格 Git 门禁,也未在 Codex/ZCode/Kimi 完成宿主验收。见[候选验收记录](tests/rust-runtime-candidate.md)和[钩子协议](hooks/__protocol__.md)。 | ||
| 离线安装使用 `install --tarball /absolute/path/to/codeguard-public-0.1.4-darwin-arm64.tgz`,仍核对相同摘要。普通 Hook 不下载包;运行时缺失或平台不支持时给出明确未完成与准备指引,不执行 PATH codeguard,不回退 Python。成功保存仅检查本次文件:已接入的 Ruff/ESLint 原生检查优先,再对未覆盖文件执行有界 WASM;疑似语法问题在已初始化工作区形成稳定原生确认任务。零恢复仅推荐原生检查,不能关闭旧任务。包内全部 32 份 grammar 可执行但**未完成精度验收**,包含 Dart、Zig。 | ||
|
|
||
| 提示事件只给固定时机指引,失败保存不扫描,Stop 提供有界 next 指引并处理重入。内部检查预算 5 秒、子进程超时 8 秒、宿主超时 10 秒;不表示所有文件系统 I/O 硬期限和真实宿主延迟已验收。auto_fix_on_save 与旧超时配置仅保留兼容含义,Rust 不静默修复源码;未初始化工作区须先显式 init 才能持久任务。 | ||
|
|
||
| 已安装插件的版本以各清单为准。本次架构重构保留现有 68 个受管技能,重点收敛判定证据、模块职责与 Java 项目感知。 | ||
| PreToolUse Git 门禁与旧 CLI/MCP 暂留 Python 兼容入口,Copilot/OpenHands 镜像与 canonical 绑定保持字节一致,不等于对应宿主验收完成。真实 Claude/Codex/ZCode/Kimi 自动触发、可信关闭策略、完整原生优先、多平台与精度仍缺。见[默认生命周期验收](tests/rust-lifecycle-default.md)、[历史候选证据](tests/rust-runtime-candidate.md)、[历史 32 语法验收](tests/rust-wasm-runtime-candidate.md)与[钩子协议](hooks/__protocol__.md)。 | ||
|
|
||
| ### 运行边界 | ||
|
|
||
| | 入口 | 检查对象 | 结果 | | ||
| |---|---|---| | ||
| | PostToolUse | 文件型工具检查本次编辑文件 | 反馈、exit 0;项目级检查延后 | | ||
| | UserPromptSubmit | 与提交意图相关的工作树变更 | 建议,不阻断用户消息 | | ||
| | UserPromptSubmit | 固定检查时机指引,不扫描源码 | 建议,不阻断用户消息 | | ||
| | PreToolUse Git 门禁 | 拟提交 index 快照或推送 HEAD 快照 | 确定违规 exit 2;不确定项明确 UNVERIFIED 并 fail-open | | ||
| | CLI check / MCP check_code_style | 项目检查,含 Java 构建验证 | 明确状态、原因、原始退出码、顺序执行证据和日志 | | ||
| | pre-commit / CI | 独立配置的检查 | 单独验收,不能由钩子成功代替 | | ||
|
|
||
| 钩子不会自动覆盖宿主的每个命令入口。历史 V0.5.4 安装证据不能代表当前版本已在 Codex、ZCode、Kimi 验收。 | ||
|
|
||
| Claude Code 的 `UserPromptSubmit` 不支持 matcher:每次提交提示都会启动旧 Python Hook。内部意图过滤未命中时,Hook 会在环境或仓库探测前退出;提交意图仍可能执行旧软检查,实际 Git 命令才进入 PreToolUse 门禁。清单无法消除每条提示的进程启动,已安装宿主的延迟尚未实测。 | ||
| Claude Code 每次 UserPromptSubmit 都启动 canonical Rust 提示绑定,不依赖关键词 matcher,也不因提示词启动 lint。Copilot/OpenHands 同步相同绑定镜像,其实际宿主协议仍待独立验收;实际 Git 命令仍由 PreToolUse 检查。真实宿主延迟尚未测量。 | ||
|
|
||
| ### 判定契约 | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.