use khive_runtime::{NoteKindSpec, NoteLifecycleSpec};
use khive_types::{
EdgeEndpointRule, EdgeRelation, EndpointKind, HandlerDef, ParamDef, VerbCategory, Visibility,
};
const GIT_LIFECYCLE: NoteLifecycleSpec = NoteLifecycleSpec {
field: "kind_status",
initial: "open",
terminal: &["closed"],
transitions: &[("open", "closed"), ("closed", "open")],
};
pub(crate) static GIT_NOTE_KIND_SPECS: [NoteKindSpec; 2] = [
NoteKindSpec {
kind: "issue",
aliases: &[],
lifecycle: GIT_LIFECYCLE,
},
NoteKindSpec {
kind: "pull_request",
aliases: &[],
lifecycle: GIT_LIFECYCLE,
},
];
pub(crate) static GIT_SCHEMA_PLAN_STMTS: [&str; 2] = [
"CREATE TABLE IF NOT EXISTS git_mirror_cursor (\
project_id TEXT NOT NULL,\
kind TEXT NOT NULL,\
cursor_value TEXT,\
updated_at INTEGER NOT NULL,\
PRIMARY KEY (project_id, kind)\
)",
"CREATE INDEX IF NOT EXISTS idx_git_mirror_cursor_updated \
ON git_mirror_cursor(updated_at DESC)",
];
pub(crate) static GIT_EDGE_RULES: [EdgeEndpointRule; 1] = [EdgeEndpointRule {
relation: EdgeRelation::Precedes,
source: EndpointKind::NoteOfKind("commit"),
target: EndpointKind::NoteOfKind("commit"),
}];
pub(crate) static GIT_HANDLERS: [HandlerDef; 1] = [HandlerDef {
name: "git.digest",
description: "Ingest commit/issue/pull_request provenance from a local git repo path or an \
https:// URL into the graph. Bounded and cursor-resumable: call repeatedly \
until the response's `done` field is true.",
visibility: Visibility::Verb,
category: VerbCategory::Commissive,
params: &[
ParamDef {
name: "source",
param_type: "string",
required: true,
description: "Absolute local path to a git repository (must contain a .git entry), \
or an https:// URL. Any https host is accepted; non-github.com hosts \
degrade to commits-only (gh cannot serve their issues/PRs). ssh://, \
git://, http://, and scp-shorthand (user@host:path) sources are \
rejected.",
},
ParamDef {
name: "project",
param_type: "string",
required: false,
description: "UUID or 8+ hex prefix of the repo-anchor project entity. When absent, \
resolved by matching properties.repo_url or name, or created if none \
is found (see the response's project_id and project_created).",
},
ParamDef {
name: "max_items",
param_type: "integer",
required: false,
description: "Bounded work for this call, counted across commits + issues + PRs \
(default 500, clamped to 1..=2000). Cursor-resumable: call again \
while the response's done field is false.",
},
ParamDef {
name: "include",
param_type: "array of string",
required: false,
description: "Which record kinds to ingest this call: any of commits | issues | \
pull_requests (default: all three).",
},
],
}];