Commit graph

22 commits

Author SHA1 Message Date
sid
19154d8968 dev: backfill task-cmds plan dir + session-inventory note in skill docs
* Brings dev/plans/26174-planctl-task-cmds/{prd,design,tasks,codex-sessions}.md onto main (was on a sibling commit during the merge)
* Adds a session-inventory consumption note to all four planning skill docs
2026-04-26 09:52:49 -06:00
sid
78000b423b docs: log pre-pr-review session for context-tokens feature 2026-04-24 00:28:03 -06:00
sid
46e0459df5 docs(planctl): context-window token awareness INTEGRATION.md section (parent 4.0)
- Threshold band table (70/85/95%), text + JSON output formats (R4.1, R4.2,
  R5.1)
- Copy-paste session-start/session-end hook snippets + planctl_start_ticks
  helper (R7.1, R7.2, R7.3)
- Env var reference (CLAUDE_SESSION_ID, CLAUDE_CODE_MAX_CONTEXT_TOKENS,
  CLAUDE_PROJECT_DIR), optional-hook note, graceful degradation behavior
  (R2.4, R3.3, R7.4)
- Troubleshooting section for common misconfigurations

Parent 4.0 from dev/plans/26174-planctl-context-tokens/tasks.md
2026-04-23 18:54:37 -06:00
sid
89c1400c83 feat(planctl): scripts/jj-hook.sh planctl session tracking (parent 3.0)
- planctl_start_ticks helper: Linux safe /proc/<pid>/stat parse (LastIndex ')'
  + awk field 20); macOS ps -o lstart + date epoch conversion (R6.2, R7.3)
- session-start: validate canonical-UUID session_id, append CLAUDE_SESSION_ID
  to $CLAUDE_ENV_FILE (if set), atomically write /tmp/planctl-sessions/<PPID>
  with UUID + start-stamp via mktemp + mv (R6.2, R7.1, R7.3)
- session-end: rm -f /tmp/planctl-sessions/<PPID> (idempotent) (R7.2, R7.3)
- test-jj-hooks.sh: PID file lifecycle test + non-UUID rejection test (R7.1,
  R7.2)
- Manual smoke: PID file + $CLAUDE_ENV_FILE updates verified

Parent 3.0 from dev/plans/26174-planctl-context-tokens/tasks.md
2026-04-23 18:52:52 -06:00
sid
b02ae7dade feat(planctl): context-window token awareness — wiring (parent 2.0)
* emit.go: emitText/emitJSON take *TokenCtx; jsonSummary extended with *jsonCtxWin (omitempty) for context_window in JSON output
* main.go: ReadTokenCtx() called once at top of run() before subcommand dispatch; threaded through runLint
* main_test.go: golden-fixture harness extended for env.txt + transcript.jsonl staging in temp HOME
* testdata/v2/context-{info,warn,error,normal,no-session,no-limit,json-warn,multi-plan}: 8 new fixtures exercising all bands + shapes

Task 2.0 from dev/plans/26174-planctl-context-tokens/prd.md
2026-04-23 18:36:35 -06:00
sid
935b86b791 feat(planctl): context-window token awareness — core (parent 1.0)
- TokenCtx + Classify + formatTokenCount (R2.2, R3.1-3.5, R4.4)
- ReadTokenCtx orchestrator: env > PID walk > transcript parse (R1.1-1.6, R2.1-2.6)
- parseLastUsage: 10MB scanner, JSONL last-assistant-wins, zero-usage qualifies (R2.1-2.3)
- parsePIDFile: strict two-line layout; rejects partial/corrupted writes (R6.2-6.3)
- resolveViaPIDWalk: 8-hop ancestor walk, liveness + start-stamp check (R1.2, R6.1, R6.3)
- proc_darwin.go (x/sys/unix kinfo_proc) + proc_linux.go (/proc/stat field 22)
- parseStatStartTime: platform-agnostic, handles comm with parens/spaces

