Skip to content

Foundation: Git working tree as PersonaBot Memory #115

Closed

Description

@DoodleBears

2026-09-30 closeout

The Git working-tree tracer, Channel Memory browsing/history, and external-change Inbox delivery were delivered in earlier slices (#297, #259, #473). PR #519 completed the final two gates:

  1. Human Memory commands use the Host-owned local-human identity already used by Channel membership. DSH authenticates access to the Host but does not distinguish people sharing one browser credential.
  2. ADR-0097 records trustworthy observation/command context and explicit, confirmed recovery across reset, merge, branch movement, and dirty working trees.

Focused integration tests, typecheck, lint, build, full CI, CodeRabbit review, a real isolated DSH/LLM reply, browser E2E, and Human visual QA passed. PR #519 is merged; #115 is closed.

Part of #114. Target milestone: v1.0.

Decision (2026-09-25)

The checked-out Git working tree is the PersonaBot's current Memory. Ordinary files, including code and binary files, are available as soon as the worktree changes. Native Git may fetch, merge, reset, and switch branches. Neither the Bot nor the Human must call an extra "accept" action. BotHarness's recorded HEAD/actor/cause is an audit and recovery checkpoint, not an admission gate. See ADR-0068.

The Orchestrator uses native file, search, Shell, and Git capabilities in its Memory Repository. It decides whether an external repository should be merged, replace current history, or be cloned elsewhere from the Human's task; when ambiguous, it asks the Human through native DSH Ask Question. Initial PersonaBot creation may import a Git URL through #298; an existing Bot still uses native Git for repository integration. There is no model-facing Memory CRUD replacement tool.

Git working-tree tracer (file and UI path delivered; audit pending)

  1. Create a PersonaBot with a real Git Memory Repository and fixed Orchestrator cwd.
  2. Use native Git to fetch an unrelated repository with code, binary files, branches, and a merge commit.
  3. Show the checked-out files immediately in Channel Memory, with bounded text preview and a binary-file indicator; Git graph shows all local branches and reachable commits.
  4. In the same Orchestrator Session, switch to a local branch and read its actual files. Git decides whether working changes permit the switch; conflicts are reported without discarding work.
  5. After restart, show the same branch, files, and graph. Record a HEAD observation without staging or committing; comprehensive operation audit and recovery remain below.
  6. Run a real DSH/LLM interaction and stop for step-by-step Human QA before expanding sibling cases.

Boundaries

  • Memory Service owns repository identity/lifecycle, trusted Session ownership, UI queries, and audit/recovery checkpoints. Git and its current worktree own files, branch topology, and history.
  • File queries refuse .git control paths and escapes through symlinks. Text preview has a bound; binary content is retained by Git and available to native tools, but is not edited as text in Channel.
  • Human text saves use an expected HEAD and an explicit Git commit. Legacy structured Markdown writing keeps its own narrower contract.
  • There is no automatic git add -A/commit of dirty files during observation, no per-branch admission gate, and no required repair for a normal uncommitted edit.
  • Session-frozen Persona text is unchanged within the same Session after a branch switch (ADR-0060).

Acceptance criteria

Out of scope

Model-visible Memory CRUD tools; initial creation import UI (tracked in #298); vector/RAG; a second content authority; automatically overwriting or merging existing Memory.

Activity

  1. added this to the v1.0 milestone on Sep 20, 2026
  2. self-assigned this
    on Sep 21, 2026
  3. DoodleBears commented on Sep 21, 2026

    @DoodleBears
    ContributorAuthor

    Slice 1(Host foundation)已提交:PR #173

    已落地:

    • 仓库 identity:新增 memory/repository.ts(ensureMemoryRepository / inspectMemoryRepository)—— mkdir + git init -b main + identity + .gitattributes;只在新仓库或无 HEAD 时做 seed commit;重新打开绝不自动提交(修掉了原来 dirty 树被当成 "Initialize memory repository" 提交的 bug)。
    • 创建即 provision:registry 增加 initializeMemory 钩子;失败返回 memory-unavailable(bridge 同码)且不写 bot record,重试幂等。
    • Orchestrator cwd = Memory Repository:runtime/adapter 共用 orchestratorCwd(bot),ownership 的 cwdReference 记录仓库路径;Assignment 暂时保留 runtime workspace 直到 Workspace Grants: folder access UI and enforced PersonaBot file boundary #116。
    • 解析改为 ownership:MemoryService.storeForSession 走 SessionOwnership.resolve;unowned session 或仓库未就绪 → 返回 undefined(fail closed),不再 cwd → findByWorkspace 反推。
    • 移除模型可见 tools:删除 memory/tools.ts 与 4 个工具注册;developer reference 现在发布空 tools 列表。

    本票剩余(后续 slice):

    1. accepted Memory Commit 边界:validation/reconciliation、actor/cause/head、accepted history/query(含 DB 记录与 post-turn reconcile 接线);
    2. pin metadata + Human-configurable budget + context preflight fail-closed;
    3. DM-only Memory surface(Channel sidebar entry:file list/read、一次 Human edit/save、accepted commit list 与 diff)——即 tracer 的 Human 验收步骤 5。

    证据:全量 555 passed(新增 repository lifecycle 4 项、registry fail-closed、ownership 解析、跨 session 服务路径;DM turn E2E 断言 Orchestrator cwdReference 为仓库路径);lint/typecheck/format/changelog/build 全绿。

  4. added a commit that references this issue on Sep 21, 2026
  5. DoodleBears commented on Sep 21, 2026

    @DoodleBears
    ContributorAuthor

    Tracer 计划(按 tracer-bullet 概念重排)+ TB2 已就绪

    不需要等 memory 功能全做完才有可验收切片。按最小端到端路径拆:

    • TB2(现在可验,只需模型 key):DM 让 bot「记住一件事」→ Orchestrator(cwd 已是 Memory Repository)用普通文件能力写 Markdown → Human 在 bots/<slug>/memory/ 与 git status 看到 provisional 文件。不需要 surface、不需要 accepted commit。
    • TB3:post-turn reconcile 把 provisional 变更验证并接受为 Memory Commit(actor/cause/head 入库)+ accepted history/diff 读取。
    • TB4:Channel sidebar 的「记忆」entry(file list/read + 一次 Human edit/save,走同一 accepted 边界)。
    • TB5:pin metadata + Human-configurable budget + context preflight fail-closed。

    TB2 的无-LLM 前置证据(真实 Host,DSH_HOME=~/.dsh-bh115,端口 3083,main 7415d9a):

    • 创建 PersonaBot 后磁盘上是真实 Git 仓库:bots/<slug>/memory/{.git,.gitattributes},seed commit 163f4ef Initialize memory repository;
    • 发送 DM(无 key,turn 失败为 retryable)后,ownership 行为 root_role=orchestrator、cwd_reference=<…>/bots/<slug>/memory —— 证明 Orchestrator cwd 已指向 Memory Repository;
    • channelSend 6ms 返回(Tracer: 发送解耦——Channel 消息提交后立即返回,Bot Inbox 异步消化 #140 语义不变)。

    运行真实 LLM 的 TB2 只差一步:在 3083 的 Web UI Settings 里配置模型 + API key(credentials 走 DSH credentials service,不进 repo)。之后 DM「记住:Acme 决定 Q4 续约。」,检查 ~/.dsh-bh115/botharness/bots/<slug>/memory/ 是否出现 LLM 写入的 Markdown(git status 显示 provisional)。

  6. DoodleBears commented on Sep 21, 2026

    @DoodleBears
    ContributorAuthor

    TB2 通过(真实 LLM,端到端) —— 修复见 PR #176

    真实 LLM(隔离实例 3085,key 来自机器级 secret)发出的 DM「请把这件事记到你的记忆里:Acme 决定 Q4 续约」的结果:

    • Orchestrator 的 request header 现在广告 31 个工具(bash / read / write / edit / glob / grep / web_search … + BotHarness 的 4 个),并且自行写入记忆仓库(没有委托 Assignment,符合「不必然委托」)。
    • 产出:facts/acme.md(含「日期 | 事实 | 来源」表格)+ 更新 MEMORY.md 索引。
    • 它自己用 bash 里的 git 提交了(410f4dc memory: Acme 决定 Q4 续约),并在 Channel 回复里给出两个路径与 commit hash,还主动说明「只记录了决定续约,合同金额/期限未记录」。
    • git status 干净,git log 两条(seed commit + 记忆提交)。

    根因与修法(PR #176):没有 agent preset 的 session "resolves against the empty global layer" —— 只有 setup 里注册的 4 个工具。两个坑:

    1. 必须在 agent factory 的 setup 里调用 agentPresets.mount();只传 meta.agentPreset 只会把名字记进 session header,不装配工具。
    2. roster 必须惰性解析:apply 时 ctx.get 拿到的可能是尚未挂载的服务,第一次修复因此仍然只有 4 个工具。

    下一步(TB3):现在 bot 自己发的是 raw git commit(没有 actor/cause trailer、未进 accepted history)—— 这正是 #115 的 accepted Memory Commit 边界要接管的:post-turn reconcile 验证 provisional 变更并接受为 Memory Commit(记录 actor/cause/head),之后 surface 只展示 accepted lineage。

  7. DoodleBears commented on Sep 21, 2026

    @DoodleBears
    ContributorAuthor

    Prompt 行为矩阵(真实 LLM:deepseek-official/deepseek-flash,reasoningEffort=high,同一 bot 连续 8 条 DM)

    # Prompt 委托 Assignment 工具 结果
    1 「你好,用一句话介绍你自己」 0 0→0 channel_send 直答 ✓
    2 「1+1 等于几?」 0 0→0 channel_send 直答「2」✓
    3 「你记得关于 Acme 的事吗?」 0 0→0 read, channel_send 读仓库 + 回答事实与出处 ✓
    4 「记住:Beta 公司本周五要回访」 0 0→0 bash, write, read, edit, channel_send 写 facts/beta.md + MEMORY.md 并自行 commit ✓
    5 独立调研(web 查发布流程 + 写 research/release-flow.md) 1 0→1 web_fetch, create_assignment, bash, glob, grep, write, read, edit 委托 1 个 Assignment(completed),Orchestrator 再用一手证据复核并提交 9e02370;source event 最终停在 needs-repair(产出与回复都成功,turn 层面有异常)
    6 两件小文档 +「可以并行」 0 (1→1) bash, present, write, read, edit, channel_send 串行直做,两份文件都产出 ✓(模型判断不值得开并行会话)
    7 「不要创建 Assignment,只回复『收到』」 0 1→1 channel_send 「收到」,遵从 ✓
    8 大任务(扫描全部 md 写 notes/index.md,「可以开 Assignment」) 0 1→1 glob, bash, write, read, edit, present, channel_send 直做 + 提交 3cb6c6d ✓(判断无需独立 cwd)

    结论

    1. 新 prompt 在 flash 模型上表现保守且合理:8 条里只有 1 次委托,且是唯一真正需要外部调研的任务;记忆读写、直答、小文档全部自己完成。
    2. 「用户明说可以并行」并没有触发并行委托(模型选了串行直做,成本更低)。若要该场景真正并行,需要在 prompt 里加更硬的 cue(例如「用户要求并行/独立推进时,每条独立线各开一个 Assignment」),或接受"由模型自行判断"。
    3. 发现一个 turn 可靠性问题:第 5 条在委托后 source event 落到 needs-repair,尽管 Assignment completed、Orchestrator 也写文件并回复。这会污染 Human Inbox 的 attention 状态,建议单独诊断(长 turn / Assignment 等待 / 工具错误后的状态机)。
    4. 三次记忆写入(410f4dc/9e02370/3cb6c6d)都是 bot 自己发的 raw git commit(无 actor/cause、未进 accepted history)——正是 TB3(accepted Memory Commit 边界)要接管的部分。
  8. 22 remaining items

  9. DoodleBears commented on Sep 25, 2026

    @DoodleBears
    ContributorAuthor

    2026-09-25 decision update — Git working tree is current Memory

    Human clarified that a PersonaBot Memory Repository should behave like a normal Git repository. The checked-out working-tree files are the Bot's current Memory immediately, including code and binary files; native Git may fetch, clone, merge, reset, and switch branches as directed. There is no additional per-branch or per-commit "acceptance" step before the Bot may read current files. Git itself determines which paths and objects it can store. BotHarness continues to enforce Session ownership and safe filesystem access, and records operation audit/recovery checkpoints without making that ledger a second source of truth for current Memory.

    The Bot chooses how to reconcile an external repository with existing Memory from the Human's task; when the strategy is ambiguous, it uses native DSH Ask Question. BotHarness does not add an import UI or replace native Git tools. This supersedes this issue's current Markdown-only, linear-history, accepted-commit authority requirements; the issue body and ADR/architecture will be updated with the implementation. First tracer: native Git changes the repo, the same Orchestrator Session reads the new working tree, and the Channel Memory surface shows the current files/branch/graph after refresh.

  10. changed the title [-]Foundation: Memory Repository / Memory Service / accepted Memory Commit[/-] [+]Foundation: Git working tree as PersonaBot Memory[/+] on Sep 25, 2026
  11. DoodleBears commented on Sep 25, 2026

    @DoodleBears
    ContributorAuthor

    Agent work outcome — Git working tree tracer

    • Agent: Codex
    • Task: codex/local/01a0cde3-1621-7382-96a1-852758cedfc0 (not a DSH Session)
    • State: completed for this tracer; Foundation: Git working tree as PersonaBot Memory #115 remains open
    • PR: #297, merged into main as 680ad04.
    • Delivered: current Git working tree is Memory, including uncommitted code and binary files; branch graph and file preview follow the checked-out worktree without an admission step. Initial Git URL creation arrived through Create PersonaBot from a Git Memory repository (HTTPS or SSH) #298/feat(memory): create PersonaBots from Git repositories #301.
    • Verification: 966 tests, typecheck, lint, build, real DSH/LLM native read of uncommitted notes.ts, Host restart, and Human QA of file/binary preview, branch switch, and refresh all passed.
    • Remaining: individual authenticated Human audit identity and explicit recovery/audit behavior under reset, merge, branch movement, and dirty working trees. DSH RC2's Remote invocation exposes a Peer ID but does not itself attest who the Human is; this must not be stored as a claimed Human identity.
  12. removed
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Sep 29, 2026
  13. DoodleBears commented on Sep 29, 2026

    @DoodleBears
    ContributorAuthor

    Agent work claim

    • Agent: Codex
    • Task: codex/local/01a0e86b-16ab-7a01-baf9-e555eec3ea62 (not a DSH Session)
    • Issue scope: Complete Foundation: Git working tree as PersonaBot Memory #115's remaining individual Human audit identity and trustworthy Memory operation audit/recovery for reset, merge, branch movement, and dirty worktrees, with real DSH and Human QA.
    • Branch: codex/115-memory-audit-recovery
    • Started: 2026-09-29 16:08 UTC
    • State: active
  14. added
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Sep 29, 2026
  15. DoodleBears commented on Sep 29, 2026

    @DoodleBears
    ContributorAuthor

    Agent work outcome — Memory audit and recovery closeout

    • Agent: Codex
    • Task: codex/local/01a0e86b-16ab-7a01-baf9-e555eec3ea62 (not a DSH Session)
    • State: completed
    • PR: #519, merged as 0a8d2f5
    • Delivered: Host-owned local Human audit identity, honest observation/command context, retained Git recovery checkpoints, confirmed restore with full pre-restore archive, and AX key sharing across WSL/Windows development homes (ADR-0097).
    • Verification: full CI and CodeRabbit passed; focused regressions cover reset, merge/conflict, branch movement, dirty files, stale selections, signing configuration, and repeat restore. An isolated DSH 0.2.0-rc.1 real model reply, browser E2E, screenshots in the PR, and Human visual QA passed.
    • Remaining Foundation: Git working tree as PersonaBot Memory #115 scope: none. Parent Wayfinder: Memory Repository / Workspace Grant / Assignment cwd #114 can close; its separate roadmap tickets retain their own scopes.
  16. removed
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

V1.0Milestone v1.0; mirrors the GitHub milestonearea:backendHost-side implementationfeature:memoryPersonaBot Memory Repository and Memory Servicescope:foundationFoundational authority, runtime, or infrastructurewayfinder:taskWayfinder task ticket

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions