Files
future-map-OPEN/tasks/2026-08-24-future-map-three-stage-automation-fixes.md
T

245 lines
10 KiB
Markdown
Raw Normal View History

2026-08-24 12:22:24 -06:00
# Future Map Three-Stage Automation Fixes — 2026-08-24
## Task Control
- Date: `2026-08-24`
- Status: Complete with scheduled-run follow-up
- Primary repository: `C:\projects\future-map\future-map-OPEN`
- Cross-process repository: `C:\projects\1-flows\flows`
- Formatter manifest: `C:\projects\productivity\automation-manifests\process-json-entries`
- Windows task: `FutureMap-InsightsHub-Daily`
- Codex automations: `process-json-entries` and `daily-future-map-ai-processing`
- Publication boundary: No Git commit, push, release, approval, or external publication was performed
## Objective
Diagnose the recurring Future Map scheduled-task failure, simplify the 6:00 AM Windows task into a deterministic exact-tag copy, and verify the complete dependency chain from formatted source JSON through Future Map intake and downstream enrichment preparation.
## Three-Stage Process
| Order | Workbook name | Live process | Schedule | Responsibility |
|---|---|---|---|---|
| 1 | `json entires processng` | Codex automation `process-json-entries` | Hourly at `:10` | Convert queued Gmail captures into template-valid, sequential source hrecords and connected media. |
| 2 | `publish future map json posts to git repo` | Windows task `FutureMap-InsightsHub-Daily` | Daily at `6:00 AM` | Copy exact-tag Future Map source JSON and referenced media into the ignored Insights Hub intake snapshot. |
| 3 | `enrich future map json posts` | Codex automation `daily-future-map-ai-processing` | Daily at `6:30 AM` | Run deterministic public preparation from intake, then enrich only new or stale signals and create draft derivatives when readiness permits. |
## Problems Found
### 1. The 6:00 AM task had too many responsibilities
The Windows task previously combined source discovery, transformation, validation, output regeneration, and other pipeline work. A validation defect anywhere in the public repository caused the copy-oriented scheduler row to report Windows result code `1`.
The task is now intentionally narrow: it performs only deterministic intake copying. Public transformation and AI enrichment remain in the separate 6:30 AM process.
### 2. The upstream formatter and copy stage disagreed about `public`
The master source template uses:
```json
"PublicationRestrictions": "public"
```
as an affirmative publishable state. The copy and downstream pipeline initially treated every non-empty value as restricted. This incorrectly excluded 11 formatted Future Map records, including source record `7093`.
The shared rule is now:
- blank or `null`: publishable legacy state;
- `public`: publishable explicit state;
- `private`, `internal`, or any other non-empty value: fail closed and exclude.
### 3. Malformed historical sources could cause destructive pruning
Four older source files remain malformed:
```text
6069.json
7026.json
7046.json
7062.json
```
If the copy stage omitted them and the downstream sync pruned everything absent from intake, their existing last-known-good public records would be deleted.
The workflow now preserves malformed source IDs that already have a public output. Their last-known-good public record remains until the source formatter repairs them. Private records and records that genuinely lose the exact Future Map tag still prune normally.
### 4. Schedule order is not strictly linear
Because `process-json-entries` runs hourly at `:10`, the morning sequence is:
```text
5:10 AM source formatter
6:00 AM exact-tag intake copy
6:10 AM source formatter runs again
6:30 AM deterministic preparation and enrichment
```
A Future Map record completed during the 6:10 AM formatter run is not in the 6:00 AM snapshot and therefore waits for the next day's copy. Atomic source writes prevent partial-record corruption; this is a latency/cutoff issue rather than a data-integrity issue.
## Work Completed
### 1. Added the deterministic exact-tag copy script
Created:
```text
data/insights-hub/scripts/copy_future_map_tagged_files.py
```
The script:
- reads source and media locations from ignored local configuration or environment variables;
- matches the exact, case-sensitive `Future Map` HubTag;
- applies the shared publication-state rule;
- copies eligible JSON byte-for-byte into `data/insights-hub/runtime/intake/hrecords`;
- copies referenced local `File` and `Image` media into `runtime/intake/files`;
- copies only changed files;
- prunes stale files from the dedicated intake snapshot;
- logs missing media and malformed sources without failing the whole copy;
- preserves unreadable records that already have a last-known-good public output;
- performs no AI work, public transformation, Git operation, or external publication.
### 2. Simplified the Windows runner
Updated:
```text
data/insights-hub/scripts/run_daily.ps1
```
It now invokes only the exact-tag copy script, writes the current-date intake log, and returns a nonzero result only for an actual configuration, access, or copy failure.
### 3. Updated the downstream processing automation
Updated live automation `daily-future-map-ai-processing` so the 6:30 AM stage:
1. confirms the current-date copy log completed successfully;
2. runs `future_map_pipeline.py sync` against `runtime/intake/hrecords` and `runtime/intake/files`;
3. stops if deterministic preparation fails;
4. processes only genuinely new or stale signals, up to 20 records per run;
5. preserves the existing no-commit, no-push, no-approval, and no-external-publication boundaries.
### 4. Aligned downstream publication handling
Updated:
```text
data/insights-hub/scripts/future_map_pipeline.py
```
The downstream sync now interprets `public` consistently with the master source template and preserves last-known-good output when a corresponding source file is temporarily unreadable.
### 5. Added regression coverage
Created or updated:
```text
data/insights-hub/tests/test_copy_future_map_tagged_files.py
data/insights-hub/tests/test_pipeline.py
```
Coverage now verifies:
- exact and case-sensitive Future Map tag matching;
- byte-for-byte source copying;
- connected-media copying;
- `public` is allowed;
- `private` and `internal` are blocked;
- malformed sources are logged;
- existing output survives an unreadable source;
- stale intake content is pruned;
- reruns are idempotent.
### 6. Updated operating documentation
Updated the Future Map repository README, Insights Hub README, scripts README, and processing skill to document the split between the 6:00 AM copy and 6:30 AM preparation/enrichment stages.
## Records Between 7073 and 7094
The following 11 records have the exact `Future Map` tag, are explicitly `public`, and are already present in the intake snapshot:
```text
7079, 7080, 7081, 7082, 7083, 7084,
7086, 7087, 7088, 7089, 7093
```
They will be available to the next 6:30 AM deterministic preparation and enrichment run.
The remaining records in that range are intentionally absent:
- `7077` is `internal`;
- `7085` is `private`;
- `7074`, `7075`, `7076`, `7078`, `7090`, `7091`, `7092`, and `7094` do not have the exact `Future Map` tag.
## Validation Evidence
### Upstream formatter
- Automation manifest strict validation: Passed.
- Deterministic formatter/executor tests: `9 of 9` passed.
- Executor writes JSON, media, and receipts atomically.
- Live enable gate `state/ENABLED`: Present at review time.
### Exact-tag copy
Latest real Windows Task Scheduler verification:
- Last run: `2026-08-24 08:22:01 -06:00`
- State: `Ready`
- Last task result: `0`
- Next run: `2026-08-25 06:00:00 -06:00`
- Exact Future Map matches: `1,005`
- Publishable records in intake: `1,003`
- Publication-blocked records: `2`
- Connected files verified in intake: `557`
- Missing connected files: `0`
- Last-known-good malformed records preserved: `4`
The source and intake copies of record `7093.json` had identical SHA-256 hashes.
### Downstream preparation and enrichment
- Insights Hub tests: `7 of 7` passed.
- Production validation: `996` current records, `996` signal pages, `2,959` connections, `10` derivatives, `0` validation errors, and `1` existing review warning.
- Isolated fresh preparation from the corrected intake validated `1,003` eligible records and pages with `0` validation errors.
- `git diff --check`: Passed; only existing Windows line-ending warnings were reported.
## Files Changed or Added
Primary implementation files:
```text
C:\projects\future-map\future-map-OPEN\data\insights-hub\scripts\copy_future_map_tagged_files.py
C:\projects\future-map\future-map-OPEN\data\insights-hub\scripts\run_daily.ps1
C:\projects\future-map\future-map-OPEN\data\insights-hub\scripts\future_map_pipeline.py
C:\projects\future-map\future-map-OPEN\data\insights-hub\tests\test_copy_future_map_tagged_files.py
C:\projects\future-map\future-map-OPEN\data\insights-hub\tests\test_pipeline.py
```
Live automation definitions involved:
```text
C:\Users\edsoe\.codex\automations\process-json-entries\automation.toml
C:\Users\edsoe\.codex\automations\daily-future-map-ai-processing\automation.toml
```
Cross-process formatter definition:
```text
C:\projects\productivity\automation-manifests\process-json-entries
C:\projects\1-flows\info-capture-processing\process-json-entries
```
## Preserved Existing Work
The Future Map repository already contained unrelated and previously generated uncommitted changes. They were preserved and not reverted. The implementation and documentation changes from this work also remain uncommitted.
## Follow-Up Tasks
- [ ] Review the first unattended full three-stage run on `2026-08-25`.
- [ ] Confirm the 11 newly eligible public records enter the public preparation output and enrichment queue.
- [ ] Decide whether the 6:00 AM snapshot is an acceptable daily cutoff or whether strict completion-based orchestration is required.
- [ ] Reconcile the `process-json-entries` manifest documentation, which still describes the workflow gate as closed/testing even though the live gate exists and the automation is running.
- [ ] Repair the four malformed historical source JSON files through the authoritative source-formatting process.
- [ ] Refresh the automations results/calendar after the next scheduled runs.
- [ ] Review, commit, and push the changes only through a separately authorized Git publication step.