| name | gtkb-sweep-commit |
| description | Sweep and locally commit all current non-ignored GroundTruth-KB worktree changes after owner authorization. Use when the owner says to "sweep commit", "commit everything", "commit all changes", consolidate verified bridge work, or perform the regular GT-KB full-worktree cleanup commit. Handles GT-KB governance hooks, inventory drift, narrative-artifact approval evidence, staged credential scans, and verification before committing. Does not push unless the owner explicitly asks. |
GT-KB Sweep Commit
Overview
Create one local commit from the current non-ignored GT-KB worktree, preserving all existing changes and satisfying the repo's governance hooks. This is for owner-authorized whole-worktree sweeps, not for narrowing or reverting someone else's work.
Operating Rules
- Treat
E:\GT-KB as the project root and do not pull live GT-KB artifacts from outside that root.
- Commit only non-ignored tracked and untracked paths returned by Git. Do not force-add ignored runtime/cache files or
.env.local.
- Do not revert, reset, or delete unrelated changes during a sweep.
- Do not push unless the owner explicitly asks for a push.
- Prefer normal
git add -A. If GT-KB implementation-start hooks block staging because current authorization state is stale or terminal, use git update-index only after confirming the owner explicitly requested a whole-worktree sweep. Pre-commit hooks must still run.
- Stop instead of committing if a real credential/secret finding appears in staged content.
Workflow
-
Inspect live state.
git status --short
$paths = @(git ls-files --modified --deleted --others --exclude-standard)
$paths.Count
If there are no paths, report the clean worktree and stop.
-
Stage the sweep.
git add -A
If the implementation-start gate blocks normal staging despite an explicit owner request to commit everything, stage the non-ignored path list directly:
$paths = @(git ls-files --modified --deleted --others --exclude-standard)
if ($paths.Count -gt 0) {
git update-index --add --remove -- $paths
}
-
Build changed-path sets for targeted verification.
$python = "groundtruth-kb\.venv\Scripts\python.exe"
$changed = @(git diff --cached --name-only --diff-filter=ACMR)
$py = @($changed | Where-Object { $_ -match '\.py$' })
$tests = @($py | Where-Object {
$_ -like 'groundtruth-kb/tests/*' -or
$_ -like 'platform_tests/*' -or
$_ -like 'tests/*'
})
-
Run required verification before commit.
git diff --cached --check
& $python -m groundtruth_kb secrets scan --staged --redacted --fail-on verified-provider
if ($py.Count -gt 0) {
$env:PYTHONPYCACHEPREFIX=".tmp\pycache"
& $python -m py_compile @py
& $python -m ruff check @py
& $python -m ruff format --check @py
}
if ($tests.Count -gt 0) {
& $python -m pytest @tests -q --tb=short
}
& $python scripts\check_dev_environment_inventory_drift.py --staged --allow-review-evidence
& $python scripts\check_narrative_artifact_evidence.py --staged
Broaden pytest when staged changes touch shared infrastructure, hooks, governance validators, or test discovery logic.
-
Fix expected gate failures and restage only the relevant generated/fixed files.
-
Ruff format drift: run & $python -m ruff format <paths> and restage those paths.
-
Inventory drift: run & $python scripts\collect_dev_environment_inventory.py, stage .groundtruth/inventory/dev-environment-inventory.json and .groundtruth/inventory/dev-environment-inventory.md, then rerun the inventory drift check.
-
Narrative-artifact evidence: generate a packet without --stage, then stage the packet manually:
groundtruth-kb\.venv\Scripts\gt.exe generate-approval-packet `
--kind narrative `
--target <protected-narrative-path> `
--artifact-id <short-kebab-id> `
--action update `
--source-ref "<bridge/verdict/source evidence or owner sweep request>" `
--explicit-change-request "<owner-visible request>" `
--change-reason "<why this narrative file changed>" `
--approval-mode auto `
--changed-by "<harness-role-id>"
git update-index --add -- .groundtruth/formal-artifact-approvals/<packet>.json
& $python scripts\check_narrative_artifact_evidence.py --staged
-
Secret scan finding: do not commit. Report the finding path and wait for owner direction; credential lifecycle is owner-managed.
-
Commit locally.
git commit -m "chore(gtkb): consolidate verified bridge work"
Use a more specific message when the sweep has a clear theme. If a commit hook fails, read the hook output, fix the specific evidence or formatting issue, restage, and retry. Do not bypass commit hooks.
-
Report final state.
git status --short
git log -1 --format="%H%n%s"
Final response should include the commit hash, verification summary, clean/dirty status, and whether a push was performed.