Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"hooks": [
{
"type": "command",
"command": "python3 \"$CLAUDE_PROJECT_DIR/harness/command_guard.py\" --format claude --role designer"
"command": "python3 \"$CLAUDE_PROJECT_DIR/.harness/engine/cli.py\" guard-command --format claude --role designer"
}
]
},
Expand All @@ -15,7 +15,7 @@
"hooks": [
{
"type": "command",
"command": "python3 \"$CLAUDE_PROJECT_DIR/harness/command_guard.py\" --format claude --role designer"
"command": "python3 \"$CLAUDE_PROJECT_DIR/.harness/engine/cli.py\" guard-command --format claude --role designer"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion .codex/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"hooks": [
{
"type": "command",
"command": "sh -c 'exec python3 \"$(git rev-parse --show-toplevel)/harness/command_guard.py\" --format claude --role designer'",
"command": "sh -c 'exec python3 \"$(git rev-parse --show-toplevel)/.harness/engine/cli.py\" guard-command --format claude --role designer'",
"timeout": 30
}
]
Expand Down
14 changes: 9 additions & 5 deletions .githooks/_runtime
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# harness 钩子公共部分(由各钩子 source):定位 harness 与解释器。
# 解释器优先用开发包运行时 venv,与 bin/verify 一致;找不到时按 HARNESS_FAIL_OPEN 决定放行或拒绝。
# delivery-harness 钩子公共部分(由各钩子 source):定位引擎与解释器。
# 解释器优先用 .harness/config/checks.toml [runtime] python(相对仓库根),与 bin/harness 一致;
# 没有配置或不可执行时用 PATH 上的 python3;都找不到时按 HARNESS_FAIL_OPEN 决定放行或拒绝。
HARNESS_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
HARNESS_PY="$HARNESS_ROOT/scratch/iterm-probe-venv/bin/python"
if [ ! -x "$HARNESS_PY" ]; then
HARNESS_CLI="$HARNESS_ROOT/.harness/engine/cli.py"
HARNESS_PY=$(sed -n '/^\[runtime\]/,/^\[/s/^python *= *"\(.*\)".*/\1/p' "$HARNESS_ROOT/.harness/config/checks.toml" 2>/dev/null | head -n 1)
if [ -n "$HARNESS_PY" ]; then
HARNESS_PY="$HARNESS_ROOT/$HARNESS_PY"
fi
if [ -z "$HARNESS_PY" ] || [ ! -x "$HARNESS_PY" ]; then
HARNESS_PY=$(command -v python3 || true)
fi
if [ -z "$HARNESS_PY" ]; then
echo "harness:找不到 python3,$(basename -- "$0") 守卫未执行。" >&2
if [ "${HARNESS_FAIL_OPEN:-0}" = 1 ]; then exit 0; fi
exit 1
fi
HARNESS_GUARD="$HARNESS_ROOT/harness/git_guard.py"
4 changes: 2 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# 保护分支上禁止提交;暂存区卫生;快速 verify(harness/git_guard.py)。
# 保护分支上禁止提交;暂存区卫生;快速 verify(.harness/engine/guards/git_guard.py)。
. "$(dirname -- "$0")/_runtime"
exec "$HARNESS_PY" "$HARNESS_GUARD" pre-commit
exec "$HARNESS_PY" "$HARNESS_CLI" guard-git pre-commit
4 changes: 2 additions & 2 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# 禁推保护分支与 tag、禁强制推送;推送前完整 verify(harness/git_guard.py)。
# 禁推保护分支与 tag、禁强制推送;推送前完整 verify(.harness/engine/guards/git_guard.py)。
. "$(dirname -- "$0")/_runtime"
exec "$HARNESS_PY" "$HARNESS_GUARD" pre-push "$@"
exec "$HARNESS_PY" "$HARNESS_CLI" guard-git pre-push "$@"
4 changes: 2 additions & 2 deletions .githooks/reference-transaction
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# 禁止本地改写/删除保护分支、移动/删除 tag(harness/git_guard.py)。
# 禁止本地改写/删除保护分支、移动/删除 tag(.harness/engine/guards/git_guard.py)。
# 每次引用更新都会调用本钩子:只在 prepared 阶段、且涉及分支或 tag 时才启动 Python。
[ "$1" = prepared ] || exit 0
input=$(cat)
Expand All @@ -10,4 +10,4 @@ esac
# 解释器缺失时放行并告警:引用守卫失效不能让整个仓库无法提交。
HARNESS_FAIL_OPEN=1
. "$(dirname -- "$0")/_runtime"
printf '%s\n' "$input" | exec "$HARNESS_PY" "$HARNESS_GUARD" reference-transaction prepared
printf '%s\n' "$input" | exec "$HARNESS_PY" "$HARNESS_CLI" guard-git reference-transaction prepared
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
## 需要人工验收的部分

<!-- 只列机器无法判定的项(真机 UI、系统授权等),写明步骤与预期;没有写「无」。
`python3 harness/acceptance.py --manual` 列出现役人工验收清单,从中挑出本 PR 涉及的编号。 -->
`bin/harness acceptance --manual` 列出现役人工验收清单,从中挑出本 PR 涉及的编号。 -->
6 changes: 3 additions & 3 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: auto-merge

# L4 自治:build 与 harness 全绿后,由 harness/policy.py 判定能否自动合并(目标态设计 9.3):
# L4 自治:build 与 harness 全绿后,由 .harness/engine/cli.py policy 判定能否自动合并(目标态设计 9.3):
# 风险 R0/R1、类别在 autonomy.toml 中为 L4、未超误差预算、不超规模阈值、任务 PR 的运行记录与 CI 轮次合格,
# 每条理由写进 job summary。
# 停机:Actions → auto-merge → Disable workflow;恢复:Enable workflow(docs/specs/delivery-harness.md §8)。
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
PR: ${{ github.event.workflow_run.pull_requests[0].number }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: python harness/policy.py --base origin/main --head "$HEAD_SHA" ${PR:+--pr "$PR"} --branch "$HEAD_BRANCH" --github
run: python .harness/engine/cli.py policy --base origin/main --head "$HEAD_SHA" ${PR:+--pr "$PR"} --branch "$HEAD_BRANCH" --github

# 不自动合并的:build 与 harness 通过后打类别标签并请仓库所有者评审,PR 出现在其待评审列表里。
# 用 GITHUB_TOKEN 只「请求评审」,不批准(仓库已关闭 Actions 批准 PR)。
Expand Down Expand Up @@ -145,5 +145,5 @@ jobs:
gh label create audit --repo "$GITHUB_REPOSITORY" --color fbca04 --force >/dev/null
gh issue create --repo "$GITHUB_REPOSITORY" --label audit --label "class:$CLASS" \
--title "抽审:PR #$PR($CLASS)" \
--body "PR #$PR 按 harness/autonomy.toml 的抽样规则被抽中($RISK $CLASS,$HEAD_SHA)。评审方对照任务书、diff 与证据包审计;发现问题时另开带 escape 与 class:$CLASS 标签的议题,写明引入的 PR #$PR。"
--body "PR #$PR 按 .harness/config/autonomy.toml 的抽样规则被抽中($RISK $CLASS,$HEAD_SHA)。评审方对照任务书、diff 与证据包审计;发现问题时另开带 escape 与 class:$CLASS 标签的议题,写明引入的 PR #$PR。"
fi
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,45 +42,45 @@ jobs:
fi

- name: Verify (quick)
run: python harness/verify.py --quick
run: python .harness/engine/cli.py verify --quick

- name: Hygiene of changes
run: python harness/hygiene.py --range "${{ steps.base.outputs.sha }}"
run: python .harness/engine/cli.py hygiene --range "${{ steps.base.outputs.sha }}"

# 已有判定器以 base 为准:追加或新增的测试代码不能让已有测试失效(评审 PR7-R2)。
- name: Existing tests (base version) on head
run: python harness/base_tests.py --base "${{ steps.base.outputs.sha }}"
run: python .harness/engine/cli.py base-tests --base "${{ steps.base.outputs.sha }}"

# 前面的检查失败时,风险等级与证据仍要生成,评审才看得到全貌。
- name: Risk level
id: risk
if: ${{ !cancelled() }}
run: python harness/risk.py --base "${{ steps.base.outputs.sha }}" --github
run: python .harness/engine/cli.py risk --base "${{ steps.base.outputs.sha }}" --github

# R1 加强判定中要执行代码的一项(2026-09-28 决定 2):声明 R1 时,改到的变异目标得分不得低于基线。
# 下降即失败;要按 R2 走的重构去掉 Risk: R1 即可(加一个不带它的提交)。
- name: Mutation score of changed targets (R1 claims)
if: ${{ !cancelled() && steps.risk.outputs.claimed_r1 == 'true' }}
run: python harness/mutate.py --check --changed-since "${{ steps.base.outputs.sha }}"
run: python .harness/engine/cli.py mutate --check --changed-since "${{ steps.base.outputs.sha }}"

# 实现任务书的 PR:归属 trailer 与运行记录(只报告;是否自动合并由 auto-merge 的 policy.py 判定)。
- name: Run record (task PRs)
if: ${{ !cancelled() }}
run: python harness/run_check.py --base "${{ steps.base.outputs.sha }}" --github
run: python .harness/engine/cli.py run-check --base "${{ steps.base.outputs.sha }}" --github

- name: Fix evidence
if: ${{ !cancelled() }}
run: python harness/evidence.py --base "${{ steps.base.outputs.sha }}" --markdown "$GITHUB_STEP_SUMMARY"
run: python .harness/engine/cli.py evidence --base "${{ steps.base.outputs.sha }}" --markdown "$GITHUB_STEP_SUMMARY"

- name: Delivery metrics
if: ${{ !cancelled() }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: python harness/metrics.py --base "${{ steps.base.outputs.sha }}" --github --markdown "$GITHUB_STEP_SUMMARY"
run: python .harness/engine/cli.py metrics --base "${{ steps.base.outputs.sha }}" --github --markdown "$GITHUB_STEP_SUMMARY"

- name: Release check (tag = build version, on main)
if: startsWith(github.ref, 'refs/tags/v')
run: python harness/release_check.py --tag "$GITHUB_REF_NAME" --commit "$GITHUB_SHA"
run: python .harness/engine/cli.py release-check --tag "$GITHUB_REF_NAME" --commit "$GITHUB_SHA"

build:
# macos-26 自带 Xcode 26:build 脚本用 actool 把 native/AppIcon.icon 编成 Liquid Glass 分层图标。
Expand All @@ -105,7 +105,7 @@ jobs:

- name: Verify (lint, hygiene, Python and Swift tests, incident replay)
# 与本机、云端同一入口(docs/plans/verifiable-delivery.md P1);--strict 不允许 Swift 检查被跳过。
run: scratch/iterm-probe-venv/bin/python harness/verify.py --strict --full
run: scratch/iterm-probe-venv/bin/python .harness/engine/cli.py verify --strict --full

# Swift 测试的「修复前失败、修复后通过」只能在 macOS 上跑(harness job 在 Linux 只做 Python,方案 §13 E4)。
- name: Fix evidence with Swift (pull requests)
Expand All @@ -114,7 +114,7 @@ jobs:
BASE: ${{ github.event.pull_request.base.sha }}
run: |
git fetch --no-tags --unshallow origin || git fetch --no-tags origin
scratch/iterm-probe-venv/bin/python harness/evidence.py --base "$BASE" --swift --markdown "$GITHUB_STEP_SUMMARY"
scratch/iterm-probe-venv/bin/python .harness/engine/cli.py evidence --base "$BASE" --swift --markdown "$GITHUB_STEP_SUMMARY"

- name: Build Agent Notification.app
run: python3 scripts/build_inbox_app.py --standalone
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: quality

# 每周的测试强度与熵治理检查(docs/specs/delivery-harness.md):较慢,不放在每次提交的门禁里。
# 周报(harness/weekly.py)在检查之后汇总交付指标,写进固定的「每周质量报告」议题;检查失败也照样出周报。
# 周报(.harness/engine/cli.py weekly)在检查之后汇总交付指标,写进固定的「每周质量报告」议题;检查失败也照样出周报。
on:
schedule:
- cron: '17 2 * * 1' # 每周一 02:17 UTC
Expand Down Expand Up @@ -34,19 +34,19 @@ jobs:
run: python -m pip install -r requirements-dev.txt

- name: Mutation score not below baseline
run: python harness/mutate.py --check
run: python .harness/engine/cli.py mutate --check

- name: Incident replay
if: ${{ !cancelled() }}
run: python harness/replay.py
run: python .harness/engine/cli.py replay

- name: Complexity ratchet
if: ${{ !cancelled() }}
run: python harness/quality.py
run: python .harness/engine/cli.py quality

- name: Weekly report
if: ${{ !cancelled() }}
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: python harness/weekly.py --publish | tee -a "$GITHUB_STEP_SUMMARY"
run: python .harness/engine/cli.py weekly --publish | tee -a "$GITHUB_STEP_SUMMARY"
File renamed without changes.
113 changes: 113 additions & 0 deletions .harness/config/checks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# delivery-harness 项目配置:检查清单、源码与语言、运行时、目录约定、身份。
# 改动本文件属于 R3(护栏本身),由用户批准。
schema = 1

[identity]
# 执行方与 Agent 推送、开 PR、评论使用的 GitHub 账号(bin/as-agent、派发的提交身份)。
agent_login = "Snowson"
agent_email = "15168246+Snowson@users.noreply.github.com"

[runtime]
# 开发包运行时 venv:bin/* 与 git 钩子优先用它,没有时退回 PATH 上的 python3。
python = "scratch/iterm-probe-venv/bin/python"
# 派发槽位清理未跟踪文件时保留、并以符号链接指向主目录的路径。
preserve = ["scratch/iterm-probe-venv"]

[sources]
# 产品代码(R1 判定:签名不变、无新依赖、无迁移)。
code = ["scripts/**", "native/**"]
# UI 代码:policy 对 UI 改动不自动合并。
ui = ["native/**"]
# 质量棘轮:Python 用 ruff C901 与体量,Swift 用轻量解析。
python_dirs = ["scripts"]
swift_dirs = ["native"]
# 数据迁移语句的检查只看产品代码。
migrations = "scripts/migrations.py"

[release]
# 发版前核对:tag 名 = "v" + 版本号;两处版本号必须同步。
version_file = "scripts/build_inbox_app.py"
short_version_var = "BUNDLE_SHORT_VERSION"
build_version_var = "BUNDLE_VERSION"

[[mutation.targets]]
name = "价格转换与防护"
file = "scripts/pricing_fetch.py"
functions = ["transform", "_price_jump", "_drop_conflicting_aliases"]
tests = ["test_pricing_fetch", "test_properties.PricingTransformProperties"]

[[mutation.targets]]
name = "热力金额分级"
file = "scripts/daily_report.py"
functions = ["cost_thresholds", "cost_level"]
tests = ["test_properties.CostThresholdProperties", "test_daily_report"]

[[mutation.targets]]
name = "过去日报告合并"
file = "scripts/daily_report.py"
functions = ["_merge_day_tasks", "_task_total"]
tests = ["test_properties.MergeNoDowngradeProperties", "test_daily_report"]

[[mutation.targets]]
name = "模型规范名"
file = "scripts/model_names.py"
functions = ["canonical"]
tests = ["test_model_names"]

[[mutation.targets]]
name = "金额计算"
file = "scripts/usage_cost.py"
functions = ["price_for_day", "model_cost", "cost_for_models", "merge_cost", "convert_display"]
tests = ["test_usage_cost"]

[[mutation.targets]]
name = "用量汇总"
file = "scripts/usage_report.py"
functions = ["period_bounds", "previous_anchor", "_merge_models", "_dimension_rows"]
tests = ["test_usage_report", "test_golden"]

[verify]
requirements = "requirements-dev.txt"
pinned_tools = ["ruff"]
order = [
"tools", "integrity", "lint", "hygiene", "quality", "docs", "acceptance", "taskbook",
"python-tests", "swift-policy", "swift-runner", "zcode-selftest", "replay",
]

[[verify.checks]]
name = "lint"
tiers = ["quick", "default", "full"]
command = ["{python}", "-m", "ruff", "check", "scripts", "tests"]

[[verify.checks]]
name = "python-tests"
command = ["{python}", "-W", "error::ResourceWarning", "-m", "unittest", "discover", "-s", "tests"]

[[verify.checks]]
name = "swift-policy"
shell = "mkdir -p build && xcrun swiftc -parse-as-library native/InboxPolicy.swift native/Shared/WidgetSnapshot.swift tests/InboxPolicyTests.swift -o build/policy-tests && ./build/policy-tests"
requires = "macos"
why_skipped = "非 macOS,Swift 检查由 macOS CI 负责"

[[verify.checks]]
name = "swift-runner"
shell = "mkdir -p build && xcrun swiftc -parse-as-library native/ProcessRunner.swift tests/ProcessRunnerTests.swift -o build/runner-tests && ./build/runner-tests"
requires = "macos"
why_skipped = "非 macOS,Swift 检查由 macOS CI 负责"

[[verify.checks]]
# AGENTS.md 要求的无 UI 自检(身份比对、搜索框结构、点击状态机、run loop)。
name = "zcode-selftest"
shell = "mkdir -p build && xcrun swiftc native/ZcodeFocus.swift -o build/zcode-focus && build/zcode-focus --self-test"
requires = "macos"
why_skipped = "非 macOS,Swift 检查由 macOS CI 负责"

[replay]
# 回放用例中 tests 写 "swift-policy" 时运行的命令(macOS)。
[replay.suites.swift-policy]
shell = "mkdir -p build && xcrun swiftc -parse-as-library native/InboxPolicy.swift native/Shared/WidgetSnapshot.swift tests/InboxPolicyTests.swift -o build/policy-tests && ./build/policy-tests"
requires = "macos"

[reports]
# 自动合并用的批准 App 的机器人账号(周报把它合并或批准的 PR 算作自动合并)。
bots = ["snowsonz-auto-merge"]
Loading
Loading