Skip to content

feat(identity): 三层身份模型 + id/name 分离 + abg auth login (PR2)#189

Open
raysonmeng wants to merge 1 commit into
feat/v3-pr1b-backbone-interfacesfrom
feat/v3-pr2-identity-auth
Open

feat(identity): 三层身份模型 + id/name 分离 + abg auth login (PR2)#189
raysonmeng wants to merge 1 commit into
feat/v3-pr1b-backbone-interfacesfrom
feat/v3-pr2-identity-auth

Conversation

@raysonmeng

Copy link
Copy Markdown
Owner

Stacked on #188 (PR1b) — base 是 feat/v3-pr1b-backbone-interfaces。逐层合并后自动 retarget。

概要 / Summary

PR2:落地三层身份模型(person / logical agent / session,§2.1–2.2)+ id/name 分离 + abg auth login,消费 PR1b 的 Store + IdentityProvider。

  • id(邮箱/GitHub 名)= 全局唯一路由键(UNIQUE,同 id 复用 = 同一人多设备);displayName 仅展示、可重(两个 Bob 路由不混)。

改动 / Changes

作用
Store auth_tokens 表 + issueToken/resolveToken/listTokens token→identity 绑定持久化(接口 + Sqlite/InMemory + Postgres-skeleton + 契约,§6.4 两实现都过)
IdentityService registerIdentity(trim/空拒绝/同 id 复用)/ registerAgent / recordSession / resolvePerson(agent 上卷 person)/ issueToken
StorePskIdentityProvider broker 真正用的 auth 驱动:authenticate = resolveToken→getIdentity,读 live store
abg auth login CLI 注册身份 + 签发 PSK token + 0600 原子写 token 文件 + 持久化绑定

测试计划 / Test plan

  • 新增 identity-service / store-psk-identity-provider(复用 IdentityProvider 契约)/ cli-auth 测试;Store 契约 25
  • bun run check exit 0 → 1719 pass / 0 fail、typecheck 干净、bundle 同步、版本对齐
  • CLI 由 subagent 写,主 agent 整合 + 通读 + cross-review

Cross-review

  • 轮 1(thorough,3 维 + 对抗式 verify):抓出并修复 1 个 HIGH 安全洞——collab.db(存 raw PSK token + 身份 PII)被 bun:sqlite 默认 0644 世界可读(Linux ~/.local/state 0755 → 任何本机用户可读走所有 token)。「与 control-token.ts 一致」的说法被实证为假(那是 0600 文件)。→ 把 collab DB 目录锁 0700(照 codex-transport.ts 模式,目录级隔离覆盖 wal/shm,比文件级 0600 持久)+ 2 条目录权限断言锁死 + .gitignore 加 collab 密钥卫生条目。
  • 轮 2 / 轮 3(lean,2 维 + verify):连续两轮 0 真实 issue → 收敛。

Backlog(RECOMMEND / 既有)

  • id 大小写规范化;StorePsk 错误回显 id;token hashing at rest(§11.3)。
  • pre-existing flaky 计时测试 DaemonClient > sendReply resolves on successful result(隔离 5/5 pass,全量套件偶发,PR2 未改)——建议单独 fix PR。
  • 跨机 token 分发 = PR3 broker provisioning(PR2 只交付 issue+verify 原语)。

🤖 Generated with Claude Code

按 spec §2.1–2.2 落地三层身份(person / logical agent / session),消费 PR1b 的
Store + IdentityProvider。id(邮箱/GitHub 名)= 全局唯一路由键(UNIQUE,同 id 复用=同一人多设备);
displayName 仅展示、可重(两个 Bob 不混)。

- Store 扩 auth_tokens 表 + issueToken/resolveToken/listTokens(接口 + Sqlite/InMemory + Postgres-skeleton + 契约,§6.4 两实现都过)。
- IdentityService:registerIdentity(id trim/空拒绝/同 id 复用)/ registerAgent / recordSession / resolvePerson(agent 上卷 person)/ issueToken(签发绑定身份的 PSK token)。
- StorePskIdentityProvider:broker 真正用的 auth 驱动——authenticate = store.resolveToken → getIdentity,读 live store(构造后签发的 token 也能认证)。
- abg auth login CLI:注册身份 + 签发 PSK token + 0600 原子写 token 文件 + 持久化绑定供 broker 校验。

测试:新增 identity-service / store-psk-identity-provider(复用 IdentityProvider 契约)/ cli-auth;Store 契约 25。
typecheck 干净;全量除一个 pre-existing flaky 计时测试(DaemonClient sendReply,隔离 5/5 pass,PR2 未改)外全绿。

Cross-review:轮1 thorough 抓出并修复 HIGH 安全洞——collab.db(存 raw PSK token + 身份 PII)
被 bun:sqlite 默认 0644 世界可读 → 把 collab DB 目录锁 0700(照 codex-transport.ts,目录级隔离覆盖
wal/shm,比文件级 0600 更持久)+ 测试锁死 + .gitignore 加密钥卫生条目;轮2/轮3 lean 连续两轮 0 收敛。

Backlog:id 大小写规范化;StorePsk 错误信息回显 id;token hashing at rest(§11.3);
pre-existing flaky DaemonClient.sendReply 计时测试(单独 fix)。跨机 token 分发=PR3 broker provisioning。

---

feat(identity): three-layer identity model + id/name separation + abg auth login (PR2)

Land the three-layer identity model (person / logical agent / session, §2.1–2.2)
consuming PR1b's Store + IdentityProvider. id (email/GitHub) is the UNIQUE routing
key (same id reused across devices); displayName is display-only and may collide.
Adds Store auth_tokens + IdentityService + StorePskIdentityProvider (the broker's
real auth driver) + `abg auth login` (issues a PSK token, 0600 token file, persisted
binding). Cross-review caught + fixed a HIGH: the collab DB (raw PSK tokens + PII)
was world-readable 0644 → the DB directory is now locked to 0700. Converged after
1 thorough + 2 lean adversarial rounds.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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