Skip to content

feat(adapter): pointer file default_task_id and actionable auto-fallback toast#23

Merged
albertgwo merged 2 commits into
mainfrom
pointer-default-task-id
May 9, 2026
Merged

feat(adapter): pointer file default_task_id and actionable auto-fallback toast#23
albertgwo merged 2 commits into
mainfrom
pointer-default-task-id

Conversation

@albertgwo
Copy link
Copy Markdown
Contributor

Purpose

Give non-git, ambient multi-agent projects a one-line way to declare a shared task id, and make the auto-fallback toast tell the operator the cheapest fix. Two pi sessions in the same scratch directory now attribute to one task without per-session env wiring.

Summary of changes

  • Pointer schema: internal/config adds an optional default_task_id field to .agent-ledger.toml.
  • Kernel CLI: new read-only agent-ledger pointer show [--json] command at internal/cli/pointer.go, with the existing init learning a --default-task-id flag that carries forward across reruns.
  • Doctor: internal/doctor surfaces default_task_id and has_default_task in the pointer check details.
  • Adapter bootstrap: adapters/shared/session-bootstrap.sh inserts a pointer step (source=pointer) between detached HEAD and the auto fallback, and emits AGENT_LEDGER_TASK_AUTO_REASON (not_in_git_repo, git_no_head, pointer_lacks_default) when the auto path fires.
  • Pi extension: adapters/pi/agent-ledger.ts adds buildAutoFallbackToast that expands the reason token into actionable guidance.
  • Audit marker: adapters/shared/marker.{sh,js} adds pointer to the harness-derived source set so reviewers can group claims by source.
  • Docs: docs/adapters.md and SPEC.md §8.2 describe the new source and the example pointer; CHANGELOG entry in Unreleased.

Changes to review

  • Resolution chain ordering in session-bootstrap.sh: pointer is step 6, between detached HEAD and the auto fallback. Confirm this priority matches the intent (explicit env still wins, harness-derived git signals still win).
  • Pointer detection looks at the cwd only; no upward search. Documented in docs/adapters.md. Decide whether to track upward search as a follow-up.
  • init --write-pointer carries an existing default_task_id forward when --default-task-id is not supplied, so reruns do not silently erase the value (internal/cli/init.go).
  • New TS export buildAutoFallbackToast in adapters/pi/agent-ledger.ts: confirm the reason-to-hint map covers every token the bootstrap can emit and that unknown tokens degrade to a (reason=...) form.
  • Adapter tests in adapters/tests/run.sh rely on a new AGENT_LEDGER_STUB_POINTER_JSON env override on the kernel stub. Confirm the stub additions stay scoped to the new cases and do not leak into earlier tests.

Comment thread agent-ledger/adapters/shared/session-bootstrap.sh Outdated
Comment thread agent-ledger/adapters/shared/session-bootstrap.sh
Comment thread agent-ledger/internal/cli/init.go Outdated
Comment thread agent-ledger/adapters/pi/agent-ledger.ts
Comment thread agent-ledger/internal/cli/init.go
Comment thread agent-ledger/internal/cli/pointer.go Outdated
Address PR #23 review feedback.

- session-bootstrap.sh: capture exit code and stderr from `agent-ledger
  pointer show --json` separately. A malformed `.agent-ledger.toml` no
  longer falls through to a misleading not_in_git_repo / git_no_head
  hint; the new AGENT_LEDGER_TASK_AUTO_REASON=pointer_unreadable surfaces
  the kernel error and points the operator at the broken file.
- session-bootstrap.sh: when neither python3 nor node is on PATH, emit a
  clear stderr warning and AUTO_REASON=pointer_parser_unavailable rather
  than silently ignoring a declared default_task_id.
- internal/cli/init.go: move the `--default-task-id requires
  --write-pointer` usage check above storage.EnsureLayout so a misuse
  no longer leaves a half-initialized ledger directory on disk.
- internal/cli/pointer.go: reword the pointerShowReport doc comment so
  future consumers do not infer existence from field absence; the
  authoritative signal is `present`.
- adapters/shared/auto-fallback-toast.js (new): node-importable mirror
  of the TS extension's AUTO_REASON_HINTS map and buildAutoFallbackToast
  helper, used by the new adapter test suite.
- adapters/tests/auto-fallback-toast.test.mjs (new): covers known
  reason, unknown reason, null reason, null taskId, and exhaustive
  coverage of every reason token the bootstrap can emit.
- adapters/tests/run.sh: byte-level parity check between the inline TS
  AUTO_REASON_HINTS and the shared JS mirror so drift is caught
  statically; new pointer_unreadable regression test using
  AGENT_LEDGER_STUB_POINTER_FAIL.
- internal/cli/init_test.go (new): tests for the side-effect-free
  usage validation, default_task_id carry-forward on rerun without
  --default-task-id, and explicit override.
- CHANGELOG: document the new auto-reason tokens and fixes.
@albertgwo albertgwo merged commit 387cbcb into main May 9, 2026
7 checks passed
@albertgwo albertgwo deleted the pointer-default-task-id branch May 9, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant