Skip to content

Commit 1feefee

Browse files
committed
daily update
1 parent 37a31ba commit 1feefee

45 files changed

Lines changed: 4470 additions & 59 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- [第 7 篇:记忆/经验分层提取——自生长的团队知识库](https://mp.weixin.qq.com/s/s253xe5LiUmgdfDo3XxAbg)(2026-08)
3939
- [第 8 篇:四维代码评审——让踩过的坑自动变成 CHECKLIST](https://mp.weixin.qq.com/s/wH_mjG5IL-0qo_qDFpODuw)(2026-08)
4040
- [第 9 篇:多仓Harness集中式管理方案](https://mp.weixin.qq.com/s/pA1CsLSAIqbeVqFV4-kVQQ)(2026-09)
41+
- [第 10 篇:如何让AI写的Wiki可信——项目知识全生命周期管理](https://mp.weixin.qq.com/s/OdESdERtINqYTBkIIVFWlQ)(2026-09)
4142

4243

4344

‎codewiki/mcp/server.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
from mcp.server.stdio import stdio_server
6464
from mcp.types import TextContent, Tool
6565

66+
from codewiki import __version__
6667
from codewiki.mcp.session import SessionStore
6768

6869
logger = logging.getLogger(__name__)
@@ -136,7 +137,10 @@
136137

137138
server = Server(
138139
"codewiki",
139-
version="5.2.1",
140+
# Single source of truth: codewiki/__init__.py (kept in sync with
141+
# pyproject.toml at release time). Never hardcode here — a stale literal
142+
# misleads clients that gate capabilities on the initialize handshake.
143+
version=__version__,
140144
instructions=_SERVER_INSTRUCTIONS,
141145
)
142146

‎codewiki/src/locks.py‎

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import logging
4646
import os
4747
import threading
48+
import time
4849
from contextlib import contextmanager
4950
from pathlib import Path
5051
from typing import IO, Iterator, Union
@@ -75,16 +76,45 @@ def _lock_for(path_key: str) -> threading.Lock:
7576
return lock
7677

7778

79+
def _open_lock_file(filepath: Union[str, Path], *, attempts: int = 50, delay: float = 0.01) -> int:
80+
"""``os.open`` with a short retry on Windows delete-pending races.
81+
82+
A sidecar lock file that another thread/process is releasing may be in
83+
the delete-pending state exactly while we open it — ``CreateFile`` then
84+
fails with ``ERROR_ACCESS_DENIED``/``ERROR_DELETE_PENDING``
85+
(``PermissionError``). This is transient: once the unlink completes,
86+
``O_CREAT`` re-creates a fresh file. Retry briefly instead of letting a
87+
release/unlink race kill the caller's whole read-modify-write sequence
88+
(observed as lost updates under threads — 2026-09-07).
89+
"""
90+
for attempt in range(attempts):
91+
try:
92+
return os.open(str(filepath), os.O_RDWR | os.O_CREAT, 0o666)
93+
except PermissionError:
94+
if attempt == attempts - 1:
95+
raise
96+
time.sleep(delay)
97+
raise AssertionError("unreachable") # pragma: no cover
98+
99+
78100
@contextmanager
79-
def file_lock(filepath: Union[str, Path]) -> Iterator[IO[str]]:
101+
def file_lock(
102+
filepath: Union[str, Path], *, unlink_on_release: bool = False
103+
) -> Iterator[IO[str]]:
80104
"""Hold an exclusive lock bound to *filepath* for the ``with`` block.
81105
82106
Yields the UTF-8 text handle that holds the lock; perform all reads and
83107
writes through it. The file is created if missing.
108+
109+
``unlink_on_release=True`` (sidecar locks only — never content files)
110+
best-effort removes the file after releasing, **still inside the per-path
111+
thread-lock critical section** so a sibling thread can never be mid-open
112+
against the delete-pending file. Windows only: the flag is ignored on
113+
Unix, where unlinking a flock'd path reintroduces the inode race.
84114
"""
85115
path_key = str(Path(filepath).resolve())
86116
with _lock_for(path_key):
87-
fd = os.open(str(filepath), os.O_RDWR | os.O_CREAT, 0o666)
117+
fd = _open_lock_file(filepath)
88118
try:
89119
_acquire_os_lock(fd)
90120
f = os.fdopen(fd, "r+", encoding="utf-8")
@@ -99,6 +129,18 @@ def file_lock(filepath: Union[str, Path]) -> Iterator[IO[str]]:
99129
os.close(fd)
100130
except OSError:
101131
pass # fd already closed via f.close()
132+
# Still inside the per-path thread lock: no thread of this process
133+
# can be mid-open here. Cross-process contenders hitting the
134+
# delete-pending window are covered by _open_lock_file's retry.
135+
if unlink_on_release and os.name == "nt": # pragma: no cover - platform branch
136+
try:
137+
os.unlink(str(filepath))
138+
except OSError:
139+
# Another holder keeps the file open — sharing violation.
140+
# The leftover is transient and bounded (≤ one file per lock
141+
# target, git-ignored); manual cleanup is safe once no
142+
# process holds the lock.
143+
pass
102144

103145

104146
def _acquire_os_lock(fd: int) -> None:

‎codewiki/src/store.py‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,19 @@ def locked(path: Path) -> Iterator[None]:
150150
over.
151151
152152
Lock-file cleanup: released lock files are best-effort removed on
153-
Windows only (deleting a file that another process has open raises a
154-
sharing violation, so the unlink can only succeed when nobody holds it —
155-
no inode race). On Unix the file is deliberately kept: ``flock`` locks
156-
the inode, and unlinking the path while a contender has it open would
157-
let a third process lock a freshly created file — two "exclusive"
153+
Windows only, *inside* the per-path thread-lock critical section via
154+
``file_lock(unlink_on_release=True)`` — the unlink used to run after the
155+
thread lock was released, and a sibling thread's ``os.open`` could hit
156+
the Windows delete-pending state mid-release (``PermissionError`` → lost
157+
update, 2026-09-07). On Unix the file is deliberately kept: ``flock``
158+
locks the inode, and unlinking the path while a contender has it open
159+
would let a third process lock a freshly created file — two "exclusive"
158160
holders of the same lock. See ``codewiki.src.locks``.
159161
"""
160162
path.parent.mkdir(parents=True, exist_ok=True)
161163
lock_file = _lock_path_for(path)
162-
with file_lock(lock_file):
164+
with file_lock(lock_file, unlink_on_release=os.name == "nt"):
163165
yield
164-
if os.name == "nt": # pragma: no cover - platform branch
165-
try:
166-
lock_file.unlink(missing_ok=True)
167-
except OSError:
168-
pass # another holder keeps it open — leave for lint_wiki sweep
169166

170167

171168
def locked_write(path: Path, content: str) -> None:

‎repowiki/.meta/telemetry/iamwangbao-163-com.jsonl‎

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -299,27 +299,27 @@
299299
{"t": "adopted", "doc": "notes/2026-09-06-调研报告的借鉴建议必须先过代码核对b2b1-痛点表述与实际不符的三处教训.md", "at": "2026-09-06T23:18:18", "key": "iamwangbao-163-com/4a93b9221bce4788a5ebc8bc4be149ce"}
300300
{"t": "hit", "doc": "notes/2026-09-05-蒸馏-subagent-自报的笔记状态不可信需用-get-task-context-的-related-notes-状态.md", "at": "2026-09-06", "n": 1}
301301
{"t": "hit", "doc": "notes/2026-08-26-read-versioned-lines-对磁盘上已不存在的-untracked-文件返回空列表产生只有-header.md", "at": "2026-09-06", "n": 1}
302-
{"t": "hit", "doc": "notes/2026-08-29-生成的-ps1-必须带-utf-8-bom否则-powershell-51-按-gbk-误读.md", "at": "2026-09-07", "n": 2}
303-
{"t": "hit", "doc": "notes/2026-09-05-github-release-正文乱码不可逆utf-8-字节被按-gbk-解码写入只能基于事实重写.md", "at": "2026-09-07", "n": 2}
304-
{"t": "hit", "doc": "notes/2026-08-03-mcp-工具-schema-不声明-session-idhandler-隐式读取.md", "at": "2026-09-07", "n": 8}
305-
{"t": "hit", "doc": "wiki/modules/KnowledgeStore.md", "at": "2026-09-07", "n": 6}
306-
{"t": "hit", "doc": "wiki/scenarios/Wiki页面生成约定与数据结构.md", "at": "2026-09-07", "n": 6}
307-
{"t": "hit", "doc": "wiki/scenarios/MCP-Server薄壳架构与参数约定.md", "at": "2026-09-07", "n": 4}
308-
{"t": "hit", "doc": "wiki/modules/CLI_Adapter.md", "at": "2026-09-07", "n": 2}
309-
{"t": "hit", "doc": "notes/2026-08-26-load-project-checklist-对-yaml-损坏静默回退-none-无日志难排查.md", "at": "2026-09-07", "n": 2}
310-
{"t": "hit", "doc": "wiki/modules/CLI_Utils.md", "at": "2026-09-07", "n": 4}
311-
{"t": "hit", "doc": "notes/2026-08-29-工作区痕迹齐备时跳过-init-workspace直接跑-bootstrap-脚本补-clone.md", "at": "2026-09-07", "n": 2}
312-
{"t": "hit", "doc": "notes/2026-08-29-subagent-定义的-frontmatter-按宿主家族分发同名文件不同-schema.md", "at": "2026-09-07", "n": 10}
313-
{"t": "hit", "doc": "notes/2026-08-23-distill-worker-subagent-定义随包发布hook-启用时自动拷贝到项目-codebuddyagent.md", "at": "2026-09-07", "n": 4}
314-
{"t": "hit", "doc": "wiki/modules/MCP_Prompts.md", "at": "2026-09-07", "n": 6}
315-
{"t": "hit", "doc": "notes/2026-08-25-mcp-参数长度受限时蒸馏-submit-走文件侧通道python-脚本直接调-handle-distill-conve.md", "at": "2026-09-07", "n": 4}
302+
{"t": "hit", "doc": "notes/2026-08-29-生成的-ps1-必须带-utf-8-bom否则-powershell-51-按-gbk-误读.md", "at": "2026-09-07", "n": 5}
303+
{"t": "hit", "doc": "notes/2026-09-05-github-release-正文乱码不可逆utf-8-字节被按-gbk-解码写入只能基于事实重写.md", "at": "2026-09-07", "n": 5}
304+
{"t": "hit", "doc": "notes/2026-08-03-mcp-工具-schema-不声明-session-idhandler-隐式读取.md", "at": "2026-09-07", "n": 17}
305+
{"t": "hit", "doc": "wiki/modules/KnowledgeStore.md", "at": "2026-09-07", "n": 14}
306+
{"t": "hit", "doc": "wiki/scenarios/Wiki页面生成约定与数据结构.md", "at": "2026-09-07", "n": 15}
307+
{"t": "hit", "doc": "wiki/scenarios/MCP-Server薄壳架构与参数约定.md", "at": "2026-09-07", "n": 10}
308+
{"t": "hit", "doc": "wiki/modules/CLI_Adapter.md", "at": "2026-09-07", "n": 5}
309+
{"t": "hit", "doc": "notes/2026-08-26-load-project-checklist-对-yaml-损坏静默回退-none-无日志难排查.md", "at": "2026-09-07", "n": 5}
310+
{"t": "hit", "doc": "wiki/modules/CLI_Utils.md", "at": "2026-09-07", "n": 7}
311+
{"t": "hit", "doc": "notes/2026-08-29-工作区痕迹齐备时跳过-init-workspace直接跑-bootstrap-脚本补-clone.md", "at": "2026-09-07", "n": 6}
312+
{"t": "hit", "doc": "notes/2026-08-29-subagent-定义的-frontmatter-按宿主家族分发同名文件不同-schema.md", "at": "2026-09-07", "n": 13}
313+
{"t": "hit", "doc": "notes/2026-08-23-distill-worker-subagent-定义随包发布hook-启用时自动拷贝到项目-codebuddyagent.md", "at": "2026-09-07", "n": 7}
314+
{"t": "hit", "doc": "wiki/modules/MCP_Prompts.md", "at": "2026-09-07", "n": 8}
315+
{"t": "hit", "doc": "notes/2026-08-25-mcp-参数长度受限时蒸馏-submit-走文件侧通道python-脚本直接调-handle-distill-conve.md", "at": "2026-09-07", "n": 6}
316316
{"t": "hit", "doc": "wiki/modules/MCP_Core.md", "at": "2026-09-07", "n": 4}
317317
{"t": "hit", "doc": "wiki/modules/MCP_Server.md", "at": "2026-09-07", "n": 6}
318318
{"t": "hit", "doc": "notes/2026-09-05-codewiki-plus-发布是手动流程三处版本引用-lightweight-tag-ci-不发布.md", "at": "2026-09-07", "n": 2}
319319
{"t": "hit", "doc": "notes/2026-08-25-doctrine-不会自动注入-agent-上下文唯一通道是-query-wikimodeoverview.md", "at": "2026-09-07", "n": 2}
320-
{"t": "hit", "doc": "wiki/reading-guide.md", "at": "2026-09-07", "n": 2}
321-
{"t": "hit", "doc": "wiki/modules/SharedConfig.md", "at": "2026-09-07", "n": 4}
322-
{"t": "hit", "doc": "notes/2026-09-04-d19knowledgestore-跨进程锁文件集中到-wiki-rootmetalockssha256目标绝对路径20.md", "at": "2026-09-07", "n": 2}
320+
{"t": "hit", "doc": "wiki/reading-guide.md", "at": "2026-09-07", "n": 4}
321+
{"t": "hit", "doc": "wiki/modules/SharedConfig.md", "at": "2026-09-07", "n": 6}
322+
{"t": "hit", "doc": "notes/2026-09-04-d19knowledgestore-跨进程锁文件集中到-wiki-rootmetalockssha256目标绝对路径20.md", "at": "2026-09-07", "n": 3}
323323
{"t": "hit", "doc": "wiki/entities/WeKnoraMCP_Server.md", "at": "2026-09-07", "n": 2}
324324
{"t": "hit", "doc": "wiki/modules/WebApp.md", "at": "2026-09-07", "n": 2}
325325
{"t": "hit", "doc": "wiki/modules/AnalysisPipeline.md", "at": "2026-09-07", "n": 4}
@@ -343,3 +343,13 @@
343343
{"t": "by_file", "doc": "notes/2026-08-23-hook-采集机制仅正式接线-codebuddyreadme-措辞用仅接线支持.md", "at": "2026-09-07", "n": 1}
344344
{"t": "by_file", "doc": "notes/2026-08-21-下一期方向资产置信分层与负反馈闭环roadmap-phase-5.md", "at": "2026-09-07", "n": 1}
345345
{"t": "by_file", "doc": "notes/2026-08-19-l0-对话归档采用链接优先零索引设计.md", "at": "2026-09-07", "n": 1}
346+
{"t": "hit", "doc": "notes/2026-09-04-file-lock-的锁文件可能是数据文件本身释放即删只能加在-storelocked-不能下沉到-file-lock.md", "at": "2026-09-07", "n": 6}
347+
{"t": "hit", "doc": "notes/2026-09-07-npx-skills-add-非交互环境停-tui用--y-跳过-a-指定-agentuniversal-目录始终落盘.md", "at": "2026-09-07", "n": 2}
348+
{"t": "hit", "doc": "notes/2026-09-07-test-locked-rmw-across-processes-在-windows-下是环境性-flaky单测重跑即过.md", "at": "2026-09-07", "n": 5}
349+
{"t": "hit", "doc": "notes/2026-09-04-锁文件清理采用仅-windows-释放即删unix-一律保留不删.md", "at": "2026-09-07", "n": 4}
350+
{"t": "hit", "doc": "notes/2026-09-07-consolidate-notes-候选-disposition-三值机制未入选笔记不再无声滞留excluded-必填.md", "at": "2026-09-07", "n": 2}
351+
{"t": "hit", "doc": "notes/2026-09-05-frontmatter-sources-有三个生产者字段形态各不相同.md", "at": "2026-09-07", "n": 1}
352+
{"t": "hit", "doc": "notes/2026-09-07-同一文件批量并发-replace-in-file-会触发写锁超时30s需顺序单发.md", "at": "2026-09-07", "n": 2}
353+
{"t": "hit", "doc": "notes/2026-09-07-mcp-server-子进程-cwd-固定为启动目录oschdir-不影响e2e-测试必须显式传-workspace-p.md", "at": "2026-09-07", "n": 1}
354+
{"t": "hit", "doc": "notes/2026-08-28-telemetry-原子写入崩溃会残留孤儿-tmppid-文件且无自动清理机制.md", "at": "2026-09-07", "n": 1}
355+
{"t": "hit", "doc": "notes/2026-09-07-lint-wiki-的-lock-sweep-是空头承诺storepy-注释承诺回收但无实现windows-残留-lck.md", "at": "2026-09-07", "n": 2}

0 commit comments

Comments
 (0)