This commit is contained in:
eddiesoehnel committed 2026-08-24 12:22:24 -06:00
1 parent aca6452f20
commit 6524457c7c
65 files changed
+2381 -192

No files matched your search

@@ -0,0 +1,140 @@
# Future Map Insights Hub Daily Automation Repair
## Task Control
- Date: `2026-08-23`
- Repository: `C:\projects\future-map\future-map-OPEN`
- Branch: `main`
- Status: Complete
- Windows task: `FutureMap-InsightsHub-Daily`
- Calendar alias: `publish future map json posts to git repo`
- Scope: Diagnose the scheduled-task failure, repair invalid public hrecords, harden reasoning-patch ingestion and unattended sync, add regression coverage, and verify the production task
- Publication boundary: No Git commit, push, release, or external publication was performed
## Objective
Determine why the daily Future Map Insights Hub preparation task returned Windows Task Scheduler result code `1`, repair the underlying data without removing valid core-document references, and add guardrails that prevent the same failure from recurring.
## Root Cause
The alias file mapped `publish future map json posts to git repo` to the Windows task `FutureMap-InsightsHub-Daily`. The task correctly launched:
```text
powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\projects\future-map\future-map-OPEN\data\insights-hub\scripts\run_daily.ps1
```
The task itself started and completed deterministic synchronization, but the pipeline intentionally returned exit code `1` after schema validation found 30 invalid records. Each contained the same core-document ID twice:
```json
"corpus_documents_consulted": [
"future-of-apparel",
"future-of-apparel"
]
```
The `future-of-apparel` reference was valid and needed to remain. The defect was the redundant second entry in a set-like array whose schema requires unique items.
The affected record IDs were:
```text
3168, 3681, 3791, 3864, 4047, 4048, 4077, 4090, 4102, 4113,
4166, 4179, 4251, 4317, 4318, 4442, 4631, 4829, 4946, 5019,
5024, 5025, 5026, 5343, 5359, 5556, 5690, 5704, 5707, 5757
```
The records were generated by `codex-gpt5-sol-medium` during August 20–21 and entered Git history in commit `8596c42`. The uniqueness requirement had already existed since August 12, indicating that the bulk enrichment path bypassed or failed to preserve the intended validated `apply-reasoning` boundary.
The August 22 log also reported malformed source JSON for record `7072`, but that source issue had been corrected before the August 23 run and was not part of the persistent 30-record failure.
## Work Completed
### 1. Repaired the 30 hrecords
Removed only the repeated second `future-of-apparel` entry from each affected record. Every record still references the `future-of-apparel` core document once. No analysis, implications, claims, classifications, related-document relationships, timestamps, or source-derived fields were changed.
### 2. Hardened reasoning-patch ingestion
Updated `data/insights-hub/scripts/future_map_pipeline.py` to deduplicate list items while preserving their original order before validating and writing `corpus_documents_consulted` from an `apply-reasoning` patch.
The normalization does not coerce invalid values into strings. Normal schema validation still runs after normalization, so invalid types and other malformed patch content remain blocking errors.
When duplicates are removed, the command emits a visible normalization message with the number of removed entries.
### 3. Added an unattended preflight gate
Updated `data/insights-hub/scripts/run_daily.ps1` so the daily task now runs full pipeline validation before starting deterministic synchronization.
If preflight validation fails:
- Sync does not start.
- Generated indexes and Markdown are not refreshed by the unattended run.
- The failure and exit code are written to the daily log.
- The PowerShell task throws and returns a nonzero result to Windows Task Scheduler.
If preflight validation passes, the normal sync and post-sync validation continue as before.
### 4. Added regression coverage
Updated `data/insights-hub/tests/test_pipeline.py` with a reasoning patch containing duplicate consulted-document IDs. The test confirms that:
- The patch is accepted after deterministic normalization.
- One duplicate is reported as removed.
- The stored public hrecord contains one `critical-states` reference.
- Completed reasoning remains preserved across an unchanged sync.
### 5. Recorded a durable repair receipt
Created the ignored local receipt:
```text
data/insights-hub/runtime/receipts/20260823-070839-deduplicate-consulted-documents.json
```
The receipt records the 30 affected signal IDs, changed workflow files, validation evidence, successful scheduled-task run, and publication boundary.
## Validation Results
Final production validation:
- Validated records: `996`
- Validated signal pages: `996`
- Validated connections: `2,954`
- Validated derivatives: `5`
- Validation errors: `0`
- Review warnings: `1` pre-existing warning unrelated to this repair
- Exact `Future Map` matches: `1,008`
- Quarantined by publication restriction: `12`
- Published public records: `996`
- Reasoning states: `981 complete`, `13 excluded`, `1 pending`, `1 stale`, `0 failed`
- Skipped unreadable records: `0`
Additional checks:
- Duplicate `future-of-apparel` scan: Passed; no duplicate arrays remain.
- Insights Hub unit tests: Passed, `5 of 5`.
- Skill validator: Passed.
- Repository audit using the `documentation-guide` profile: Passed with no findings.
- `git diff --check`: Passed.
- Hardened `run_daily.ps1`: Passed end to end with exit code `0`.
- Receipt JSON parse: Passed.
## Windows Task Scheduler Verification
Ran `FutureMap-InsightsHub-Daily` through Windows Task Scheduler after the repair.
- Last run: `2026-08-23 07:07:54 -06:00`
- Final state: `Ready`
- Last task result: `0`
- Next scheduled run: `2026-08-24 06:00:00 -06:00`
The automation calendar should report success after its next status refresh.
## Preserved Existing Work
Existing generated changes for signal `7072` and its related indexes and Markdown were preserved. They were not reverted, overwritten manually, or represented as part of the 30-record repair.
## Remaining Publication Caveat
Despite its calendar alias, `FutureMap-InsightsHub-Daily` performs deterministic local preparation only. It does not stage, commit, or push Git changes. This matches the contained Insights Hub operating rules, which treat Git publication as a separate authorized action.
No commit or push was performed during this task.
@@ -0,0 +1,245 @@
# 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.