// SPDX-License-Identifier: GPL-2.0-only
/*
 *  ppm/include/ppm/resolver.h
 *
 *  Copyright (C) 2026 Project Tick
 */

#ifndef PPM_RESOLVER_H
#define PPM_RESOLVER_H

#include <ppm/error.h>
#include <ppm/manifest.h>
#include <ppm/lockfile.h>
#include <ppm/registry.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Resolver — given a root manifest and a registry handle, produce a
 * lockfile that satisfies every declared requirement under the one-version
 * rule. The algorithm is PubGrub; on failure it yields a human-readable
 * explanation of which constraints conflicted.
 */

typedef struct ppm_resolver_opts {
    int        offline;     /* refuse network access            */
    int        prefer_newer;/* break ties towards higher versions */
} ppm_resolver_opts_t;

ppm_error_t ppm_resolve(const ppm_manifest_t      *root,
                        ppm_registry_t            *registry,
                        const ppm_resolver_opts_t *opts,
                        ppm_lockfile_t           **out_lock,
                        char                     **out_report);

#ifdef __cplusplus
}
#endif

#endif /* PPM_RESOLVER_H */
