- TypeScript 86%
- CSS 14%
Tangled Migrator #
A local-first GitHub-to-Tangled issue migrator. Review the source and destination, import with durable checkpoints, recover individual records, and verify the result before retiring the original tracker.
Built with Next.js App Router, React, TypeScript, Tailwind CSS, and shadcn/ui. The interface uses System Mono and supports Light, Dark, and System appearance. Licensed under MIT.
Contents #
- What it migrates
- Requirements
- Quick start
- Migration workflow
- Identity, dates, and issue state
- Large Markdown bodies
- Pause, resume, and recovery
- Verification and receipts
- Local data and backups
- Authorization and network access
- Limits and troubleshooting
- Development
- Releases and Tangled CI
- License
What it migrates #
| Source information | Destination behavior |
|---|---|
| Issues | Native Tangled tickets with their original titles and source attribution |
| Open/closed state | Open, closed, or completed according to the GitHub state and completion reason |
| Comments | Native comments attached to the imported ticket's actual URI and current CID |
| Labels | Label definitions used by exported issues and ticket label references |
| Authors, dates, and original numbers | Preserved in imported prose and source metadata |
| Assignees and milestones | Preserved as source metadata/provenance rather than native assignment or milestone migration |
| Oversized issue/comment Markdown | Complete text retained as a verified Markdown artifact, linked from the native record |
Pull requests, reviews, discussions, projects, Git history, branches, repository creation, CI workflows, deployment settings, and secrets are outside this tool's import scope. Existing source attachment/image links are preserved as links; the migrator does not copy their files. Keep the source archive and those linked assets available.
The tool currently targets GitHub.com source repositories and existing repositories addressed through https://tangled.org/<handle>/<repository>. It is an operator-run local application, not a hosted migration service.
Requirements #
- Node.js 20.9.0 or newer to run Next.js.
- Bun 1.4.4 or newer for dependencies, the launcher, and tests.
- GitHub CLI (
gh) installed onPATH, authenticated with access to the source repository. - An existing Tangled destination repository and an ATProto account authorized to perform the chosen repository operations.
- Network access to GitHub, Tangled's repository API, ATProto identity services, the account's PDS, and the destination knot.
Check the source login before starting:
gh auth login
gh auth status
No GitHub token or ATProto password belongs in a source file or .env file. The exporter uses the existing gh login; destination authorization happens in the browser.
Quick start #
Canonical repository: samclemente.me/tangled-migrator on Tangled. Versioned source downloads appear with the v0.1.1 tag.
git clone https://tangled.org/samclemente.me/tangled-migrator
cd tangled-migrator
bun install --frozen-lockfile
bun run build
bun start
Open http://127.0.0.1:43148.
Use the launcher rather than calling next start directly: it binds Next.js to loopback and supplies the private state location and per-launch request nonce expected by the local API.
Port and state directory #
bun start --port 43149 --state-dir /absolute/private/path
| Option | Default | Purpose |
|---|---|---|
--port |
PORT, or 43148 |
Loopback port; accepted range is 1024–65535 |
--state-dir |
.migrator relative to the launch working directory |
Persistent plans, checkpoints, and recovery audit data |
--help |
— | Show launcher usage without starting Next.js |
Keep the same 127.0.0.1 origin and port when resuming a browser OAuth session. localhost is not interchangeable with 127.0.0.1 in this app's host checks.
Run only one server process per state directory. State writes are atomic, but there is no cross-process import lock. A separate development/test instance needs both a different port and a different state directory.
Migration workflow #
1. Connect #
Enter:
- GitHub Repository:
owner/repository. - Tangled Repository: the destination's full
https://tangled.org/handle/repositoryURL. - Your ATProto Handle: the importing account's handle.
Select Build Migration Plan. This resolves the destination repository DID and knot, exports issues and all comment pages through gh, excludes pull requests, and produces a deterministic plan. This step does not create destination records.
The source export is not a transactional snapshot. If the observed comment count changes while exporting, the app stops rather than accepting an incomplete comment history.
2. Review #
Check the source, destination, issue/comment/label counts, and any oversized-Markdown notice. Use Export Plan to retain a copy, then confirm that you reviewed the source and destination.
The plan contains source bodies and metadata. Treat it as private if the source repository is private.
3. Migrate #
Select Sign In and authorize the destination-scoped permissions. Then use Check Connection and Start Import or Resume Import.
Check Connection is read-only: it checks service-token authorization and the destination manifest. It does not create a test record or prove that every future payload will be accepted.
Each destination write is preceded by a durable local intent. Record creation, author attribution, and final-state updates are saved separately, so resume can continue from the correct stage.
4. Verify #
After every planned record is imported, select Verify Migration. Only a successful destination audit completes this stage. Export the final receipt and keep the source archive until you have reviewed the imported tracker.
A completed progress counter alone is not proof of a verified migration.
Identity, dates, and issue state #
Imported records are attributed to the account performing the migration. The tool does not impersonate original GitHub authors. Their names, original timestamps, source URLs, and original issue numbers remain in provenance.
Tangled assigns native creation timestamps and native issue/comment IDs. An original GitHub issue number is not guaranteed to become the same Tangled ticket number, and native records are not backdated. Receipts provide the crosswalk from source issues to actual destination URIs.
| GitHub state | Tangled state |
|---|---|
| Open | Open |
| Closed with a completed reason | Completed |
| Closed with another or unknown reason | Closed |
Tangled requires a ticket to be created open. The migrator attributes that first version, applies the final state using an optimistic CID guard, then attributes the final version. Comments resolve the imported parent's actual URI and latest CID immediately before creation.
Label keys are deterministic for the source repository. The destination may normalize label color casing, timestamps, and optional reference type tags. Verification allows the specific supported normalizations while checking the remaining content and identity.
Large Markdown bodies #
The current compatibility budget is 65,536 UTF-8 JSON bytes, including the request envelope and the final-state update budget. It is smaller than the native ticket text limit. Review and Migrate identify records that need the fallback.
For an oversized body, the migrator:
- Preserves the entire planned Markdown body, including appended source provenance.
- Uploads it as
text/markdownusing destination-scoped authorization. - Downloads the result and verifies its byte length and SHA-256 hash.
- Creates and attributes a retained
org.tangled.repo.artifact, pinned to the destination's current default-branch commit. - Creates the issue/comment with a short download link, content hash, and original source attribution.
No source text is silently truncated. The file/Markdown limit is 50 MiB (52,428,800 bytes). A resolvable default-branch commit is required to retain the artifact. Image/video-only markup embeds are not used to disguise Markdown files.
The knot may serve the download as application/octet-stream; the uploaded blob metadata, exact bytes, and hash are what bind it to the original Markdown. Final verification checks the retained artifact, its attribution, and the downloaded bytes again.
Uploads, artifact creation, artifact attribution, and the native record each have durable stages. An unknown artifact-create outcome stops for reconciliation; there is currently no dedicated in-app reset for an ambiguous artifact creation. Do not discard the checkpoint or keep issuing creates in that situation.
Pause, resume, and recovery #
Graceful pause #
Pause Import lets an active mutation and its receipt finish before stopping at a safe boundary. Wait for the paused state before closing the tab or stopping the server. Abrupt tab closure, network loss, or process termination can still leave an uncertain outcome.
To resume, use the same state directory, source repository, destination repository, and importing account. Sign in again if browser credentials are unavailable or the required scopes changed. Recheck the connection and review confirmation when prompted.
The source repository, destination DID, and importing DID identify a saved migration. Replacing the plan with a different plan is rejected after progress has been recorded. Starting a fresh state directory is not a substitute for recovering a stopped import.
Reconcile a stopped record #
On Migrate, use Reconcile An Imported Record to select a saved entry or pending intent, then select Reconcile Comment or Reconcile Record.
- If a matching record exists, resume can adopt it only after content and identity checks. Conflicting content or multiple source matches stop the operation.
- If a complete scan finds no matching record for an uncertain create, the dialog offers Confirm Retry. Confirmation triggers a second fresh scan and checks that the saved state has not changed before resetting only that attempt marker.
- Confirmation expires after two minutes; run the check again if necessary.
Resume Import is a separate action. Reconciliation does not automatically start a new remote write.
Delete And Retry #
For a specific existing problematic imported record, Delete And Retry shows its source, destination URI, and expected CID, followed by a permanent-delete confirmation.
Deletion is blocked when the record was edited by another account or has dependent imported/native records. The app checks native comment and label references outside this migration as well as its own saved dependencies. A fresh CID guard protects against deleting a different revision.
After the destination confirms absence, the app archives the old receipt/intent, resets only the selected operation, and advances its retry generation. Reimport creates a new native identity and fresh attribution keys; it does not restore the deleted native ID or overwrite earlier attribution records. Retained Markdown artifacts are kept.
If a delete response is lost or the page is reloaded, use Check Deletion Outcome. This performs read-only absence verification and finishes local reconciliation without replaying the deletion. A saved deletion intent can be checked after its initial confirmation period when the saved migration snapshot remains unchanged.
Verification and receipts #
Verification reads the actual destination records and checks:
- Destination URI and current CID against saved receipts.
- Content against the original plan and supported server normalizations.
- Actual parent identity/CID for comments.
- Initial and final author attestations for state transitions.
- Retained artifacts, their attestations, and full Markdown byte hashes when used.
Export Receipt is also available before completion for diagnostics. A partial receipt must not be represented as a completed migration. Receipts include the source-to-destination crosswalk, checkpoint, verification result, and reconciliation audit history.
Plans and receipts can include source content, account/repository identifiers, metadata, and recovery details. Review and redact them before sharing.
Local data and backups #
The default state directory is ignored by Git:
.migrator/
active.json
projects/
<project-key>.json
State directories use owner-only permissions (0700); files use 0600. Writes use private temporary files, file/directory synchronization, and atomic rename. State is not encrypted by this application. GitHub credentials remain managed by gh; browser OAuth credentials are not written into these state files.
For a consistent backup:
- Pause and wait for the in-flight operation to finish.
- Stop the local server.
- Copy the entire state directory, including
active.jsonandprojects/, to a private location. - Keep any exported plan and receipt with equivalent access protection.
Restore the complete directory, start the launcher with that --state-dir, and sign in if required. Browser credentials are separate from the state backup. Do not manually remove individual intents or receipts to force progress; use reconciliation.
Authorization and network access #
Sign-in currently requests these permissions up front, all RPC permissions bound to the verified destination service audience <repository-DID>#tangled_knot:
| Permission | Use |
|---|---|
atproto |
Required ATProto OAuth scope |
repo:org.tangled.graph.attestation?action=create&action=update |
Attribution records on the importing account's PDS |
rpc:com.atproto.repo.createRecord |
Destination labels, tickets, comments, and retained artifacts |
rpc:com.atproto.repo.putRecord |
Final issue state updates |
rpc:com.atproto.repo.deleteRecord |
Explicitly confirmed per-record recovery deletions |
rpc:com.atproto.repo.uploadBlob |
Verified oversized-Markdown uploads |
Receiving a scope does not trigger its operation: planning is read-only, imports require review/start, and deletions require their own confirmation. Scope changes require a new sign-in. No CI secrets or deployment permissions are requested.
PDS OAuth tokens stay behind the OAuth session fetch handler. Each knot write uses a fresh, single-use, method-scoped service JWT; cached token reuse is not supported. Only public read requests and service tokens intended for the verified knot are sent there.
The local server binds to 127.0.0.1, checks Host and Origin, and requires a per-launch nonce for API access. Diagnostic messages expose bounded codes/statuses/phases instead of raw provider payloads or tokens. No hosted analytics or migration relay is required.
Limits and troubleshooting #
| Symptom/code | Meaning and next step |
|---|---|
| GitHub CLI unavailable or export failed | Check gh is installed, authenticated, and can access the repository. Inspect locally without sharing raw private output. |
GITHUB_EXPORT_CHANGED |
The observed source comment count changed. Re-export before starting writes. |
AuthenticationRequired / ScopeMissingError |
Check the connection and sign in again for the current exact repository scopes. |
RequestTooLarge / HTTP 413 |
The request exceeds the knot's limit. Review the full-Markdown fallback and upload grant; a retry of the unchanged oversized JSON will not help. |
HTTP_429 |
Rate limiting. Wait before resuming; do not repeatedly trigger new writes. |
INCOMPLETE_RECORD_SCAN |
Pagination was malformed, repeated, or incomplete. Retry the read/check; do not assume the destination record is absent. |
AMBIGUOUS_CREATE_OUTCOME |
A create may have succeeded. Use the in-app reconciliation flow before allowing a retry. |
EXISTING_RECORD_CONFLICT / multiple source matches |
Inspect the specific destination record(s). Do not overwrite or delete unrelated content. |
AMBIGUOUS_ARTIFACT_CREATE_OUTCOME |
Inspect the retained artifact and checkpoint; automatic blind recreation is blocked. |
| Changed/missing record or attribution during verification | Inspect the source-to-destination receipt and changed record before considering the migration complete. |
| Wrong host or local nonce error | Open the exact launcher URL; a stopped/restarted server or a different origin can invalidate an old page. |
Additional export limits: at most 10,000 issues, four comment-export workers, a 180-second timeout per gh request, and 64 MiB of stdout per export command. These are client limits, not promises about destination throughput. Other knot quotas, permissions, and payload validation still apply.
The importer makes bounded retries for safe reads. It does not automatically replay uncertain mutations. Only run migrations into a destination whose visibility and access policy are appropriate for the source data.
Development #
# Local development, with isolated state/port if another instance is running
bun run dev --port 43149 --state-dir /absolute/private/development-state
# Checks
bun test
bun run typecheck
bun run build
Do not rebuild the same .next output or restart the server underneath a running migration. Pause first, or use a separate checkout and state directory for an independent app build. Documentation-only changes do not require restarting the application.
Source map #
| Path | Responsibility |
|---|---|
src/app/ |
Next.js routes, layout, global theme, and local API adapter |
src/ui/ |
Connect/Review/Migrate/Verify interface, OAuth integration, recovery dialogs |
src/components/ui/ |
Generated shadcn/ui components |
src/core/planner.mjs |
Deterministic source plan, provenance, logical IDs, hashes |
src/core/executor.mjs |
Durable intents, mutation stages, parent references, retry generations |
src/core/large-record.mjs |
Request budgets and retained full-Markdown artifact lifecycle |
src/auth/ |
Method-scoped service tokens, knot adapters, blob verification, destination audit |
src/server/ |
Loopback launcher/runtime, GitHub export, identity checks, private state, recovery API |
src/proxy.ts |
Host boundary, no-store responses, CSP and per-request script nonces |
Regression coverage includes lost responses, single-use authorization, native IDs, comment parent versions, state changes, server normalization, null pagination cursors, graceful pause, retry/deletion guards, atomic checkpoints, and verified Markdown attachments. Provider integration tests use isolated fake destinations; they are not a substitute for reviewing a real migration's final receipt.
Contributions should keep source fixtures generic, preserve existing receipts and source provenance, test recovery paths, and avoid adding credentials, source exports, private checkpoints, or raw provider diagnostics to the repository. Validate UI changes in Chrome.
Releases and Tangled CI #
Version 0.1.1 is packaged as a portable source archive with SHA-256 checksums. Run bun run package after testing and building in an isolated checkout. See release instructions and the changelog for verification, Tangled repository setup, and publishing. The Tangled workflow runs tests, a production build, type checks, and source packaging without migration credentials.
License #
Tangled Migrator is distributed under the MIT License. See LICENSE for the full terms.
Generated shadcn/ui components retain the upstream MIT notice in THIRD_PARTY_NOTICES.md. Other dependencies retain their respective licenses and notices.