Parent 1.0 from dev/plans/26174-planctl-context-tokens/tasks.md
2026-04-23 17:38:37 -06:00
sid
54d32b10e1 wip(claude:f102018b): session end 2026-04-23 17:04:31 -06:00
sid
21f53f9436 docs: multi-agent workspace guidance, session inventory, JJ_AGENT_FEATURE (planned) 2026-04-23 12:50:27 -06:00
sid
30cfa9ffa4 wip(claude:aa2b9173): session end 2026-04-23 11:30:40 -06:00
sid
a988a953a9 dev: planctl context-window token usage PRD 2026-04-23 11:30:40 -06:00
Sid
1a29ff50b2 fix(planctl): paren-aware tag extraction and splitting
Some checks failed
planctl / build-test (1.22, macos-latest) (push) Has been cancelled
planctl / build-test (1.22, ubuntu-latest) (push) Has been cancelled
planctl / build-test (1.22, windows-latest) (push) Has been cancelled
planctl / build-test (stable, macos-latest) (push) Has been cancelled
planctl / build-test (stable, ubuntu-latest) (push) Has been cancelled
planctl / build-test (stable, windows-latest) (push) Has been cancelled
planctl / bench (push) Has been cancelled
Pre-PR codex review found a gap in the R1.1 annotation grammar handling:

* scanTagAfterOpener treated the first '_' after an opener as the
  closing delimiter regardless of paren nesting, so a legitimate
  tag like `_Requirements: R1.1 (foo_bar)_` would incorrectly
  close at the underscore inside the annotation.
* parseTagBody split on every ', ' regardless of paren context, so
  `_Requirements: R1.1 (note, with comma), R2.1_` split into
  three bogus refs.

Both are per-spec: PRD R1.1 defines annotation body as 'arbitrary
non-) characters', which includes _ and ,. The state machine and
the ref-splitter are now paren-depth-aware; regression tests added
for both cases.
2026-04-21 20:42:08 -06:00
Sid
c32ae6c99e feat(planctl): docs + close-out
* README.md: new `## planctl` section after the jj-commitd section —
  description, `go install` command, classification-code list,
  pointer to the plan dir.
* AGENTS.md: bullet under `dev/ workflow` pointing agents at
  `planctl lint` as a pre-codex sanity gate.
* dev/README.md: "Pre-codex planctl lint gate" paragraph in the
  Skill workflow section.
* tasks.md: appended full traceability matrix — one row per PRD
  R-id and one per design D§ id, with the tasks and tests covering
  each. Grep-verifiable against the `// spec:planctl/*` anchors.
* Dogfood pass (task 9.5) against dev/plans/26172-planctl/ flushed
  out real self-violations in the plan docs:
    - Expanded en-dash range tags (`R1.1–R1.7`) to explicit
      comma-separated lists.
    - Dropped comma-containing annotations (`D§0 (D-2, D-5)` →
      `D§0`).
    - Added D§2 / D§3 / D§7 umbrella citations to tasks 5.3 /
      3.1 / 7.7.
    - Applied the design §3.4 bold-prefix EARS exemption to R5.3
      / R5.4 / R5.5 / R5.11 (grammatically valid but non-strict
      EARS) by prepending short bold labels.
    - Updated PRD R5.11 to say `plan-directory basename` instead
      of `relative path from CWD` — resolving a long-standing
      divergence with task 6.4 + design §3.7 + the implementation.
* Final dogfood: `26172-planctl: clean (79 tasks, 45 requirements,
  21 design sections)`.

Parent task 9.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session: 019db302-b8a9-7e53-b1e3-feab4ed7081f (2 rounds).
2026-04-21 20:39:08 -06:00
Sid
3dc1273a7a feat(planctl): CI workflow + perf benchmark
* .forgejo/workflows/planctl.yml: build/test matrix across
  {ubuntu-latest, macos-latest, windows-latest} × {1.22, stable}
  per D-3 / PRD R7.4. Dedicated bench job on ubuntu+stable so
  ns/op numbers stay comparable across runs. Path filters scope
  CI to planctl-adjacent changes only.
* cmd/planctl/bench_test.go: Benchmark_Lint_BigPlan times the full
  lint pipeline on testdata/perf/big-plan/. Local M4 Pro: ~720µs,
  two orders of magnitude under M3's 100ms target.
* TestLint_BigPlan_SoftCeiling logs (via direct os.Stderr write —
  not t.Logf, which is suppressed without -v) when wall time
  exceeds 100ms. Soft check per task 8.3 — CI runner variance
  means a hard assert would be flaky; the visible stderr line is
  the regression signal.
* Windows line-ending handling already landed in parent-7's
  harness (CRLF → LF normalisation on both sides of golden
  compare), so 8.4 is satisfied by construction.

Parent task 8.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session: 019db2f3-2f80-7fc0-b7bb-9e1f677f978e (2 rounds).
2026-04-21 20:14:06 -06:00
Sid
3bc838f86e feat(planctl): end-to-end fixtures + golden-file test harness
* main_test.go: TestGoldenFixtures sweeps
  testdata/{clean,dirty,inline-code-exclusion,multi}/**; compares
  stdout against expected.golden and exit against expected.exit.
  --update flag regenerates sidecars. Per-fixture invocation
  overrides via optional args.txt (with FIXTURE substitution) and
  cwd-rel.txt. Handles flat-layout fixtures (prd.md at class root)
  and multi-plan layouts (dev/plans/ subtree).
* CRLF normalisation on both sides of the golden compare per
  design §7.4's Windows-CI contract.
* Clean fixtures: simple-plan (prd+tasks), with-design-plan
  (prd+design+tasks, full coverage).
* Dirty single-class fixtures: orphan-requirement, orphan-design,
  uncovered-requirement, uncovered-design, tag-syntax, tag-unclosed,
  ears-violation, missing-closeout-file. Each isolates one
  diagnostic class; ears-violation-strict and ears-violation-no-ears
  share the plan via args.txt overrides.
* tag-unclosed-with-recovery fixture: codex R1 regression guard for
  design §3.3 recovery — the recovery line uniquely cites D§2.2 so
  broken recovery would surface as uncovered-design.
* inline-code-exclusion fixture: decoys cite an undeclared R9.9 so
  any masking leak would trip orphan-requirement.
* Multi-plan fixtures: case-c (repo root with dev/plans/{alpha,beta,
  archive/retired}/, Case C upward walk + archive skip); case-b
  (deeply-nested cwd inside a plan dir, Case B resolution).
* Perf fixture testdata/perf/big-plan/ — synthetic 5-file plan
  (~90 KB) with 36 R-ids, 18 D§ sections, 72 tasks (all covered).
  Parent 8 wires Benchmark_Lint_BigPlan.

Parent task 7.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session: 019db2ed-d621-7bc0-90f2-05feb5e2fe50 (2 rounds).
2026-04-21 20:06:26 -06:00
Sid
5a14a1b413 feat(planctl): emit — text and JSON formatters
* emit.go (new): PlanResult (moved from main.go), emitText,
  emitJSON, shared severityLabel / countSeverities helpers.
* emitText: R5.10 single-plan branch (diagnostics or R5.3 clean-
  summary, no headers / aggregate) + R5.9 multi-plan branch
  (`=== <basename> ===` per-plan header, blank-line separator,
  aggregate "N plans linted, E errors, W warnings" with always-
  plural labels).
* emitJSON: jsonl format per R5.11 with struct-tag-pinned field
  order (plan_dir, path, line, severity, code, message), terminal
  {"summary":{"plans":N,"errors":E,"warnings":W}} object,
  SetEscapeHTML(false) so ampersands / `<` stay raw.
* Empty Path (directory-level diagnostics: missing-prd,
  missing-closeout-file) renders with the plan-dir basename in
  text mode; in JSON the shape is uniform with `path=""` and
  plan_dir carrying the basename.
* main.go: runLint selects emitText or emitJSON based on
  flags.format; placeholder emitter removed.
* emit_test.go: single-plan clean, single-plan dirty, multi-plan
  text, multi-plan JSONL validity, clean-plan JSON (summary-only),
  --strict promoting warnings → exit 1, clean → 0, errors → 1.

Parent task 6.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session: 019db2d1-e9ae-7fc0-9b8b-270db5f0b2a3 (1 round, approved on R1).
2026-04-21 19:36:16 -06:00
Sid
4d865dfd82 feat(planctl): plan-dir discovery + CLI dispatch wiring
* main.go: resolvePlans implementing the R5.1 / design §3.5 decision
  tree — Case A (explicit path stat) and a unified upward walk for
  Cases B (cwd inside plan dir) and C (cwd ancestor has dev/plans/)
  with archive/ filter and lex sort; Case D returns the 3-option
  error. No downward WalkDir.
* Hand-rolled parseLintFlags accepting --format={text,json},
  --strict, --no-ears, --color={auto,always,never} (no-op per D-1),
  both --flag=value and --flag value forms. Unknown flag → error.
* runLint orchestrator: resolvePlans → loadPlan (reads prd/design/
  tasks via Scan + os.Stat for close-out markers) → lintPlan
  (BuildIndex + 4 rule checkers, missing-PRD short-circuit per R3.2,
  PlanDir backfill, sortDiagnostics). Placeholder text emitter —
  task 6 replaces with the full emitText/emitJSON from design §3.7.
* computeExit returns 0/1 per R5.4/R5.5; 2 is reserved for outer
  discovery/I-O failures (runLint returns 2 directly on those paths).
* main_test.go: TestResolvePlans covers Cases A (valid + invalid), B
  (deeply-nested cwd), C (3 plans + archive filter + lex sort), D
  (no ancestor); TestParseLintFlags covers every documented flag
  plus unknown-flag rejection and last-value-wins. The prior stub
  test TestRun_LintStub was replaced with TestRun_LintMissingPRD —
  the stub assertion no longer holds now that runLint actually runs
  the pipeline. Output-format assertions may need revision when
  task 6.6 lands per tasks.md 5.6 note.

Parent task 5.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session: 019db2ca-721d-7b11-8760-639b2588b114 (1 round, approved on R1).
2026-04-21 19:27:18 -06:00
Sid
77e1ff19b6 feat(planctl): lint rules — tag-syntax, cross-reference, file-presence, EARS
* lint.go: Severity / Code (full set) / Diagnostic types migrated
  here from their temporary home in index.go. Code constants form the
  grep-stable public contract per design §4.
* checkTagSyntax (passthrough over idx.MalformedTags).
* checkCrossRef with four diagnostic classes (orphan-requirement,
  orphan-design, uncovered-requirement, uncovered-design), R2.8
  hasDesign gate, R2.9 infra-sentinel exemption, and sorted-id emission
  for stable uncovered-* order.
* checkCloseoutFiles gated on R3.4 fully-closed-out definition
  (at-least-one + all-checked); emits Line=0 diagnostics with empty
  Path for the emitter to substitute plan-dir.
* newMissingPRDResult: R3.1/R3.2 fatal short-circuit.
* checkEars with the five design §3.4 regex patterns, narrow
  `^\*\*[^*]+\*\*` bold-prefix exemption, and --no-ears R4.4 skip.
* sortDiagnostics uses sort.SliceStable with (Path, Line, Code,
  Message) tie-breakers so output is deterministic run-to-run per
  PRD §6 even when two diagnostics share the first three keys
  (missing-closeout-file Line=0 pair).
* Position extended with a Text field populated at extraction time
  so checkEars keeps its literal `(idx, skip)` signature without
  passing a second *ScanResult.
* lint_test.go: one subtest per checker plus sort stability
  regression.

Parent task 4.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session: 019db2b8-21c8-7d61-85d6-1da5c18d8033 (2 rounds).
2026-04-21 19:11:29 -06:00
Sid
3f63d24c41 feat(planctl): indexer — R-id / D§ id / tag / task-line extraction
* index.go types: Plan, TagRef, Kind (+ KindRequirements/KindDesign),
  TaskLine, Index, Position; Diagnostic / Severity / Code stubs parked
  here until task 4.1 moves them to lint.go.
* Grammar validators: isValidReqID / isValidDesID / isInfraRef backed
  by compile-time regex patterns; infra sentinel handled transparently.
* Tag state machine (extractTagsFromLine) with the design §3.3
  "Tag-unclosed recovery" semantics — forward scan that treats an inner
  `_Requirements:` / `_Design:` opener as a recovery signal, so
  `_Requirements: R3 _Design: D§2_` produces one tag-unclosed + one
  well-formed D§2 extraction. extractTags composes mask → state
  machine → body-parse.
* PRD R-id extraction via ast.ListItem walk (AST-primary) with regex
  fallback for malformed lists.
* Design D§ extraction via ast.Heading level 2-4 walk. Pattern widened
  to tolerate the `## 0. Scope` period-space convention used by
  level-2 headings in the in-repo design.md.
* Task-line extraction via east.TaskCheckBox walk; Indent from raw
  line leading spaces; InCode[] exclusion per R3.3.
* BuildIndex orchestrator + extractTaskTags helper.
* Table-driven index_test.go covering all 10 cases from sub-task 3.9;
  assertDiagsExact fails on extras so in-fence / inline-code-span
  exclusion and recovery fixtures are tight.
* 39 `// spec:planctl/*` traceability anchors across index.go.

Parent task 3.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session: 019db26e-629f-7f51-afe2-28dbb1d14ba6 (3 rounds).
2026-04-21 17:55:41 -06:00
Sid
aa73e2f727 feat(planctl): scanner — goldmark-backed InCode + LineMask classification
* cmd/planctl/scan.go: Scan() / scanBytes() construct a goldmark parser with
  the TaskList extension; AST walk populates InCode[] for CodeBlock /
  FencedCodeBlock / HTMLBlock and LineMask[] for inline CodeSpan nodes with
  +/-1 byte extension to cover the surrounding backticks.
* offsetToLineCol folds '\n' bytes into the preceding line so block segment
  Stop-1 maps correctly — a subtle off-by-one that tripped the closing fence
  and trailing blank-line tests before the fix landed.
* cmd/planctl/scan_test.go: 7 test functions covering fenced / indented /
  HTML blocks, inline code spans (substring + exact-range), nested emphasis
  around code, mixed features in one document, EOF-in-fenced-block, and
  trailing-newline splitLines variations.
* go.mod: goldmark promoted from indirect to direct (scan.go imports it).

Parent task 2.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session 019db23c-6c44-7d00-b3a4-6653882f0964 (2 rounds).
2026-04-21 17:02:59 -06:00
Sid
a7a79eab65 feat(planctl): project skeleton — cmd/planctl, goldmark dep, subcommand dispatch
* cmd/planctl/main.go: run() entry, --help (usage + classification codes),
  --version, lint subcommand stub, R6.1 sentinel for v2-reserved subcommands
  (list/next/complete/new-plan), R5.8 exit-2 for unknown subcommand/flag.
* go.mod: require github.com/yuin/goldmark v1.8.2 (will be promoted from
  indirect to direct once the scanner imports it in parent task 2).
* cmd/planctl/main_test.go: 8 subtests covering help/version/v2-reserved/
  unknown/no-args/lint-stub with // spec:planctl/... tags mirroring production.
* .gitignore: add planctl binary so stray go-build artifacts don't trip jj's
  snapshot size limit.

Parent task 1.0 from dev/plans/26172-planctl/tasks.md.
Codex code-review session 019db22d-7978-7e70-ae87-5242d1eedc25 (3 rounds).
2026-04-21 17:02:59 -06:00
Sid
7467ef65f8 feat(planctl): initialize feature branch + migrate plan dir
Planner→implementer handoff per dev/README.md: move the 26172-planctl plan dir (prd, design, tasks, codex-sessions, handoff) from the shared plans commit into this feature branch via jj squash, so tasks.md is visible in the branch's history for /process-task-list to consume.

Parent task 0.0 from dev/plans/26172-planctl/tasks.md.
2026-04-21 17:02:59 -06:00
Sid
ed72ab9d5c dev: add spec-driven workflow, agent skills, and AGENTS.md convention 2026-04-19 23:37:12 -06:00