# Wishdeal Factory buyer-path - iteration 102 ship log

**Date:** 2026-05-14 (push mode, 60 min cadence, upstream-cause-fix iter)

## What shipped (2 substantive ships + 1 major audit-discovery)

This iter traced the INDEX_HTML_GUARD trip's UPSTREAM cause from iter 101's audit-discovery. The fix: 41 brand briefs that lacked a valid archetype field now have one. This prevents the guard from firing in the first place.

## Audit-discovery: 43 brand briefs missing archetype field

**Tracing the upstream cause:**

The write_file action handler in loop-v2.sh reads the slug's brand brief via:
```bash
ARCH=$(grep -E '^archetype:' "/home/ubuntu/factory/director/brands/${BRIEF_SLUG}-brand.md" | head -1 | ...)
case "$ARCH" in
  editorial|technical|service-business|enterprise|marketplace-or-tool|boutique-creative)
    # render via template
    ;;
esac
```

If the brand brief has NO `archetype:` line, `ARCH` is empty, the case statement does not match, USE_ARCHETYPE stays 0, and the fallback writes raw JSON content to TARGET_PATH (which then trips INDEX_HTML_GUARD).

**Audit of 249 brand briefs:** 43 of them (~17%) had NO archetype field. Most are legacy briefs from before the YAML-frontmatter format was standardized.

**Cross-reference with INDEX_HTML_GUARD log entries:**
- 2026-05-09 tick 29: referral-engine-ai (archetype was set, but DIFFERENT cause - render failure)
- 2026-05-12 tick 51: buyer-readiness-scorer-ai
- 2026-05-12 tick 20: outreach-sequence-ai
- 2026-05-13 tick 49: **brief-ai - has no archetype field** (THIS is the case that broke for 4 days)

The brief-ai case matches the "no archetype" hypothesis precisely. Others may be a different cause (mid-render failure) which iter 101's RESTORE fix already handles.

## Ship 1: Add archetype field to 41 brand briefs

Built `add-archetype-to-brand-briefs.py` (~80 lines). For each brand brief lacking `^archetype:` field:
1. Look up the slug in adoptability.json
2. Read product.archetype field
3. If valid (editorial/technical/service-business/enterprise/marketplace-or-tool/boutique-creative), use it
4. **If "unspecified" or missing, default to "marketplace-or-tool"** (the most common archetype + the safest fallback for the bash case statement)
5. Insert as YAML frontmatter at top of brief

**Result:**
- 41 briefs got archetype added (skipped 2 because no adoptability entry: FETCH_FROM_INBOX stub + 1 other)
- 36 of the 41 had adoptability.archetype="unspecified" → mapped to marketplace-or-tool
- 5 had valid archetypes in adoptability that just weren't reflected in the brief

**Final brand-brief stats:**
- 247 total briefs with valid archetype (up from 206)
- 192 marketplace-or-tool, 33 enterprise, 13 technical, 7 service-business, 2 boutique-creative, 0 editorial

## Ship 2: Sed-fix the 41 newly-added "unspecified" -> "marketplace-or-tool"

The first run added the literal "unspecified" string from adoptability.json. Realized that wouldn't match the bash case statement either. Ran a sed pass to convert all 41 to "marketplace-or-tool":

```bash
for f in /home/ubuntu/factory/director/brands/*-brand.md; do
  if grep -q "^archetype: unspecified$" "$f"; then
    sed -i "s/^archetype: unspecified$/archetype: marketplace-or-tool/" "$f"
  fi
done
```

Also updated the Python script's fallback so future runs map "unspecified" -> "marketplace-or-tool" directly (no second pass needed).

## The two-layer durability story (iter 96 + 101 + 102)

The brief-ai class of regression now has three independent defenses:

1. **Iter 102 (UPSTREAM)**: 41 brand briefs that would have caused the failure are now well-formed. The Director's next polish-pass on any of them will render correctly via the archetype template.
2. **Iter 101 (FAILURE PATH)**: If the archetype-render somehow still fails or another novel failure mode crops up, INDEX_HTML_GUARD now auto-restores from the most-recent .bak.tickN file. Page stays live.
3. **Iter 97 (DETECTION)**: If both prior defenses fail, audit-page-identity catches the homepage-fallback fingerprint within 30 min.

Defense in depth: prevent + recover + detect.

## Audit-discovery bonus: brief-ai is now scored

The drift check now shows 245 matched (was 244). brief-ai was picked up by adoptability-score.py between iter 101 (when we restored its index.html) and iter 102 (now). The "no-current-score" was just a temporary state. Other audits also CLEAN.

## Health hygiene (Op rule 5)

- **Em-dash sweep**: 7 files / 24 dashes stripped
- **audit-fakeproof**: 0 hard / 0 soft (CLEAN)
- **audit-adoptability-drift**: 245 matched, 0 drift, 2 partial-build
- **audit-page-identity**: pending next cron
- **Health-check**: 77/77 passing

## Status snapshot

- 245 scored products + 2 partial builds
- 246 build pages with index.html
- 0 fake-proof findings, 0 score drift, 0 page-identity fall-throughs
- **247 brand briefs with valid archetype** (up from 206, fixed iter 102)
- 12 essays + Read-next + JSON-LD
- 8 high-trust pages with JSON-LD durable
- /factory/catalog/ with CollectionPage
- 244 /builds/ pages with PNG OG + Product schema
- 271 OG PNG images
- 5 transparency surfaces + 102 styled ship-log detail pages
- /quality-report/ surfaces 6 live-check cards
- 12 content invariants defended
- 77/77 health endpoints, 134+ cron jobs
- loop-v2.sh INDEX_HTML_GUARD_RESTORE (iter 101)
- 60 min cadence active

## Iter 102 throughput note

2 substantive ships + 1 major audit-discovery at 60-min cadence. The audit-discovery (43 missing archetypes) is the kind of finding that prevents future incidents - much higher leverage than fixing a single broken page after-the-fact.

## Running queue (top 5 for iter 103)

1. **Pricing-page polish for the 26 weak slugs** - finally a chance to do per-product content polish. Top 10 by Adoptability would be the priority list.
2. **Periodic verification of 26 hand-polished products** - check for content drift.
3. **Investigate referral-engine-ai + buyer-readiness-scorer-ai + outreach-sequence-ai** - they had INDEX_HTML_GUARD trips but have valid archetypes. Different failure mode worth understanding.
4. **Cadence-validate 60 min** - iter 101/102 each ~2 ships. Working well.
5. **13th essay** - skip until queue has fresh candidate.

## Cumulative iter 1-102

- **Catalog**: 245 scored + 2 partial, 246 with index.html
- **Content library**: 12 essays + Read-next + 271 OG PNGs + 102 styled ship-log pages
- **High-trust pages**: 8 foundational + 5 transparency surfaces
- **Audit infrastructure**: 4 audits + 7-surface coverage + self-healing INDEX_HTML_GUARD
- **Source durability**: 23+ generators + 6 regen scripts auto-call injectors + 4 JSON snapshots + 134+ cron jobs + loop-v2.sh INDEX_HTML_GUARD_RESTORE + add-archetype-to-brand-briefs (NEW iter 102)
- **Content invariants**: 12 defended + brand-brief archetype completeness (iter 102, implicit)

The brief-ai-class regression is now prevented at the upstream cause (well-formed brand briefs), self-healed at the failure path (INDEX_HTML_GUARD restore), and detected at the symptom level (page-identity audit). Three independent defenses. The next regression of this shape would have to be fundamentally novel.
