[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6C37KAG1JN2FJ899GW8903E":3,"skill-same:01M6C37KAG1JN2FJ899GW8903E":88},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":51,"linkOnly":52,"markdownContent":53,"markdownBody":54,"frontMatter":55,"refName":64,"commitSha":65,"skillDirectory":66,"forksCount":67,"repositoryHtmlUrl":68,"repositoryHomepageUrl":69,"ownerHtmlUrl":70,"ownerBlogUrl":71,"ownerDescription":72,"updatedAt":73,"install":74,"resources":87},"01M6C37KAG1JN2FJ899GW8903E","verify-archive","归档完整性校验","Verify archive integrity with self-verifying SHA-256 checksums, generate VERIFY.md, and optionally create W3C PROV provenance","使用自验证 SHA-256 校验和验证归档的完整性，生成 VERIFY.md，并可选择创建 W3C PROV 溯源信息","jmagly\u002Faiwg","jmagly","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1159087?v=4","01M6C10AK8N2WCSQN11FYGTJWN","Joseph Magly","01M6C10AQ8A2RMED1Y1BSVY7NF",229,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fmedia-curator\u002Fskills\u002Fverify-archive\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8CCB7F9NTFH1F7981EYJXGR","媒体档案管理与数字保存","SCENARIO","使用场景",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8CCB7FT60CVS40JZCHMSKJZ","媒体档案管理员","PROFESSION","适用职业",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50],"verify","verify archive","archive","grep","path","checksums","with","efficiency","self","fix","write","read","create","haiku","Bash","Media","sha-256","provenance","integrity","generate","2026-11-10 10:12:30",false,"---\nnamespace: aiwg\nname: verify-archive\nplatforms: [all]\ndescription: Verify archive integrity with self-verifying SHA-256 checksums, generate VERIFY.md, and optionally create W3C PROV provenance\ncommandHint:\n  argumentHint: \u003Carchive_path> [--generate] [--verify] [--provenance] [--fix]\n  allowedTools: Bash, Read, Write, Glob, Grep\n  model: haiku\n  category: media-curator\n  modelRole: efficiency\n  modelTier: economy\n---\n\n# verify-archive\n\nDetect bit rot, tampering, and transfer errors in media archives through cryptographic checksum verification. Maintain provenance records and fixity information for long-term preservation.\n\n## Purpose\n\nMedia archives degrade over time through:\n- **Bit rot**: Silent data corruption in storage media\n- **Transfer errors**: Corruption during network transfer or backup\n- **Tampering**: Unauthorized modifications\n- **Media failure**: Gradual deterioration of physical storage\n\nThis command generates self-verifying checksum manifests, performs integrity verification, and optionally creates W3C PROV provenance records with PREMIS fixity metadata.\n\n## Parameters\n\n| Parameter | Required | Description |\n|-----------|----------|-------------|\n| `archive_path` | Yes | Path to media archive directory |\n| `--generate` | No | Generate new CHECKSUMS.sha256 manifest |\n| `--verify` | No | Verify existing manifest against files |\n| `--provenance` | No | Generate PROVENANCE.jsonld with PREMIS fixity |\n| `--fix` | No | Regenerate manifest after archive changes |\n\n**Mutually exclusive modes**: Use `--generate` for initial setup, `--verify` for routine checks, `--fix` after making changes.\n\n## CHECKSUMS.sha256 Format\n\nSelf-verifying manifest with cryptographic integrity protection:\n\n```\n# MANIFEST_HASH: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n# Generated: 2026-02-14T18:45:22.387654321Z\n# Verify with: tail -n +4 CHECKSUMS.sha256 | sha256sum\n1a2b3c4d...  .\u002Faudio\u002Fepisode-001.opus\n5e6f7g8h...  .\u002Faudio\u002Fepisode-002.opus\n9i0j1k2l...  .\u002Fvideo\u002Frecording-2026-02-14.mp4\n3m4n5o6p...  .\u002Fplaylists\u002Ffavorites.m3u\n7q8r9s0t...  .\u002FREADME.md\n```\n\n**Format specification**:\n- **Line 1**: `# MANIFEST_HASH: \u003Csha256>` - SHA-256 hash of manifest content (lines 4+)\n- **Line 2**: `# Generated: \u003Ctimestamp>` - ISO 8601 UTC timestamp with nanosecond precision\n- **Line 3**: `# Verify with: tail -n +4 CHECKSUMS.sha256 | sha256sum` - Self-verification command\n- **Lines 4+**: `\u003Chash>  \u003Cpath>` - File checksums in sha256sum format\n\n**Self-verification property**: Modifying any hash entry invalidates the manifest hash. The manifest is tamper-evident.\n\n**Coverage**: ALL files in the archive are checksummed:\n- Audio files (opus, mp3, flac, m4a, aac)\n- Video files (mp4, mkv, webm, avi)\n- Images (jpg, png, webp, svg)\n- Text files (md, txt, srt, vtt)\n- Playlists (m3u, m3u8, pls)\n- Scripts and metadata (json, yaml, sh)\n\n**Exclusions**: Only `CHECKSUMS.sha256` itself is excluded to prevent circular dependency.\n\n## Verification Procedures\n\n### Quick Verification (Manifest Integrity)\n\nVerify manifest has not been tampered with (sub-second):\n\n```bash\ncd \u002Fpath\u002Fto\u002Farchive\n\n# Extract manifest hash from header\nEXPECTED=$(grep '^# MANIFEST_HASH:' CHECKSUMS.sha256 | awk '{print $3}')\n\n# Compute hash of manifest content (lines 4+)\nACTUAL=$(tail -n +4 CHECKSUMS.sha256 | sha256sum | awk '{print $1}')\n\n# Compare\nif [ \"$EXPECTED\" = \"$ACTUAL\" ]; then\n  echo \"✓ Manifest integrity verified\"\nelse\n  echo \"✗ Manifest has been tampered with\"\n  exit 1\nfi\n```\n\n**Use case**: Daily automated checks to detect manifest corruption without verifying all files.\n\n### Full Verification (All Files)\n\nVerify all files match their checksums (minutes to hours depending on archive size):\n\n```bash\ncd \u002Fpath\u002Fto\u002Farchive\n\n# First verify manifest integrity\nEXPECTED=$(grep '^# MANIFEST_HASH:' CHECKSUMS.sha256 | awk '{print $3}')\nACTUAL=$(tail -n +4 CHECKSUMS.sha256 | sha256sum | awk '{print $1}')\n\nif [ \"$EXPECTED\" != \"$ACTUAL\" ]; then\n  echo \"✗ Manifest integrity check failed - stopping\"\n  exit 1\nfi\n\necho \"✓ Manifest integrity verified\"\n\n# Then verify all files\ntail -n +4 CHECKSUMS.sha256 | sha256sum -c\n```\n\n**Use case**: Weekly\u002Fmonthly deep verification to detect bit rot.\n\n### Quiet Mode (Failures Only)\n\nShow only files that failed verification:\n\n```bash\ncd \u002Fpath\u002Fto\u002Farchive\ntail -n +4 CHECKSUMS.sha256 | sha256sum -c --quiet\n```\n\n**Exit codes**:\n- `0` - All files verified successfully\n- `1` - One or more files failed verification\n\n**Use case**: Cron jobs and automated monitoring.\n\n## Timestamp Standard\n\nAll timestamps use ISO 8601 UTC with nanosecond precision:\n\n**Format**: `YYYY-MM-DDTHH:MM:SS.NNNNNNNNNZ`\n\n**Example**: `2026-02-14T18:45:22.387654321Z`\n\n**Generation command**:\n```bash\ndate -u +%Y-%m-%dT%H:%M:%S.%NZ\n```\n\n**Requirements**:\n- Always UTC (trailing `Z`), never local timezone\n- Nanosecond precision (9 decimal places)\n- ISO 8601 compliant\n- Monotonic (later timestamps are lexicographically greater)\n\n## Workflow\n\n### Initial Setup (--generate)\n\n```bash\naiwg verify-archive \u002Fpath\u002Fto\u002Farchive --generate\n```\n\n**Steps**:\n1. Find all files recursively (excluding `CHECKSUMS.sha256`)\n2. Compute SHA-256 hash for each file\n3. Sort results by path (deterministic order)\n4. Generate timestamp in ISO 8601 UTC format\n5. Write checksums to temporary file\n6. Compute SHA-256 of checksum content\n7. Add self-verifying header with manifest hash\n8. Write final `CHECKSUMS.sha256`\n9. Generate `VERIFY.md` with human-readable instructions\n\n**Bash implementation**:\n```bash\nARCHIVE_PATH=\"\u002Fpath\u002Fto\u002Farchive\"\nTIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%S.%NZ)\n\ncd \"$ARCHIVE_PATH\"\n\n# Generate checksums (exclude manifest itself)\nfind . -type f ! -name \"CHECKSUMS.sha256\" -print0 | \\\n  sort -z | \\\n  xargs -0 sha256sum > \u002Ftmp\u002Fchecksums.tmp\n\n# Compute manifest hash\nMANIFEST_HASH=$(sha256sum \u002Ftmp\u002Fchecksums.tmp | awk '{print $1}')\n\n# Write final manifest with self-verifying header\n{\n  echo \"# MANIFEST_HASH: $MANIFEST_HASH\"\n  echo \"# Generated: $TIMESTAMP\"\n  echo \"# Verify with: tail -n +4 CHECKSUMS.sha256 | sha256sum\"\n  cat \u002Ftmp\u002Fchecksums.tmp\n} > CHECKSUMS.sha256\n\nrm \u002Ftmp\u002Fchecksums.tmp\n\necho \"✓ Generated CHECKSUMS.sha256 with $MANIFEST_HASH\"\n```\n\n### Routine Verification (--verify)\n\n```bash\naiwg verify-archive \u002Fpath\u002Fto\u002Farchive --verify\n```\n\n**Steps**:\n1. Read `MANIFEST_HASH` from header\n2. Compute hash of manifest content (lines 4+)\n3. Compare hashes (quick integrity check)\n4. If manifest is intact, verify all files against checksums\n5. Report any mismatches or missing files\n\n### Regeneration After Changes (--fix)\n\n```bash\naiwg verify-archive \u002Fpath\u002Fto\u002Farchive --fix\n```\n\n**Use case**: After adding\u002Fremoving\u002Fmodifying files in the archive.\n\n**Steps**:\n1. Backup existing `CHECKSUMS.sha256` to `CHECKSUMS.sha256.bak`\n2. Regenerate manifest (same as `--generate`)\n3. Report changes: added files, removed files, modified files\n4. Keep backup for comparison\n\n**Example output**:\n```\nBacked up existing manifest to CHECKSUMS.sha256.bak\nRegenerating checksums...\nChanges detected:\n  Added: .\u002Faudio\u002Fepisode-003.opus\n  Modified: .\u002FREADME.md (hash changed)\n  Removed: .\u002Faudio\u002Fepisode-001-draft.opus\n✓ Generated new CHECKSUMS.sha256\n```\n\n## VERIFY.md Template\n\nHuman-readable verification instructions placed in archive root:\n\n```markdown\n# Archive Integrity Verification\n\nThis archive contains a self-verifying checksum manifest for detecting corruption, tampering, or transfer errors.\n\n## Quick Verification (Manifest Integrity)\n\nVerify the manifest has not been tampered with (sub-second):\n\n\\`\\`\\`bash\ncd \"$(dirname \"$0\")\"\nEXPECTED=$(grep '^# MANIFEST_HASH:' CHECKSUMS.sha256 | awk '{print $3}')\nACTUAL=$(tail -n +4 CHECKSUMS.sha256 | sha256sum | awk '{print $1}')\n[ \"$EXPECTED\" = \"$ACTUAL\" ] && echo \"✓ Manifest integrity verified\" || echo \"✗ Manifest tampered\"\n\\`\\`\\`\n\n## Full Verification (All Files)\n\nVerify all files match their checksums:\n\n\\`\\`\\`bash\ncd \"$(dirname \"$0\")\"\ntail -n +4 CHECKSUMS.sha256 | sha256sum -c\n\\`\\`\\`\n\n## Archive Information\n\n- **Generated**: {TIMESTAMP}\n- **File count**: {FILE_COUNT}\n- **Total size**: {TOTAL_SIZE}\n- **Manifest hash**: {MANIFEST_HASH}\n\n## Recommended Verification Schedule\n\n- **Daily**: Quick manifest integrity check\n- **Weekly**: Full file verification\n- **After transfer**: Full verification immediately after copying\u002Fdownloading\n- **Before backup**: Verify source integrity before creating backup\n\n## If Verification Fails\n\n1. **Manifest integrity failure**: Manifest has been tampered with or corrupted. Regenerate from source.\n2. **File verification failure**: File has been corrupted or modified. Restore from backup or regenerate.\n\n## Regeneration\n\nAfter making changes to the archive, regenerate the manifest:\n\n\\`\\`\\`bash\naiwg verify-archive . --fix\n\\`\\`\\`\n\n---\n\n*Self-verifying checksums using SHA-256 (NIST FIPS 180-4)*\n```\n\n**Template variables**:\n- `{TIMESTAMP}` - ISO 8601 generation timestamp\n- `{FILE_COUNT}` - Number of files in manifest\n- `{TOTAL_SIZE}` - Total archive size in human-readable format\n- `{MANIFEST_HASH}` - SHA-256 hash of manifest content\n\n## PROVENANCE.jsonld Integration\n\nW3C PROV-O format with PREMIS fixity metadata:\n\n```json\n{\n  \"@context\": {\n    \"prov\": \"http:\u002F\u002Fwww.w3.org\u002Fns\u002Fprov#\",\n    \"premis\": \"http:\u002F\u002Fwww.loc.gov\u002Fpremis\u002Frdf\u002Fv3\u002F\",\n    \"schema\": \"http:\u002F\u002Fschema.org\u002F\",\n    \"xsd\": \"http:\u002F\u002Fwww.w3.org\u002F2001\u002FXMLSchema#\"\n  },\n  \"@graph\": [\n    {\n      \"@id\": \"urn:uuid:ARCHIVE_UUID\",\n      \"@type\": [\"prov:Entity\", \"premis:IntellectualEntity\"],\n      \"prov:generatedAtTime\": {\n        \"@type\": \"xsd:dateTime\",\n        \"@value\": \"2026-02-14T18:45:22.387654321Z\"\n      },\n      \"premis:hasFixity\": {\n        \"@type\": \"premis:Fixity\",\n        \"premis:hasMessageDigest\": \"sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\n        \"premis:hasMessageDigestAlgorithm\": \"SHA-256\",\n        \"premis:hasMessageDigestOriginator\": \"aiwg verify-archive v2026.2.6\",\n        \"premis:fixityCheckDateTime\": {\n          \"@type\": \"xsd:dateTime\",\n          \"@value\": \"2026-02-14T18:45:22.387654321Z\"\n        }\n      },\n      \"schema:contentUrl\": \".\u002FCHECKSUMS.sha256\"\n    },\n    {\n      \"@id\": \"urn:uuid:ACTIVITY_UUID\",\n      \"@type\": \"prov:Activity\",\n      \"prov:startedAtTime\": {\n        \"@type\": \"xsd:dateTime\",\n        \"@value\": \"2026-02-14T18:45:20.123456789Z\"\n      },\n      \"prov:endedAtTime\": {\n        \"@type\": \"xsd:dateTime\",\n        \"@value\": \"2026-02-14T18:45:22.387654321Z\"\n      },\n      \"prov:wasAssociatedWith\": {\n        \"@id\": \"urn:aiwg:agent:media-curator\"\n      }\n    },\n    {\n      \"@id\": \"urn:aiwg:agent:media-curator\",\n      \"@type\": \"prov:SoftwareAgent\",\n      \"schema:name\": \"AIWG Media Curator\",\n      \"schema:softwareVersion\": \"2026.2.6\"\n    }\n  ]\n}\n```\n\n**Key relationships**:\n- `premis:hasFixity` - Links entity to fixity information\n- `premis:hasMessageDigest` - SHA-256 hash with `sha256:` prefix\n- `premis:fixityCheckDateTime` - When verification was performed\n- `prov:wasAssociatedWith` - Agent that performed verification\n\n**Use case**: Long-term digital preservation requiring audit trails and provenance chains.\n\n## Standards Compliance\n\n| Standard | Purpose | Reference |\n|----------|---------|-----------|\n| SHA-256 | Cryptographic hash function | NIST FIPS 180-4 |\n| ISO 8601 | Timestamp format | ISO 8601:2019 |\n| PREMIS 3.0 | Preservation metadata | Library of Congress |\n| W3C PROV-O | Provenance ontology | W3C Recommendation 2013 |\n| JSON-LD 1.1 | Linked data format | W3C Recommendation 2020 |\n\n## Error Handling\n\n**Missing archive**: Exit with error if archive path does not exist.\n\n**No CHECKSUMS.sha256**: For `--verify`, exit with error. For `--generate`, create new manifest.\n\n**Hash mismatch**: Report which files failed, exit code 1.\n\n**Permission errors**: Report files that cannot be read, continue verification for accessible files.\n\n**Corrupt manifest**: If manifest cannot be parsed, exit with error and suggest regeneration.\n\n## Deliverables\n\nWhen running `--generate` or `--fix`:\n\n1. **CHECKSUMS.sha256** - Self-verifying checksum manifest\n2. **VERIFY.md** - Human-readable verification instructions\n\nWhen running `--provenance`:\n\n3. **PROVENANCE.jsonld** - W3C PROV-O provenance record with PREMIS fixity\n\n## Examples\n\n**Initial setup**:\n```bash\naiwg verify-archive ~\u002Fmedia\u002Fpodcast-archive --generate\n```\n\n**Routine verification**:\n```bash\naiwg verify-archive ~\u002Fmedia\u002Fpodcast-archive --verify\n```\n\n**After adding new episodes**:\n```bash\naiwg verify-archive ~\u002Fmedia\u002Fpodcast-archive --fix\n```\n\n**Generate with provenance**:\n```bash\naiwg verify-archive ~\u002Fmedia\u002Fpodcast-archive --generate --provenance\n```\n\n**Automated monitoring** (cron):\n```bash\n0 2 * * * aiwg verify-archive \u002Fmedia\u002Farchives\u002Fpodcast --verify --quiet || echo \"Archive verification failed\" | mail -s \"Alert\" admin@example.com\n```\n\n## References\n\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fhuman-authorization.md — Seek explicit authorization before regenerating or fixing checksums (--generate, --fix)\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fintegrity-verification\u002FSKILL.md — Core integrity verification patterns used by this skill\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fprovenance-tracking\u002FSKILL.md — Provenance records generated via --provenance flag\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fcurate\u002FSKILL.md — Orchestration skill that invokes verify-archive as a curation phase\n","# verify-archive\n\nDetect bit rot, tampering, and transfer errors in media archives through cryptographic checksum verification. Maintain provenance records and fixity information for long-term preservation.\n\n## Purpose\n\nMedia archives degrade over time through:\n- **Bit rot**: Silent data corruption in storage media\n- **Transfer errors**: Corruption during network transfer or backup\n- **Tampering**: Unauthorized modifications\n- **Media failure**: Gradual deterioration of physical storage\n\nThis command generates self-verifying checksum manifests, performs integrity verification, and optionally creates W3C PROV provenance records with PREMIS fixity metadata.\n\n## Parameters\n\n| Parameter | Required | Description |\n|-----------|----------|-------------|\n| `archive_path` | Yes | Path to media archive directory |\n| `--generate` | No | Generate new CHECKSUMS.sha256 manifest |\n| `--verify` | No | Verify existing manifest against files |\n| `--provenance` | No | Generate PROVENANCE.jsonld with PREMIS fixity |\n| `--fix` | No | Regenerate manifest after archive changes |\n\n**Mutually exclusive modes**: Use `--generate` for initial setup, `--verify` for routine checks, `--fix` after making changes.\n\n## CHECKSUMS.sha256 Format\n\nSelf-verifying manifest with cryptographic integrity protection:\n\n```\n# MANIFEST_HASH: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n# Generated: 2026-02-14T18:45:22.387654321Z\n# Verify with: tail -n +4 CHECKSUMS.sha256 | sha256sum\n1a2b3c4d...  .\u002Faudio\u002Fepisode-001.opus\n5e6f7g8h...  .\u002Faudio\u002Fepisode-002.opus\n9i0j1k2l...  .\u002Fvideo\u002Frecording-2026-02-14.mp4\n3m4n5o6p...  .\u002Fplaylists\u002Ffavorites.m3u\n7q8r9s0t...  .\u002FREADME.md\n```\n\n**Format specification**:\n- **Line 1**: `# MANIFEST_HASH: \u003Csha256>` - SHA-256 hash of manifest content (lines 4+)\n- **Line 2**: `# Generated: \u003Ctimestamp>` - ISO 8601 UTC timestamp with nanosecond precision\n- **Line 3**: `# Verify with: tail -n +4 CHECKSUMS.sha256 | sha256sum` - Self-verification command\n- **Lines 4+**: `\u003Chash>  \u003Cpath>` - File checksums in sha256sum format\n\n**Self-verification property**: Modifying any hash entry invalidates the manifest hash. The manifest is tamper-evident.\n\n**Coverage**: ALL files in the archive are checksummed:\n- Audio files (opus, mp3, flac, m4a, aac)\n- Video files (mp4, mkv, webm, avi)\n- Images (jpg, png, webp, svg)\n- Text files (md, txt, srt, vtt)\n- Playlists (m3u, m3u8, pls)\n- Scripts and metadata (json, yaml, sh)\n\n**Exclusions**: Only `CHECKSUMS.sha256` itself is excluded to prevent circular dependency.\n\n## Verification Procedures\n\n### Quick Verification (Manifest Integrity)\n\nVerify manifest has not been tampered with (sub-second):\n\n```bash\ncd \u002Fpath\u002Fto\u002Farchive\n\n# Extract manifest hash from header\nEXPECTED=$(grep '^# MANIFEST_HASH:' CHECKSUMS.sha256 | awk '{print $3}')\n\n# Compute hash of manifest content (lines 4+)\nACTUAL=$(tail -n +4 CHECKSUMS.sha256 | sha256sum | awk '{print $1}')\n\n# Compare\nif [ \"$EXPECTED\" = \"$ACTUAL\" ]; then\n  echo \"✓ Manifest integrity verified\"\nelse\n  echo \"✗ Manifest has been tampered with\"\n  exit 1\nfi\n```\n\n**Use case**: Daily automated checks to detect manifest corruption without verifying all files.\n\n### Full Verification (All Files)\n\nVerify all files match their checksums (minutes to hours depending on archive size):\n\n```bash\ncd \u002Fpath\u002Fto\u002Farchive\n\n# First verify manifest integrity\nEXPECTED=$(grep '^# MANIFEST_HASH:' CHECKSUMS.sha256 | awk '{print $3}')\nACTUAL=$(tail -n +4 CHECKSUMS.sha256 | sha256sum | awk '{print $1}')\n\nif [ \"$EXPECTED\" != \"$ACTUAL\" ]; then\n  echo \"✗ Manifest integrity check failed - stopping\"\n  exit 1\nfi\n\necho \"✓ Manifest integrity verified\"\n\n# Then verify all files\ntail -n +4 CHECKSUMS.sha256 | sha256sum -c\n```\n\n**Use case**: Weekly\u002Fmonthly deep verification to detect bit rot.\n\n### Quiet Mode (Failures Only)\n\nShow only files that failed verification:\n\n```bash\ncd \u002Fpath\u002Fto\u002Farchive\ntail -n +4 CHECKSUMS.sha256 | sha256sum -c --quiet\n```\n\n**Exit codes**:\n- `0` - All files verified successfully\n- `1` - One or more files failed verification\n\n**Use case**: Cron jobs and automated monitoring.\n\n## Timestamp Standard\n\nAll timestamps use ISO 8601 UTC with nanosecond precision:\n\n**Format**: `YYYY-MM-DDTHH:MM:SS.NNNNNNNNNZ`\n\n**Example**: `2026-02-14T18:45:22.387654321Z`\n\n**Generation command**:\n```bash\ndate -u +%Y-%m-%dT%H:%M:%S.%NZ\n```\n\n**Requirements**:\n- Always UTC (trailing `Z`), never local timezone\n- Nanosecond precision (9 decimal places)\n- ISO 8601 compliant\n- Monotonic (later timestamps are lexicographically greater)\n\n## Workflow\n\n### Initial Setup (--generate)\n\n```bash\naiwg verify-archive \u002Fpath\u002Fto\u002Farchive --generate\n```\n\n**Steps**:\n1. Find all files recursively (excluding `CHECKSUMS.sha256`)\n2. Compute SHA-256 hash for each file\n3. Sort results by path (deterministic order)\n4. Generate timestamp in ISO 8601 UTC format\n5. Write checksums to temporary file\n6. Compute SHA-256 of checksum content\n7. Add self-verifying header with manifest hash\n8. Write final `CHECKSUMS.sha256`\n9. Generate `VERIFY.md` with human-readable instructions\n\n**Bash implementation**:\n```bash\nARCHIVE_PATH=\"\u002Fpath\u002Fto\u002Farchive\"\nTIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%S.%NZ)\n\ncd \"$ARCHIVE_PATH\"\n\n# Generate checksums (exclude manifest itself)\nfind . -type f ! -name \"CHECKSUMS.sha256\" -print0 | \\\n  sort -z | \\\n  xargs -0 sha256sum > \u002Ftmp\u002Fchecksums.tmp\n\n# Compute manifest hash\nMANIFEST_HASH=$(sha256sum \u002Ftmp\u002Fchecksums.tmp | awk '{print $1}')\n\n# Write final manifest with self-verifying header\n{\n  echo \"# MANIFEST_HASH: $MANIFEST_HASH\"\n  echo \"# Generated: $TIMESTAMP\"\n  echo \"# Verify with: tail -n +4 CHECKSUMS.sha256 | sha256sum\"\n  cat \u002Ftmp\u002Fchecksums.tmp\n} > CHECKSUMS.sha256\n\nrm \u002Ftmp\u002Fchecksums.tmp\n\necho \"✓ Generated CHECKSUMS.sha256 with $MANIFEST_HASH\"\n```\n\n### Routine Verification (--verify)\n\n```bash\naiwg verify-archive \u002Fpath\u002Fto\u002Farchive --verify\n```\n\n**Steps**:\n1. Read `MANIFEST_HASH` from header\n2. Compute hash of manifest content (lines 4+)\n3. Compare hashes (quick integrity check)\n4. If manifest is intact, verify all files against checksums\n5. Report any mismatches or missing files\n\n### Regeneration After Changes (--fix)\n\n```bash\naiwg verify-archive \u002Fpath\u002Fto\u002Farchive --fix\n```\n\n**Use case**: After adding\u002Fremoving\u002Fmodifying files in the archive.\n\n**Steps**:\n1. Backup existing `CHECKSUMS.sha256` to `CHECKSUMS.sha256.bak`\n2. Regenerate manifest (same as `--generate`)\n3. Report changes: added files, removed files, modified files\n4. Keep backup for comparison\n\n**Example output**:\n```\nBacked up existing manifest to CHECKSUMS.sha256.bak\nRegenerating checksums...\nChanges detected:\n  Added: .\u002Faudio\u002Fepisode-003.opus\n  Modified: .\u002FREADME.md (hash changed)\n  Removed: .\u002Faudio\u002Fepisode-001-draft.opus\n✓ Generated new CHECKSUMS.sha256\n```\n\n## VERIFY.md Template\n\nHuman-readable verification instructions placed in archive root:\n\n```markdown\n# Archive Integrity Verification\n\nThis archive contains a self-verifying checksum manifest for detecting corruption, tampering, or transfer errors.\n\n## Quick Verification (Manifest Integrity)\n\nVerify the manifest has not been tampered with (sub-second):\n\n\\`\\`\\`bash\ncd \"$(dirname \"$0\")\"\nEXPECTED=$(grep '^# MANIFEST_HASH:' CHECKSUMS.sha256 | awk '{print $3}')\nACTUAL=$(tail -n +4 CHECKSUMS.sha256 | sha256sum | awk '{print $1}')\n[ \"$EXPECTED\" = \"$ACTUAL\" ] && echo \"✓ Manifest integrity verified\" || echo \"✗ Manifest tampered\"\n\\`\\`\\`\n\n## Full Verification (All Files)\n\nVerify all files match their checksums:\n\n\\`\\`\\`bash\ncd \"$(dirname \"$0\")\"\ntail -n +4 CHECKSUMS.sha256 | sha256sum -c\n\\`\\`\\`\n\n## Archive Information\n\n- **Generated**: {TIMESTAMP}\n- **File count**: {FILE_COUNT}\n- **Total size**: {TOTAL_SIZE}\n- **Manifest hash**: {MANIFEST_HASH}\n\n## Recommended Verification Schedule\n\n- **Daily**: Quick manifest integrity check\n- **Weekly**: Full file verification\n- **After transfer**: Full verification immediately after copying\u002Fdownloading\n- **Before backup**: Verify source integrity before creating backup\n\n## If Verification Fails\n\n1. **Manifest integrity failure**: Manifest has been tampered with or corrupted. Regenerate from source.\n2. **File verification failure**: File has been corrupted or modified. Restore from backup or regenerate.\n\n## Regeneration\n\nAfter making changes to the archive, regenerate the manifest:\n\n\\`\\`\\`bash\naiwg verify-archive . --fix\n\\`\\`\\`\n\n---\n\n*Self-verifying checksums using SHA-256 (NIST FIPS 180-4)*\n```\n\n**Template variables**:\n- `{TIMESTAMP}` - ISO 8601 generation timestamp\n- `{FILE_COUNT}` - Number of files in manifest\n- `{TOTAL_SIZE}` - Total archive size in human-readable format\n- `{MANIFEST_HASH}` - SHA-256 hash of manifest content\n\n## PROVENANCE.jsonld Integration\n\nW3C PROV-O format with PREMIS fixity metadata:\n\n```json\n{\n  \"@context\": {\n    \"prov\": \"http:\u002F\u002Fwww.w3.org\u002Fns\u002Fprov#\",\n    \"premis\": \"http:\u002F\u002Fwww.loc.gov\u002Fpremis\u002Frdf\u002Fv3\u002F\",\n    \"schema\": \"http:\u002F\u002Fschema.org\u002F\",\n    \"xsd\": \"http:\u002F\u002Fwww.w3.org\u002F2001\u002FXMLSchema#\"\n  },\n  \"@graph\": [\n    {\n      \"@id\": \"urn:uuid:ARCHIVE_UUID\",\n      \"@type\": [\"prov:Entity\", \"premis:IntellectualEntity\"],\n      \"prov:generatedAtTime\": {\n        \"@type\": \"xsd:dateTime\",\n        \"@value\": \"2026-02-14T18:45:22.387654321Z\"\n      },\n      \"premis:hasFixity\": {\n        \"@type\": \"premis:Fixity\",\n        \"premis:hasMessageDigest\": \"sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\n        \"premis:hasMessageDigestAlgorithm\": \"SHA-256\",\n        \"premis:hasMessageDigestOriginator\": \"aiwg verify-archive v2026.2.6\",\n        \"premis:fixityCheckDateTime\": {\n          \"@type\": \"xsd:dateTime\",\n          \"@value\": \"2026-02-14T18:45:22.387654321Z\"\n        }\n      },\n      \"schema:contentUrl\": \".\u002FCHECKSUMS.sha256\"\n    },\n    {\n      \"@id\": \"urn:uuid:ACTIVITY_UUID\",\n      \"@type\": \"prov:Activity\",\n      \"prov:startedAtTime\": {\n        \"@type\": \"xsd:dateTime\",\n        \"@value\": \"2026-02-14T18:45:20.123456789Z\"\n      },\n      \"prov:endedAtTime\": {\n        \"@type\": \"xsd:dateTime\",\n        \"@value\": \"2026-02-14T18:45:22.387654321Z\"\n      },\n      \"prov:wasAssociatedWith\": {\n        \"@id\": \"urn:aiwg:agent:media-curator\"\n      }\n    },\n    {\n      \"@id\": \"urn:aiwg:agent:media-curator\",\n      \"@type\": \"prov:SoftwareAgent\",\n      \"schema:name\": \"AIWG Media Curator\",\n      \"schema:softwareVersion\": \"2026.2.6\"\n    }\n  ]\n}\n```\n\n**Key relationships**:\n- `premis:hasFixity` - Links entity to fixity information\n- `premis:hasMessageDigest` - SHA-256 hash with `sha256:` prefix\n- `premis:fixityCheckDateTime` - When verification was performed\n- `prov:wasAssociatedWith` - Agent that performed verification\n\n**Use case**: Long-term digital preservation requiring audit trails and provenance chains.\n\n## Standards Compliance\n\n| Standard | Purpose | Reference |\n|----------|---------|-----------|\n| SHA-256 | Cryptographic hash function | NIST FIPS 180-4 |\n| ISO 8601 | Timestamp format | ISO 8601:2019 |\n| PREMIS 3.0 | Preservation metadata | Library of Congress |\n| W3C PROV-O | Provenance ontology | W3C Recommendation 2013 |\n| JSON-LD 1.1 | Linked data format | W3C Recommendation 2020 |\n\n## Error Handling\n\n**Missing archive**: Exit with error if archive path does not exist.\n\n**No CHECKSUMS.sha256**: For `--verify`, exit with error. For `--generate`, create new manifest.\n\n**Hash mismatch**: Report which files failed, exit code 1.\n\n**Permission errors**: Report files that cannot be read, continue verification for accessible files.\n\n**Corrupt manifest**: If manifest cannot be parsed, exit with error and suggest regeneration.\n\n## Deliverables\n\nWhen running `--generate` or `--fix`:\n\n1. **CHECKSUMS.sha256** - Self-verifying checksum manifest\n2. **VERIFY.md** - Human-readable verification instructions\n\nWhen running `--provenance`:\n\n3. **PROVENANCE.jsonld** - W3C PROV-O provenance record with PREMIS fixity\n\n## Examples\n\n**Initial setup**:\n```bash\naiwg verify-archive ~\u002Fmedia\u002Fpodcast-archive --generate\n```\n\n**Routine verification**:\n```bash\naiwg verify-archive ~\u002Fmedia\u002Fpodcast-archive --verify\n```\n\n**After adding new episodes**:\n```bash\naiwg verify-archive ~\u002Fmedia\u002Fpodcast-archive --fix\n```\n\n**Generate with provenance**:\n```bash\naiwg verify-archive ~\u002Fmedia\u002Fpodcast-archive --generate --provenance\n```\n\n**Automated monitoring** (cron):\n```bash\n0 2 * * * aiwg verify-archive \u002Fmedia\u002Farchives\u002Fpodcast --verify --quiet || echo \"Archive verification failed\" | mail -s \"Alert\" admin@example.com\n```\n\n## References\n\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fhuman-authorization.md — Seek explicit authorization before regenerating or fixing checksums (--generate, --fix)\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fintegrity-verification\u002FSKILL.md — Core integrity verification patterns used by this skill\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fprovenance-tracking\u002FSKILL.md — Provenance records generated via --provenance flag\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fcurate\u002FSKILL.md — Orchestration skill that invokes verify-archive as a curation phase\n",{"name":5,"namespace":56,"platforms":57,"commandHint":59,"description":7},"aiwg",[58],"all",{"model":44,"category":60,"modelRole":38,"modelTier":61,"allowedTools":62,"argumentHint":63},"media-curator","economy","Bash, Read, Write, Glob, Grep","\u003Carchive_path> [--generate] [--verify] [--provenance] [--fix]","main","6754967c344ccb087a8de06972f55a41067b291b","agentic\u002Fcode\u002Fplugins\u002Fmedia-curator\u002Fskills\u002Fverify-archive",36,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg","https:\u002F\u002Faiwg.io","https:\u002F\u002Fgithub.com\u002Fjmagly","https:\u002F\u002Fintegrolabs.io","ml\u002Fai, industrial automation, safety\u002Fsecurity, ssi\r\n\r\nmagly.net\r\nintegrolabs.io\r\naiwg.io\r\nfortemi.com\r\npagenary.com\r\nbytecask.com","2026-11-14 10:46:34",{"source":9,"skillName":5,"commands":75,"prompt":85,"zipAvailable":86},[76,79,82],{"tool":77,"command":78},"npx","npx skills add jmagly\u002Faiwg --skill verify-archive",{"tool":80,"command":81},"bunx","bunx skills add jmagly\u002Faiwg --skill verify-archive",{"tool":83,"command":84},"pnpm","pnpm dlx skills add jmagly\u002Faiwg --skill verify-archive","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fmedia-curator\u002Fskills\u002Fverify-archive\u002FSKILL.md",true,[],[89,97,102,127,146,151],{"skillNo":90,"name":91,"nameZh":17,"description":92,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":96},"01M78KW7PZJ9YQZQMW84SN2YD4","plugin-search","Search marketplaces for plugins using configured local manifests and directory caches; rank matching plugins by observed installs, review tier and cache dates without installing or fetching anything","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Futils\u002Fskills\u002Fplugin-search\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":98,"name":91,"nameZh":17,"description":92,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":96},"01M78KSEZS9ZNNFESY9ANW22S0","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Fskills\u002Fplugin-search\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":17,"description":105,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":51},"01M70QA0BSYJ49EES9V4RE8QH1","host-hardening","Read-only system hardening baseline and plan-first host hardening recommendations for SSH, Docker bind addresses, firewall persistence, datastores, exporters and audit retention.","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fsecurity-engineering\u002Fskills\u002Fhost-hardening\u002FSKILL.md",[],[109,110,111,112,113,42,114,115,116,117,118,119,120,45,121,122,123,124,125,126],"hardening","host","host hardening","verification","secrets","request","remediation","recommendations","audit","plan","port","bind","access","only","retention","re","never","firewall",{"skillNo":128,"name":129,"nameZh":17,"description":130,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":51},"01M70PNT2Z4HMZPRBTAF6073NN","exposure-analysis","Read-only firewall analysis and effective host exposure reconstruction for Docker published ports, UFW bypass, stale rules, CDN scope, IPv6 asymmetry and external probe allowlists.","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fforensics\u002Fskills\u002Fexposure-analysis\u002FSKILL.md",[],[134,135,136,137,138,41,42,139,119,125,45,140,110,141,122,142,143,126,144,145],"analysis","exposure analysis","collection","reconstruction","operator","credentials","unknown","internet","local","scope","ports","ufw",{"skillNo":147,"name":104,"nameZh":17,"description":105,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":51},"01M70P8QATMPKA78E4FT5D2TNA","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsecurity-engineering\u002Fskills\u002Fhost-hardening\u002FSKILL.md",[],[109,110,111,124,125,126,120,123,116,113,42,114,115,117,118,119,112,45,121,122],{"skillNo":152,"name":129,"nameZh":17,"description":130,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":153,"categories":154,"keywords":155,"publishedAt":51},"01M70NMPVJ5H0JH131P60FW4R8","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fforensics-complete\u002Fskills\u002Fexposure-analysis\u002FSKILL.md",[],[134,135,145,144,138,143,142,122,137,41,42,139,119,136,45,140,110,126,125,141]]