docs: FILE_LIFECYCLE — mtime, watcher detection-only, version V1.2
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
document_type: "design_doc"
|
document_type: "design_doc"
|
||||||
service: "MOMENTRY_CORE"
|
service: "MOMENTRY_CORE"
|
||||||
title: "File Lifecycle — Pre-Processing & Registration"
|
title: "File Lifecycle — Pre-Processing & Registration"
|
||||||
version: "V1.0"
|
version: "V1.2"
|
||||||
date: "2026-05-15"
|
date: "2026-05-15"
|
||||||
author: "M5"
|
author: "M5"
|
||||||
status: "draft"
|
status: "draft"
|
||||||
@@ -14,7 +14,7 @@ status: "draft"
|
|||||||
|------|-------|
|
|------|-------|
|
||||||
| Scope | All managed file types (video, image, document, spreadsheet, presentation) |
|
| Scope | All managed file types (video, image, document, spreadsheet, presentation) |
|
||||||
| Status | Draft |
|
| Status | Draft |
|
||||||
| Applies to | Watcher pre-processor + Register API |
|
| Applies to | Pre-process API (explicit) + Register API |
|
||||||
| Key concept | Two-phase flow: birth certificate (`.pre.json`) → civil registration (DB INSERT) |
|
| Key concept | Two-phase flow: birth certificate (`.pre.json`) → civil registration (DB INSERT) |
|
||||||
|
|
||||||
> **Applicable to all managed file types**: video, image, document (pdf, docx, pages, key, numbers), spreadsheet, presentation, and any other file registered in the system. The pre-processor registers any file type found by the watcher. ffprobe is used when applicable; files that ffprobe cannot parse receive minimal filesystem metadata as a fallback.
|
> **Applicable to all managed file types**: video, image, document (pdf, docx, pages, key, numbers), spreadsheet, presentation, and any other file registered in the system. The pre-processor registers any file type found by the watcher. ffprobe is used when applicable; files that ffprobe cannot parse receive minimal filesystem metadata as a fallback.
|
||||||
@@ -43,7 +43,7 @@ A file enters the system in two distinct phases:
|
|||||||
|
|
||||||
### Trigger
|
### Trigger
|
||||||
|
|
||||||
File watcher (`src/watcher/watcher.rs`) polls monitored directories every 60 seconds. When a new file is detected, pre-processor runs automatically.
|
Pre-processing is triggered explicitly via the register API or a dedicated pre-process endpoint. It is NOT automatic — the watcher only detects new files without modifying them.
|
||||||
|
|
||||||
### Computation Steps
|
### Computation Steps
|
||||||
|
|
||||||
@@ -153,8 +153,9 @@ curl -X POST http://localhost:3002/api/v1/files/register \
|
|||||||
## File Lifecycle State Diagram
|
## File Lifecycle State Diagram
|
||||||
|
|
||||||
```
|
```
|
||||||
File detected by watcher
|
File detected by watcher (detection only, no modification)
|
||||||
│
|
│
|
||||||
|
│ Pre-processing triggered explicitly (API or register)
|
||||||
▼
|
▼
|
||||||
[Pre-Processor]
|
[Pre-Processor]
|
||||||
├─ SHA256 (DNA / fingerprint)
|
├─ SHA256 (DNA / fingerprint)
|
||||||
@@ -168,7 +169,7 @@ File detected by watcher
|
|||||||
│ (user calls POST /api/v1/files/register)
|
│ (user calls POST /api/v1/files/register)
|
||||||
▼
|
▼
|
||||||
[Register Handler]
|
[Register Handler]
|
||||||
├─ Read .pre.json (skip recomputation)
|
├─ Read .pre.json → skip recomputation
|
||||||
├─ Dedup check (content_hash collision?)
|
├─ Dedup check (content_hash collision?)
|
||||||
├─ Name check + rename?
|
├─ Name check + rename?
|
||||||
└─ INSERT INTO videos
|
└─ INSERT INTO videos
|
||||||
@@ -182,7 +183,7 @@ registration_time = NOW()
|
|||||||
|
|
||||||
| # | Task | File |
|
| # | Task | File |
|
||||||
|---|------|------|
|
|---|------|------|
|
||||||
| 1 | Modify watcher pre-processor: SHA256 + probe + write `.pre.json` for all file types | `src/watcher/watcher.rs` |
|
| 1 | Expose `pre_process_file()` as public function (SHA256 + probe + UUID → `.pre.json`) | `src/watcher/watcher.rs` |
|
||||||
| 2 | Register: read `.pre.json`, skip SHA256/probe if cached | `src/api/server.rs` → `register_single_file` |
|
| 2 | Register: read `.pre.json`, skip SHA256/probe if cached | `src/api/server.rs` → `register_single_file` |
|
||||||
| 3 | UUID: use `birthday` from `.pre.json` (or `fs::metadata().created()` fallback) | `src/api/server.rs` |
|
| 3 | UUID: use `birthday` from `.pre.json` (or `fs::metadata().created()` fallback) | `src/api/server.rs` |
|
||||||
| 4 | INSERT status: `registered`, registration_time: `NOW()` | `src/api/server.rs` |
|
| 4 | INSERT status: `registered`, registration_time: `NOW()` | `src/api/server.rs` |
|
||||||
@@ -194,3 +195,4 @@ registration_time = NOW()
|
|||||||
|---------|------|---------|
|
|---------|------|---------|
|
||||||
| V1.0 | 2026-05-15 | Initial design — birth certificate (pre-process) + civil registration two-phase flow |
|
| V1.0 | 2026-05-15 | Initial design — birth certificate (pre-process) + civil registration two-phase flow |
|
||||||
| V1.1 | 2026-05-15 | Reclassified from DESIGN to STANDARDS as design standard |
|
| V1.1 | 2026-05-15 | Reclassified from DESIGN to STANDARDS as design standard |
|
||||||
|
| V1.2 | 2026-05-15 | mtime replaces birthtime for UUID stability across rsync; watcher is detection-only |
|
||||||
|
|||||||
Reference in New Issue
Block a user