fix(offload): emit render-safe MMD metadata#218
Conversation
Signed-off-by: rocke.dong <qc_dong@126.com>
|
currently 'mmdc -i 001-fix-unauthorized-access.mmd -o 001.svg' will raise error; after this fix, we can render safe mmd file from td agent memory. |
|
Thanks for the PR! We'll take a look at the MMD metadata format change. |
The render-safe `%% mmd-meta:` comment does not contain the literal `%%{`,
so isEmptyShellMmd's stale guard let a freshly L2-generated 3-line MMD
(metadata + flowchart TD + one node) be classified as an empty shell and
deleted on task transition. Add a format-aware hasMmdHeaderMeta() presence
check (covers both comment and legacy directive forms, regardless of which
fields are populated) and reuse it in the guard. Note the render-safe
benefit in the L2 prompt: the .mmd stays a real graph humans can render.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Follow-up commit
Fix: added a centralized Benefit recap (also noted in the L2 prompt): the comment form keeps the |
Per data-safety priority, never let the cleanup heuristic remove a content-bearing graph. Extract a pure isEmptyShellMmdContent() predicate that flags an MMD as a deletable shell only when it has no metadata header (either format) AND no node status/summary/Timestamp marker, within the tiny skeleton size. Any graph with real content is always preserved; false positives can only ever keep a file, never unlink valid data. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Heads up on a data-loss bug this change introduced (and how I fixed it). While testing I noticed the format switch broke the empty-shell cleanup. That guard decides whether an MMD is just a throwaway skeleton, and if so it hard-deletes the file ( Fixed in two steps:
Net effect: the cleanup can now only err on the safe side. Worst case it keeps a skeleton it could've removed; it can never delete a graph that has real content. Added tests for both pieces and the build's green. |
Summary
%% mmd-meta: {...}) instead of an arbitrary directive (%%{...}%%).%%{...}%%parsing.Test plan
mmdcrenders an MMD file containing%% mmd-meta: {...}metadatanpx vitest run src/offload/mmd-meta.test.tsnpm testnpm run build