/**
 * GraphProvider adapter contract (optional plugin — read-only projection in v0.x).
 */

const PROVIDER_CONTRACT = {
  name: "string",
  methods: ["health", "query"],
  optionalMethods: ["project"]
};

function createGraphProviderStub(name = "local") {
  return {
    name,
    async health() {
      return { ok: true, detail: "local fallback (no graph index)" };
    },
    async query(_query, _scope) {
      return [];
    }
  };
}

function validateGraphProvider(provider) {
  const errors = [];
  if (!provider?.name) errors.push("provider.name required");
  if (typeof provider.health !== "function") errors.push("provider.health required");
  if (typeof provider.query !== "function") errors.push("provider.query required");
  return { valid: errors.length === 0, errors };
}

module.exports = {
  PROVIDER_CONTRACT,
  createGraphProviderStub,
  validateGraphProvider
};
