/** * Data model for the local knowledge graph. * * Entities and relationships are stored as YAML source files in * `.aidlc/knowledge/` (source of truth) and mirrored into a SQLite index * (derived cache). Built-in types are closed sets; `custom:` extends * both without a schema change. * * Requirements: KG 1.1–1.5, 2.4, 11.1 * * @module */ /** Built-in entity types (KG Req 1.1). */ export declare const ENTITY_TYPES: readonly ["module", "service", "domain-entity", "convention", "decision", "debt", "dependency", "endpoint", "config"]; export type BuiltInEntityType = (typeof ENTITY_TYPES)[number]; export type EntityType = BuiltInEntityType | `custom:${string}`; /** Built-in relationship types (KG Req 1.4). */ export declare const RELATIONSHIP_TYPES: readonly ["depends-on", "implements", "calls", "owns", "contains", "extends", "uses", "produces", "consumes", "conflicts-with"]; export type BuiltInRelationshipType = (typeof RELATIONSHIP_TYPES)[number]; export type RelationshipType = BuiltInRelationshipType | `custom:${string}`; /** * Current schema version for the **YAML sources** (KG Req 11.1). * * Not the index's. It used to be both, and bumping it to add a column to the cache * would also stamp the new number into every source file's `_meta` that the next * `compact` rewrote, which makes older CLIs warn about files they could read before. * The index's own version is `INDEX_SCHEMA_VERSION` in `index/sqlite-index.ts` * (knowledge-index-misses-merged-yaml/AC-14, design DD3) — bump that one for a cache * change, and this one only when the on-disk YAML shape really changes. */ export declare const KNOWLEDGE_SCHEMA_VERSION = 1; /** Confidence assigned to facts inferred by static analysis (KG Req 8.3). */ export declare const DISCOVERY_CONFIDENCE = 0.6; /** Default confidence for agent-asserted facts (KG Req 8.3). */ export declare const AGENT_CONFIDENCE = 0.9; /** Entities below this confidence are excluded from context output (KG Req 7.5). */ export declare const STALE_CONFIDENCE_FLOOR = 0.3; /** * The `source` value meaning "this fact came from an agent, not from a file". * * The single declaration site for the sentinel (stale-graph-entries/AC-13). It was a * bare literal in three places — the writer's default, the seeder, and the index's * file-mapping predicate — and this instance added a fourth reader that resolves every * *non*-sentinel `source` against the disk. A check whose skip list is its own copy of * the literal is a check that starts reporting all 89 agent-inferred entities the day * one of the copies is respelled. * * One occurrence is deliberately left alone: the `DEFAULT 'agent-inferred'` in the * index's `CREATE TABLE` text. That is schema, not a comparison — interpolating a * constant into DDL buys nothing and makes the schema string depend on a value a * future edit could change without a migration. */ export declare const AGENT_INFERRED_SOURCE = "agent-inferred"; /** * Relative path of the knowledge directory within a project. * * Declared here rather than in `engine.ts`, which is where it used to live and * still re-exports it. `engine.ts` imports `SqliteIndex`, so a `doctor` migration * that reached for the constant would have pulled the whole index — and * `node:sqlite`'s experimental warning — onto the default path of * `aidlc doctor` for the sake of one string (stale-graph-entries/AC-17). */ export declare const KNOWLEDGE_DIR: string; /** A node in the knowledge graph (KG Req 1.2, 12.1). */ export interface Entity { /** Unique lowercase slug, e.g. "payment-service". */ id: string; type: EntityType; /** Human-readable name. */ name: string; /** Free-text explanation. */ description: string; /** Certainty 0.0–1.0. */ confidence: number; /** File path the fact derives from, or "agent-inferred". */ source: string; /** Who asserted the fact: git user name, "auto-discovery", or AIDLC_AUTHOR. */ author: string; tags: string[]; /** ISO 8601 timestamp of last confirmation. */ lastVerified: string; metadata?: Record; } /** A directed, typed edge between two entities (KG Req 1.3). */ export interface Relationship { /** Source entity id. */ from: string; /** Target entity id. */ to: string; type: RelationshipType; metadata?: Record; lastVerified: string; } /** `_meta` header document present in every YAML source file (KG Req 2.4). */ export interface SourceFileMeta { schemaVersion: number; /** * Stamped when the file is created and **not maintained** afterwards. Index * freshness is deliberately not tracked in the sources: the index is a * disposable cache, and keeping a timestamp current here would mean writing * every tracked file on every rebuild — the defect * `knowledge-rebuild-readonly` removed. Nothing reads this field. */ lastIndexed: string; entityType: string; } export interface GraphQueryResult { entities: Entity[]; relationships: Relationship[]; totalCount: number; } export interface ContextOutput { markdown: string; tokenEstimate: number; entityCount: number; sections: string[]; } /** Entity ids are lowercase slugs: letters, digits, hyphens. */ export declare const ENTITY_ID_RE: RegExp; export declare function isValidEntityType(type: string): boolean; export declare function isValidRelationshipType(type: string): boolean; /** * Map an entity type to its YAML source filename (KG Req 2.1). * Custom types share a single `custom.yaml`. */ export declare function sourceFileForType(type: string): string; /** Relationships live in a dedicated cross-cutting file. */ export declare const RELATIONSHIPS_FILE = "relationships.yaml"; /** * Directory holding one file per record of a type: the legacy file's name * without `.yaml` (`decisions.yaml` → `decisions/`). Two branches that each add * a record touch different files, so they never conflict on a merge — an * append to one shared file always did (autopilot-merge-lane-stalls-on-conflicts/AC-1). */ export declare function recordDirForType(type: string): string; /** Directory holding one file per relationship (AC-2). */ export declare const RELATIONSHIPS_DIR = "relationships"; /** * File name for one record, derived from its key alone so the same id always * lands in the same file (AC-3). A key that is not already a safe lowercase name * becomes a slug plus a hash of the key, so `@scope/pkg` and `@scope-pkg` stay * apart and no name can carry a path separator or `..` out of its directory. * * @param key - Entity id, or `----` for a relationship. * @param alwaysHash - Append the hash even to a plain key. */ export declare function recordFileName(key: string, alwaysHash?: boolean): string; /** Record file name for a relationship (AC-3). */ export declare function relationshipFileName(rel: { from: string; type: string; to: string; }): string; //# sourceMappingURL=types.d.ts.map