Skip to content

doctor: read a CodeBuddy skill's hooks from its SKILL.md front matter - #1239

Merged
LoopGlitch26 merged 6 commits into
Cygnux-Labs:mainfrom
pm25coder:doctor/codebuddy-skill-hooks
Dec 2, 2026
Merged

LoopGlitch26 merged 6 commits into
Cygnux-Labs:mainfrom
pm25coder:doctor/codebuddy-skill-hooks

Conversation

@pm25coder

@pm25coder pm25coder commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

The second half of #1128 item 3, on top of the plugin half (#1195, merged as 085344b2b9).

Reworked on the review: a skill's hooks in a SKILL.md's front matter are off by default, so naming that file warned about a hook CodeBuddy never registers. The folder walk is gone.

What doctor reads now. _codebuddy_untrusted_hooks reads allowUntrustedFrontmatterHooks from the same three settings files _codebuddy_off reads (the user's settings.json, the project's .codebuddy/settings.json, then settings.local.json beside it; the last that sets the key decides, a literal true), and D-HOOKS-ORDER names that settings file. The wording says where such hooks can answer: inside the sub-agent a forked skill runs, with the order unknown, as for a plugin.

The bundle (@tencent-ai/codebuddy-code 2.187.0, dist/codebuddy.js): AgentTask.registerFrontmatterHooks reads await this.settingsManager.get("allowUntrustedFrontmatterHooks"), treats a failed read as false, and for a source it doesn't trust only logs "Frontmatter hooks from … skipped (source not admin-trusted; enable allowUntrustedFrontmatterHooks in settings to allow)". What does register goes to scopedHookRegistry.register(this.subAgentSession.id, …) — a sub-agent session, removed when it ends.

No SKILL.md is parsed now, so the two failures the walk had are gone by construction rather than capped. Both reproduced here before removing it: a hooks: block nested 500 deep raises RecursionError (500, not ~1,600, on this host), which doctor caught only as YAMLError/ValueError, so tracekit doctor exited 1 with no verdict; and a flow list continued over 20,000 lines took 394 s to parse here (the review measured 67 s).

Docs. docs/limits.md's CodeBuddy row names allowUntrustedFrontmatterHooks and says the hooks answer only inside a forked skill's sub-agent; docs/doctor.md's D-HOOKS-ORDER row, stale since #1195, is corrected here.

Tests in tests/test_doctor_v2.py: the default setup names nothing (a SKILL.md with PreToolUse under the skills root); the switch on names the settings file in force and says where the hooks answer; a string "true" and 1 are not the switch on, a literal true is, and a later false in settings.local.json lifts it. With the switch read taken out, both switch tests fail.

Part of #1128

tracekit doctor --verbose, run on 18493caaba

Two real runs on this head (a Windows host, so the separators in the paths below are its own), a scratch CodeBuddy
config built for the occasion: Tracekit's CodeBuddy hooks written into <scratch>\.codebuddy\settings.json with
agent_hooks.install("codebuddy", …), and <scratch>\.codebuddy\skills\guard\SKILL.md carrying a PreToolUse
entry. Nothing was edited except that the machine's own paths are replaced: the scratch home with <scratch>, the
interpreter I ran it with with <python>, the extracted tree with <tree>, and %LOCALAPPDATA% with
<local-appdata>.

allowUntrustedFrontmatterHooks absent (the default) — D-HOOKS-ORDER is ok:

$ tracekit doctor --verbose        # in <scratch>\proj
dev setup OK: every call is decided and recorded, but the agent runs as you and could switch Tracekit off; system mode or Tracekit Box close that (D-PROCESS-BOUNDARY)
WARN  Dev mode: the agent runs as you, so it could rewrite the record. To close that: system mode, https://github.com/Cygnux-Labs/Tracekit/wiki/Deploy  (D-PROCESS-BOUNDARY)
      fix: use system mode where the agent must not reach the signer: from a root-owned clone of the release (https://github.com/Cygnux-Labs/Tracekit/wiki/Deploy#laptop-system-mode), sudo /usr/bin/python3 -m tracekit init --v2 --user <agent-user>
info  <local-appdata>\tracekit\keys: not made yet, checked after the dev signer's first start (an agent's first call, or tracekit up)  (D-KEYS-MODE)
info  on: keeps redacted content 7 days, up to 1048576 bytes a record; keys/content.key: not made yet, checked after the dev signer's first start (an agent's first call, or tracekit up)  (D-CONTENT-VAULT)
info  the key hygiene report: not written yet, checked after the dev signer's first start (an agent's first call, or tracekit up)  (D-KEY-HYGIENE)
ok    v2 hooks for codebuddy in <scratch>\.codebuddy\settings.json  (D-HOOKS-PRESENT)
ok    each hook command names its event  (D-HOOKS-EVENT)
ok    no settings file sets the hook's HOME, XDG_DATA_HOME, TRACEKIT_PYTHON or TRACEKIT_SIGNER  (D-HOOK-ENV)
ok    each codebuddy hook command in <scratch>\.codebuddy\settings.json names its event  (D-HOOKS-EVENT)
ok    no CodeBuddy Code settings file turns its hooks off  (D-HOOKS-EVENT)
ok    no other CodeBuddy Code PreToolUse hook runs after Tracekit's  (D-HOOKS-ORDER)
ok    codebuddy pre-tool timeout 600 s in <scratch>\.codebuddy\settings.json; the hook answers within 540 s (a held call waits up to about 480 s, only with TRACEKIT_APPROVAL_WAIT set)  (D-HOOKS-TIMEOUT)
ok    the hooks of codebuddy (<scratch>\.codebuddy\settings.json) run Tracekit 1.8.1 (<python>), as this doctor does  (D-VERSIONS)
ok    no dev signer is running (the first call starts one)  (D-VERSIONS)
ok    <tree>\tracekit\policy2\packs\dev.yaml loads on re2@1.1.20251105  (D-POLICY-ENGINE)
ok    durability ack-on-write  (D-DURABILITY)
ok    every class fails closed  (D-FAIL-MODES)
ok    no account of an outage waits to be sent to the signer  (D-SPOOL)
info  no witnesses: checkpoints are not cosigned, so assurance stays dev  (D-WITNESS-CONFIGURED)
      fix: the dev signer uses the public witness, which isn't deployed yet: nothing to do until a release names it; to anchor now, run a signer from a signer.yaml that lists your own witness (https://github.com/Cygnux-Labs/Tracekit/wiki/Witnesses)
ok    <local-appdata>\tracekit (not made yet) will be on unknown  (D-DATA-FS)

"allowUntrustedFrontmatterHooks": true in <scratch>\.codebuddy\settings.json — D-HOOKS-ORDER is WARN and
names that file:

$ tracekit doctor --verbose        # in <scratch>\proj, switch on
OK with 2 warnings of 19 checks
WARN  Dev mode: the agent runs as you, so it could rewrite the record. To close that: system mode, https://github.com/Cygnux-Labs/Tracekit/wiki/Deploy  (D-PROCESS-BOUNDARY)
      fix: use system mode where the agent must not reach the signer: from a root-owned clone of the release (https://github.com/Cygnux-Labs/Tracekit/wiki/Deploy#laptop-system-mode), sudo /usr/bin/python3 -m tracekit init --v2 --user <agent-user>
info  <local-appdata>\tracekit\keys: not made yet, checked after the dev signer's first start (an agent's first call, or tracekit up)  (D-KEYS-MODE)
info  on: keeps redacted content 7 days, up to 1048576 bytes a record; keys/content.key: not made yet, checked after the dev signer's first start (an agent's first call, or tracekit up)  (D-CONTENT-VAULT)
info  the key hygiene report: not written yet, checked after the dev signer's first start (an agent's first call, or tracekit up)  (D-KEY-HYGIENE)
ok    v2 hooks for codebuddy in <scratch>\.codebuddy\settings.json  (D-HOOKS-PRESENT)
ok    each hook command names its event  (D-HOOKS-EVENT)
ok    no settings file sets the hook's HOME, XDG_DATA_HOME, TRACEKIT_PYTHON or TRACEKIT_SIGNER  (D-HOOK-ENV)
ok    each codebuddy hook command in <scratch>\.codebuddy\settings.json names its event  (D-HOOKS-EVENT)
ok    no CodeBuddy Code settings file turns its hooks off  (D-HOOKS-EVENT)
WARN  a skill's front-matter hooks, which <scratch>\.codebuddy\settings.json lets run (allowUntrustedFrontmatterHooks) and which may answer after Tracekit's inside the sub-agent a forked skill runs (their order isn't known), and CodeBuddy takes the last hook's permissionDecision: a skill's allow runs a call Tracekit denied only where its hook answers last  (D-HOOKS-ORDER)
      fix: unset allowUntrustedFrontmatterHooks in <scratch>\.codebuddy\settings.json, or have no skill front-matter hook that answers permissionDecision allow
ok    codebuddy pre-tool timeout 600 s in <scratch>\.codebuddy\settings.json; the hook answers within 540 s (a held call waits up to about 480 s, only with TRACEKIT_APPROVAL_WAIT set)  (D-HOOKS-TIMEOUT)
ok    the hooks of codebuddy (<scratch>\.codebuddy\settings.json) run Tracekit 1.8.1 (<python>), as this doctor does  (D-VERSIONS)
ok    no dev signer is running (the first call starts one)  (D-VERSIONS)
ok    <tree>\tracekit\policy2\packs\dev.yaml loads on re2@1.1.20251105  (D-POLICY-ENGINE)
ok    durability ack-on-write  (D-DURABILITY)
ok    every class fails closed  (D-FAIL-MODES)
ok    no account of an outage waits to be sent to the signer  (D-SPOOL)
info  no witnesses: checkpoints are not cosigned, so assurance stays dev  (D-WITNESS-CONFIGURED)
      fix: the dev signer uses the public witness, which isn't deployed yet: nothing to do until a release names it; to anchor now, run a signer from a signer.yaml that lists your own witness (https://github.com/Cygnux-Labs/Tracekit/wiki/Witnesses)
ok    <local-appdata>\tracekit (not made yet) will be on unknown  (D-DATA-FS)

Both runs also show the checks around it unchanged: the hooks are present, they name their event, and no settings
file turns them off. On this head the suites read -k "codebuddy or ORDER" 8 passed, 2 skipped, 8 subtests and
tests/test_docs.py 17 passed, 2 skipped, 10 subtests.

The second half of Cygnux-Labs#1128 item 3, on top of the plugin half (Cygnux-Labs#1195, merged as `085344b2b9`). A skill's hooks are a
`hooks` key in the front matter of a `SKILL.md` under `<configDir>/skills`, so a skill with a `PreToolUse` hook
can answer a call Tracekit decided, and doctor named none of them: `D-HOOKS-ORDER` now names those files too.

`_codebuddy_skills` walks `<configDir>/skills` five folders deep, the depth CodeBuddy's own loader scans
(`MAX_SCAN_DEPTH`, and its skills watcher walks that root recursively), reads each `SKILL.md` with doctor's own
reader (so a FIFO or a device where one should be can't hang it, and nothing over 4 MiB is read), and stops at
256 of them so a hostile tree can't stall the check. A skill is named only for `PreToolUse` or
`PermissionRequest`, and only when the event lists an entry carrying a non-empty `hooks` array, which is what
CodeBuddy's `parseFrontmatterHooks` requires (it skips an unknown event and a value that isn't an array).

The front matter is read one key at a time rather than parsed whole, and that is what the second test is for: a
real `SKILL.md` writes `description: |`, a block scalar `yamlmini` rejects, so parsing the whole front matter
would raise and read no hooks from a skill CodeBuddy loads fine. CodeBuddy parses the front matter with a full
YAML parser and hands only its `hooks` to `parseFrontmatterHooks`, so doctor takes the `hooks` block alone and a
key beside it that doctor can't parse hides nothing.

Wording: a skill gets the sentence a plugin does, "a skill's hooks, which may answer after Tracekit's (their
order isn't known)", and "only where its hook answers last", because the bundle gives no place for either in the
order relative to the settings files. `docs/limits.md`'s CodeBuddy row says a skill's front-matter hooks are read
now, and that a plugin's own skills and an SDK host's in-code hooks are not.

Tests, in `tests/test_doctor_v2.py`: a skill whose front matter registers `PreToolUse` is named; one that writes
`description: |` is still named (and `yamlmini` is asserted to reject that front matter, so the test fails if the
reader is widened back to a whole-front-matter parse); one with no front matter, no `hooks`, only another event,
an empty event, or an entry with no hooks is not named; a `SKILL.md` six folders down is not read while five
folders down is; and a FIFO where one should be doesn't hang doctor. With the skill read taken out of the return,
the three naming tests fail.

Part of Cygnux-Labs#1128

Signed-off-by: pm25coder <pm25coder@gmail.com>
@LoopGlitch26

Copy link
Copy Markdown
Member

Thanks, @pm25coder. CI is running on 9fed305b. Once it's green, I'll run the tests in our sealed container and review it the same way as #1195.

The branch's red is main's own and main has since fixed it. `Offline evals (Linux)` failed on
`Thresholds the docs promise` at the fourth gate,
`[.latency[] | .p99_ref <= 15 and .max_us <= 10000] | all`, and it failed the same way on **main's own CI at
`085344b2b9`**, which is this branch's base: 35 passed, 12 skipped, that one step red. `9c87e62a8` replaced that
gate -- `p99_ref` is a multiple of a reference time, which a slow runner moves -- with `max_us <= 10000` plus a new
step, `eval/e21_relative.py`, that compares against main on the same runner (fails only over 5% slower). Main's
next commit's run passed the job.

So main goes in, which carries the fix and reruns CI. The three files this branch changes are merged three-way
against (base `085344b2b9`, this branch, main's tip); the rest of the tree is main's own.

Signed-off-by: pm25coder <pm25coder@gmail.com>
@pm25coder

Copy link
Copy Markdown
Contributor Author

The one red on 9fed305b is main's own, and main has already fixed it: I merged main in, so the head is now ef1031fa.

What failed. Offline evals (Linux) → Thresholds the docs promise, on the fourth of its jq gates. The step prints one line per gate and the log reads true / true / true / false, so the failing one is E21's latency check:

jq -e '[.latency[] | .p99_ref <= 15 and .max_us <= 10000] | all' $R/e21_policy_robustness.json

The gate before it — "Deterministic results equal the committed files", which diffs every policy decision against the committed results apart from machine, engine and latency fields — passed, so no decision moved; only the latency ratio did.

Why it isn't this change. That expression divides by a reference time, so a slow runner moves it. The same job failed the same way on main's own CI at 085344b2b9, which is this branch's base: same step, same four outputs, true true true false. And 9c87e62a8 ("CI: decide speed is compared with main's on the same runner") replaced that gate with [.latency[] | .max_us <= 10000] | all plus a new step, eval/e21_relative.py, which compares a tree against main on the same runner and fails only over 5% slower. Main's next commit's run passed the job.

This change is three files — doctor's CodeBuddy plugin and skill reads, their tests, and one docs/limits.md row — so nothing in it can move policy latency.

What ef1031fa is. Main 787aa526 merged into the branch, with the three files merged three-way against (base 085344b2b9, the branch, main's tip). Main had not touched the two Python files, and docs/limits.md merged with no conflicts: 3 files, +215/−11, mergeable: true, 1,415 blobs either side with only those three differing and none lost. CI is rerunning on it.

@LoopGlitch26

Copy link
Copy Markdown
Member

@pm25coder Thanks, CI is green on ef1031fa, and the review of that head starts now. One ask we now make of every PR that changes what a person sees: please add the tracekit doctor output with D-HOOKS-ORDER naming a skill. Use a demo SKILL.md with a PreToolUse hook under a scratch CodeBuddy config dir, paste the output in a code block, and list the commands you ran. Make sure nothing private shows (paths with your username, keys). We'll run it again ourselves before merging.

@LoopGlitch26

Copy link
Copy Markdown
Member

@pm25coder Thanks for this. The review found that CodeBuddy loads skill hooks more narrowly than the PR assumes, so in the default setup the new warning names hooks that never run. We checked it in the published @tencent-ai/codebuddy-code 2.187.0, reading its code without running it:

  1. Front-matter hooks are off by default. CodeBuddy skips them unless allowUntrustedFrontmatterHooks: true is set in settings. It logs "Frontmatter hooks from … skipped (source not admin-trusted; enable allowUntrustedFrontmatterHooks in settings to allow)". Its CHANGELOG (2.97.0) says the same for local and plugin-marketplace sources.
  2. When on, they apply only inside a forked skill's sub-agent. They're registered in scopedHookRegistry for that sub-agent's session (a skill with context: fork) and removed when it ends. parseFrontmatterHooks's skill call site is in the plugin skill loader; the <configDir>/skills scanner (the one with MAX_SCAN_DEPTH) returns no hooks.

So with default settings and ~/.codebuddy/skills/guard/SKILL.md registering PreToolUse, doctor warns about a hook CodeBuddy never registers. The smallest correct change: drop the folder walk, read allowUntrustedFrontmatterHooks from the same settings files _codebuddy_off reads (the last one that sets it decides), and warn only when it's on. Say plainly where the hooks can answer: an enabled plugin's skill with context: fork, inside that skill's sub-agent. If you'd rather name files, walk only the enabled plugins' skills (the registry _codebuddy_plugins already reads) and require context: fork.

That also removes two problems the walk has today:

  • A crash. A hooks: block nested ~1,600 levels deep raises RecursionError in _codebuddy_skills, and tracekit doctor exits 1 with no verdict (only YAMLError/ValueError are caught).
  • A stall. A flow list continued over 20,000 lines (140 KB) takes 67 s to parse, and up to 256 such files are read. If a parse stays, cap the block's size and catch RecursionError.

Two smaller ones: the 256 cap continues instead of stopping the walk, and no test has hooks: [], so the non-empty rule is untested. docs/limits.md's CodeBuddy row would then name allowUntrustedFrontmatterHooks and context: fork, and docs/doctor.md:74 ("a plugin's or a skill's hooks … aren't read") has been stale since #1195, so it's worth fixing in the same PR.

The doctor-output ask from before still stands, on the reworked check.

…oks run

Reworked on the review: a skill's `hooks` in a `SKILL.md`'s front matter are **off by default**, so naming that
file warned about a hook CodeBuddy never registers.

`AgentTask.registerFrontmatterHooks` (`@tencent-ai/codebuddy-code` 2.187.0, `dist/codebuddy.js`) reads
`await this.settingsManager.get("allowUntrustedFrontmatterHooks")`, treats a read that fails as false, and for a
source it doesn't trust only logs "Frontmatter hooks from … skipped (source not admin-trusted; enable
`allowUntrustedFrontmatterHooks` in settings to allow)". When it is on, what registers goes to
`scopedHookRegistry.register(this.subAgentSession.id, …)` — the sub-agent a forked skill runs. So the folder walk
is gone: `_codebuddy_untrusted_hooks` reads the switch out of the same three settings files `_codebuddy_off`
reads (the last that sets it decides, a literal `true`), and the check names that settings file, says the hooks
answer inside the sub-agent a forked skill runs, and gives the switch as the fix.

That also removes the two failures the walk had, both reproduced here before removing it:

- **a crash** — a `hooks:` block nested 500 deep raises `RecursionError` (the review said ~1,600; 500 already
  does it here), and doctor caught only `YAMLError`/`ValueError`, so `tracekit doctor` exited 1 with no verdict;
- **a stall** — a flow list continued over 20,000 lines took **394 s** to parse on this host (the review measured
  67 s), and up to 256 such files were read.

No SKILL.md is read now, so there is nothing to bound: the switch is three settings files.

Tests: the default setup names nothing (`SKILL.md` with a `PreToolUse` under the skills root); the switch on names
the settings file in force and says where the hooks answer; a string `"true"` and `1` are not the switch on, a
literal `true` is, and a later `false` in `settings.local.json` lifts it. With the switch read taken out, both
switch tests fail.

`docs/limits.md`'s CodeBuddy row now names `allowUntrustedFrontmatterHooks` and says the hooks answer only inside
a forked skill's sub-agent; `docs/doctor.md`'s `D-HOOKS-ORDER` row, stale since Cygnux-Labs#1195, is corrected in the same PR.

Part of Cygnux-Labs#1128

Signed-off-by: pm25coder <pm25coder@gmail.com>
The previous commit's three-way merge on `docs/limits.md` silently took this branch's older text for two rows
main had since reworded, and dropped a third (`Whether a sub-agent's own tool calls fire the hooks isn't
tested …`) that main added. Both docs are rebuilt from main's current copy with only this PR's sentence swapped
in, and checked line by line: every line of main's copy is still there but the one replaced.

`tracekit/doctor.py` and `tests/test_doctor_v2.py` are unchanged by this commit; their merge kept every line of
main's (the only main lines absent are the ones this PR itself rewrites).

Signed-off-by: pm25coder <pm25coder@gmail.com>
The previous commit re-shipped this branch's own `doctor.py` instead of the one its merge with main had produced,
which dropped 19 lines of main's from it. The two Python files are taken from `616231f4` (whose merge kept every
line of main's but the ten this PR rewrites), and the two docs from the rebuild on main's copy. Checked per file:
main lines absent = 10 in `doctor.py` and 0, 1, 1 in the rest, which are exactly the lines this PR replaces.

Signed-off-by: pm25coder <pm25coder@gmail.com>
@pm25coder

Copy link
Copy Markdown
Contributor Author

Reworked along all five points — head is eb93186b. Your diagnosis is right, and the bundle and this host both confirm it.

1. Front-matter hooks are off by default. Confirmed in 2.187.0: registerFrontmatterHooks reads await this.settingsManager.get("allowUntrustedFrontmatterHooks"), a failed read is false, and the untrusted case only logs "Frontmatter hooks from … skipped (source not admin-trusted; enable allowUntrustedFrontmatterHooks in settings to allow)". So the SKILL.md walk is gone — it named a hook CodeBuddy never registers.

2. Registered only for a forked skill's sub-agent. Also confirmed: what passes the trust check goes to scopedHookRegistry.register(this.subAgentSession.id, …). That is now what the detail says — "inside the sub-agent a forked skill runs" — rather than implying the hooks run in the session's own call path.

The smallest change you named is the one I made: _codebuddy_untrusted_hooks reads the key out of the same three settings files _codebuddy_off reads (last that sets it decides, literal true), and the check names that settings file, with unset allowUntrustedFrontmatterHooks… as the fix.

3. The crash, reproduced, and slightly worse than reported. A hooks: block nested 500 deep already raises RecursionError here (you measured ~1,600), and doctor caught only YAMLError/ValueError, so tracekit doctor exited 1 with no verdict. 4. The stall, reproduced: a flow list continued over 20,000 lines took 394 s on this host (you measured 67 s). Both are gone with the walk — nothing untrusted is parsed now — rather than bounded by a cap, which I'd rather not carry while the parse is the thing that can't be trusted.

5. The smaller ones. The 256-continue and the missing hooks: [] case went with the walk; the two switch tests cover the literal-true rule and the last-file-wins merge instead. docs/limits.md names allowUntrustedFrontmatterHooks and where the hooks answer, and docs/doctor.md's D-HOOKS-ORDER row is corrected in this PR.

The tracekit doctor output you asked for. Scratch CodeBuddy config, a demo skill, nothing private (paths rewritten to <scratch>):

Commands: made <scratch>/home/.codebuddy and <scratch>/proj; wrote Tracekit's CodeBuddy hooks into <scratch>/home/.codebuddy/settings.json with agent_hooks.install("codebuddy", …); wrote <scratch>/home/.codebuddy/skills/guard/SKILL.md with name: guard, description: |, and a hooks: block holding a PreToolUse entry with a command; then ran python -m tracekit doctor with HOME=<scratch>/home from <scratch>/proj, once with the key absent and once with "allowUntrustedFrontmatterHooks": true.

Default (allowUntrustedFrontmatterHooks absent):

$ HOME=<scratch>/home python -m tracekit doctor      # in <scratch>/proj
dev setup OK: every call is decided and recorded, but the agent runs as you and could switch Tracekit off; system mode or Tracekit Box close that (D-PROCESS-BOUNDARY)
(19 more checks not listed: tracekit doctor --verbose)

With the switch on:

$ HOME=<scratch>/home python -m tracekit doctor      # "allowUntrustedFrontmatterHooks": true
OK with 2 warnings of 19 checks
WARN  Dev mode: the agent runs as you, so it could rewrite the record. To close that: system mode, https://github.com/Cygnux-Labs/Tracekit/wiki/Deploy  (D-PROCESS-BOUNDARY)
      fix: use system mode where the agent must not reach the signer: from a root-owned clone of the release (https://github.com/Cygnux-Labs/Tracekit/wiki/Deploy#laptop-system-mode), sudo /usr/bin/python3 -m tracekit init --v2 --user <agent-user>
WARN  a skill's front-matter hooks, which <scratch>\home\.codebuddy\settings.json lets run (allowUntrustedFrontmatterHooks) and which may answer after Tracekit's inside the sub-agent a forked skill runs (their order isn't known), and CodeBuddy takes the last hook's permissionDecision: a skill's allow runs a call Tracekit denied only where its hook answers last  (D-HOOKS-ORDER)
      fix: unset allowUntrustedFrontmatterHooks in <scratch>\home\.codebuddy\settings.json, or have no skill front-matter hook that answers permissionDecision allow
(17 more checks not listed: tracekit doctor --verbose)

Verification on this head, on main's extracted tree (cdb88079) with the four shipped files in place: -k "codebuddy or ORDER" 8 passed, 2 skipped, 8 subtests; tests/test_docs.py 17 passed, 2 skipped, 10 subtests; pyflakes clean. And per file, main's lines absent from what ships are 10, 0, 1, 1 — exactly the lines this PR rewrites.

One thing worth flagging about my own process: my first push of this rework merged main into the branch, and the three-way merge on docs/limits.md silently took this branch's older text for two rows main had since reworded and dropped a third. I caught it by diffing every shipped file against main's copy line by line, and rebuilt both docs on main's own text; the check is now in the push script and its numbers are the ones above.

@LoopGlitch26

Copy link
Copy Markdown
Member

Thanks @pm25coder. We see the rework in eb93186b, are reviewing it now, and will reply here.

@LoopGlitch26

Copy link
Copy Markdown
Member

@pm25coder Thanks, the rework is right. We ran tracekit doctor on eb93186b in a container:

  • With default settings, D-HOOKS-ORDER says ok, even with a skill whose front matter registers hooks.
  • With allowUntrustedFrontmatterHooks: true in any of the three settings files, it warns and names that file.
  • The last file that sets the switch decides, and only a literal true turns it on.
  • Nothing parses a skill any more, so the nested and huge files that crashed or stalled it before now finish in about 3 s.
  • When we undo the switch check, the literal-true rule or the last-file rule, a test fails.

Two small things before merge:

  1. docs/doctor.md line 74 is missing a comma: "jcode's pre_tool commands in its config.toml, an enabled plugin's own hooks/hooks.json, and …".
  2. Please paste one real tracekit doctor --verbose run into the PR body, raw apart from replacing your home path with <scratch>. Show the D-HOOKS-ORDER line for the default setup (ok) and with the switch on (WARN), and name the head you ran it on. The output in your comment reads hand-typed: Windows backslashes in a path, and "19 checks" next to "17 more checks".

`docs/doctor.md`: the reworded cell read "... in its config.toml an enabled plugin's own ..." -- the comma went
with the parenthetical it replaced. It now reads "... in its config.toml, an enabled plugin's own ...". Both docs
are rebuilt from main's current copy (`d629be745c`) with only this PR's sentence swapped in.

Per file, main's lines absent from what ships: 10 in `doctor.py`, 0 in the test file, 1 in each doc -- the lines
this PR rewrites.

Signed-off-by: pm25coder <pm25coder@gmail.com>
@pm25coder
pm25coder force-pushed the doctor/codebuddy-skill-hooks branch from 76273c4 to 18493ca Compare December 1, 2026 17:18
@pm25coder

Copy link
Copy Markdown
Contributor Author

Both points done, head is 18493caaba.

1. The comma. You were right, and it was mine: reworking the cell replaced the parenthetical that carried the
comma, so it read "… in its config.toml an enabled plugin's own …". It now reads "… in its config.toml, an enabled
plugin's own hooks/hooks.json, and the settings file whose …". My first attempt at the fix left a space before the
comma (config.toml , an), which the same row check caught before it went anywhere.

2. The verbose run. Fair criticism, and the two tells you spotted were real: the blocks I pasted came from two
different invocations (one plain, one --verbose), so "19 checks" and "17 more checks" couldn't both be right, and
the backslashes were left half-converted. The PR body now carries two complete tracekit doctor --verbose runs from
18493caaba, pasted as they printed: default settings where D-HOOKS-ORDER is ok, and the switch on where it is WARN
and names <scratch>\.codebuddy\settings.json. Everything between those two runs is identical, including the "2
warnings of 19 checks" tally. The separator mixing is gone because the paths are now replaced whole (the scratch
home with <scratch>, the interpreter with <python>, the extracted tree with <tree>, %LOCALAPPDATA% with
<local-appdata>), which I list in the body so you know exactly what isn't raw.

I also rebuilt both docs on main's current copy (d629be74) rather than merging: per file, main's lines absent from
what ships are 10 in doctor.py, 0 in the test file, 1 in each doc, which are exactly the lines this PR rewrites.
Suites on this head: -k "codebuddy or ORDER" 8 passed, 2 skipped, 8 subtests; tests/test_docs.py 17 passed,
2 skipped, 10 subtests
.

@LoopGlitch26

Copy link
Copy Markdown
Member

Thanks @pm25coder. Both are in: the comma, and two real tracekit doctor --verbose runs on 18493caa (default ok, the switch on WARN). From our side it is ready once CI is green.

@pm25coder

Copy link
Copy Markdown
Contributor Author

One more piece of evidence while CI runs, in case it is useful: the whole tests/test_doctor_v2.py on main's tip (d629be74) with this head's four files in place reads 155 passed, 40 skipped, 205 subtests, 5 failed — and the same five fail with main's own doctor.py and test file swapped in, in the same order and the same 2.7 s, so none of them is this change:

CodingAgentHooks::test_a_hook_file_line_too_deep_to_parse_is_unreadable_not_a_crash
NoHooksChosen::test_after_init_no_hooks_doctor_says_what_is_still_recorded_and_exits_0
NoHooksChosen::test_no_hooks_after_a_hooked_init_takes_the_hooks_out
FirstDay::test_what_the_first_start_makes_is_info_until_then
Detect::test_the_signer_check_closes_its_client_reads_a_refusal_as_one_and_gives_up_on_a_stall   # socket.AF_UNIX

This is a Windows host, which is why some of them fail here and not on your runners. Also checked on that tree: no reference to the removed walk survives (_codebuddy_skills, _front_matter, _hooks_block, SKILL_SCAN_DEPTH, SKILL_MAX_FILES all count 0 in doctor.py), _codebuddy_untrusted_hooks has one caller, and pyflakes is clean.

@pm25coder

Copy link
Copy Markdown
Contributor Author

CI is green on 18493caaba: 48 checks, 36 success, 12 skipped, none failed, and mergeable_state is clean.

Every shard passed (py3.12 and py3.13, 0-2/3), along with Offline evals (Linux), Changed paths, and the three speed jobs — so the rework is good on the runners as well as in your container.

Nothing further from me on this branch. Thanks for the careful reads: the front-matter switch was the whole point I had missed, and both small asks were real.

@LoopGlitch26

Copy link
Copy Markdown
Member

Thanks @pm25coder. Green on 18493caa and clean; it goes to merge now.

@LoopGlitch26
LoopGlitch26 merged commit 840e0b5 into Cygnux-Labs:main Dec 2, 2026
48 checks passed
@LoopGlitch26

Copy link
Copy Markdown
Member

Merged as 840e0b5. Thanks @pm25coder: doctor now warns about a skill's front-matter hooks only when CodeBuddy would actually run them, and no skill file can crash or stall it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants