From 530e0a77f1c23dd4fd4671ec0c2ab4843ff21900 Mon Sep 17 00:00:00 2001 From: eddiesoehnel Date: Wed, 16 Sep 2026 06:16:13 -0600 Subject: [PATCH] added --- .env.example | 3 + .gitignore | 8 ++ AUTOMATION.md | 59 +++++++++++++++ README.md | 40 ++++++++++ automation.schema.json | 142 +++++++++++++++++++++++++++++++++++ automation.yaml | 120 +++++++++++++++++++++++++++++ host-overrides.example.yaml | 8 ++ requirements-validation.txt | 3 + scripts/validate_manifest.py | 70 +++++++++++++++++ task-prompt.md | 25 ++++++ 10 files changed, 478 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 AUTOMATION.md create mode 100644 README.md create mode 100644 automation.schema.json create mode 100644 automation.yaml create mode 100644 host-overrides.example.yaml create mode 100644 requirements-validation.txt create mode 100644 scripts/validate_manifest.py create mode 100644 task-prompt.md diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8cc215d --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +# Names only. Never commit real values. +REPLACE_ME_SECRET= + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be470b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.env +host-overrides.yaml +logs/ +output/ +state/ +__pycache__/ +*.pyc + diff --git a/AUTOMATION.md b/AUTOMATION.md new file mode 100644 index 0000000..376e1a0 --- /dev/null +++ b/AUTOMATION.md @@ -0,0 +1,59 @@ +# Replace Me Automation — Operations Runbook + +## Purpose and owner + +- Outcome: Replace me. +- Owner: Replace me. +- Repository: Replace me. +- Manifest version: `0.1.0` + +## Scheduler record + +- Platform: Codex desktop scheduled task +- Scheduler task ID or link: Replace me after creating the scheduled task. +- Active host: `dell-workstation` +- Standby host: `travel-laptop` +- Cadence and timezone: Every Monday at 09:00 America/Denver + +## Normal operation + +1. The active host starts the task from `task-prompt.md`. +2. The run acquires or verifies the idempotency state declared in `automation.yaml`. +3. Outputs and the run log are written to their declared locations. +4. The success contract is verified and a notification is sent. + +## Manual test + +1. Confirm required software, connectors, secrets, permissions, inputs, and output paths. +2. Confirm scheduled execution remains disabled. +3. Run `python scripts/validate_manifest.py --strict`. +4. Execute `task-prompt.md` manually in the declared working directory. +5. Verify every success-contract item and inspect the run log. +6. Record the test date and evidence here. + +Latest manual test: Never + +## Failover: primary host to standby + +1. Pause or disable the scheduler on the old host. If it is unreachable, fence it by revoking its lease, credential, or network access to the destination it writes to. +2. Pull the pinned repository revision onto the standby host. +3. Create `host-overrides.yaml` from the example and restore secrets from the approved secret store. +4. Restore durable runtime state and confirm the recovery point. +5. Validate the manifest and perform one manual test. +6. Change the documented active/standby roles and enable the schedule on the new active host. +7. Review the first scheduled run. Do not re-enable the old host without reversing this process. + +## Restore requirements + +- Secret backup location: Replace me; record the system name, never the secret value. +- Runtime-state backup location: Replace me. +- Required external accounts/connectors: Replace me. +- Host bootstrap instructions: Replace me. + +## Disable or retire + +1. Disable the actual scheduler first. +2. Confirm no run is active. +3. Preserve required outputs, logs, and state according to retention policy. +4. Set `automation.status` to `paused` or `retired`, update `last_reviewed`, and commit the change. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..1e0a715 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Automation Manifest Template + +This directory is the source template for every AI-built automation. Copy it into the automation's repository, replace the example values, validate it, test one manual run, and only then enable its schedule. + +`automation.yaml` is an internal, version-controlled operating contract. It is not an OpenAI/Codex import format and does not create a scheduled task by itself. The actual scheduler configuration must match the manifest. + +## Files + +- `automation.yaml` — machine-readable source of truth. +- `automation.schema.json` — validation rules for the manifest. +- `task-prompt.md` — durable task prompt used by the scheduled run. +- `AUTOMATION.md` — human/AI runbook and disaster-recovery record. +- `host-overrides.example.yaml` — example of machine-specific paths; copy to `host-overrides.yaml`, which is ignored by Git. +- `.env.example` — names of required secrets and configuration, never secret values. +- `scripts/validate_manifest.py` — schema and unresolved-placeholder validator. + +## New automation workflow + +1. Copy this entire directory into the automation repository. +2. Replace every `replace-me` value and edit `task-prompt.md` and `AUTOMATION.md`. +3. Keep all durable prompts, skills, scripts, schemas, and recovery instructions in Git. +4. Put host-specific paths in `host-overrides.yaml` and secret values in the host's secret store or untracked `.env` file. +5. Install validation dependencies and run: + + ```powershell + python -m pip install -r requirements-validation.txt + python scripts/validate_manifest.py --strict + ``` + +6. Run the automation manually and verify its expected output and notifications. +7. Configure the real scheduler from `trigger` and record its scheduler ID in `AUTOMATION.md`. +8. Enable exactly one execution host. Keep standby hosts disabled until failover. +9. Commit and push the definition. Do not commit secrets, runtime state, or host overrides. + +## Portability rule + +Git stores what the automation is. The scheduler determines when it runs. The active host determines where it runs. Runtime state and secrets live outside Git but must have documented restore procedures. + +For local Codex scheduled tasks, keep the active computer on, the desktop app running, and the project directory available. Web-scheduled tasks can use uploaded context and connected tools, but cannot directly work in a folder on a computer. + diff --git a/automation.schema.json b/automation.schema.json new file mode 100644 index 0000000..3196ce4 --- /dev/null +++ b/automation.schema.json @@ -0,0 +1,142 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.invalid/schemas/automation-manifest-1.0.json", + "title": "Automation Manifest", + "type": "object", + "additionalProperties": false, + "required": [ + "schema_version", "automation", "source", "trigger", "execution", + "hosts", "requirements", "inputs", "outputs", "observability", + "failure_policy", "recovery", "security", "change_control" + ], + "properties": { + "schema_version": { "const": "1.0" }, + "automation": { + "type": "object", + "additionalProperties": false, + "required": ["id", "name", "description", "version", "status", "owner", "tags"], + "properties": { + "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" }, + "name": { "type": "string", "minLength": 3 }, + "description": { "type": "string", "minLength": 10 }, + "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" }, + "status": { "enum": ["draft", "testing", "active", "paused", "retired"] }, + "owner": { "type": "string", "minLength": 1 }, + "tags": { "type": "array", "items": { "type": "string", "minLength": 1 }, "uniqueItems": true } + } + }, + "source": { + "type": "object", + "additionalProperties": false, + "required": ["repository", "definition_path", "revision_policy"], + "properties": { + "repository": { "type": "string", "minLength": 1 }, + "definition_path": { "type": "string", "minLength": 1 }, + "revision_policy": { "enum": ["pinned-release", "pinned-commit", "tracked-branch"] } + } + }, + "trigger": { + "type": "object", + "additionalProperties": false, + "required": ["type", "enabled_by_default"], + "properties": { + "type": { "enum": ["schedule", "event", "manual"] }, + "schedule": { + "type": "object", + "additionalProperties": false, + "required": ["human", "timezone"], + "properties": { + "human": { "type": "string", "minLength": 1 }, + "timezone": { "type": "string", "minLength": 1 }, + "rrule": { "type": ["string", "null"] } + } + }, + "event": { "type": ["object", "null"] }, + "enabled_by_default": { "type": "boolean" } + }, + "allOf": [ + { "if": { "properties": { "type": { "const": "schedule" } } }, "then": { "required": ["schedule"] } } + ] + }, + "execution": { + "type": "object", + "additionalProperties": false, + "required": ["platform", "mode", "task_prompt", "working_directory", "skills", "command", "timeout_minutes", "concurrency", "idempotency"], + "properties": { + "platform": { "enum": ["codex-desktop", "chatgpt-web", "codex-cli", "external-scheduler", "other"] }, + "mode": { "enum": ["local-project", "isolated-worktree", "web", "script", "manual"] }, + "task_prompt": { "type": "string", "minLength": 1 }, + "working_directory": { "type": ["string", "null"] }, + "skills": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": ["path", "required"], + "properties": { "path": { "type": "string", "minLength": 1 }, "required": { "type": "boolean" } } + } + }, + "command": { "type": ["string", "null"] }, + "timeout_minutes": { "type": "integer", "minimum": 1 }, + "concurrency": { + "type": "object", + "additionalProperties": false, + "required": ["max_active_runs", "overlap_policy"], + "properties": { + "max_active_runs": { "type": "integer", "minimum": 1 }, + "overlap_policy": { "enum": ["skip", "queue", "cancel-previous", "parallel"] } + } + }, + "idempotency": { + "type": "object", + "additionalProperties": false, + "required": ["strategy", "state_location"], + "properties": { + "strategy": { "enum": ["scheduled-window", "input-hash", "external-lock", "none"] }, + "state_location": { "type": ["string", "null"] } + } + } + } + }, + "hosts": { + "type": "object", + "additionalProperties": false, + "required": ["activation_policy", "primary", "standby", "overrides_file"], + "properties": { + "activation_policy": { "const": "single-active-host" }, + "primary": { "$ref": "#/$defs/host" }, + "standby": { "type": "array", "items": { "$ref": "#/$defs/host" } }, + "overrides_file": { "type": "string", "minLength": 1 } + } + }, + "requirements": { + "type": "object", + "required": ["software", "tools_and_connectors", "secrets", "permissions"], + "properties": { + "software": { "type": "array", "items": { "type": "object" } }, + "tools_and_connectors": { "type": "array", "items": { "type": ["string", "object"] } }, + "secrets": { "type": "array", "items": { "type": "object", "required": ["name", "required", "source"] } }, + "permissions": { "type": "object" } + } + }, + "inputs": { "type": "object", "required": ["sources", "parameters"] }, + "outputs": { "type": "object", "required": ["artifacts", "success_contract"] }, + "observability": { "type": "object", "required": ["run_log", "health", "notifications"] }, + "failure_policy": { "type": "object", "required": ["retries", "after_final_failure", "partial_output_policy"] }, + "recovery": { "type": "object", "required": ["runbook", "recovery_time_objective_hours", "recovery_point_objective_hours", "failover"] }, + "security": { "type": "object", "required": ["secrets_in_repository", "destructive_actions", "external_writes"] }, + "change_control": { "type": "object", "required": ["last_reviewed", "review_cadence_days", "required_checks"] } + }, + "$defs": { + "host": { + "type": "object", + "additionalProperties": false, + "required": ["id", "role"], + "properties": { + "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" }, + "role": { "enum": ["active", "cold-standby", "disabled"] } + } + } + } +} + diff --git a/automation.yaml b/automation.yaml new file mode 100644 index 0000000..f1fe43f --- /dev/null +++ b/automation.yaml @@ -0,0 +1,120 @@ +schema_version: "1.0" + +automation: + id: replace-me-automation-id + name: Replace Me Automation + description: Replace with the outcome this automation produces. + version: "0.1.0" + status: draft + owner: replace-me-owner + tags: + - replace-me + +source: + repository: replace-me-repository-url + definition_path: automation.yaml + revision_policy: pinned-release + +trigger: + type: schedule + schedule: + human: Every Monday at 09:00 + timezone: America/Denver + rrule: "FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0" + enabled_by_default: false + +execution: + platform: codex-desktop + mode: local-project + task_prompt: task-prompt.md + working_directory: . + skills: + - path: replace-me-skill-or-remove-this-entry + required: true + command: null + timeout_minutes: 60 + concurrency: + max_active_runs: 1 + overlap_policy: skip + idempotency: + strategy: scheduled-window + state_location: replace-me-durable-state-location + +hosts: + activation_policy: single-active-host + primary: + id: dell-workstation + role: active + standby: + - id: travel-laptop + role: cold-standby + overrides_file: host-overrides.yaml + +requirements: + software: + - name: ChatGPT desktop app + version: current-supported + tools_and_connectors: [] + secrets: + - name: REPLACE_ME_SECRET_OR_REMOVE + required: true + source: host-secret-store + permissions: + filesystem: + - path: . + access: read-write + network: restricted + +inputs: + sources: + - name: replace-me-input + location: replace-me-location + required: true + parameters: {} + +outputs: + artifacts: + - name: primary-output + location: output/ + format: markdown + retention_days: 90 + success_contract: + - Expected artifact exists and is non-empty. + - Completion notification includes the artifact location. + +observability: + run_log: logs/runs.jsonl + health: + stale_after_minutes: 120 + notifications: + on_success: inbox + on_failure: inbox + +failure_policy: + retries: + max_attempts: 2 + backoff_minutes: 15 + after_final_failure: notify-owner + partial_output_policy: retain-and-mark-failed + +recovery: + runbook: AUTOMATION.md + recovery_time_objective_hours: 4 + recovery_point_objective_hours: 24 + failover: + require_old_host_disabled_or_fenced: true + require_manual_test_before_enable: true + +security: + secrets_in_repository: forbidden + destructive_actions: require-explicit-approval + external_writes: least-privilege + +change_control: + last_reviewed: "2026-08-21" + review_cadence_days: 90 + required_checks: + - manifest-validation + - manual-test + - first-scheduled-run-review + diff --git a/host-overrides.example.yaml b/host-overrides.example.yaml new file mode 100644 index 0000000..dd1dddb --- /dev/null +++ b/host-overrides.example.yaml @@ -0,0 +1,8 @@ +# Copy to host-overrides.yaml on each host. That file is intentionally ignored by Git. +host_id: replace-me-host-id +working_directory: C:/replace/me/automation-repository +paths: + output: C:/replace/me/automation-output + logs: C:/replace/me/automation-logs + state: C:/replace/me/automation-state + diff --git a/requirements-validation.txt b/requirements-validation.txt new file mode 100644 index 0000000..e8a42e5 --- /dev/null +++ b/requirements-validation.txt @@ -0,0 +1,3 @@ +jsonschema>=4.18,<5 +PyYAML>=6,<7 + diff --git a/scripts/validate_manifest.py b/scripts/validate_manifest.py new file mode 100644 index 0000000..aa449d0 --- /dev/null +++ b/scripts/validate_manifest.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +"""Validate automation.yaml against its JSON Schema and find template markers.""" + +from __future__ import annotations + +import argparse +import json +import sys +from pathlib import Path +from typing import Any, Iterator + +import yaml +from jsonschema import Draft202012Validator + + +ROOT = Path(__file__).resolve().parents[1] +DEFAULT_MANIFEST = ROOT / "automation.yaml" +DEFAULT_SCHEMA = ROOT / "automation.schema.json" +PLACEHOLDER_MARKERS = ("replace-me", "replace me", "example.invalid") + + +def iter_strings(value: Any, path: str = "$") -> Iterator[tuple[str, str]]: + if isinstance(value, dict): + for key, child in value.items(): + yield from iter_strings(child, f"{path}.{key}") + elif isinstance(value, list): + for index, child in enumerate(value): + yield from iter_strings(child, f"{path}[{index}]") + elif isinstance(value, str): + yield path, value + + +def main() -> int: + parser = argparse.ArgumentParser() + parser.add_argument("manifest", nargs="?", type=Path, default=DEFAULT_MANIFEST) + parser.add_argument("--schema", type=Path, default=DEFAULT_SCHEMA) + parser.add_argument("--strict", action="store_true", help="Fail on unresolved template markers.") + args = parser.parse_args() + + manifest = yaml.safe_load(args.manifest.read_text(encoding="utf-8")) + schema = json.loads(args.schema.read_text(encoding="utf-8")) + errors = sorted(Draft202012Validator(schema).iter_errors(manifest), key=lambda e: list(e.absolute_path)) + + if errors: + print("Manifest schema validation failed:", file=sys.stderr) + for error in errors: + location = "$" + "".join(f"[{part!r}]" for part in error.absolute_path) + print(f"- {location}: {error.message}", file=sys.stderr) + return 1 + + unresolved = [ + (path, value) + for path, value in iter_strings(manifest) + if any(marker in value.lower() for marker in PLACEHOLDER_MARKERS) + ] + if unresolved: + stream = sys.stderr if args.strict else sys.stdout + print("Unresolved template markers:", file=stream) + for path, value in unresolved: + print(f"- {path}: {value}", file=stream) + if args.strict: + return 2 + + print(f"Valid manifest: {args.manifest}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) + diff --git a/task-prompt.md b/task-prompt.md new file mode 100644 index 0000000..7536bb6 --- /dev/null +++ b/task-prompt.md @@ -0,0 +1,25 @@ +# Task prompt: Replace Me Automation + +## Objective + +Replace this section with the exact outcome required from every run. + +## Inputs + +- Read the inputs declared in `automation.yaml`. +- Stop and report a clear failure if any required input is unavailable. + +## Procedure + +1. Replace this list with the stable, repeatable workflow. +2. Use only the tools, skills, paths, and external systems declared in the manifest. +3. Preserve source data unless the manifest explicitly authorizes a write. +4. Write outputs only to the declared artifact locations. + +## Completion contract + +- Verify every item in `outputs.success_contract`. +- Record the run result in the declared run log. +- Report success only after the output has been verified. +- On failure, preserve useful partial output, explain the blocking condition, and follow `failure_policy`. +