fix(工作日誌暫存): 收編舊名目錄,並掃出定址不到的孤兒

雜湊規則從 8 碼改成完整 40 碼那一刻,還沒寫進 wiki 的暫存留在舊名底下。
現行程式拿 40 碼去查,查不到那些目錄,裡面的條目就再也寫不出去。

沒人發現是因為兩種狀態長得一樣:「真的沒有待寫」與「待寫卡在舊名底下」
對呼叫端都是成功。技能於是照常回報完成,日誌卻一筆都沒有。

兩道處置。推得出對映的(舊名等於 H 加新名前 7 碼)由 list、cat、merge
一併收編,clear 與 commit 也連舊目錄一起清——commit 不放行的話,已經寫進
wiki 的暫存清不掉,下一輪會整批重複寫一次。推不出對映的交給新的 orphans
子命令掃出來回報,要有人看到才處理得掉。
This commit is contained in:
2026-09-02 15:27:03 +08:00
parent 7ff79005c2
commit e762cf986e
3 changed files with 98 additions and 31 deletions
+6 -1
View File
@@ -49,7 +49,7 @@ The `{HASH}` in every page name above is computed with `jsc-gitea/tools/hash-id`
Done when the hosting `{owner}/{repo}` and the full 40-character uppercase `{HASH}` are both known.
2. Run `tools/worklog-target.sh "{HASH}" all` and `tools/worklog-target.sh friday` in parallel. `all` prints `PAGE=LOG_{HASH}` and `CONTENTS=LOG_CONTENTS`; `friday` prints the Friday of the current work week as `yyyy-MM-dd`, which drives the page content and the row dates. Exit 2 means the arguments were rejected, so fix them and rerun. Exit 4 from `friday` means this machine's `date` does no date arithmetic: stop and report it, because a hand-picked Friday is exactly what goes wrong across a month or year boundary. Done when both page names and that Friday date are known.
3. Fill `templates/log-entry.md` with the ten facts of this one task and save it to a file. Done when that file holds exactly one entry.
4. Run `tools/worklog-pending.sh merge {HASH} {entry file}`. It prints `MERGED=` (pending content in time order, then this task's entry), `CLAIM=` (the pending files it took) and `PENDING=` (how many). Pending content was written by an earlier stage that ended without a work log, so it belongs in **this** write.
4. Run `tools/worklog-pending.sh merge {HASH} {entry file}`. It prints `MERGED=` (pending content in time order, then this task's entry), `CLAIM=` (the pending files it took) and `PENDING=` (how many). Pending content was written by an earlier stage that ended without a work log, so it belongs in **this** write. `merge` also picks up the legacy `H` + first 7 characters directory of the same `{HASH}`, so pending content stored under the previous hash rule still reaches the wiki.
| Exit | Do |
| --- | --- |
@@ -58,6 +58,11 @@ The `{HASH}` in every page name above is computed with `jsc-gitea/tools/hash-id`
| 2 | The `{HASH}` is none of the three accepted shapes — 40 uppercase hex characters, 8 uppercase hex characters, or `H` plus 7 uppercase hex characters — or the entry file argument is missing. The last two are old pending directories left by the previous hash rule and are accepted only until the migration finishes. Pass the value `hash-id` printed, unshortened, and rerun from step 1 |
Done when `MERGED` and `CLAIM` are known.
4.5. Run `tools/worklog-pending.sh orphans`. It takes no `{HASH}` and scans the whole pending area for directories that are not 40 uppercase hex characters. Exit 0 means there are none, so carry on silently. Exit 4 prints one `{directory}<TAB>{file count}<TAB>{path}` line per orphan: report every line to the user and carry on with this run — an orphan belongs to some other repository, so it never blocks this one.
Why this runs at all: a directory the current rule cannot address holds work-log entries that no run will ever write, and nothing else reports them. "No pending content" and "pending content stranded under a name this rule cannot address" both reach the caller as success, so without this scan the entries stay invisible until somebody reads the directory by hand. Step 4 already adopts the one legacy shape that can be derived from `{HASH}`; this scan covers every shape that cannot.
Done when the scan exited 0, or its lines were reported to the user.
5. Read `PAGE` from the LOG wiki repo of step 1 via `jsc-gitea:wiki`, and branch on the exit code the underlying `gitea.sh wiki-get` returned. **Only exit 4 means the page is not there yet.** Reading any other code as "it does not exist" builds a fresh page from `templates/log-entry.md` and appends to that — which replaces the whole existing work log with this one entry, and no entry on it can be recovered from the wiki afterwards.
| Exit | Do |