Skip to content

Repair and prevent missing lifecycle metadata on worktrees #334

@chubes4

Description

@chubes4

Problem

A large share of registered worktrees have missing lifecycle metadata, which prevents cheap inventory cleanup from classifying them safely.

Observed locally on 2026-05-11:

  • studio wp datamachine-code workspace worktree list --stale --format=json | jq 'group_by(.stale) | map({stale: .[0].stale, count: length}) | sort_by(.count) | reverse'
  • Result included 285 worktrees with stale: missing_metadata.
  • Liveness grouping included 334 rows with liveness_reason: metadata_missing.
  • Cheap cleanup review reported 17 metadata_reconciliation_candidates, but the full reconcile-metadata --dry-run path timed out after 300 seconds.

Example stale record shape:

{
  "handle": "agents-api@agents-api-agent-identity-store",
  "repo": "agents-api",
  "branch": "agents-api/agent-identity-store",
  "dirty": 1,
  "state": null,
  "created_at": null,
  "liveness": "unknown",
  "liveness_reason": "metadata_missing",
  "owner_full": { "site": "unknown", "agent": "unknown", "user": "unknown" },
  "metadata": []
}

Why this matters

Without lifecycle metadata, DMC cannot distinguish abandoned worktrees from active work, cannot attribute ownership/session/task context, and cannot safely move rows into cleanup eligibility from cheap inventory alone.

Desired outcome

DMC should both repair existing missing metadata and make future worktree creation/finalization metadata durable enough that this class of drift does not recur.

Acceptance criteria

  • Provide a bounded metadata reconciliation command/job that can repair missing metadata in batches.
  • Reconciled rows get enough owner/session/task/lifecycle fields for future inventory cleanup classification.
  • Worktree creation and adoption paths always persist lifecycle metadata or fail loudly.
  • Reporting distinguishes unrepaired legacy rows from newly-created metadata regressions.

Related

AI assistance

  • AI assistance: Yes
  • Tool(s): OpenCode (GPT-5.5)
  • Used for: Drafting the issue from local DMC command output reviewed by Chris.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions