feat: adopt local SQLite engineering memory and quality gates
This commit is contained in:
@@ -13,3 +13,13 @@ approval is the default; a Work-wide waiver must be explicit and recorded. Follo
|
||||
guidance across sessions and never infer authority from task simplicity or model
|
||||
output. During implementation, use experiments and evidence when needed, adapt
|
||||
within the DEC, and revisit questioned commitments before affected execution.
|
||||
|
||||
SQLite is the default local memory; use a contract-4 CLI to read and mutate it.
|
||||
If unavailable, report the tool gap after reading bootstrap instructions. Never
|
||||
assume unreadable memory is empty. State is outside Git by default; do not install
|
||||
new tools or migrate a consumer merely because new code exists.
|
||||
|
||||
Required project/Work gates must actually pass for the evaluated state. Keep
|
||||
required attachments until checks finish; retain short results and let eligible
|
||||
temporary inputs retire after completion. Requested outputs belong outside AIE
|
||||
state. Legitimate historical retirement is different from missing current input.
|
||||
|
||||
@@ -17,7 +17,8 @@ Use `ai-engineering` (or its installed alias `aie`). No server or model API is n
|
||||
payloads, decisions and plan history when relevant; context references are not
|
||||
the payload itself. Follow the Work guidance. Ask the human for DIRECT or
|
||||
EXPLORATORY when missing; never infer a choice or approval. Carry a recorded
|
||||
choice into future sessions. Without a CLI, inspect the portable files directly.
|
||||
choice into future sessions. SQLite memory requires a compatible CLI. Without it,
|
||||
read bootstrap guidance and report the tool gap; never infer an empty workspace.
|
||||
4. Distinguish observations verified now, historical evidence, assumptions and
|
||||
proposals. Record refinement with `discussion add --text` or `--text-file`,
|
||||
choosing an explicit `--author`. Resolve questions with RESPONSE/CONCLUSION
|
||||
@@ -30,7 +31,7 @@ Use `ai-engineering` (or its installed alias `aie`). No server or model API is n
|
||||
|
||||
Run `aie project compatibility --format json` before considering an update. `status`
|
||||
includes a compatibility summary and the diagnostic command. The diagnostic is
|
||||
read-only: it inspects actual canonical files and record revisions, without locks,
|
||||
read-only: it inspects actual typed records and their revisions (or legacy files), without locks,
|
||||
backups, model calls or migrations. It includes AIE completion receipts, while ignored
|
||||
runs, local backups and ordinary artifact payloads are excluded. Use `project validate`
|
||||
for integrity.
|
||||
@@ -54,18 +55,19 @@ rewrite a completed Work merely to materialize current fields, topics or surveys
|
||||
|
||||
`aie onboard` refreshes the entry instructions and manifest, with backups, while
|
||||
leaving Works, evidence and revision history unchanged. A newer unsupported manifest
|
||||
or contract is refused rather than overwritten; use a compatible CLI. No required
|
||||
migration is registered in this release. Future conversions must have an explicit
|
||||
public command, scope, preview, backups and repeatable execution. Do not invent a
|
||||
migration or inspect AIE source code to discover consumer update procedures; report
|
||||
public-interface gaps with evidence instead.
|
||||
or contract is refused rather than overwritten; use a compatible CLI. Legacy reading does not require conversion. `storage migrate --format json` previews
|
||||
an optional supported legacy-to-SQLite conversion; `--apply --expect HASH` applies
|
||||
only that reviewed state. Originals and historical hashes/approvals are preserved.
|
||||
`--recover` or `--rollback` use the operation fingerprint after interruption. Rollback
|
||||
refuses to lose new SQLite writes. Installation/onboard/reads never migrate storage.
|
||||
Use the public command and documentation rather than inferring a procedure from code.
|
||||
|
||||
The current entry contract is 3 and advertises Work guidance, human DEC requests,
|
||||
and optional Plan experiments in addition to DF open-agenda import. Contract 1
|
||||
projects remain readable without Work migration. An import-enabled manifest needs
|
||||
contract 2 and the `discussion-import` capability; older CLIs must be updated before
|
||||
reading it. Refresh entry files with `onboard` after compatibility inspection,
|
||||
preserving historical Works and their approvals.
|
||||
The current entry contract is 4. It declares SQLite/local memory, quality gates and
|
||||
temporary artifacts, preserving contract-3 guidance and Plan experiments. Contracts
|
||||
1, 2 and 3 remain readable on the legacy backend. A SQLite workspace requires the
|
||||
matching contract 4 and database schema; incompatible combinations are refused.
|
||||
`init` selects SQLite and adds `/.ai-engineering/` to .gitignore without requiring
|
||||
Git. `--version-state` leaves ignore policy to the developer; it never untracks files.
|
||||
|
||||
## Work conduct and human authority
|
||||
|
||||
@@ -208,7 +210,7 @@ the requester. An important child reopening reopens RESULTS ancestors, retaining
|
||||
history; optional changes do not. Explicit EPIC reopening suspends automatic authority
|
||||
so replanning is possible; child-caused reopening preserves unchanged-scope authority.
|
||||
`epic show/check/history` inspects state. `epic reconcile [WRK] --requester NAME
|
||||
--request-id KEY` recovers missed propagation from files; repeated checks do not
|
||||
--request-id KEY` recovers missed propagation from persisted state; repeated checks do not
|
||||
duplicate completion/receipts. Reads never invoke an adapter or perform transitions.
|
||||
Publication is per file; corrupt records and interrupted orphan publication may still
|
||||
need deliberate repair. Use public CLI/Verification lifecycle APIs for notification;
|
||||
@@ -281,8 +283,8 @@ success from a status label. Respect read-only repository policy and the OS sand
|
||||
## Verification and closure
|
||||
|
||||
When the last required step completes, AIE consolidates its Plan and rechecks the
|
||||
Work's Plans. All required Plans completed, with no pending questions/surveys or
|
||||
draft DECs, completes the Work automatically. Criteria/results/evidence belong to
|
||||
Work's Plans. All required Plans completed, with current required gates passed and no pending
|
||||
questions/surveys or draft DECs, completes the Work automatically. Criteria/results/evidence belong to
|
||||
the Plans/steps; no new Work-level checklist or model call is required. Completion
|
||||
records SYSTEM_PLANS origin, humanApproved=false and an owned receipt identifying
|
||||
the exact Plan revisions. Empty sets and explicit BLOCKED/CANCELLED states remain
|
||||
@@ -309,7 +311,7 @@ Do not mark COMPLETED through a generic status change. Use disposable test data;
|
||||
never confuse a historical report with a test run performed now.
|
||||
|
||||
Update canonical code, tests, specs and documentation. There is no mandatory Lesson
|
||||
entity. `work archive` retains all files/history; `work reopen --by NAME --reason TEXT`
|
||||
entity. `work archive` retains useful memory/history; `work reopen --by NAME --reason TEXT`
|
||||
allows new evidence and reorientation while retaining earlier completion records.
|
||||
Never delete history as housekeeping. `import discussion --source ID=PATH` previews
|
||||
DF DSCs with AGDs open; repeat sources for a multi-project umbrella and use
|
||||
@@ -321,15 +323,44 @@ are skipped and changed inputs require review without overwriting. Prepared Work
|
||||
publish individually; after partial publication, preview again to resume without
|
||||
duplicates. Closed agendas, DECs, Plans and Lessons are not imported.
|
||||
|
||||
## Portable files and errors
|
||||
## Storage, temporary artifacts and errors
|
||||
|
||||
SQLite owns operational Work memory in `.ai-engineering/aie.db`. Store typed fields,
|
||||
prose and relationships, never files encoded as BLOB/base64 or equivalent TEXT.
|
||||
Small configuration and entry files bootstrap discovery. New revisions and related
|
||||
references commit in one transaction; related reads share a snapshot. Writer waits
|
||||
are bounded. RUN application failure rolls back the proposal and separately records
|
||||
its diagnostic, with no reverted applied references.
|
||||
|
||||
Work IDs are uppercase hexadecimal; child IDs are Work-local decimal identifiers.
|
||||
Discussion and new decision/plan prose use Markdown bodies with versioned YAML front
|
||||
matter. Use CLI mutations for IDs and references; human-authored prose remains portable.
|
||||
Revisions live beside their records in `.history`, with SHA-256 links. `.local` stores
|
||||
locks/backups and is not canonical state. Writes are atomic per file, not across all
|
||||
records; validation diagnoses interrupted cross-record publication. Preserve backups
|
||||
and repair deliberately, rather than silently dropping missing references.
|
||||
Legacy Markdown/YAML and `.history` remain readable on the file backend. Explicit
|
||||
migration retains original bytes externally when historical hashes need them.
|
||||
Legacy originals retained in place are not a second writable authority.
|
||||
|
||||
Exit codes: 0 success, 1 unexpected I/O/runtime error, 2 invalid input, 3 missing
|
||||
resource, 4 validation/readiness failure. Read `--help` for exact command options.
|
||||
Required project gates and additional Work gates are cumulative. Configure with
|
||||
`gate configure ID --title TEXT --procedure TEXT --input PATH --by NAME`, adding
|
||||
`--work WRK` for a Work-specific gate and `--require-evidence` when needed. Read
|
||||
`gate status WRK` to obtain the evaluatedHash before running the procedure externally.
|
||||
Record the actual result with `gate record WRK project/ID --expect HASH
|
||||
--invocation TEXT --outcome PASS|FAIL --summary TEXT --by NAME --observed
|
||||
[--evidence ART]`. Human DEC approval is separate. Files, Work scope/guidance, DEC
|
||||
revisions or gate-definition changes require current evaluation. Gate history and
|
||||
delivery snapshots retain the short observed result; the CLI does not execute or
|
||||
semantically verify repository commands.
|
||||
|
||||
Temporary evidence stays on the filesystem while checks need it. Work completion
|
||||
persists validation before discarding eligible payloads after commit. Context exposes
|
||||
AVAILABLE, DISCARD_PENDING, DISCARDED, STRUCTURED or RETAINED_LEGACY. Missing input
|
||||
before a check is an error; retired evidence cannot satisfy a fresh evaluation after
|
||||
reopening. `artifact recover WRK` finishes interrupted publication/cleanup. Reads do
|
||||
not clean up or mark checks passed. Unknown residue requires inspection.
|
||||
|
||||
New Plan/EPIC receipts are structured database facts, with no extra payload file.
|
||||
Legacy originals and migration safety copies are preserved. Requested outputs belong
|
||||
at their delivery destination outside AIE state; cleanup never targets their source.
|
||||
Raw transport, credentials, environment and complete logs are not retained as memory.
|
||||
Git synchronization, Git LFS, Work/DEC export and backup as a feature are outside this
|
||||
local version. The migration safety copy is specifically for conversion recovery.
|
||||
|
||||
Exit codes: 0 success, 1 I/O/runtime error, 2 invalid input, 3 missing resource,
|
||||
4 validation/readiness failure. Read `--help` for exact command options.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"protocolVersion": 3,
|
||||
"protocolVersion": 4,
|
||||
"protocol": "ai-engineering",
|
||||
"entrypoint": "README.md",
|
||||
"instructions": "AGENTS.md",
|
||||
@@ -9,7 +9,7 @@
|
||||
"command": "ai-engineering",
|
||||
"aliases": ["aie"],
|
||||
"startup": ["status --format json", "next-actions --format json", "work context <WRK> --format markdown"],
|
||||
"capabilities": ["protocol-compatibility", "work-guidance", "human-decision-request", "plan-experiments", "work", "discussion", "topics", "surveys", "answer-history", "proposal-dispositions", "fixture-adapters", "local-cli-adapters", "guided-agent-setup", "agent-doctor", "agent-routing", "run-provenance", "epic", "epic-policy-authorization", "epic-propagation", "epic-reconciliation", "decision-approval", "decision-history", "plan-decision-promotion", "discussion-import", "import-preview", "import-provenance", "planning", "step-dependencies", "evidence", "completion", "plan-consolidation", "cancelled-scope-review", "work-reconciliation", "archive", "reopen"],
|
||||
"capabilities": ["sqlite-storage", "local-memory", "quality-gates", "temporary-artifacts", "storage-migration", "protocol-compatibility", "work-guidance", "human-decision-request", "plan-experiments", "work", "discussion", "topics", "surveys", "answer-history", "proposal-dispositions", "fixture-adapters", "local-cli-adapters", "guided-agent-setup", "agent-doctor", "agent-routing", "run-provenance", "epic", "epic-policy-authorization", "epic-propagation", "epic-reconciliation", "decision-approval", "decision-history", "plan-decision-promotion", "discussion-import", "import-preview", "import-provenance", "planning", "step-dependencies", "evidence", "completion", "plan-consolidation", "cancelled-scope-review", "work-reconciliation", "archive", "reopen"],
|
||||
"humanApproval": "explicit-attestation",
|
||||
"execution": "external-human-or-agent",
|
||||
"legacyImport": true
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
-- Ownership, identity and revision foundation. Domain tables extend these keys.
|
||||
CREATE TABLE aie_schema (
|
||||
singleton INTEGER PRIMARY KEY CHECK (singleton=1),
|
||||
schema_version INTEGER NOT NULL CHECK (schema_version=1)
|
||||
);
|
||||
INSERT INTO aie_schema VALUES (1, 1);
|
||||
|
||||
CREATE TABLE work_identity (
|
||||
work_id TEXT PRIMARY KEY NOT NULL
|
||||
);
|
||||
CREATE TABLE work_location (
|
||||
work_id TEXT PRIMARY KEY NOT NULL REFERENCES work_identity(work_id),
|
||||
folder TEXT NOT NULL UNIQUE
|
||||
);
|
||||
CREATE TABLE epic_link (
|
||||
parent_work_id TEXT NOT NULL REFERENCES work_identity(work_id),
|
||||
child_work_id TEXT NOT NULL UNIQUE REFERENCES work_identity(work_id),
|
||||
important INTEGER NOT NULL CHECK(important IN (0,1)),
|
||||
PRIMARY KEY(parent_work_id,child_work_id),
|
||||
CHECK(parent_work_id<>child_work_id)
|
||||
);
|
||||
|
||||
CREATE TABLE identity_sequence (
|
||||
scope TEXT NOT NULL,
|
||||
kind TEXT NOT NULL,
|
||||
high_water INTEGER NOT NULL CHECK (high_water>=0),
|
||||
PRIMARY KEY (scope, kind)
|
||||
);
|
||||
INSERT INTO identity_sequence VALUES ('project', 'work', 0);
|
||||
|
||||
CREATE TABLE quality_gate (
|
||||
scope TEXT NOT NULL,
|
||||
gate_id TEXT NOT NULL,
|
||||
work_id TEXT REFERENCES work_identity(work_id),
|
||||
title TEXT NOT NULL,
|
||||
procedure TEXT NOT NULL,
|
||||
evidence_required INTEGER NOT NULL CHECK(evidence_required IN (0,1)),
|
||||
revision INTEGER NOT NULL CHECK(revision>0),
|
||||
updated_by TEXT NOT NULL,
|
||||
PRIMARY KEY(scope,gate_id),
|
||||
CHECK((scope='project' AND work_id IS NULL) OR (work_id IS NOT NULL AND scope=work_id))
|
||||
);
|
||||
CREATE TABLE quality_gate_input (
|
||||
scope TEXT NOT NULL,
|
||||
gate_id TEXT NOT NULL,
|
||||
ordinal INTEGER NOT NULL CHECK(ordinal>=0),
|
||||
path TEXT NOT NULL,
|
||||
PRIMARY KEY(scope,gate_id,ordinal),
|
||||
FOREIGN KEY(scope,gate_id) REFERENCES quality_gate(scope,gate_id)
|
||||
);
|
||||
CREATE TABLE quality_delivery (
|
||||
work_id TEXT NOT NULL REFERENCES work_identity(work_id),
|
||||
completed_at TEXT NOT NULL,
|
||||
gate_count INTEGER NOT NULL CHECK(gate_count>=0),
|
||||
PRIMARY KEY(work_id,completed_at)
|
||||
);
|
||||
CREATE TABLE quality_delivery_gate (
|
||||
work_id TEXT NOT NULL,
|
||||
completed_at TEXT NOT NULL,
|
||||
gate_key TEXT NOT NULL,
|
||||
result_id TEXT NOT NULL,
|
||||
result_sha256 TEXT NOT NULL,
|
||||
result_kind TEXT NOT NULL DEFAULT 'gate' CHECK(result_kind='gate'),
|
||||
result_revision INTEGER NOT NULL DEFAULT 1 CHECK(result_revision=1),
|
||||
PRIMARY KEY(work_id,completed_at,gate_key),
|
||||
FOREIGN KEY(work_id,completed_at) REFERENCES quality_delivery(work_id,completed_at),
|
||||
FOREIGN KEY(work_id,result_kind,result_id,result_revision) REFERENCES record_identity(work_id,kind,local_id,revision) DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
|
||||
CREATE TABLE record_identity (
|
||||
work_id TEXT NOT NULL,
|
||||
kind TEXT NOT NULL CHECK (kind IN ('work','discussion','topic','survey','disposition','decision','plan','epic','run','artifact','gate','receipt')),
|
||||
local_id TEXT NOT NULL,
|
||||
revision INTEGER NOT NULL CHECK (revision>0),
|
||||
PRIMARY KEY (work_id,kind,local_id,revision),
|
||||
FOREIGN KEY (work_id) REFERENCES work_identity(work_id) DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
CREATE INDEX record_by_kind ON record_identity(kind,work_id,local_id,revision);
|
||||
|
||||
CREATE TABLE current_record (
|
||||
work_id TEXT NOT NULL,
|
||||
kind TEXT NOT NULL,
|
||||
local_id TEXT NOT NULL,
|
||||
revision INTEGER NOT NULL,
|
||||
PRIMARY KEY (work_id,kind,local_id),
|
||||
FOREIGN KEY (work_id,kind,local_id,revision)
|
||||
REFERENCES record_identity(work_id,kind,local_id,revision) DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
|
||||
CREATE TABLE record_reference (
|
||||
work_id TEXT NOT NULL,
|
||||
kind TEXT NOT NULL,
|
||||
local_id TEXT NOT NULL,
|
||||
revision INTEGER NOT NULL,
|
||||
field TEXT NOT NULL,
|
||||
ordinal INTEGER NOT NULL CHECK (ordinal>=0),
|
||||
target_work_id TEXT NOT NULL,
|
||||
target_kind TEXT NOT NULL,
|
||||
target_id TEXT NOT NULL,
|
||||
target_revision INTEGER NOT NULL,
|
||||
PRIMARY KEY (work_id,kind,local_id,revision,field,ordinal),
|
||||
FOREIGN KEY (work_id,kind,local_id,revision)
|
||||
REFERENCES record_identity(work_id,kind,local_id,revision) DEFERRABLE INITIALLY DEFERRED,
|
||||
FOREIGN KEY (target_work_id,target_kind,target_id,target_revision)
|
||||
REFERENCES record_identity(work_id,kind,local_id,revision) DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
CREATE INDEX references_to_record ON record_reference(target_work_id,target_kind,target_id,target_revision);
|
||||
|
||||
CREATE TABLE record_format (
|
||||
work_id TEXT NOT NULL,
|
||||
kind TEXT NOT NULL,
|
||||
local_id TEXT NOT NULL,
|
||||
revision INTEGER NOT NULL,
|
||||
document_version INTEGER NOT NULL CHECK(document_version IN (1,2)),
|
||||
original_path TEXT,
|
||||
original_sha256 TEXT,
|
||||
PRIMARY KEY (work_id,kind,local_id,revision),
|
||||
CHECK((original_path IS NULL)=(original_sha256 IS NULL)),
|
||||
FOREIGN KEY (work_id,kind,local_id,revision)
|
||||
REFERENCES record_identity(work_id,kind,local_id,revision) DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
|
||||
CREATE TABLE artifact_lifecycle (
|
||||
work_id TEXT NOT NULL,
|
||||
artifact_id TEXT NOT NULL,
|
||||
kind TEXT NOT NULL DEFAULT 'artifact' CHECK(kind='artifact'),
|
||||
revision INTEGER NOT NULL DEFAULT 1 CHECK(revision=1),
|
||||
state TEXT NOT NULL CHECK(state IN ('AVAILABLE','DISCARD_PENDING','DISCARDED','RETAINED_LEGACY','STRUCTURED')),
|
||||
checked_sha256 TEXT,
|
||||
checked_at TEXT,
|
||||
PRIMARY KEY(work_id,artifact_id),
|
||||
CHECK((checked_sha256 IS NULL)=(checked_at IS NULL)),
|
||||
CHECK(state NOT IN ('DISCARD_PENDING','DISCARDED','STRUCTURED') OR checked_sha256 IS NOT NULL),
|
||||
FOREIGN KEY(work_id,kind,artifact_id,revision) REFERENCES record_identity(work_id,kind,local_id,revision) DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
Reference in New Issue
Block a user