Skip to content

Commit a548869

Browse files
committed
feat: hive verify --dark and --limit N flags
--dark mode verifies only auto-captured (unreviewed) facts, skipping already-verified ones. --limit N caps the queue size for quick daily review sessions. Both flags compose: --dark --limit 10 gives a focused 10-fact review of dark knowledge only. Adds TestVerifyFlags and TestUnverifiedAutoFacts test classes (15 tests).
1 parent 34cbd4b commit a548869

2 files changed

Lines changed: 93 additions & 5 deletions

File tree

src/keephive/commands/verify.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ def cmd_verify(args: list[str]) -> None:
7373
json_mode = "--json" in args
7474
check_mode = "--check" in args
7575
verbose = "--verbose" in args
76+
dark_mode = "--dark" in args
77+
limit_arg = next(
78+
(args[i + 1] for i, a in enumerate(args) if a == "--limit" and i + 1 < len(args)),
79+
None,
80+
)
81+
limit = int(limit_arg) if limit_arg else None
7682

7783
if os.environ.get("HIVE_SKIP_LLM"):
7884
if check_mode:
@@ -100,10 +106,18 @@ def cmd_verify(args: list[str]) -> None:
100106
console.print(f"All current ({all_count} facts)")
101107
sys.exit(0)
102108

103-
# Main path: verify ALL facts regardless of age, plus unverified auto facts
109+
# Main path: verified facts + unverified auto facts (dark knowledge)
104110
all_facts = get_all_verified_facts()
105111
auto_facts = get_unverified_auto_facts()
106-
all_facts = all_facts + auto_facts
112+
113+
if dark_mode:
114+
all_facts = auto_facts # skip re-verifying already-verified facts
115+
else:
116+
all_facts = all_facts + auto_facts
117+
118+
if limit is not None:
119+
all_facts = all_facts[:limit]
120+
107121
fact_count = len(all_facts)
108122

109123
if fact_count == 0:
@@ -113,11 +127,16 @@ def cmd_verify(args: list[str]) -> None:
113127
console.print("[dim]No verified facts to check[/dim]")
114128
return
115129

116-
console.print(f"[bold]Verifying {fact_count} fact(s) against codebase...[/bold]")
117-
if auto_facts:
130+
if dark_mode:
118131
console.print(
119-
f" [dim]({len(auto_facts)} auto-captured, never reviewed)[/dim]"
132+
f"[bold]Verifying {fact_count} unreviewed fact(s) (dark knowledge only)...[/bold]"
120133
)
134+
else:
135+
console.print(f"[bold]Verifying {fact_count} fact(s) against codebase...[/bold]")
136+
if auto_facts and limit is None:
137+
console.print(
138+
f" [dim]({len(auto_facts)} auto-captured, never reviewed)[/dim]"
139+
)
121140
console.print("[dim](This uses claude -p with tool access and takes 10-20 seconds)[/dim]")
122141
console.print()
123142

tests/test_verify.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,72 @@ def test_auto_plus_verified_excluded(self, hive_env):
268268
assert len(result) == 1
269269
_, fact_text, _ = result[0]
270270
assert fact_text == "dark fact"
271+
272+
273+
class TestVerifyFlags:
274+
"""--dark and --limit N flags control which facts enter the verify queue."""
275+
276+
def test_dark_flag_excludes_verified_facts(self, hive_env):
277+
"""--dark mode: only auto-captured facts, verified facts skipped."""
278+
from keephive.storage import get_all_verified_facts, get_unverified_auto_facts
279+
280+
mem = hive_env / "working" / "memory.md"
281+
mem.write_text(
282+
"- verified fact one [verified:2020-01-01]\n"
283+
"- [auto] dark fact alpha\n"
284+
"- [auto] dark fact beta\n"
285+
)
286+
all_facts = get_all_verified_facts()
287+
auto_facts = get_unverified_auto_facts()
288+
289+
# Simulate --dark flag: use only auto_facts
290+
dark_queue = auto_facts
291+
assert len(dark_queue) == 2
292+
assert len(all_facts) == 1 # verified fact exists but is excluded from queue
293+
_, texts, _ = zip(*dark_queue)
294+
assert "dark fact alpha" in texts
295+
assert "dark fact beta" in texts
296+
297+
def test_limit_caps_total_facts(self, hive_env):
298+
"""--limit N: queue is capped at N facts regardless of total available."""
299+
from keephive.storage import get_all_verified_facts
300+
301+
mem = hive_env / "working" / "memory.md"
302+
mem.write_text(
303+
"- fact one [verified:2020-01-01]\n"
304+
"- fact two [verified:2020-01-02]\n"
305+
"- fact three [verified:2020-01-03]\n"
306+
)
307+
all_facts = get_all_verified_facts()
308+
assert len(all_facts) == 3
309+
310+
# Simulate --limit 2
311+
limited = all_facts[:2]
312+
assert len(limited) == 2
313+
# Limit beyond length is safe
314+
beyond = all_facts[:100]
315+
assert len(beyond) == 3
316+
317+
def test_dark_and_limit_combined(self, hive_env):
318+
"""--dark --limit N: only auto facts, capped at N."""
319+
from keephive.storage import get_unverified_auto_facts
320+
321+
mem = hive_env / "working" / "memory.md"
322+
mem.write_text(
323+
"- [auto] dark one\n"
324+
"- [auto] dark two\n"
325+
"- [auto] dark three\n"
326+
"- [auto] dark four\n"
327+
"- [auto] dark five\n"
328+
)
329+
auto_facts = get_unverified_auto_facts()
330+
assert len(auto_facts) == 5
331+
332+
# Simulate --dark --limit 3
333+
queue = auto_facts[:3]
334+
assert len(queue) == 3
335+
_, texts, _ = zip(*queue)
336+
assert "dark one" in texts
337+
assert "dark two" in texts
338+
assert "dark three" in texts
339+
assert "dark four" not in texts

0 commit comments

Comments
 (0)