This page explains what repository hooks do in vstack and how to enable or disable them.
vstack manages repository-level hook artifacts under .github/hooks/*.json.
Hooks run on Copilot session and tool events. They support safety, audit, and quality checks.
Hooks use two different version concepts with different owners:
| Field | Example | Owner | Meaning |
|---|---|---|---|
Hook payload version |
1 in .github/hooks/<name>.json |
GitHub Copilot hook contract | Envelope/schema version for the JSON hook payload ({"version": 1, "hooks": {...}}). |
Artifact template version |
20260514002 in src/vstack/_templates/hooks/<name>/hook.yaml |
vstack template lifecycle | Revision token for the hook template artifact, tracked in .vstack/vstack.json and used for drift/ownership checks. |
These fields are intentionally different and should not be forced to match.
- If Copilot changes the hook envelope contract in the future, payload
versionmay move from1to2or higher. - Hook template revision tokens can still increment independently for normal template updates.
Operational rule: treat payload version as contract compatibility, and artifact version as vstack-managed template revision.
vstack ships these baseline hooks:
| Hook | Purpose |
|---|---|
agent-call-audit |
Records actor and delegation visibility for agent and subagent flows. |
session-audit |
Records generic session, prompt, and tool telemetry without actor data. |
log-retention-cleanup |
Prunes old hook log directories based on retention policy. |
pre-tool-safety-gate |
Detects risky tool actions before execution and applies policy behavior. |
post-edit-format |
Runs or records formatting-related checks after edit operations. |
post-edit-markdown-quality |
Applies markdown quality checks for docs-oriented changes. |
post-commit-security-scan |
Runs post-commit safety/security checks when configured. |
In .vstack/config.yaml:
hooks:
enabled: true
mode: auditenabled: falsedisables generation of baseline hook artifacts.modesets default behavior mode for generated hooks.
hooks:
hooks:
post-edit-markdown-quality:
enabled: false
pre-tool-safety-gate:
mode: enforcehooks:
log_level: minimal
log_retention_days: 7
log_dir: .vstack/logs
hooks:
session-audit:
log:
level: verbose
name: session-audit.log
retention_days: 14Runtime pruning is enforced for hook logs:
- On each hook event path, vstack prunes old day directories under
log_dir. - Pruning only targets directories named
YYYYMMDD. agent-call-auditapplies the same retention tohook-agent-call-unknown-events.tsv, because it is stored in the per-day directory that is pruned.- Retention defaults to
metadata.log.retention_days(currently7) and can be overridden withVSTACK_HOOK_RETENTION_DAYS. - Invalid override values (non-numeric or non-positive) safely fall back to
7.
session-auditis for generic telemetry only. It tracks payload volume and event metadata for session and tool activity.agent-call-auditis for actor and delegation telemetry only. It tracks who acted and where control was delegated.
When session-audit runs in minimal mode, logs include compact visibility fields without storing full prompt payload text:
- Every minimal record includes
timestamp,event,size_bytes,estimated_tokens, andhook_execution_ms. preToolUseandpostToolUsealso includetool_nameandtool_call_id.userPromptSubmittedalso includesslash_commandwhen a prompt starts with/...; otherwise it recordsnone.
Raw event payloads are written only in verbose mode.
When agent-call-audit runs in minimal mode, it writes compact JSONL records to .vstack/logs/YYYYMMDD/hook-agent-call.log:
- Every minimal record includes
timestamp,event,size_bytes,estimated_tokens, andhook_execution_ms. sessionStartandsessionEndincludesession_id,actor_name,actor_type, andmodel_used.preToolUseandpostToolUseincludesession_id,actor_name,actor_type,tool_name,delegated_agent_name, andmodel_used.- Delegation calls are explicit:
preToolUselogsdelegationStartwhentool_nameisrunSubagent.postToolUselogsdelegationEndwhentool_nameisrunSubagent.
delegated_agent_nameis best-effort and extracted when delegation payload fields are present, especially forrunSubagentcalls.- Unknown suppression in minimal mode is counter-based:
- Suppressed unknown events persist in
.vstack/logs/YYYYMMDD/hook-agent-call-unknown-events.tsvassession_id<TAB>reason<TAB>count. - The hook aggregates counts per
(session_id, reason)instead of appending duplicate rows. - Legacy 2-column rows (
session_id<TAB>reason) are treated ascount=1when summarizing and rewriting. sessionEndemits anunknownSummaryrecord with aggregated per-session counts before cleanup.
- Suppressed unknown events persist in
hook-agent-call-unknown-events.tsv is an internal counter file for minimal-mode unknown suppression.
It preserves per-session unknown reasons so sessionEnd can emit an accurate unknownSummary, and it helps operators track parser quality and unknown-rate drift over time.
actor_name, actor_type, tool_name, delegated_agent_name, and model_used are best-effort and may remain unknown when payload fields are unavailable.
Use this compact reference to see which fields each hook emits per mode and event.
| Hook | Mode | Event | Emitted fields |
|---|---|---|---|
session-audit |
minimal |
any event | timestamp, event, size_bytes, estimated_tokens, hook_execution_ms |
session-audit |
minimal |
preToolUse |
base fields + tool_name, tool_call_id |
session-audit |
minimal |
postToolUse |
base fields + tool_name, tool_call_id |
session-audit |
minimal |
userPromptSubmitted |
base fields + slash_command |
session-audit |
verbose |
any event | raw payload passthrough |
agent-call-audit |
minimal |
any event | timestamp, event, size_bytes, estimated_tokens, hook_execution_ms |
agent-call-audit |
minimal |
sessionStart |
base fields + session_id, actor_name, actor_type, model_used |
agent-call-audit |
minimal |
sessionEnd |
base fields + session_id, actor_name, actor_type, model_used |
agent-call-audit |
minimal |
preToolUse |
base fields + session_id, actor_name, actor_type, tool_name, delegated_agent_name, model_used |
agent-call-audit |
minimal |
postToolUse |
base fields + session_id, actor_name, actor_type, tool_name, delegated_agent_name, model_used |
agent-call-audit |
verbose |
any event | raw payload passthrough |
base fields in this table means timestamp, event, size_bytes, estimated_tokens, and hook_execution_ms.
vstack init --only hook
vstack manifest status --target . --only hook
vstack manifest verify --target . --only hook