
Research
Shai-Hulud Descends to Hades: Miasma Worm Campaign Spreads with New PyPI Wave
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.
harbor-spec
Advanced tools
Harbor-spec: context governance engine for AI coding, with contract drift detection, DDT validation, workflow facades, L2 README generation, module capsules, and advisory health checks.
Harbor-spec 是 AI coding 时代的上下文治理引擎。 让代码、契约、测试、派生上下文、决策记录与 CI 门禁保持一致。
语言: 中文 | English
AI coding 让写代码越来越快,但也让代码与契约之间更容易出现不同步,导致修一个bug可能新增好几个bug。 HarborSpec 让代码、契约、派生上下文、复核基线与 CI 门禁保持一致,从而让代码可验证、可追溯、可治理。
harbor startharbor finish --sync-contextharbor accept
HarborSpec 是一个面向 AI coding / vibe coding / agentic coding 的本地上下文治理工具。
当 AI 可以快速生成和修改代码之后,真正变难的不是“写代码”,而是:
HarborSpec 的目标是:
让 AI 编程工作流中的上下文、契约、派生文档和语义基线变得可检查、可追踪、可接受。
它不是另一个文档生成器,也不是另一个 Copilot。 它是一个 repo-local 的 context governance layer。
AI 改了实现,但契约没变:
Implementation changed, contract static.
HarborSpec 会在 checkpoint 中提示潜在语义漂移,并通过 Contract Impact Classifier 标记高风险变更,例如:
AI 通常会优先读取压缩后的上下文视图,例如模块 README、Module Capsule、项目结构视图。 但这些视图可能已经过期。
HarborSpec 在 .harbor/views/** 中维护 canonical generated views,并通过 integrity frontmatter 与 stale 检查判断它们是否仍然可信。
重要决策容易散落在聊天记录、commit message 或口头讨论中。
HarborSpec 提供 Diary 机制,将重要变更、架构决策和上下文演进写入:
.harbor/diary/YYYY-MM.jsonl
AI 工具很容易自动运行命令、修改文件、刷新文档、接受基线。
HarborSpec 明确区分:
HarborSpec 的上下文治理可以理解为三层:
| 层级 | 名称 | 作用 | 典型文件 / 命令 |
|---|---|---|---|
| L1 | Constitution / Rules | 全局规则、安全策略、项目治理边界 | AGENTS.md、.harbor/rules/**、.harbor/policy.yaml、.harbor/safety.yaml |
| L2 | Module Context | 模块级上下文、AI 可读的派生视图 | .harbor/views/l2/**、.harbor/views/modules/**、harbor stale |
| L3 | Contract / Docstring | 函数级契约、测试绑定、具体实现语义 | Docstring、type hints、DDT、l3_version、harbor checkpoint |
简化理解:
L1 决定 AI 应该遵守什么规则。
L2 决定 AI 应该先读哪些模块上下文。
L3 决定某个函数、接口或行为的具体契约。
flowchart TD
L1[L1 Rules / Policy / Safety] --> L2[L2 Module Context Views]
L2 --> L3[L3 Contracts / Docstrings / Tests]
L3 --> Source[Source Implementation]
Source --> Checkpoint[harbor checkpoint]
L2 --> Stale[harbor stale]
L1 --> Doctor[harbor doctor]
Checkpoint --> Accept[harbor accept]
Stale --> Doctor
这也是为什么 HarborSpec 同时包含:
checkpoint:关注 L3 contract / implementation driftstale:关注 L2 generated context 是否过期doctor:关注 L1 / workspace / derived views / skill references 的整体健康HarborSpec 明确区分 事实源 与 派生上下文。
| 优先级 | 层级 | 示例 |
|---|---|---|
| 1 | Safety / Policy | tool sandbox、.harbor/safety.yaml、.harbor/policy.yaml |
| 2 | Explicit Contract | docstring、schema、CLI contract、public API |
| 3 | Contract Tests / DDT | explicit l3_version 绑定测试 |
| 4 | Source Implementation | 当前源码实现 |
| 5 | Human-authored Docs | README、design docs、rules |
| 6 | Canonical Generated Views | .harbor/views/** |
| 7 | Exports / Skills | <module>/README.md、.agents/skills/** |
| 8 | Cache / State / Temp | .harbor/cache/**、.harbor/state/** |
关键规则:
.harbor/views/** 是 canonical generated context,但不是 source of truth。<module>/README.md 是 L2 README export,不是 canonical L2。docs/harbor/** 是 legacy / optional export,不是 canonical storage。specs/diary/** 是 legacy diary read-compatible,不是新写入目标。semantic drift / contract gap,再通过测试、DDT 或人工确认裁决。pip install harbor-spec
在项目根目录执行:
harbor init
harbor init 在 v1.3.0 中是交互式 Setup Wizard:
.harbor/config/harbor.yaml(canonical config)。AGENTS.md.harbor/rules/role-rules.md.harbor/rules/project-rules-guide.md.harbor/policy.yaml.harbor/safety.yaml.harbor/rules/project-rules.md,应由 AI coding 工具基于 guide 和项目实际情况生成。.harbor/rules/*.md。docs/harbor/** 是 legacy / deprecated path,不作为 v1.3.0 新初始化目标。.env,仅追加缺失 HARBOR_* key,不覆盖已有 key。--force 只影响模板类文件覆盖;不会覆盖 .env 里已存在的 HARBOR_* key。--dry-run 在交互模式下仍会提问但不写文件;非 TTY 且参数不完整时使用安全默认并输出预览计划。harbor init --dry-run --language zh --project new --governance --no-governance-docs --no-llm
新项目提示策略:
harbor checkpoint / harbor accept”。harbor startharbor finish --sync-context + harbor doctorharbor acceptharbor checkpoint
它会检查当前 Harbor baseline 状态,并执行快速 DDT 检查。
python -m harbor.cli.main start
# Work with your AI IDE...
python -m harbor.cli.main finish --sync-context
python -m harbor.cli.main doctor
本地源码验证场景建议优先使用 python -m harbor.cli.main ...,确保命令命中当前工作区源码,而不是用户机器上可能尚未刷新的全局 harbor.exe。
如果你已经人工复核并准备接受新基线:
python -m harbor.cli.main accept
HarborSpec 搭配 Cursor、Windsurf、Trae、Claude Code、Codex 等 AI IDE 的终端使用体验最佳。 推荐让 AI 读取
AGENTS.md与.harbor/rules/**,但不要让 AI 自动执行harbor accept。
大多数 AI coding 任务只需要记住这条主线:
harbor start
# AI coding
harbor finish --sync-context
harbor doctor
# human review
harbor accept
| 命令 | 作用 | 是否建议 AI 自动执行 |
|---|---|---|
harbor start | 开始任务前查看工作区和 Harbor 状态 | 可以 |
harbor finish --sync-context | 收尾检查,并刷新 changed L2 README 与 Module Capsule | 仅在明确收尾流程中可以 |
harbor doctor | 综合健康检查 | 可以 |
harbor accept | 人工确认后接受新的 Harbor baseline | 不应自动执行 |
更严格的本地收尾:
python -m harbor.cli.main finish --sync-context
python -m harbor.cli.main stale
python -m harbor.cli.main doctor
说明:
finish --sync-context 仍是 changed-scope sync,不是 full rebuild。harbor docs --all --write 与 harbor module seal --all --write,但不会自动执行。stale 精确检查 L2 README 与 Module Capsule 是否过期。doctor 做整体健康检查。harbor log?只有当本次变更包含重要决策时才建议执行:
harbor log
适合记录:
harbor finish --sync-context 不会自动写 Diary。
harbor log 必须由人类明确授权。
如果你只是想先起草 reviewable Diary Draft,可以运行:
harbor log draft
harbor log draft --format json
harbor log draft --since-last-accept
harbor log draft --since-last-log
harbor log draft --from-report .harbor/reports/checkpoint.json
harbor log draft --output .harbor/reports/log-draft.md
边界:
harbor log draft 只生成 reviewable Diary Draft,不写 Written Diary Entryharbor log draft 不写 .harbor/diary/**harbor log draft 默认边界策略是:marker-first -> accept-fallback -> recent-fallbackharbor log draft --since-last-log 强制使用 last_log_markerharbor log draft --since-last-accept 强制使用 latest acceptharbor log draft 不推进 last_log_marker.harbor/diary/** 变化不会单独触发新的可写 draftSuggested Diary Entry,不提示 harbor log write,也不刷新 latest draft cacheharbor log draft --from-report <path> 仍可显式使用 report 生成 draftharbor log draft 的 --output 可写 .harbor/reports/**harbor log draft 的 --output 指向 .harbor/diary/** 必须拒绝harbor log draft 在 v1.4.1 不调用 LLMharbor log draft 不输出文件正文或 diff 正文harbor log / Diary write 仍需人工授权HarborSpec v1.4.x 提供三个 CI gate:
harbor checkpoint --ci
harbor stale --ci
harbor doctor --ci
checkpoint --ci严格 baseline gate。
默认读取仓库内 accepted baseline artifact:
.harbor/baseline/accepted-checkpoint.json
会阻断:
accepted_baseline_missingaccepted_baseline_invalidcontract_required=true)分类说明(当前实现):
contract_gap:缺少必需契约源,默认可阻断。contract_parse_error:存在契约源但无法可靠解析/分类,默认可阻断。skipped_no_contract:目标不要求契约,语义审计跳过,advisory / non-blocking。possible_semantic_drift:仅在存在可比较契约时才可能出现。contract_changed:契约变化(基线未接受时阻断)。contract_and_body_changed:契约与实现同时变化(基线未接受时阻断)。ddt_version_baseline_missing:DDT 基线缺失 advisory / non-blocking。possible_contract_impact:默认 advisory,除非被状态门禁升级。accepted_baseline_missing:CI 中缺少 .harbor/baseline/accepted-checkpoint.json,不会回退到 runtime cache。accepted_baseline_invalid:accepted baseline artifact schema 或内容非法,需在本地修复后提交。stale --ci派生上下文 freshness gate。
会阻断:
不会阻断:
<module>/README.md export mismatchdoctor --ci整体健康 gate。
默认只阻断:
DoctorCheckResult.status == FAIL
不会因为普通 WARN / SKIP 直接失败,例如:
所有 CI JSON 命令均保证:
writes_files=falseacceptcheckpoint --ci --format json 还会额外给出:
baseline_sourcebaseline_pathbaseline_found示例:
harbor checkpoint --ci --format json
harbor stale --ci --format json
harbor doctor --ci --format json
Repair guidance(v1.3.1)补充:
guidance 是可选附加字段(optional additive field),不会删除或改变现有 JSON 字段语义。guidance 默认由确定性规则生成,不使用 LLM,不会改变 checkpoint/stale/doctor 的 pass/fail 判定。--advice off 关闭 guidance 输出(保留原有 reason/suggested_action/next_steps 等字段)。possible_semantic_drift 仅做保守提示,不默认判定“实现错”或“契约错”。harbor next --from <report.json> 为只读解释命令,不执行自动修复、不运行 accept/log/lock。HarborSpec v1.3.0 使用 .harbor/* 作为 canonical workspace。
.harbor/
config/
harbor.yaml # canonical config
views/
project-structure.md # canonical project structure view
l2/
<module>/README.md # canonical L2 README
_meta.json # canonical L2 metadata
modules/
<module>/
module-card.md
review-checklist.md
debug-playbook.md
diary/
YYYY-MM.jsonl # canonical diary
reports/
dogfooding/
cache/ # ignored runtime cache
state/ # ignored runtime state
exports/ # ignored generated exports
建议追踪:
.harbor/config/harbor.yaml
.harbor/views/**
.harbor/diary/**
.harbor/reports/dogfooding/**
docs/design/**
建议忽略:
.harbor/cache/**
.harbor/state/**
.harbor/exports/**
.pytest_cache/**
**/__pycache__/**
Legacy / export 路径:
| 路径 | 定位 |
|---|---|
.harbor/config.yaml | legacy config read-compatible |
.harbor/l2_meta.json | legacy L2 metadata read-compatible |
specs/diary/** | legacy diary read-compatible |
docs/harbor/** | optional docs export / legacy |
<module>/README.md | human-readable L2 README export |
.harbor/views/** 中的 canonical generated markdown views 会包含 integrity frontmatter。
示例:
---
generated_by: harbor-spec
harbor_version: 1.4.2
view_type: l2_readme
module: harbor/core
generation_command: harbor docs --module harbor/core --write
stale_policy: fail-closed
source_path_count: 12
source_paths_truncated: false
source_fingerprint: sha256:...
contract_fingerprint: sha256:...
generator_fingerprint: sha256:...
generated_at: 2026-05-09T10:00:00Z
---
说明:
generated_at 仅用于信息展示。generated_at。generated_at,避免无意义 Git diff。.harbor/views/** is generated context.HarborSpec 命令较多,但日常不需要全部记住。 建议按使用场景理解。
| 命令 | 说明 |
|---|---|
harbor start | 开始任务前查看 Harbor 状态 |
harbor checkpoint | 本地检查点:status + fast DDT + contract impact 摘要 |
harbor finish | 收尾检查,不刷新派生上下文 |
harbor finish --sync-context | 收尾检查,并刷新 changed L2 README 与 Module Capsule |
harbor stale | 检查派生上下文 freshness |
harbor doctor | 综合健康检查 |
harbor accept | 人工接受新 Harbor baseline |
| 命令 | 说明 |
|---|---|
harbor checkpoint --ci | 严格 baseline gate |
harbor stale --ci | canonical generated views freshness gate |
harbor doctor --ci | workspace health gate |
--format json | 输出机器可读 JSON |
通常你只需要:
python -m harbor.cli.main finish --sync-context
需要精确控制时可使用:
| 命令 | 说明 |
|---|---|
python -m harbor.cli.main project structure --write | 写入 canonical project structure view |
python -m harbor.cli.main docs --changed --write | 刷新 changed modules 的 L2 README |
python -m harbor.cli.main docs --module <module> --write | 刷新单模块 L2 README |
python -m harbor.cli.main module seal --changed --write | 刷新 changed modules 的 Module Capsule |
python -m harbor.cli.main module seal <module> --write | 刷新单模块 Module Capsule |
如果你已经确认 editable install 已刷新,裸命令仍可作为等价调用,例如 harbor project structure --write。
| 命令 | 说明 |
|---|---|
harbor workspace inspect | 查看 canonical / legacy / export / cache / state 布局 |
harbor workspace inspect --format json | 输出机器可读 workspace report |
harbor workspace migrate --dry-run | 只读迁移计划 |
harbor workspace migrate --dry-run --format json | 机器可读 dry-run report |
注意:
harbor workspace migrate --write is not implemented in v1.3.0.
| 命令 | 说明 |
|---|---|
harbor module inspect <module> | 查看模块索引上下文 |
harbor module seal <module> | 预览 Module Capsule |
harbor module seal <module> --write | 写入 Module Capsule |
harbor module stale <module> | 检查单模块 Capsule freshness |
harbor module promote-skill <module> | 可选:将高价值模块晋升为 skill |
promote-skill 是手动动作,不建议默认对所有模块执行。
| 命令 | 说明 |
|---|---|
harbor init | 初始化 Harbor workspace |
harbor adopt <path> | 接管存量代码 |
harbor config list | 查看配置 |
harbor config add <pattern> | 添加扫描路径 |
harbor config remove <pattern> | 移除路径 |
harbor lock | 底层 runtime cache / 索引重建操作 |
harbor accept | 写入 accepted baseline artifact,并可选刷新本地 cache |
日常建议使用 harbor accept 作为人工接受命令;CI 只运行 checkpoint --ci,不运行 lock。
HarborSpec 推荐使用分层规则系统,而不是把所有规范塞进一个超长 prompt。
推荐结构:
AGENTS.md # 跨工具共享入口
.harbor/rules/role-rules.md # TRAE / IDE 轻入口
.harbor/rules/project-rules.md # 本项目专属规则
.harbor/policy.yaml # 机器可读治理策略
.harbor/safety.yaml # 机器可读安全策略
.agents/skills/** # 可选 skill integration artifacts
只读检查:
harbor start
harbor checkpoint
harbor stale
harbor doctor
harbor workspace inspect
harbor workspace migrate --dry-run
CI gate:
harbor checkpoint --ci
harbor stale --ci
harbor doctor --ci
明确收尾流程中可执行:
harbor finish --sync-context
harbor log draft
harbor log draft --format json
harbor log draft --since-last-accept
harbor log draft --since-last-log
harbor log draft --from-report .harbor/reports/checkpoint.json
harbor log draft --output .harbor/reports/log-draft.md
必须由人类明确授权:
harbor accept
harbor log
harbor lock
harbor module promote-skill <module>
git tag
git push
原因:
accept 接受新的 Harbor baselinelog 写入决策记忆lock 更新底层基线promote-skill 生成外部 integration artifactgit tag/push 属于发布动作harbor log draft 属于安全草稿命令:
.harbor/diary/**--output 仅允许写 .harbor/reports/**,指向 .harbor/diary/** 必须拒绝checkpoint 用于回答:
当前代码相对 Harbor baseline 是否发生了语义变化?
它会检查:
常用命令:
harbor checkpoint
harbor checkpoint --ci
stale 用于回答:
AI 要读取的 L2 README / Module Capsule 是否还是最新?
它关注的是 .harbor/views/** 中的 canonical generated views。
如果 source / contract / generator 发生变化,但派生视图没有刷新,stale --ci 会失败。
常用修复方式:
harbor finish --sync-context
doctor 用于回答:
Harbor workspace 整体是否健康?
它会检查:
doctor --ci 默认只对 FAIL 阻断,WARN/SKIP 作为 advisory。
L2 README 是模块级 AI context view。
canonical 路径:
.harbor/views/l2/<module>/README.md
默认 export:
<module>/README.md
L2 README 帮助 AI 快速理解:
Module Capsule 是更面向维护动作的上下文包。
canonical 路径:
.harbor/views/modules/<module>/
module-card.md
review-checklist.md
debug-playbook.md
它适合在 debug、review、refactor 前帮助 AI 判断:
Module Capsule 是 derived maintenance view,不是 source of truth。
DDT 用于防止“测试仍然是绿的,但测的是旧契约”。
示例:
from harbor.core.ddt import harbor_ddt_target
@harbor_ddt_target("harbor.core.sync.SyncEngine.check_status", l3_version=1)
def test_sync_engine_drift_detection():
...
严格目标必须使用显式 l3_version,不要使用 strategy="latest"。
DDT baseline advisory(新增):
DDT_VERSION_BASELINE_MISSING / ddt_version_baseline_missing 表示绑定结构合法,但未找到 L3 version baseline。l3_version,需要人工先复核 baseline 再 harbor accept。Diary 用于记录重要变更和决策。
harbor log
canonical 写入路径:
.harbor/diary/YYYY-MM.jsonl
specs/diary/** 仅 legacy read-compatible。
如果只需要 reviewable draft 而不是写入 Diary,可使用:
harbor log draft
它会基于 change-window snapshots / reports / git status 汇总 evidence,但不会写 .harbor/diary/**。
HarborSpec 的核心检查不强制依赖 LLM。
如果你希望启用语义审计,可以配置 .env:
HARBOR_LLM_PROVIDER=openai
HARBOR_LLM_API_KEY=sk-xxxxxx
HARBOR_LLM_BASE_URL=https://api.openai.com/v1
HARBOR_LANGUAGE=zh
也可使用其他兼容 OpenAI API 的 provider。
语义审计短路规则(当前实现):
CONTRACT_GAP 与 SKIPPED_NO_CONTRACT 场景不会调用 LLM。harbor check --format jsonl 在跳过场景会输出 llm_called=false。harbor check --format jsonl 当前不是“纯 JSONL-only”输出:仍会包含人类可读 DDT 区块,语义审计部分输出 JSONL 行。没有契约 ≠ 契约漂移。只有存在可比较契约时,Harbor 才会进入语义漂移判断。
CONTRACT_GAP:目标要求契约,但没有有效契约源。SKIPPED_NO_CONTRACT:目标不要求契约,语义审计被跳过。CONTRACT_PARSE_ERROR:存在契约源,但无法可靠解析或分类。v1.3.0 的目标是把 HarborSpec 从“契约/文档检查工具”升级为 agentic coding context governance workflow。
核心新增:
.harbor/* workspace.harbor/views/** generated context viewsharbor checkpoint --ciharbor stale --ciharbor doctor --ci对于已有项目,可以先初始化:
harbor init
查看配置:
harbor config list
接管已有代码:
harbor adopt backend/ --strategy safe
模式:
| 模式 | 说明 |
|---|---|
safe | 仅接管已有 docstring 的函数 |
aggressive | 为 public 函数插入 TODO 模板 |
--dry-run | 只预览,不写入 |
接管后由人类确认是否接受基线:
harbor accept
HarborSpec 默认遵守以下原则:
--ci 不自动修复workspace migrate --dry-run 不写文件finish --sync-context 只做 changed-scope 派生上下文刷新与同 scope stale 自检,不会自动全量重建accept 必须人工授权log 必须人工授权lock 不应由 AI 自动执行AGENTS.md:跨工具共享入口.harbor/rules/role-rules.md:TRAE / IDE 轻入口.harbor/rules/project-rules.md:本项目专属规则docs/design/harbor-workspace-layout-v1.md:workspace layout 设计说明.harbor/views/project-structure.md:canonical project structure view.harbor/views/l2/**:canonical L2 README.harbor/views/modules/**:canonical Module Capsule不是。 HarborSpec 会生成上下文视图,但这些视图只是 advisory context。 它的核心是治理代码、契约、测试、派生上下文和基线之间的一致性。
不需要。 大多数情况下只需要:
harbor start
harbor finish --sync-context
harbor doctor
发布前再运行:
pytest
harbor checkpoint --ci
harbor stale --ci
harbor doctor --ci
harbor stale 和 harbor doctor 有什么区别?stale 关注 generated views 是否过期。
doctor 关注 Harbor workspace 整体健康。
简单理解:
stale = freshness check
doctor = health check
harbor finish --sync-context 会自动写 Diary 吗?不会。 它只刷新 changed modules 的 L2 README 与 Module Capsule,并做收尾检查。
harbor log 必须手动执行。
harbor log draft 会写 Diary 或调用 LLM 吗?不会。
harbor log draft 只生成 reviewable Diary Draft
harbor log draft 不写 .harbor/diary/**
harbor log draft 的 --output 可写 .harbor/reports/**
harbor log draft 的 --output 指向 .harbor/diary/** 必须拒绝
harbor log draft 在 v1.4.1 不调用 LLM
LLM-assisted draft 属于 future work,不是 v1.4.1 当前能力
harbor log draft 不输出文件正文或 diff 正文
默认模式下只有存在 meaningful new evidence 时才会生成可写 draft
reports alone 在默认模式下只是 supplementary evidence
仅 .harbor/diary/** 变化不会单独触发新的可写 draft
如果需要真正写入 Diary,仍然要由人类明确授权执行 harbor log。
harbor accept 可以让 AI 自动执行吗?不建议。
accept 代表接受新的 Harbor baseline,必须由人类确认。
workspace migrate --write 吗?不支持。 v1.3.0 仅支持:
harbor workspace migrate --dry-run
它只输出迁移计划,不写文件。
Harbor-spec v1.4.2.2 是围绕 Windows 主机编码兼容性的维护补丁版本,用于完成 cp1252 runner closure,并收口纯 JSON stdout 的统一输出策略。
_emit_json_stdout():
main() contract/docstring、accepted baseline 与 generated context 一并对齐python -m harbor.cli.main acceptpython -m harbor.cli.main checkpoint --ci --format jsonpython -m harbor.cli.main stale --ci --format jsonpython -m harbor.cli.main doctor --ci --format jsonCI:
3.93.103.11windows-full-governanceHarbor-spec v1.4.2 在 v1.4.1 的 Log Draft / Controlled Write workflow 之上,恢复 TypeScript 主线,并先补齐 richer contract source 之前必须稳定的治理基础。
IndexBuilder / runtime cache / SQLite 持久化路径统一接入 .tstarget_id / func_id / language / symbol_kind / qualified_namecontract_source_kinds / contract_source_fingerprints / source_confidence_summarycheckpoint --ci 的正式 baseline truth:
.harbor/baseline/accepted-checkpoint.jsoninterface / type advisory-first data contract discoveryz.object(...) / z.enum(...) shallow Zod source recognitionexport default function / export default class public surface evidencecontract_hash = normalized contract source bundle hashharbor next / JSON metadata 输出:
export_modedata_contract_kindschema_source_kindcontract_source_kindscontract_source_fingerprintssource_confidence_summaryharbor finish --sync-contextharbor stale --ci --format jsonharbor doctor --ci --format json.d.ts scanningpackage exports / tsconfig path aliasinterface/type 或 Zod 自动升级为 blocking gatefunc_id / target_id 兼容不回归v1.4.1 Log Draft / Controlled Write workflow 保持零回归Harbor-spec v1.4.0 引入 first-class TypeScript contract governance。
这不是“仅增加 TS 文件扫描”,而是 Harbor 从 Python FunctionContract / docstring-centric 治理,演进到 language-neutral ContractSubject 模型的第一步。
ContractSubject / ContractSource / LanguageAdapterAdapterRegistry:统一语言适配器入口.ts 文件发现(需显式启用)export functionexport async functionexport const arrow / async arrowexport class public methodcontract_presence / contract_requiredcheckpoint --ci TypeScript MVP category:
contract_gapskipped_no_contractunsupported_syntax_advisoryharbor next 对 TypeScript MVP category 的 deterministic guidance.js/.jsx/.tsx/.d.ts 默认扫描interface/type blocking gatelanguages:
python:
enabled: true
typescript:
enabled: true
enabled=trueenabled=false,需要显式启用.ts.tsx/.js/.jsx/.d.ts 默认不扫描func_id 保留兼容target_id/language/symbol_kind/adapter 以 additive identity fields 方式新增Harbor-spec v1.4.1 将日志工作流明确分为三层:
Evidence -> Draft Cache / Save -> Controlled Write
这些命令会为当前 change window 产生运行时证据:
harbor checkpoint
harbor finish
harbor accept
规则:
.harbor/state/change-windows/**harbor log draft 总结,但不会直接成为 Written Diary Entryharbor log draft
harbor log draft --save
harbor log draft --since-last-accept
harbor log draft --output .harbor/reports/log-draft.md
规则:
harbor log draft 默认在 stdout 展示 reviewable draft.harbor/diary/** 变化,也不会单独触发新的可写 draft--from-report <path> 时,report 才可作为主 evidence 生成 draftharbor log draft 才会写:
.harbor/state/log/latest-draft.md.harbor/state/log/latest-draft.jsonharbor log draft 默认边界策略是:marker-first -> accept-fallback -> recent-fallbackharbor log draft --since-last-log 强制使用 last_log_markerharbor log draft --since-last-accept 强制使用 latest acceptharbor log draft --save 会生成:
.harbor/reports/log-draft-YYYYMMDD-HHMMSS.md.harbor/reports/log-draft-YYYYMMDD-HHMMSS.jsonharbor log draft --output <path> 使用显式输出路径,且优先于 --saveharbor log draft 不写 .harbor/diary/**harbor log draft 不推进 last_log_markerharbor log draft --output 指向 .harbor/diary/** 必须拒绝harbor log write
harbor log write --yes
harbor log write --from-latest-draft
harbor log write --from-draft .harbor/reports/log-draft.md
规则:
harbor log write 默认读取 latest draft--yes 时必须交互确认--yes 必须拒绝--yes 是显式授权写入 source-of-truth decision memory--from-draft 只允许受控来源:.harbor/reports/** 或 latest draft cache.harbor/diary/**、.env、.env.*、secrets/**、repo 外路径必须拒绝为 draft source.harbor/diary/YYYY-MM.jsonl 后,更新 .harbor/state/log/last_log_marker.jsonlast_log_marker 代表“上一次已经正式写入 Diary 的日志节点”,属于 runtime state,不是 source-of-truth memoryharbor log draft 不写 Diary,harbor log write 才会写 Diary.harbor/state/** 和 .harbor/reports/** 都不是 source of truth.harbor/diary/** 才是 source-of-truth decision memoryharbor log draft / harbor log draft --saveharbor log write 或 harbor log write --yesApache-2.0
FAQs
Harbor-spec: context governance engine for AI coding, with contract drift detection, DDT validation, workflow facades, L2 README generation, module capsules, and advisory health checks.
We found that harbor-spec demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.