2025-09-09 19:34:03 +00:00
# Service Processing Details
2026-02-19 20:22:59 +00:00
This document describes current service behavior in the processing pipeline.
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
## Active Pipeline Services
2025-09-09 19:34:03 +00:00
### 1. storeEventRunner
2026-02-19 20:22:59 +00:00
**Purpose**: Entry point for upload events.
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Code locations ** :
- `cmd/storeEventRunner/`
- `api/storeEventRunner/`
- `internal/document/store/`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Behavior ** :
- Consumes S3 event notifications
- Validates supported event/object patterns
- Extracts bucket/key/hash metadata
- Publishes to `DOCINIT`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Output ** : `{bucket, key, hash}` to `DOCINIT` .
2025-09-09 19:34:03 +00:00
---
### 2. docInitRunner
2026-02-19 20:22:59 +00:00
**Purpose**: Document registration and deduplication.
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Code locations ** :
- `cmd/docInitRunner/`
- `api/docInitRunner/`
- `internal/document/init/`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Behavior ** :
- Parses upload metadata from S3 key
- Deduplicates by client/hash
- Creates document and entry records for new documents
- Publishes new documents to `DOCSYNC`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Output ** : `{document_id}` to `DOCSYNC` for new documents.
2025-09-09 19:34:03 +00:00
---
2026-02-19 20:22:59 +00:00
### 3. docSyncRunner
**Purpose**: Sync eligibility gate.
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Code locations ** :
- `cmd/docSyncRunner/`
- `api/docSyncRunner/`
- `internal/document/sync/`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Behavior ** :
- Loads document + client state
- Checks client sync status
- Publishes eligible documents to `DOCCLEAN`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Output ** : `{document_id}` to `DOCCLEAN` when eligible.
2025-09-09 19:34:03 +00:00
---
2026-02-19 20:22:59 +00:00
### 4. docCleanRunner
**Purpose**: Document validation/cleaning stage.
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Code locations ** :
- `cmd/docCleanRunner/`
- `api/docCleanRunner/`
- `internal/document/clean/`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Behavior ** :
- Idempotent clean processing
- Validates MIME/content constraints and S3-backed inputs
- Stores clean version entries
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Output ** : none. The active pipeline currently ends after clean.
2025-09-09 19:34:03 +00:00
---
2026-02-19 20:22:59 +00:00
### 5. clientSyncRunner
**Purpose**: Re-queue all documents for a client.
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Code locations ** :
- `cmd/clientSyncRunner/`
- `api/clientSyncRunner/`
- `internal/client/sync/`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Behavior ** :
- Consumes `CLIENTSYNC`
- Enumerates client documents
- Publishes each to `DOCSYNC`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
**Output ** : `{document_id}` to `DOCSYNC` for each client document.
2025-09-09 19:34:03 +00:00
2026-05-08 21:42:46 +00:00
---
### 6. batch folder cleanup
**Purpose**: Remove empty folders auto-created by legacy ZIP batch extraction when all file outcomes are terminal.
**Code locations ** :
- `internal/document/batch/foldercleanup/`
- `internal/server/api/batch_worker.go`
- `internal/database/queries/batch.sql`
**Behavior ** :
- Locks the batch row before finalizing cleanup
- Requires terminal batch status plus persisted outcome evidence
- Detaches rejected current-batch documents and upload rows from candidate folders
- Deletes only safe empty auto-created folders
- Retries ready cleanup from the QueryAPI background worker
**Output ** : updates `batch_uploads.folder_cleanup_completed_at` ; may null rejected `documents.folderId` and `documentUploads.folder_id` ; may delete safe candidate folders.
2026-02-19 20:22:59 +00:00
## Deprecated Compatibility Services
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
These services are retained for deployment compatibility and are currently health-only/no-op:
- `cmd/docTextRunner/`
- `cmd/querySyncRunner/`
- `cmd/queryRunner/`
- `cmd/queryVersionSyncRunner/`
2025-09-09 19:34:03 +00:00
2026-02-19 20:22:59 +00:00
## Active Data Flow Summary
``` text
2025-09-09 19:34:03 +00:00
S3 Upload Event
2026-02-19 20:22:59 +00:00
-> storeEventRunner
-> docInitRunner
-> docSyncRunner
-> docCleanRunner
2026-05-08 21:42:46 +00:00
-> batch folder cleanup (for legacy ZIP batches)
2025-09-09 19:34:03 +00:00
```
2026-02-19 20:22:59 +00:00
``` text
Client Sync Trigger
-> clientSyncRunner
-> docSyncRunner
-> docCleanRunner
2025-09-09 19:34:03 +00:00
```