Skip to content

Fix cross-group scheduled tasks getting wrong chat_jid#5

Closed
gavrielc wants to merge 1 commit intomainfrom
claude/fix-scheduled-task-jid-jTs3Y
Closed

Fix cross-group scheduled tasks getting wrong chat_jid#5
gavrielc wants to merge 1 commit intomainfrom
claude/fix-scheduled-task-jid-jTs3Y

Conversation

@gavrielc
Copy link
Copy Markdown
Collaborator

@gavrielc gavrielc commented Feb 1, 2026

When the main group scheduled a task for a target_group, the chatJid was
incorrectly using the main group's JID because the container passed its
own JID in the IPC message. Now the host process looks up the correct
JID for the target group from registeredGroups instead of trusting the
IPC payload.

https://claude.ai/code/session_01LEiLiUcbVeWQ4HXxj6p3pJ

When the main group scheduled a task for a target_group, the chatJid was
incorrectly using the main group's JID because the container passed its
own JID in the IPC message. Now the host process looks up the correct
JID for the target group from registeredGroups instead of trusting the
IPC payload.

https://claude.ai/code/session_01LEiLiUcbVeWQ4HXxj6p3pJ
@gavrielc
Copy link
Copy Markdown
Collaborator Author

gavrielc commented Feb 1, 2026

Conflicts with PR #3's IPC authorization changes. The fix concept is still valid (looking up target JID from registeredGroups instead of trusting IPC payload), but needs to be re-applied to the new code structure.

@gavrielc gavrielc closed this Feb 1, 2026
gavrielc added a commit that referenced this pull request Feb 1, 2026
…alidation

- PR #10: Add sentinel markers for robust JSON parsing between container
  and host. Fallback to last-line parsing for backwards compatibility.

- PR #5: Look up target JID from registeredGroups instead of trusting
  IPC payload, fixing cross-group scheduled tasks getting wrong chat_jid.

- PR #8: Add lightweight schedule validation in container MCP that
  returns errors to agents (cron syntax, positive interval, valid ISO
  timestamp). Also defensive validation on host side.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
deverman pushed a commit to deverman/nanoclawswift that referenced this pull request Feb 2, 2026
…alidation

- PR qwibitai#10: Add sentinel markers for robust JSON parsing between container
  and host. Fallback to last-line parsing for backwards compatibility.

- PR qwibitai#5: Look up target JID from registeredGroups instead of trusting
  IPC payload, fixing cross-group scheduled tasks getting wrong chat_jid.

- PR qwibitai#8: Add lightweight schedule validation in container MCP that
  returns errors to agents (cron syntax, positive interval, valid ISO
  timestamp). Also defensive validation on host side.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rlin1027 referenced this pull request in Rlin1027/NanoGemClaw Feb 6, 2026
Extended ContainerInput with mediaPath field:
- container-runner.ts: Added mediaPath to ContainerInput interface
- agent-runner/index.ts: Added mediaPath to internal ContainerInput
- index.ts: Pass mediaPath through runAgent -> runContainerAgent

Media handling flow:
1. User sends image via Telegram
2. extractMediaInfo() detects media type
3. downloadMedia() saves to groups/{folder}/media/
4. mediaPath passed to container as /workspace/group/media/{filename}
5. Agent can now analyze images using Gemini's vision capabilities

This enables image analysis without additional configuration.
@TomGranot TomGranot deleted the claude/fix-scheduled-task-jid-jTs3Y branch February 12, 2026 15:51
gavrielc added a commit that referenced this pull request Feb 17, 2026
…dently

- Remove post-apply base update from apply.ts (base is stable, only
  changes on core updates)
- Re-author Discord skill modify files against clean core (no Telegram
  dependency — Discord and Telegram are independent skills)
- Remove Docker contamination from both Telegram and Discord skill
  packages (restore Apple Container runtime from clean core)
- Update architecture docs: principle #5 and Section 1 reflect stable
  base correctly
- Update skills-system-status.md to reflect Phase 2 completion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tunmaker pushed a commit to tunmaker/nanoclaw that referenced this pull request Feb 24, 2026
…alidation

- PR qwibitai#10: Add sentinel markers for robust JSON parsing between container
  and host. Fallback to last-line parsing for backwards compatibility.

- PR qwibitai#5: Look up target JID from registeredGroups instead of trusting
  IPC payload, fixing cross-group scheduled tasks getting wrong chat_jid.

- PR qwibitai#8: Add lightweight schedule validation in container MCP that
  returns errors to agents (cron syntax, positive interval, valid ISO
  timestamp). Also defensive validation on host side.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
withhonor007 pushed a commit to withhonor007/nanoclaw-slack that referenced this pull request Feb 25, 2026
commit 452a9f8363c151bf440d405de195614307b3ca4f
Author: brand <gialovcompotrds@gmail.com>
Date:   Wed Feb 25 16:43:52 2026 +0000

    restore

commit 55dbe9d4a57884ec5065ef6ba41704c2aac9f462
Author: brand <gialovcompotrds@gmail.com>
Date:   Wed Feb 25 16:38:56 2026 +0000

    feat(skill/slack): include groups/main CLAUDE.md in package modifies with Slack formatting guidance

commit 846c6dbd6aca5ee57fda83c94f5afd1c5f7bf69d
Author: brand <gialovcompotrds@gmail.com>
Date:   Wed Feb 25 16:26:22 2026 +0000

    docs(contributing): document nanorepo package-based skill format alongside instruction-based format

commit 1e024930d9dc93955939dc2581da860a050fc74c
Author: brand <gialovcompotrds@gmail.com>
Date:   Wed Feb 25 16:25:53 2026 +0000

    fix(skill-pr): revert src/container-runner.ts to main baseline; ANTHROPIC_BASE_URL fix moved to fix/anthropic-base-url-passthrough branch

commit b651b3f0ac459afadde5d302e55074587f0dec38
Author: brand <gialovcompotrds@gmail.com>
Date:   Wed Feb 25 16:24:46 2026 +0000

    feat(slack): downgrade skill version from 1.0.0 to 0.1.2 for pre-release alignment

commit ce81959f2e2b8adb2d32ade429b1f334086836f6
Author: brand <gialovcompotrds@gmail.com>
Date:   Wed Feb 25 16:04:52 2026 +0000

    docs(slack): 更新技术债务文档至 v1.4,重新分类债务项并调整优先级

    - 版本号 1.3 → 1.4,更新日期 2026-02-25
    - 全局优先级"中等"改为"见各项优先级"
    - 新增"Part I: 核心代码架构债务"分类标题,明确债务项需修改 `src/` 主代码库
    - 债务项 #1 新增"优先级:中等 — 第二通道集成前必须解决"标签
    - 开发决策声明中"Part I 项"替代"所有债务项",限定范围更精确
    - 修正"Post-Application Revision"措

commit 6ce563117813ade0b9474ead36c0d7e172993bc0
Author: brand <gialovcompotrds@gmail.com>
Date:   Wed Feb 25 15:41:55 2026 +0000

    docs(slack): 移除技术债务文档,已通过 Path C 实现解决

    - 删除 slack-technical-debt-zh.md(413 行)
    - 债务项 #1-qwibitai#4(*_ONLY 标志、路由增强、IPC 扩展、配置统一)已通过 skill-first Path C 实现(getChatName + IPC auto-resolve + resolveChannelName)
    - 债务项 qwibitai#5(核心文件修改)已在 W6 审计中确认为通用基础设施改进,无需回退
    - 文档版本 1.3,最后更新 2026-02-25,标记为"中等优先级"

commit a14d55f7885370673d095b0a376c7ab3cff68b58
Author: brand <gialovcompotrds@gmail.com>
Date:   Wed Feb 25 15:34:25 2026 +0000

    docs(slack): 更新用户指南术语和结构,新增 API 恢复章节

    - 标题改为"用户指南"(原"用户手册")
    - 统一术语:App→应用、Token→令牌、Main Channel→主频道、故障排查→故障排除、运维与监控→操作与监控
    - 新增第 10 节"API 恢复与弹性",说明 AI API 宕机时的失败消息丢弃和恢复后处理新消息机制
    - 概述部分新增自动 API 恢复功能说明
    - 前置条件表格标题"条件"改为"要求"
    - 简化描
atakankarsli added a commit to atakankarsli/nanoclaw that referenced this pull request Feb 27, 2026
…nts-a-k

feat: heartbeat, model routing, and agent behavior improvements
blaykeelder1-commits pushed a commit to blaykeelder1-commits/nanoclaw that referenced this pull request Mar 2, 2026
- qwibitai#5: Add 10s minimum cooldown between container spawns per group
  to prevent rapid credit burn from burst messages
- qwibitai#8: WhatsApp queue flush now stops on first failure instead of
  losing remaining messages (peek-then-shift pattern)
- qwibitai#10: Cap WhatsApp outgoing queue at 100 messages to prevent
  memory leak during extended disconnects
- qwibitai#14: Advance scheduled task next_run BEFORE enqueueing to prevent
  60s scheduler poll from double-firing the same task

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dptts added a commit to dptts/nanoclaw that referenced this pull request Mar 7, 2026
Prevents agents from receiving notifications for their own actions
on Forgejo (comments, PRs, self-assignments, etc.).

Changes:
- Filter out payload.sender from all recipients in determineRecipients()
- Skip noisy webhook events: closed, labeled, unlabeled, deleted
- Add 4 comprehensive tests for self-notification filtering

This solves the issue where agents were getting spammed with
notifications for every action they performed.

Fixes qwibitai#5

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
akasha-scheuermann pushed a commit to rscheuermann/nanoclaw that referenced this pull request Mar 14, 2026
…alidation

- PR qwibitai#10: Add sentinel markers for robust JSON parsing between container
  and host. Fallback to last-line parsing for backwards compatibility.

- PR qwibitai#5: Look up target JID from registeredGroups instead of trusting
  IPC payload, fixing cross-group scheduled tasks getting wrong chat_jid.

- PR qwibitai#8: Add lightweight schedule validation in container MCP that
  returns errors to agents (cron syntax, positive interval, valid ISO
  timestamp). Also defensive validation on host side.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bebekim pushed a commit to bebekim/goodclaw that referenced this pull request Mar 14, 2026
…alidation

- PR qwibitai#10: Add sentinel markers for robust JSON parsing between container
  and host. Fallback to last-line parsing for backwards compatibility.

- PR qwibitai#5: Look up target JID from registeredGroups instead of trusting
  IPC payload, fixing cross-group scheduled tasks getting wrong chat_jid.

- PR qwibitai#8: Add lightweight schedule validation in container MCP that
  returns errors to agents (cron syntax, positive interval, valid ISO
  timestamp). Also defensive validation on host side.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
kvasa pushed a commit to kvasa/nanoclaw that referenced this pull request Mar 15, 2026
…itai#8, qwibitai#11 + tests)

Security:
- Fix command injection in stopContainer(): use execFileSync/execFile with
  argument arrays instead of exec() with shell string interpolation.
  Renamed stopContainer() to stopContainerArgs() returning [bin, ...args].

Robustness:
- Fix cursor race condition (index.ts): saveState(chatJid) now does atomic
  read-modify-write of only that group's cursor, preventing cross-group
  cursor clobber when concurrent groups save/rollback simultaneously.
- Cap outgoing message queues in WhatsApp and Slack channels at 1000
  entries to prevent OOM when connection stays down.
- Add double-resolve guard in container-runner Promise (safeResolve()).
- Cache loadSenderAllowlist() result with 5s TTL to avoid synchronous
  file I/O on every incoming message.

Tests:
- mount-security.test.ts: 32 new tests for validateMount, validateAdditionalMounts,
  loadMountAllowlist (previously zero coverage on security-critical module).
- reaction-tracker.test.ts: 11 new tests covering race conditions between
  finalize() and transition timer.
- cursor-isolation.test.ts: 6 regression tests verifying per-group cursor isolation.
- Updated container-runtime.test.ts and sender-allowlist.test.ts for new APIs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Quirds pushed a commit to thankyourobot/tyr-aios that referenced this pull request Mar 24, 2026
…ge to both files

onboarding-patterns.md:
- Reorder pillars: Workspace Orientation moves from qwibitai#5 to qwibitai#3, before Access and Rhythms
- Add sequencing rationale at top of Five Pillars section
- Add operational notes nudge to Completing Onboarding

gap-analysis.md:
- Add operational notes nudge to Relationship to Onboarding: agent should write
  a brief ops note in projects/gap-analysis/ before closing onboarding so future
  sessions don't need to re-read the reference file

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
luisherranz pushed a commit to luisherranz/nanoclaw that referenced this pull request Mar 31, 2026
Critical bugs:
- Bug qwibitai#4: Remove sequence from content hash to prevent duplicates on
  repeated PreCompact calls. Hash is now sha256(session_id:role:content).
- Bug qwibitai#5: storeMessages() now returns count of newly inserted messages.
  PreCompact only creates leaf summaries for newly inserted messages,
  preventing re-summarization of already-stored content.

Should-fix:
- #1/qwibitai#10: Add dbInitialized flag to skip redundant schema setup on
  repeated initLcmDatabase() calls (fast path for MCP tool calls).
- qwibitai#6: Depth-capped condensation now attempts API summarization first,
  falls back to truncated concatenation with 10K token cap instead of
  unbounded blob.
- qwibitai#7: Skip API call entirely when neither ANTHROPIC_API_KEY nor
  ANTHROPIC_AUTH_TOKEN is set, go straight to deterministic fallback.

Nice-to-have:
- qwibitai#3: Remove duplicate LcmMessage/LcmSummary from src/types.ts.
  Single source of truth is container/agent-runner/src/lcm-store.ts.
@Nate-Vish Nate-Vish mentioned this pull request Mar 31, 2026
5 tasks
morrowgarrett added a commit to morrowgarrett/nanoclaw that referenced this pull request Apr 1, 2026
…ation

qwibitai#5 Warm container: Already supported via 30min IDLE_TIMEOUT + IPC piping.
   Docker startup is only 0.4s; Claude Code init is the real bottleneck.
   Full elimination requires embedded SDK (future).

qwibitai#6 Frozen memory snapshot + prompt caching:
- Query memU once at container start for relevant context
- Inject as immutable system prompt prefix
- Enables Anthropic's automatic prefix caching (50-75% token savings)
- Memory context frozen for session duration (no mid-turn re-queries)

qwibitai#7 Smart model routing: Skipped — Agent SDK doesn't expose model selection
   in query options. Would require SDK changes or CLI wrapper.

qwibitai#8 FTS5 session search:
- Added FTS5 virtual table on messages for full-text cross-session search
- Auto-synced via INSERT/DELETE triggers
- searchMessages() function for keyword-based message recall
- Complements memU's semantic search with fast keyword search

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Quirds added a commit to thankyourobot/tyr-aios that referenced this pull request Apr 8, 2026
Adversarial review surfaced 10+ issues with the junction table migration
and maintenance features. Resolved the ones that matter most for
pre-production deploy:

Schema cleanup:
- Collapsed all 7 LCM migrations into base schema (DBs will be wiped
  before production, no upgrade path needed)
- Dropped dead JSON columns (source_message_ids, parent_summary_ids,
  child_summary_ids) that were write-only after junction table refactor
- Removed legacy session_id→conversation_id rename
- Removed lcm_schema_version and migration framework entirely

API cleanup:
- StoreSummaryInput now takes sourceMessageIds/childSummaryIds as arrays
  (was: JSON-stringified strings)
- Removed silent try/catch on JSON parse failures
- Removed the range-based fallback in lcm-subagent read_source
  (junction tables are authoritative)
- Renamed getCoveredLeafIds → getCoveredSummaryIds (name was a lie:
  returned any covered summary, not just leaves)

Dead code removal:
- Deleted lcm-transcript-repair.ts entirely (was wired at wrong point
  in architecture: applied to stored messages, but our pipeline never
  re-sends those to an API, so it was fixing a problem we don't have)
- Removed unused repairToolPairing import in lcm-helpers.ts

Safety & correctness:
- Pruning safety floors: minRetainedConversations (default 1) and
  maxDeleteFraction (default 0.5), with force=true override
- Integrity check qwibitai#3 (leaf lineage) bumped from warning to error
  since getMessagesForSummary has no fallback path
- Integrity check qwibitai#4 (condensed lineage) same treatment
- Integrity check qwibitai#5 (orphans) rewrote N+1 query loop as a single
  JOIN query using the junction table index

DR script (aios-infra):
- Extended dr-test.sh with LCM integrity checks: summarization stall
  detection, orphan leaf/condensed summary detection, schema verification

125 tests passing, tsc clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
niels-emmer added a commit to niels-emmer/nanoclaw that referenced this pull request Apr 9, 2026
- Read HTTP Content-Type header from audio download response instead of
  hardcoding audio/ogg; falls back to Matrix event info.mimetype
- Map MIME type to correct file extension for OpenAI Whisper (webm, ogg,
  wav, flac, mp3, mp4) — fixes 400 errors from Chrome-based Element Web
  which sends audio/webm;codecs=opus
- Add HTTP response status check before attempting transcription
- Docs: add issues qwibitai#5 (container image loss) and qwibitai#6 (voice transcription
  MIME mismatch) to DEBUG_CHECKLIST.md with diagnosis commands
- Docs: add Linux systemd commands to Service Management section

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
luisherranz pushed a commit to luisherranz/nanoclaw that referenced this pull request Apr 10, 2026
Critical bugs:
- Bug qwibitai#4: Remove sequence from content hash to prevent duplicates on
  repeated PreCompact calls. Hash is now sha256(session_id:role:content).
- Bug qwibitai#5: storeMessages() now returns count of newly inserted messages.
  PreCompact only creates leaf summaries for newly inserted messages,
  preventing re-summarization of already-stored content.

Should-fix:
- #1/qwibitai#10: Add dbInitialized flag to skip redundant schema setup on
  repeated initLcmDatabase() calls (fast path for MCP tool calls).
- qwibitai#6: Depth-capped condensation now attempts API summarization first,
  falls back to truncated concatenation with 10K token cap instead of
  unbounded blob.
- qwibitai#7: Skip API call entirely when neither ANTHROPIC_API_KEY nor
  ANTHROPIC_AUTH_TOKEN is set, go straight to deterministic fallback.

Nice-to-have:
- qwibitai#3: Remove duplicate LcmMessage/LcmSummary from src/types.ts.
  Single source of truth is container/agent-runner/src/lcm-store.ts.
chocoSprite added a commit to chocoSprite/nanoclaw that referenced this pull request Apr 12, 2026
router.ts (62줄)에서 4개 함수(escapeXml/formatMessages/stripInternalTags/
formatOutbound)를 신규 src/formatting.ts로 분리. 신호:

- 해당 함수들의 테스트 파일 이름이 이미 formatting.test.ts였음 (의도된
  구조와 현재 구조의 mismatch 명시 표시)
- index.ts:84의 "Re-export for backwards compatibility during refactor"
  hack 본인이 임시 표시 남김 (이제 제거 가능)
- routeOutbound는 dead code (호출 0건) 발견하여 함께 삭제

router.ts 62→8줄 (findChannel만 남음). index.ts/session-commands.ts/
db.test.ts/formatting.test.ts import 경로 갱신. 408/408 통과.
project_final_review.md qwibitai#5 완료.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
foxsky added a commit to foxsky/nanoclaw that referenced this pull request Apr 12, 2026
…index

Three parallel review agents (reuse, quality, efficiency) flagged
actionable items on Phase 2:

1. TYPE SAFETY (Agent 1 qwibitai#5, Agent 2 qwibitai#4): The pending_approval response
   field was not declared in UpdateResult, and new AdminResult fields
   (offer_register, merged, source_archived, notes_added) were only
   returned via 'as any' casts. Fixed:
   - UpdateResult extended with pending_approval: { request_id,
     target_chat_jid, message, parent_board_id }
   - AdminResult extended with offer_register, merged, source_archived,
     notes_added (used by merge_project and handle_subtask_approval)
   - All 4 'as any' casts in the Phase 2 code removed
   - Also cleaned up `parentBoard?.group_jid ?? null` dead fallback
     (the null case was already made unreachable by the earlier
     fail-fast guard)

2. UNUSED INDEX (Agent 3 qwibitai#6): idx_subtask_requests_status on
   (status, target_board_id) was never queried — the dominant query
   is the PK lookup on request_id (O(1)). Removed the index and the
   drift-guard test that asserted its existence. Added a comment
   explaining the decision so a future scan-by-pending query can
   reinstate it.

Deferred (acceptable at current scale):
- subtask_requests grows unbounded: zero boards have opted into
  approval mode, so no current users. Revisit when adoption warrants.
- N+1 insert in approve loop: typical batches < 10 subtasks,
  better-sqlite3 caches prepared statements.
- decision field conflates handle_subtask_approval + process_minutes_
  decision: matches existing codebase pattern.
- Reject/approve notification duplication: only 2 sites with small
  variation, helper extraction would save ~2 lines.

236 engine / 365 skill tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dm-j pushed a commit to dm-j/nanoclaw that referenced this pull request Apr 13, 2026
…alidation

- PR qwibitai#10: Add sentinel markers for robust JSON parsing between container
  and host. Fallback to last-line parsing for backwards compatibility.

- PR qwibitai#5: Look up target JID from registeredGroups instead of trusting
  IPC payload, fixing cross-group scheduled tasks getting wrong chat_jid.

- PR qwibitai#8: Add lightweight schedule validation in container MCP that
  returns errors to agents (cron syntax, positive interval, valid ISO
  timestamp). Also defensive validation on host side.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
alanz added a commit to alanz/nanoclaw that referenced this pull request Apr 18, 2026
…g fixes

Three divergences resolved against the current implementation:

- Incremental reset archives (#1/qwibitai#2): ArchiveAndStartThrowawayOnReset now
  binds a prior_archives lookup, derives latest_prior_at, and passes it as
  messages_since on the new archive (null = full transcript). Added
  NonOverlappingArchivesPerSession invariant to assert no message timestamp
  sits inside the range of two non-placeholder archives for the same session.
  All other creation sites set messages_since: null.

- Path format (qwibitai#4): all example archive paths now include the {HHmm} time
  component that the code has always written.

- ThrowawaySession status (qwibitai#5): creation sites changed from status: queued
  (undeclared) to status: running, matching the code where runContainerAgent
  is called immediately with no queued step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gavrielc added a commit that referenced this pull request Apr 18, 2026
PR #5 review flagged three behavior changes that shouldn't have slipped
in. This commit reverts each to match the pre-refactor behavior exactly.

1. User upsert ordering. Split the router hook into two setters:
   setSenderResolver (runs before agent resolution) and setAccessGate
   (runs after). Restores the pre-PR sequence where the users row is
   upserted even if the message is dropped by wiring or trigger rules.

2. dropped_messages audit. Moved src/modules/permissions/db/dropped-messages.ts
   back to src/db/dropped-messages.ts. The table is core audit infra, not
   permissions-specific. Router re-writes rows for no_agent_wired and
   no_trigger_match; the access gate writes rows for policy refusals.

3. Permissionless container fallback. Dropped. poll-loop restores the
   original deny-all check when NANOCLAW_ADMIN_USER_IDS is empty.

Module contract doc updated with the two-hook shape.

Validation: host build clean, 137/137 host tests, 17/17 container
tests, typecheck clean, service boots to "NanoClaw running" with
permissions module registering both hooks and clean SIGTERM shutdown.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gavrielc added a commit that referenced this pull request Apr 18, 2026
PR #5 moved src/db/users.ts and src/db/user-roles.ts into the permissions
module. The channels branch's telegram adapter still imported from the
old paths — update to src/modules/permissions/db/*.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gavrielc added a commit that referenced this pull request Apr 18, 2026
…optional

Promotes approvals to the default tier with a public API (requestApproval +
registerApprovalHandler) that other modules consume. Self-modification
(install_packages / request_rebuild / add_mcp_server) moves into a new
optional module that registers delivery actions + matching approval handlers
via the new API.

## Approvals (default tier)

- Adds `src/modules/approvals/primitive.ts` exporting `requestApproval`,
  `registerApprovalHandler`, `notifyAgent`. Absorbs `pickApprover` /
  `pickApprovalDelivery` / `channelTypeOf` from the deleted `src/access.ts`.
- Rewrites `response-handler.ts` to dispatch to registered approval handlers
  on approve (action-keyed Map). Reject path is centralized.
- Drops the three self-mod-specific delivery-action registrations from
  `approvals/index.ts`; they belong to self-mod now.
- `onecli-approvals.ts` now imports picks from the primitive instead of
  `src/access.ts`.

## Self-mod (optional tier)

- New `src/modules/self-mod/` with request handlers (validate input + call
  requestApproval) and apply handlers (orchestration on approve).
- `apply.ts` owns updateContainerConfig + buildAgentGroupImage + killContainer
  calls. Self-mod depends on approvals (via registerApprovalHandler +
  requestApproval + notifyAgent) and on core (container-runner, container-config).
- Registers 3 delivery actions + 3 approval handlers at import time.

## Other changes

- `src/access.ts` and `src/access.test.ts` deleted. Tests split across
  `src/modules/approvals/picks.test.ts` (approver selection) and
  `src/modules/permissions/permissions.test.ts` (access + roles + DM).
- `src/modules/index.ts` barrel: approvals loads before self-mod so
  registerApprovalHandler is bound when self-mod registers at import time.

## Validation

- `pnpm run build` clean
- `pnpm test` — 137 host tests pass
- `bun test` in container/agent-runner — 17 tests pass
- Service starts; boot log shows `OneCLI approval handler started`,
  `NanoClaw running`; clean SIGTERM shutdown

Resolves the transitional tier violation flagged in PR #5 where core
imported from the permissions optional module via `src/access.ts`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants