Repository navigation
Conversation
Implements `mem put <dir> --watch` for automatic one-way ingestion of new/changed files from a watched directory into mem. ## What changed **CLI flag** - Added `--watch` / `-w` flag to `mem put` command - Requires a directory path (errors on files or stdin) - Polls every 5s (interval hardcoded, could be configurable in future) **Watch daemon** (\`watchDir\`) - Polling loop with size-based change detection - Tracks file states (path → last known size) in memory - Ingests new/changed files via existing \`uploadFile\` path - Skips hidden files/directories (starting with \`.\\`) - Computes relative paths for target folder structure **Per-cycle reports** - Text format: \`Cycle N: scanned=X ingested=Y unchanged=Z failed=W\` - JSON format (\`--format json\`): machine-readable report object - Failures listed per file with error messages - Daemon continues on individual file failures (fail-closed per file) **Graceful lifecycle** - SIGINT/SIGTERM handling for clean shutdown - Exits cleanly if watched directory disappears - No write-back to local disk (strictly one-way) - No deletion propagation (local deletes don't remove mem content) ## Requirements covered - **REQ-001**: One-way watch daemon — \`mem put <path> --watch\` watches directory and ingests new/changed files - **REQ-002**: Per-cycle import report — each cycle emits report with added/unchanged/failed counts - **REQ-003**: Boundary hard constraints — no write-back, no deletion propagation, no bidirectional sync - **REQ-004**: Canon consolidation — formal tracking item for scan/auto-sync family ## Non-goals (by design) - No bidirectional sync, conflict resolution, or deletion propagation (Phase 2) - No fsnotify/event-driven watching (polling is simpler and portable) - No mobile/share-link/preview scope creep - No re-indexing behavior changes beyond what ingestion already triggers ## Test plan - [ ] Manual: \`mem put ./test-dir --watch\`, add files, verify ingestion - [ ] Manual: Modify file, verify re-ingestion - [ ] Manual: Delete local file, verify mem content NOT deleted - [ ] Manual: Ctrl+C, verify clean shutdown - [ ] CI green - [ ] Reviewer approval Closes bytefolk#110
wadrzl
requested review from
Bindy-lbb,
PeterGuy326 and
waterbro-8
as code owners
September 20, 2026 09:51
waterbro-8
requested changes
Sep 20, 2026
waterbro-8
left a comment
Collaborator
There was a problem hiding this comment.
REQUEST_CHANGES。请关掉本 PR,不要 Closes #110。
- #110 已有实现: mem #225(sun-970,head
bf68d03d,已 APPROVE,含cmds_watch*.go、跨平台 lock、测试、ingest)。本 PR 是同一 issue 的第二份、更薄的 fork 实现。 - 本切片缺测试、CI 未跑;变更检测只用 size,同大小改内容会漏;
printWatchReportJSON手拼 JSON;signal.Notify(..., os.Kill)接不住 SIGKILL 也不是可移植的优雅退出。 - 我推不了 fork。请 close #226,让 #225 rebase 到最新 main 后合。作者 wadrzl 未映射钉钉。
Author
|
Closing — duplicates already APPROVED #225. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #110
Implements
mem put <dir> --watchfor automatic one-way ingestion of new/changed files from a watched directory into mem.What changed
CLI flag
--watch/-wflag tomem putcommandWatch daemon (
watchDir)uploadFilepath.)Per-cycle reports
Cycle N: scanned=X ingested=Y unchanged=Z failed=W--format json): machine-readable report objectGraceful lifecycle
Requirements covered
mem put <path> --watchwatches directory and ingests new/changed filesNon-goals (by design)
Test plan
mem put ./test-dir --watch, add files, verify ingestion