Titan sync

From optave/ops-codegraph-tool · View interactive version

Titan sync is an AI agent skill from the GitHub repository optave/ops-codegraph-tool. Identify overlapping fixes across audit results, plan shared abstractions, produce an ordered execution plan with logical commit grouping (Titan Paradigm Phase 3)

How to use this skill

Skill file

Titan GLOBAL SYNC — Cross-Cutting Analysis & Execution Plan

You are running the GLOBAL SYNC phase of the Titan Paradigm.

Your goal: analyze GAUNTLET results to find overlapping problems, identify shared abstractions that should be built before individual fixes, group changes into logical commits, and produce an ordered execution plan.

Context budget: This phase reads artifacts, not source. Keep codegraph queries targeted — only for specific relationship questions between failing targets.


Step 0 — Pre-flight: find or join the Titan worktree

  1. Locate the Titan session. Prior phases (RECON, GAUNTLET) may have run in a different worktree or branch. Search for it:

```bash

git worktree list

```

For each worktree, check if it contains Titan artifacts:

```bash

ls <worktree-path>/.codegraph/titan/titan-state.json 2>/dev/null

```

Also check branches:

```bash

git branch -a --list 'titan'

```

Decision logic:

  1. Ensure worktree isolation:

```bash

git rev-parse --show-toplevel && git worktree list

```

If not in a worktree, stop: "Run /worktree first."

  1. Sync with main:

```bash

git fetch origin main && git merge origin/main --no-edit

```

If there are merge conflicts, stop: "Merge conflict detected. Resolve conflicts and re-run /titan-sync."

  1. Load artifacts. Read:
  1. Validate state. If titan-state.json fails to parse, stop: "State file corrupted. Run /titan-reset."
  1. Check GAUNTLET completeness. If gauntlet-summary.json has "complete": false:

> "GAUNTLET incomplete (<N>/<M> batches). SYNC will plan based on known failures only. Run /titan-gauntlet first for a complete plan."

  1. Extract. From artifacts, collect:

Step 1 — Drift detection: has main moved since GAUNTLET?

The codebase may have changed between GAUNTLET and now. Detect this before planning on stale audit data.

  1. Compare main SHA:

```bash

git rev-parse origin/main

```

Compare against titan-state.json → mainSHA. If identical, skip to Step 2.

  1. If main has advanced, find what changed:

```bash

git diff --name-only <mainSHA>..origin/main

```

  1. Cross-reference with GAUNTLET results. Check which changed files overlap with:
  1. Classify staleness:

| Level | Condition | Action |

|-------|-----------|--------|

| none | main unchanged | Continue normally |

| low | Changed files don't overlap with any audited targets | Continue — note drift |

| moderate | Some FAIL/DECOMPOSE targets are in changed files (<30% affected) | Continue but flag affected targets — their audit results may be outdated. Mark clusters containing them as "needs-verification" |

| high | >30% of FAIL targets affected OR shared dependencies changed | Warn user: "Main has changed significantly since GAUNTLET. Audit results for N targets may be stale. Recommend /titan-gauntlet re-run for affected targets before planning." |

| critical | New files added to src/ that would be in priority queue, or deleted files that were FAIL targets | Stop: "Codebase structure changed. Run /titan-recon to rebuild baseline, then /titan-gauntlet." |

  1. Append drift report to .codegraph/titan/drift-report.json (the file is a JSON array — read existing entries, push the new entry, write back; same schema as GAUNTLET, with "detectedBy": "sync").
  1. Update state: Set titan-state.json → mainSHA to current origin/main.
  1. If moderate: Proceed but annotate affected clusters in sync.json with "driftWarning": true. The execution order should prioritize non-stale targets and defer stale ones pending re-audit.
  1. If re-running SYNC and a previous drift-report.json exists with reassessmentScope.targets, re-read GAUNTLET results only for those targets and rebuild affected clusters.

Step 2 — Find dependency clusters among failing targets

For FAIL/DECOMPOSE targets that share a file or community, check connections:

codegraph path <target1> <target2> -T --json

Group connected failures into clusters. Also check for cycles among them:

codegraph cycles --functions --json

Filter to cycles including at least one FAIL/DECOMPOSE target.


Step 3 — Identify shared dependencies and ownership

For each cluster, find what they share:

codegraph deps <key-file> --json

Look for:

Check code ownership for cross-team coordination:

codegraph owners <file1> <file2> -T --json

If different teams own files in the same cluster, note the coordination requirement.

Run branch structural diff to see what's already changed:

codegraph branch-compare main HEAD -T --json

Avoid re-auditing or conflicting with in-progress work.


Step 4 — Detect extraction candidates

For DECOMPOSE targets:

codegraph context <target> -T --json
codegraph ast --kind call --file <file> -T --json

Look for:


Step 5 — Plan shared abstractions

Identify what to build BEFORE individual fixes:

  1. Interface extractions — shared dependency → extract interface
  2. Utility extractions — repeated patterns → shared utility
  3. Module splits — god files → split by community structure
  4. Cycle breaks — circular deps → identify weakest link

For each, check blast radius:

codegraph fn-impact <shared-dep> -T --json

Step 6 — Build execution order with logical commits

Phases (in order)

  1. Dead code cleanup — zero risk, reduces noise
  1. Shared abstractions — before individual fixes
  1. Cycle breaks — unblocks dependent targets
  1. Decompositions — highest risk, after abstractions
  1. Fail fixes — ordered by blast radius (lowest first)
  1. Warn improvements — optional, lowest priority

Ordering within each phase

Each commit should:


Step 7 — Write the SYNC artifact

Write .codegraph/titan/sync.json:

{
  "phase": "sync",
  "timestamp": "<ISO 8601>",
  "clusters": [
    {
      "id": 1,
      "name": "<descriptive>",
      "targets": ["t1", "t2"],
      "sharedDeps": ["mod"],
      "hasCycle": false,
      "owners": ["team-a", "team-b"],
      "proposedAction": "Extract interface"
    }
  ],
  "abstractions": [
    {
      "type": "interface_extraction|utility_extraction|module_split|cycle_break",
      "description": "...",
      "source": "<current location>",
      "unblocks": ["t1", "t2"],
      "blastRadius": 0,
      "commit": "refactor: ..."
    }
  ],
  "executionOrder": [
    {
      "phase": 1,
      "label": "Dead code cleanup",
      "targets": ["sym1", "sym2"],
      "risk": "none",
      "commit": "chore: remove dead code",
      "dependencies": []
    }
  ],
  "deadCodeTargets": ["<from recon>"],
  "cyclesInvolvingFailures": []
}

Update titan-state.json: set currentPhase to "sync".


Step 8 — Report to user

Print:


Issue Tracking

Throughout this phase, if you encounter any of the following, append a JSON line to .codegraph/titan/issues.ndjson:

Format (one JSON object per line, append-only):

{"phase": "sync", "timestamp": "<ISO 8601>", "severity": "bug|limitation|suggestion", "category": "codegraph|tooling|process|codebase", "description": "<what happened>", "context": "<command, cluster, or artifact involved>"}

Log issues as they happen — don't batch them. The /titan-close phase compiles these into the final report.


Rules

Self-Improvement

This skill lives at .claude/skills/titan-sync/SKILL.md. Edit if clustering misses connections or execution order causes conflicts.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.