Add file_locked frontmatter guard hook for hand-tuned files #292
Labels
No labels
P0
P1
P2
P3
bug
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#292
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
os-sdlc implement (and agents generally) sometimes edit hand-tuned files unprompted. Assessed 2026-08-06 via multi-agent review (hook mechanics, cc-os hook survey, Codex, simplifier + premortem perspectives): verdict is build it, narrow scope.
Design: a PreToolUse hook (first in cc-os) matching Write|Edit|NotebookEdit reads the target file's on-disk YAML frontmatter; if
metadata.file_locked: true, returnpermissionDecision: askwith a reason so edits must be presented as before/after diffs and approved. PreToolUse hooks apply to subagent tool calls too.Constraints from assessment:
---prefix); expand to other .md/Obsidian later.Reuse: plugins/os-aidd-lint/hooks/post_tool_use.rb as Ruby hook template; os-doc-hygiene scanner.py/patch_applier.py have frontmatter parsers. Placement (new plugin vs os-status) and mechanism choice vs settings.json permission rules to be recorded as an ADR at implementation time.
Direction revised after grill session 2026-08-06 — this comment supersedes conflicting parts of the description:
Execution order across the three tickets: this one first.
Work started 2026-08-06, in-session on branch main (direct commit, no PR). Implementing as python hook plugins/os-status/hooks/pre_tool_use.py per the revised-direction comment above.
Resolution
Done: Implemented file_locked frontmatter guard: PreToolUse hook plugins/os-status/hooks/pre_tool_use.py registered in os-status hooks.json (matcher Write|Edit|MultiEdit|NotebookEdit). Opt-in metadata.file_locked: true on any .md (case-insensitive extension) returns permissionDecision ask; fail-closed on opened-but-unparseable frontmatter; lock decision reads on-disk file only; ask reason calls out lock removal (Write/Edit/MultiEdit). Charter expansion recorded as ADR-0104 (amends ADR-0022); os-status CLAUDE.md + invariants 9-13 updated; plugin cache refreshed.
Evidence: Commit
079f5ccon main. Tests: python3 tests/pre_tool_use_test.py = 31 passed; python3 tests/hook_test.py = 80 passed (unchanged). Two-axis code review (standards + spec) completed; all findings fixed (.MD suffix bypass, tab-indent detection, case-sensitive lock value, doc sync).Follow-ups: #294 (merge os-status+os-shortcuts into os plugin, noun-first naming ADR) then #293 (frontmatter registry doc + CRUD skill) — already filed, execution order #294 before #293. No other follow-ups.