// H6 (Phase G) — Linear outbound sync skeleton.
//
// When a planning_artifacts row is created via H2 chunk extraction AND
// the operator has Linear MCP active, host-cp posts a new Linear issue
// (OR appends a comment to an existing linked issue if linear_issue_url
// is already populated on the row).
//
// PHASE G SHIPS SKELETON ONLY. The MCP-from-host wiring is not yet in
// host-cp; full Linear outbound posting lands in a follow-up commit
// when the MCP runtime story for host-cp is settled (today MCP lives in
// the operator's Claude Code runtime, not host-cp).
//
// Reverse channel (incoming Linear webhooks update artifact row status):
// EXPLICITLY OUT OF SCOPE for Phase G per plan body Out of scope list.
// Deferred to follow-up plan.

/**
 * Best-effort Linear outbound sync. Returns null when MCP is unavailable
 * (the typical case today — silent no-op). When MCP wires in, this
 * function resolves to the posted issue URL which the caller can persist
 * back to planning_artifacts.linear_issue_url.
 *
 * @param {object} args
 * @param {string} args.artifactId
 * @param {string} args.title
 * @param {unknown} args.body            — JSON body of the artifact
 * @param {string} args.sessionId
 * @returns {Promise<string | null>}     — Linear issue URL or null
 */
export async function syncArtifactToLinear({ artifactId, title, body, sessionId }) {
  // Probe for Linear MCP availability via host-cp's bootstrap config (TBD).
  // Until that surface exists, return null. Logging the intent surfaces
  // the wiring gap to operators inspecting host-cp logs.
  void artifactId;
  void title;
  void body;
  void sessionId;
  console.log(
    `[linear-sync] outbound skip — Linear MCP not yet wired to host-cp; ` +
      `artifactId=${artifactId} sessionId=${sessionId}`,
  );
  return null;
}
