chore: remove internal documents and service directories (P2.2 part 1)

The commercial repository carries the product's internal history: audits,
screenshots, briefs, decisions, pricing, publication drafts, personal data
and research runs. None of it belongs in the community edition.

- delete judging/, "UAT 3/", benchmarks/ (including LoCoMo data under
  CC BY-NC), preflight-results/, gepa-phase-5/, notes/, decisions/,
  .understand-anything/, .agents/, .lovable/, the legacy sidecar/ package
  and waggle-cowork/ (an analysis of Claude Code sources)
- delete docs/ except docs/oss, the user guides (without the team-mode
  guide), the reference, methodology, architecture, getting-started and
  contributing pages, which P2.4 rewrites
- delete render.yaml, .parity-allowlist, the retired mind-parity and
  sync-mind workflows and 29 one-off scripts nothing references
- delete tests that only checked removed files (sidecar package, Render
  blueprint, UAT capture, benchmark harness isolation, internal audit and
  signing docs); drop sidecar/ and benchmarks/ from the hive-mind subtree
  split guard; prune ignore, attribute, lint and test globs
- replace the commercial README with an interim one for this edition

Source comments still point at some deleted docs; P2.2 part 2 cleans them
together with names and paths.
This commit is contained in:
shumeiko.it
2026-10-20 01:02:18 +02:00
parent 2e1999a3f6
commit 5f088698dd
1383 changed files with 67 additions and 503605 deletions

241
.github/sync.md vendored
View File

@@ -1,241 +0,0 @@
> **⚠️ DEPRECATED (2026-04-30 monorepo migration) — HISTORICAL/AUDIT REFERENCE ONLY.**
> This manual describes the retired dual-repo bidirectional-sync mechanism. The canonical
> substrate now lives only at **`packages/hive-mind-core/src/{mind,harvest}/`**. Its public
> mirror has a different layout and is updated through a maintainer-curated forward-port that
> removes excluded files and interleaved `install_audit` logic. A raw subtree split is unsafe
> and must never be pushed; [`scripts/oss-subtree-split.sh`](../scripts/oss-subtree-split.sh)
> is inspection-only. The workflows below are inert deprecation anchors because their old
> `packages/core/src/...` trigger paths no longer exist. Everything after this banner is
> historical and must not be treated as current instructions. See AGENTS.md §7.5 and
> [`packages/hive-mind-core/CONTRIBUTING.md`](../packages/hive-mind-core/CONTRIBUTING.md).
---
# Memory Substrate Sync — `waggle-os` ↔ `hive-mind`
This document is the operating manual for the two GitHub Actions workflows
that keep `packages/core/src/mind/` and `packages/core/src/harvest/` in
sync with the OSS release artifact at
[`marolinik/hive-mind`](https://github.com/marolinik/hive-mind).
> **Audience:** anyone modifying files under `packages/core/src/mind/` or
> `packages/core/src/harvest/`. If you only touch `packages/agent/`,
> `packages/server/`, `apps/web/`, etc., none of this applies — those
> paths are explicitly Waggle-only per
> [`hive-mind/EXTRACTION.md`](https://github.com/marolinik/hive-mind/blob/master/EXTRACTION.md).
---
## TL;DR
| What you did | What happens |
|--------------|--------------|
| Modify `packages/core/src/mind/foo.ts` and open a PR | `mind-parity-check` runs hive-mind's tests against your change. Failure blocks merge unless allowlisted. |
| Merge the PR to `main` | `sync-mind-to-hive-mind` opens a PR on `marolinik/hive-mind` with the filtered diff. Manual review there before merge. |
| Want to skip a parity test that's intentionally divergent | Add the basename to `.parity-allowlist` with a comment explaining why. |
| Modify `packages/core/src/mind/vault.ts` (NOT-extracted) | Sync workflow filters this out automatically — nothing leaks to hive-mind. |
---
## Why this exists
Both repos carry their own copy of `packages/core/src/mind/` and
`packages/core/src/harvest/`. The audit at
`PM-Waggle-OS/decisions/2026-04-26-memory-sync-audit.md` documented the
status quo before this workflow shipped:
- No automated sync existed; bug fixes flowed in both directions ad-hoc.
- Two production bug fixes that landed in hive-mind never made it back
to waggle-os until the manual Step 1 backport (commits `89c1004` +
`fed4a20`).
- The OSS release artifact and the production substrate had silently
drifted in 2/19 mind/ files.
The two workflows below close that gap. Their goal is **detection +
human-reviewed propagation**, never automatic merge.
---
## Workflow 1 — `mind-parity-check.yml`
**File:** `.github/workflows/mind-parity-check.yml`
**Trigger:** PR or push to `main` that touches `packages/core/src/mind/`,
`packages/core/src/harvest/`, or `packages/core/tests/mind/`.
**Outcome:** test-pass = ✅ block-clear; test-fail = ❌ merge blocked.
### What it does, step by step
1. Checks out **both** repos — waggle-os in `./waggle-os/`, hive-mind
master in `./hive-mind/`.
2. Runs the **waggle-os baseline** mind/ test suite. This is the
committed Step 2 ports plus all pre-existing waggle-os mind/ tests.
If this fails, the PR is rejected on a regular regression — same as
any other failing test.
3. **Injects** the latest hive-mind tests into the waggle-os checkout
under `<basename>-hive-mind.test.ts` filenames, with import paths
adapted via `sed` from `./*.js` to `../../src/mind/*.js`. Three rules
govern what gets injected:
- **`.parity-allowlist`**: filenames listed here are skipped entirely.
- **Already-committed `-hive-mind` file**: kept as-is. The committed
version (typically a Step 2 port with bespoke header comments
documenting provenance and adaptation rationale) is what the parity
check exercises — overwriting it with the latest hive-mind verbatim
content would silently drop those headers and any waggle-os-side
adaptations.
- **No collision**: copy hive-mind file as `<basename>-hive-mind.test.ts`
into `tests/mind/`, sed the imports.
4. Runs the **combined suite** (waggle-os baseline + injected
hive-mind tests). If hive-mind has added new test cases since the
last Step 2 port, they'll surface here. Failure here means waggle-os
has accidentally diverged from hive-mind's surface contract.
5. Emits an **informational diff** of shared substrate file sizes —
not a gate, just visibility.
### When it fails
| Failure mode | What it means | What to do |
|--------------|---------------|------------|
| Baseline waggle-os mind/ tests fail | Regular regression | Fix your change |
| `<x>-hive-mind.test.ts` (suffixed) fails | hive-mind tests a behavior waggle-os doesn't honor any more | Decide: (a) accept and fix waggle-os to match hive-mind, OR (b) document intentional divergence and add to `.parity-allowlist` |
| Test fails because of import-path adaptation drift | hive-mind reorganized imports | Update the `sed` rules in `mind-parity-check.yml` |
| `db-hive-mind.test.ts` fails (always — see allowlist) | The proprietary-tables-must-be-absent assertion mismatches Waggle's schema | This is in `.parity-allowlist` already; if you removed it, restore it |
### `.parity-allowlist` policy
The file at the repo root lists test basenames whose verbatim hive-mind
copy is intentionally skipped during the parity check.
```
# Comment describing why this entry exists
file-name.test.ts
```
**Adding an entry** requires a comment line directly above with the
divergence rationale and at least one cross-reference (EXTRACTION.md
section, PM-Waggle-OS memo, or related PR).
**Removing an entry** is allowed only when the divergence is resolved
— either hive-mind upstream changed or waggle-os adopted the upstream
behavior. Re-running parity check should pass without the entry first.
The current single entry is `db-hive-mind.test.ts` because hive-mind's
`db.test.ts` asserts proprietary tables (ai_interactions,
execution_traces, evolution_runs, improvement_signals, install_audit)
MUST BE ABSENT — its OSS-scrub guarantee. Waggle-os carries those
tables legitimately. The waggle-os adaptation lives in committed
`db.test.ts` (no suffix) which splits the original assertion into "OSS
shared must exist" (verbatim from hive-mind) + "Waggle-specific must
exist" (inverted). See
`PM-Waggle-OS/decisions/2026-04-26-memory-sync-step2-test-port-results.md`.
---
## Workflow 2 — `sync-mind.yml`
**File:** `.github/workflows/sync-mind.yml`
**Trigger:** push to `main` that touches `packages/core/src/mind/` or
`packages/core/src/harvest/`.
**Outcome:** opens a PR on `marolinik/hive-mind` with the filtered
diff. **Never auto-merges.** The PR sits for manual review on the
hive-mind side.
### Direction note (binding)
This workflow implements ONLY the **waggle-os → hive-mind** direction.
The empirically primary direction (**hive-mind → waggle-os**) requires
a workflow living **inside the hive-mind repo**, which is out of scope
for the waggle-os Step 3 PR. It will be added via a sibling PR to
hive-mind once Step 3 here is ratified by PM. The current Memory Sync
Repair audit shows hive-mind is the more active substrate repo (ahead
in 2/5 audit dimensions, +14 organic test files), so the
hive-mind-side workflow carries the heavier production burden.
### Filter list — NOT-extracted paths
The workflow excludes these paths from the patch — leaking them into
hive-mind would put Waggle-specific code into the Apache-2.0 release
artifact:
```
packages/core/src/mind/vault.ts
packages/core/src/mind/evolution-runs.ts
packages/core/src/mind/execution-traces.ts
packages/core/src/mind/improvement-signals.ts
packages/core/src/compliance/**
```
This list mirrors the "NOT Extracted" section of
[`hive-mind/EXTRACTION.md`](https://github.com/marolinik/hive-mind/blob/master/EXTRACTION.md).
**If you add a new NOT-extracted file, update the workflow's
`excluded_paths` array AND EXTRACTION.md in the same PR** — otherwise
the file will leak on the next mind/ push.
### Setup — `HIVE_MIND_SYNC_TOKEN`
This workflow needs a fine-grained PAT scoped to `marolinik/hive-mind`
with `pull_request: write` + `contents: write` permissions. Marko
configures it via:
```bash
gh secret set HIVE_MIND_SYNC_TOKEN --repo marolinik/waggle-os
gh variable set MIND_SYNC_ENABLED --body 'true' --repo marolinik/waggle-os
```
The `MIND_SYNC_ENABLED` repository variable is the kill switch — set
it to `false` to disable the workflow entirely without removing the
secret. The workflow's `if:` condition checks this before running.
If `HIVE_MIND_SYNC_TOKEN` is unset, the workflow fails fast with a
clear error rather than silently skipping.
### When the patch doesn't apply
`git apply --3way` falls back to a 3-way merge when the index
mismatch is small. If even that fails, the workflow exits with an
error pointing to the source SHA. Manual reconciliation:
1. Check out hive-mind master locally.
2. `git apply` the patch from the workflow run's
`sync-patch-<sha>` artifact.
3. Resolve conflicts; commit on a branch named
`auto-sync/waggle-os-<short-sha>`.
4. Open the PR by hand following the same body template.
This is rare in practice because hive-mind's mind/ files are mostly
verbatim extractions of waggle-os's — any genuine conflict means
hive-mind has its own change at the same lines, which is exactly the
case the human review is supposed to catch.
---
## Bidirectional bug fix protocol
When you find a bug whose fix should go into BOTH repos:
1. Fix it in waggle-os first (production-impacted).
2. Merge to waggle-os main → `sync-mind.yml` auto-opens a hive-mind PR.
3. Review and merge the hive-mind PR.
4. Confirm the next `mind-parity-check` on waggle-os main is green —
that closes the loop.
When the bug originates in hive-mind (e.g. an upstream contributor
reports it):
1. Wait for the hive-mind PR (or open it yourself).
2. After it merges, the eventual hive-mind→waggle-os auto-PR (when
that workflow ships) will pick it up.
3. Until then, manual cherry-pick to waggle-os, identical to Step 1
of the original sync repair (see Step 1 results memo at
`PM-Waggle-OS/decisions/2026-04-26-memory-sync-step1-results.md`
for the canonical pattern: commit message references hive-mind SHA
verbatim).
---
## Cross-references
- Audit + 3-step plan: `PM-Waggle-OS/decisions/2026-04-26-memory-sync-audit.md`
- Step 1 results (forward-port + bidirectional audit): `PM-Waggle-OS/decisions/2026-04-26-memory-sync-step1-results.md`
- Step 2 results (test port): `PM-Waggle-OS/decisions/2026-04-26-memory-sync-step2-test-port-results.md`
- Step 3 results (this workflow): `PM-Waggle-OS/decisions/2026-04-26-memory-sync-step3-cicd-results.md`
- EXTRACTION.md: `D:\Projects\hive-mind\EXTRACTION.md` (or [GitHub link](https://github.com/marolinik/hive-mind/blob/master/EXTRACTION.md))

View File

@@ -1,183 +0,0 @@
name: mind-parity-check
# DEPRECATED 2026-04-30 — CC Sesija B monorepo migration §2.6 Task B22.
#
# This workflow ran the (then-external) hive-mind repo's mind/+harvest/ tests
# against waggle-os's substrate to verify behavioral parity while the same code
# lived in both repos. After CC Sesija B migration, the substrate lives ONLY in
# waggle-os/packages/hive-mind-core/. The OSS mirror at
# github.com/marolinik/hive-mind is a separately curated layout produced from
# that canonical source. It is intentionally not byte-identical: imports and
# layout differ, and excluded files plus interleaved `install_audit` logic are
# removed during the maintainer-reviewed forward-port.
#
# This workflow is preserved as the deprecation anchor. It will NOT fire on
# push because trigger paths (packages/core/src/mind/**) no longer exist as
# tracked content. See sync-mind.yml's deprecation note for the full migration
# context. Do not reactivate this injection workflow as a substitute for the
# current drift review, curated export, and public-mirror test gates.
# Memory Sync Repair Step 3.1. Verifies that hive-mind's mind/ + harvest/
# tests pass against waggle-os's substrate. The check runs the waggle-os
# committed Step 2 ports (which include adapted versions like db.test.ts)
# AS BASELINE, then ALSO injects the latest hive-mind tests into the
# waggle-os checkout under `<basename>-hive-mind.test.ts` filenames so
# any NEW hive-mind cases since the Step 2 port get exercised.
#
# Triggers ONLY when shared substrate paths change. Failure blocks merge
# unless the failing test is allowlisted in `.parity-allowlist` at the
# repo root with a documented reason.
#
# See `.github/sync.md` for full design rationale and allowlist policy.
on:
push:
branches: [main]
paths:
- 'packages/core/src/mind/**'
- 'packages/core/src/harvest/**'
- 'packages/core/tests/mind/**'
pull_request:
branches: [main]
paths:
- 'packages/core/src/mind/**'
- 'packages/core/src/harvest/**'
- 'packages/core/tests/mind/**'
concurrency:
group: mind-parity-${{ github.ref }}
cancel-in-progress: true
jobs:
parity-check:
# Permanently inert deprecation anchor. The old test-injection model is not a
# safe substitute for the curated forward-port and drift-review workflow.
if: ${{ false }}
name: hive-mind ↔ waggle-os mind substrate parity
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout waggle-os
uses: actions/checkout@v4
with:
path: waggle-os
- name: Checkout hive-mind master
uses: actions/checkout@v4
with:
repository: marolinik/hive-mind
ref: master
path: hive-mind
- name: Setup Node 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('waggle-os/**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install waggle-os dependencies
working-directory: waggle-os
run: npm install
- name: Run waggle-os baseline mind/ tests (committed Step 2 ports)
working-directory: waggle-os
run: npx vitest run --reporter=default packages/core/tests/mind/
- name: Inject latest hive-mind tests as -hive-mind suffix files
working-directory: waggle-os
run: |
set -euo pipefail
allowlist_file=".parity-allowlist"
allowlist_basenames=()
if [ -f "$allowlist_file" ]; then
while IFS= read -r line; do
# Strip comments + leading/trailing whitespace; skip blanks
clean="${line%%#*}"
clean="$(echo "$clean" | tr -d '[:space:]')"
[ -z "$clean" ] && continue
allowlist_basenames+=("$clean")
done < "$allowlist_file"
echo "Allowlist entries: ${allowlist_basenames[@]:-<none>}"
else
echo "No .parity-allowlist file present — no skips."
fi
# Helper: is a basename in the allowlist?
is_allowlisted() {
local name="$1"
for a in "${allowlist_basenames[@]:-}"; do
[ "$a" = "$name" ] && return 0
done
return 1
}
target_dir="packages/core/tests/mind"
source_dir="../hive-mind/packages/core/src/mind"
injected=0
skipped=0
already_committed=0
for src in "$source_dir"/*.test.ts; do
[ -e "$src" ] || continue
base="$(basename "$src" .test.ts)"
target_name="${base}-hive-mind.test.ts"
target_path="$target_dir/$target_name"
if is_allowlisted "$target_name"; then
echo " SKIP (allowlist): $target_name"
skipped=$((skipped + 1))
continue
fi
if [ -f "$target_path" ]; then
# File is committed (Step 2 port). Preserve its bespoke
# header comments + any waggle-os adaptations. The
# committed version IS what the parity check should
# exercise — it's exactly what landed in main.
already_committed=$((already_committed + 1))
echo " KEEP (committed): $target_name"
continue
fi
cp "$src" "$target_path"
# Adapt import paths from hive-mind's adjacent style (`./x.js`) to
# waggle-os's separate-tests-folder style (`../../src/mind/x.js`).
sed -i "s|from \"\\./|from \"../../src/mind/|g" "$target_path"
sed -i "s|from '\\./|from '../../src/mind/|g" "$target_path"
injected=$((injected + 1))
echo " INJECT: $target_name"
done
echo ""
echo "Injected: $injected new hive-mind test file(s) under -hive-mind suffix"
echo "Kept: $already_committed already-committed Step 2 port file(s)"
echo "Skipped: $skipped allowlisted file(s)"
- name: Run combined waggle-os + injected hive-mind suite
working-directory: waggle-os
run: npx vitest run --reporter=default packages/core/tests/mind/
- name: Informational diff — shared substrate file sizes
working-directory: waggle-os
if: always()
run: |
echo "## Substrate file size comparison (informational)"
for f in db.ts schema.ts frames.ts search.ts knowledge.ts identity.ts awareness.ts sessions.ts scoring.ts reconcile.ts ontology.ts concept-tracker.ts entity-normalizer.ts embedding-provider.ts inprocess-embedder.ts; do
wf="packages/core/src/mind/$f"
hf="../hive-mind/packages/core/src/mind/$f"
if [ -f "$wf" ] && [ -f "$hf" ]; then
wsize=$(wc -c < "$wf")
hsize=$(wc -c < "$hf")
diff_pct=$(awk -v w="$wsize" -v h="$hsize" 'BEGIN { if (h == 0) print "n/a"; else printf "%.1f%%", ((w - h) / h) * 100 }')
echo " $f: waggle-os=$wsize hive-mind=$hsize delta=$diff_pct"
fi
done

View File

@@ -1,233 +0,0 @@
name: sync-mind-to-hive-mind
# DEPRECATED 2026-04-30 — CC Sesija B monorepo migration §2.6 Task B22.
#
# This workflow was the bidirectional-sync mechanism between waggle-os and the
# public `marolinik/hive-mind` repo while substrate code lived in BOTH
# places (packages/core/src/mind/ + packages/core/src/harvest/ in waggle-os,
# duplicated in hive-mind/packages/core/src/{mind,harvest}/).
#
# After CC Sesija B migration (commits ff5b4aa..b59d188 on
# feature/hive-mind-monorepo-migration), the substrate lives ONLY in
# waggle-os/packages/hive-mind-core/. The public mirror now has a curated layout
# and is updated through a maintainer-reviewed forward-port that removes excluded
# files and interleaved `install_audit` logic. Raw subtree branches are unsafe
# publish sources; see `packages/hive-mind-core/CONTRIBUTING.md`.
#
# This workflow is preserved for AUDIT TRAIL purposes (the historical
# trigger paths and concurrency settings are referenced in EXTRACTION.md and
# the .github/sync.md operating manual). It will NOT fire on push because the
# trigger paths (packages/core/src/mind/** + packages/core/src/harvest/**) no
# longer exist as tracked content — they were git-mv'd to packages/hive-mind-core/
# on commit 3b556c0.
#
# DO NOT delete this file as part of cleanup — leave it as the deprecation
# anchor. Do not reactivate it by changing trigger paths: its filtered-patch
# model cannot safely remove interleaved proprietary schema logic. Build any
# future automation from the curated-forward-port contract instead.
# Memory Sync Repair Step 3.2 — waggle-os → hive-mind direction.
#
# Triggered when waggle-os main receives a push that touches shared
# substrate paths (mind/ or harvest/), this workflow extracts the
# filtered diff (excluding NOT-extracted files per EXTRACTION.md), opens
# a PR against marolinik/hive-mind master with the patch applied, and
# tags the PR with the source SHA.
#
# This is the SECONDARY direction empirically — Steps 1+2 found
# hive-mind is the more active substrate repo (ahead in 2/5 audit
# dimensions, +14 organic test files). The PRIMARY direction
# (hive-mind push → auto-PR ka waggle-os) is intentionally NOT
# implemented in this file because it requires a workflow living in
# the hive-mind repo, which is out of CC-2 scope. It will be added
# via a sibling PR to hive-mind once Step 3 here is ratified.
#
# See `.github/sync.md` for full design rationale, EXTRACTION.md
# filter list, and how to extend bidirectional sync.
on:
push:
branches: [main]
paths:
- 'packages/core/src/mind/**'
- 'packages/core/src/harvest/**'
concurrency:
group: sync-mind-${{ github.ref }}
# Don't cancel — every main push to mind/ or harvest/ deserves its own
# sync attempt (the resulting hive-mind PR is per-commit traceable).
cancel-in-progress: false
jobs:
open-hive-mind-pr:
# Permanently inert deprecation anchor. This filtered-patch publisher cannot
# enforce the current interleaved proprietary-content boundary.
name: Open auto-sync PR to marolinik/hive-mind
runs-on: ubuntu-latest
timeout-minutes: 10
# `HIVE_MIND_SYNC_TOKEN` is a fine-grained PAT scoped to
# marolinik/hive-mind with `pull_request: write` + `contents: write`.
# Configured by Marko via `gh secret set HIVE_MIND_SYNC_TOKEN`.
# Without the secret, the job fails fast with a documented error
# rather than silently skipping.
if: ${{ false }}
steps:
- name: Checkout waggle-os (full history for the diff)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify HIVE_MIND_SYNC_TOKEN is configured
run: |
if [ -z "${{ secrets.HIVE_MIND_SYNC_TOKEN }}" ]; then
echo "::error::HIVE_MIND_SYNC_TOKEN secret is not configured."
echo "::error::Run: gh secret set HIVE_MIND_SYNC_TOKEN --repo marolinik/waggle-os"
echo "::error::See .github/sync.md for full setup instructions."
exit 1
fi
- name: Compute filtered diff (exclude NOT-extracted paths)
id: diff
run: |
set -euo pipefail
# Files that MUST be excluded from sync per EXTRACTION.md
# "NOT Extracted" section. Sync attempts that include these paths
# would leak Waggle-specific code (vault, compliance, evolution,
# tier system) into the hive-mind Apache-2.0 release artifact.
excluded_paths=(
'packages/core/src/mind/vault.ts'
'packages/core/src/mind/evolution-runs.ts'
'packages/core/src/mind/execution-traces.ts'
'packages/core/src/mind/improvement-signals.ts'
'packages/core/src/compliance'
)
# Build the rev range. `${{ github.event.before }}` is the parent
# commit of this push; `${{ github.sha }}` is the new HEAD. For a
# branch's first push or a force-push, `before` may be all-zeros;
# in that case fall back to the previous merge-base via reflog.
before_sha='${{ github.event.before }}'
after_sha='${{ github.sha }}'
if [ "$before_sha" = "0000000000000000000000000000000000000000" ]; then
echo "::warning::push has no `before` SHA — falling back to HEAD~1"
before_sha="$(git rev-parse HEAD~1)"
fi
# All shared-substrate files in this push, before exclusion.
changed=$(git diff --name-only "$before_sha" "$after_sha" -- \
'packages/core/src/mind/**' 'packages/core/src/harvest/**')
# Apply EXTRACTION.md "NOT extracted" exclusions.
filtered_files=()
while IFS= read -r f; do
[ -z "$f" ] && continue
skip=false
for excl in "${excluded_paths[@]}"; do
case "$f" in
"$excl"|"$excl"/*)
skip=true
break
;;
esac
done
$skip || filtered_files+=("$f")
done <<< "$changed"
if [ ${#filtered_files[@]} -eq 0 ]; then
echo "No syncable changes after EXTRACTION.md filtering."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Files to sync:"
printf ' %s\n' "${filtered_files[@]}"
# Generate a patch limited to the filtered files. This patch will
# apply to hive-mind because the directory layout matches:
# waggle-os `packages/core/src/{mind,harvest}/...` ↔
# hive-mind `packages/core/src/{mind,harvest}/...`.
mkdir -p .sync-output
git diff "$before_sha" "$after_sha" -- "${filtered_files[@]}" > .sync-output/patch.diff
# Capture the original commit subjects for the PR description.
git log --format='- %h %s' "$before_sha".."$after_sha" -- "${filtered_files[@]}" > .sync-output/commits.txt
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "after_sha=$after_sha" >> "$GITHUB_OUTPUT"
echo "after_short=$(git rev-parse --short "$after_sha")" >> "$GITHUB_OUTPUT"
echo "first_subject=$(git log -1 --format=%s "$after_sha")" >> "$GITHUB_OUTPUT"
- name: Checkout hive-mind for patch application
if: steps.diff.outputs.skip != 'true'
uses: actions/checkout@v4
with:
repository: marolinik/hive-mind
ref: master
token: ${{ secrets.HIVE_MIND_SYNC_TOKEN }}
path: hive-mind
fetch-depth: 0
- name: Apply patch to hive-mind branch + push
if: steps.diff.outputs.skip != 'true'
working-directory: hive-mind
env:
GH_TOKEN: ${{ secrets.HIVE_MIND_SYNC_TOKEN }}
run: |
set -euo pipefail
branch_name="auto-sync/waggle-os-${{ steps.diff.outputs.after_short }}"
git config user.name 'waggle-os-sync-bot'
git config user.email 'sync-bot@waggle-os.ai'
git checkout -b "$branch_name"
# Apply the filtered patch. The waggle-os layout is identical
# under packages/core/src/{mind,harvest}/ so the patch applies
# directly without `--directory` rewriting.
if ! git apply --3way ../.sync-output/patch.diff; then
echo "::error::Patch did not apply cleanly. Manual reconciliation required."
echo "::error::Source SHA: ${{ steps.diff.outputs.after_sha }}"
exit 1
fi
git add -A
git commit -m "chore(sync): auto-sync from waggle-os@${{ steps.diff.outputs.after_short }}
Source: marolinik/waggle-os main @ ${{ steps.diff.outputs.after_sha }}
Subject: ${{ steps.diff.outputs.first_subject }}
See PR description for the full list of waggle-os commits in this batch."
git push origin "$branch_name"
- name: Open PR on hive-mind
if: steps.diff.outputs.skip != 'true'
working-directory: hive-mind
env:
GH_TOKEN: ${{ secrets.HIVE_MIND_SYNC_TOKEN }}
run: |
set -euo pipefail
branch_name="auto-sync/waggle-os-${{ steps.diff.outputs.after_short }}"
commit_list="$(cat ../.sync-output/commits.txt)"
gh pr create \
--repo marolinik/hive-mind \
--base master \
--head "$branch_name" \
--title "auto-sync from waggle-os@${{ steps.diff.outputs.after_short }}: ${{ steps.diff.outputs.first_subject }}" \
--body "$(printf 'Automated cross-repo sync — Memory Sync Repair Step 3.2 (waggle-os → hive-mind direction).\n\n## Source\n- Repo: marolinik/waggle-os\n- Branch: main\n- HEAD: %s\n- Workflow run: %s/%s/actions/runs/%s\n\n## Filtering\nThis patch was filtered to exclude paths listed under "NOT Extracted" in EXTRACTION.md:\n- packages/core/src/mind/vault.ts\n- packages/core/src/mind/evolution-runs.ts\n- packages/core/src/mind/execution-traces.ts\n- packages/core/src/mind/improvement-signals.ts\n- packages/core/src/compliance\n\n## Originating commits in this batch\n\n%s\n\n## Review checklist\n- [ ] Patch applied cleanly to hive-mind master without 3-way conflicts\n- [ ] No NOT-extracted paths sneaked through (sanity-check the diff against EXTRACTION.md)\n- [ ] Test deltas (if any) make sense for the OSS surface; no Waggle-specific test fixtures\n- [ ] mind-parity-check on waggle-os side is GREEN before merging this PR (otherwise the sync would re-introduce a regression)' \
"${{ steps.diff.outputs.after_sha }}" \
"${{ github.server_url }}" \
"${{ github.repository }}" \
"${{ github.run_id }}" \
"$commit_list")"
- name: Upload patch as artifact (debug aid)
if: always() && steps.diff.outputs.skip != 'true'
uses: actions/upload-artifact@v4
with:
name: sync-patch-${{ steps.diff.outputs.after_short }}
path: .sync-output/
retention-days: 30