Software Requirements and Architecture Specification
Version: 0.1.0 | Status: Proposed | Product name: Working title
Provide a persistent, model-independent memory and knowledge platform that allows AI agents and applications to retain experiences, retrieve relevant information, share verified knowledge, resume work and improve future task performance through evidence-based learning.
The platform shall support software development, research, business processes, personal assistants and other domains. Coding-specific capabilities shall be optional extensions, not assumptions embedded in the core model.
Goals:
Non-goals for the MVP: training or fine-tuning foundation models; autonomous execution of external actions; guaranteeing factual correctness of generated answers; requiring a specific agent framework, protocol, database, model or vendor; building a general-purpose workflow automation platform. The system supplies evidence and context; agents remain responsible for interpreting and validating it.
| Actor | Responsibilities |
|---|---|
| Agent | Retrieves context, records experiences, proposes knowledge and checkpoints work |
| Human user | Creates memories, reviews evidence, corrects knowledge and manages personal scope |
| Knowledge curator | Reviews candidates, conflicts and verification records |
| Administrator | Manages access, providers, retention, backups and operational settings |
| Application | Integrates through documented machine interfaces |
| Background processor | Executes authorized ingestion, indexing, maintenance and optional enrichment jobs |
flowchart TD
A[Agents and applications] --> G[Integration boundary]
U[Human administration] --> G
G --> P[Identity and authorization]
P --> M[Memory and session service]
P --> R[Retrieval and context service]
P --> K[Knowledge ingestion service]
P --> L[Learning and verification service]
P --> H[Relationship service]
M --> S[Persistent storage capability]
R --> S
R --> I[Search and indexing capability]
K --> Q[Durable job processing]
L --> Q
H --> S
Q --> E[Embedding provider]
Q --> F[Optional inference provider]
Q --> D[Document and code parsers]
Q --> S
Q --> I
R --> E
The three principal runtime roles are (1) application/API and orchestration, (2) persistent storage and retrieval indexes, and (3) model inference/embedding processing. They may be co-located, independently deployed, or provided by external services. A separate worker, document store, reverse proxy or identity provider may be introduced when justified. No container count or container technology is mandated. Only authorized integration surfaces should be exposed publicly; backend services should be private by default.
| Type | Purpose | Example |
|---|---|---|
| Working | Current task state, checkpoints | Remaining steps in a coding task |
| Episodic | Time-bound experience and outcome | A test failed after a dependency upgrade |
| Semantic | Facts and concepts | Meaning of a database transaction |
| Procedural | Reusable instructions and skills | How to restore a database |
| Preference | User or organization preferences | Preferred scripting conventions |
| Decision | Recorded choices and rationale | Chosen application architecture |
| Constraint | Applicable requirements or rules | Controllers must not contain business logic |
| Lesson | Generalized learning from evidence | Verify runtime compatibility before loading assemblies |
| Hypothesis | Unverified proposed explanation | A timeout may be caused by connection exhaustion |
| Goal | Desired outcome | Complete a migration |
| Solution | Reusable problem resolution | A tested repair procedure |
Reference documents are not themselves learned memories. Relationships are separately represented and can connect memories, concepts and source material. Memory type shall be extensible; verification state and access permissions shall be independent of type.
Priority: M = MVP mandatory; L = later release. Requirements are normative when marked M or when their later module is implemented.
| ID | Priority | Requirement |
|---|---|---|
| FR-001 | M | Create, read, update, list, retire and delete authorized memory records. |
| FR-002 | M | Store content, summary (optional), type, scope, tags, provenance, lifecycle and verification state. |
| FR-003 | M | Maintain immutable revision history for substantive memory changes, subject to deletion policy. |
| FR-004 | M | Organize memories and documents by tenant and hierarchical namespace; support project and personal scopes. |
| FR-005 | M | Detect exact duplicate submissions within authorized scope and support idempotent writes. |
| FR-006 | M | Ingest plain text and Markdown documents; preserve source identity, revision and original content or durable reference. |
| FR-007 | M | Segment reference content into addressable chunks with source locators and stable revision references. |
| FR-008 | M | Generate, store and query embeddings through a replaceable provider; track model identity, dimensions and source revision. |
| FR-009 | M | Provide lexical, semantic and metadata-filtered retrieval; combine lexical and semantic rankings. |
| FR-010 | M | Assemble relevant memories and document evidence under a caller-provided context budget. |
| FR-011 | M | Retrieve exact items and source passages by identifier without semantic search. |
| FR-012 | M | Create sessions, record experiences and save/restore working state with concurrency protection. |
| FR-013 | M | Accept proposed lessons and facts linked to evidence; support review, approval, rejection and supersession. |
| FR-014 | M | Record verification method, outcome, reviewer and exact memory revision. |
| FR-015 | M | Apply access, status, validity and retention filters to all retrieval paths before disclosure. |
| FR-016 | M | Process durable ingestion/indexing jobs with status, retries and failure reporting. |
| FR-017 | M | Expose authenticated, documented, machine-readable API contracts and standardized errors. |
| FR-018 | M | Export authorized canonical records and source metadata; support import with validation. |
| FR-019 | M | Record security-relevant actions and basic retrieval metrics without logging secrets. |
| FR-020 | M | Record explicit memory usefulness feedback linked to retrieval results. |
| FR-021 | L | Ingest PDF, HTML, Git repositories and other source formats through adapters. |
| FR-022 | L | Detect semantic duplicates and potential contradictions, subject to review. |
| FR-023 | L | Extract entities and typed, evidence-backed relationships; provide bounded graph traversal and graph-enhanced retrieval. |
| FR-024 | L | Provide AI-assisted summarization, reflection, entity extraction and consolidation. |
| FR-025 | L | Index source code by language-aware symbols, qualified names, locations and revisions. |
| FR-026 | L | Provide repository dependency and test-to-requirement relationship analysis. |
| FR-027 | L | Provide a browser-based administration and knowledge review interface. MVP may use API/CLI. |
| FR-028 | L | Support managed service quotas, usage accounting and billing integration. |
| FR-029 | L | Support automated source refresh and incremental indexing. |
The following are logical collections/entities, not a mandatory physical table schema. Implementations may normalize, partition or combine records provided invariants remain enforceable. Identifiers are opaque and stable; timestamps use UTC; references to evidence identify immutable revisions where possible.
| Entity | Principal fields |
|---|---|
| Tenant | id, name, status, settings |
| Principal | id, tenant, type (human/agent/service), status |
| Access grant | principal, resource scope, permissions, expiry |
| Project | id, tenant, name, description, status |
| Namespace | id, tenant, parent, optional project/owner, name, inheritance policy |
| Memory type | id, code, description |
| Memory | id, tenant, namespace, type, current revision, lifecycle status, validity, creator, timestamps |
| Memory revision | id, memory id, revision number, title, summary, content, structured attributes, tags, confidence, importance, content hash, change reason |
| Document | id, tenant, namespace, source URI, format, title, current revision |
| Document revision | id, document id, source revision, hash, original content/reference, extraction metadata |
| Chunk | id, document revision, parent chunk, ordinal, content, summary, source locator, token estimate |
| Evidence link | id, memory revision, target source revision/chunk/experience, role (supports/contradicts/context), excerpt or locator |
| Embedding model | id, provider, model revision, dimensions, metric, preprocessing configuration |
| Embedding | id, source revision or chunk, representation, model id, vector, source hash, indexing state |
| Session | id, tenant, namespace, agent, objective, status, timestamps |
| Checkpoint | session id, revision, structured working state, timestamp |
| Experience | id, session, task, problem, action, result, outcome, environment, evidence references, timestamp |
| Learning candidate | id, namespace, proposed content/type, source experience/evidence, author, review state, resulting memory id |
| Verification | id, memory revision or candidate, method, result, reviewer, evidence, timestamp |
| Retrieval query | id, principal, session, filters, strategy, timing, budget, counts |
| Retrieval result | query id, result id, target revision, rank, score components, included flag |
| Feedback | id, retrieval result, author, usefulness, optional comments |
| Job | id, tenant, type, input reference, state, attempt count, error code, timestamps |
| Audit event | id, tenant, principal, action, resource, outcome, timestamp |
| Entity (later) | id, namespace, type, canonical key, name, aliases, properties |
| Relationship (later) | id, source entity, target entity, type, scope, evidence, validity, confidence |
| Memory-entity link (later) | memory revision, entity, role, relevance |
| Conflict (later) | id, affected revisions, evidence, status, resolution |
| Code symbol (later) | repository/revision, qualified name, signature, kind, source span, chunk/entity references |
Use a versioned, transport-neutral operation model. An HTTP/JSON REST binding is the recommended initial interoperable interface, not a mandatory internal implementation. Publish a machine-readable contract (for HTTP, OpenAPI or equivalent), schemas, examples and compatibility policy. All paths below are illustrative proposed HTTP bindings under /api/v1.
| Operation | Proposed endpoint | Purpose | Priority |
|---|---|---|---|
| Remember | POST /remember | Create a persistent memory | M |
| Recall | POST /recall | Search learned memories | M |
| Search | POST /search | Search original reference content | M |
| Context | POST /context | Assemble a task briefing | M |
| Learn | POST /learn | Submit a reusable knowledge candidate | M |
| Get memory | GET /memories/{id} | Retrieve exact record/revision | M |
| List memories | GET /memories | Filter and paginate records | M |
| Correct | PATCH /memories/{id} | Create a revised memory | M |
| Forget | DELETE /memories/{id} | Request authorized deletion | M |
| Review | POST /candidates/{id}/review | Approve/reject candidate | M |
| Verify | POST /memories/{id}/verifications | Record evidence-based review | M |
| Sources | GET /memories/{id}/sources | Retrieve authorized evidence | M |
| History | GET /memories/{id}/versions | Retrieve revision history | M |
| Retire | POST /memories/{id}/retire | Exclude from normal recall | M |
| Ingest | POST /ingestion/jobs | Submit reference material | M |
| Job status | GET /jobs/{id} | Inspect durable job state | M |
| Document | GET /documents/{id} | Retrieve source metadata | M |
| Chunk | GET /chunks/{id} | Retrieve original passage | M |
| Start session | POST /sessions | Create agent session | M |
| Record experience | POST /sessions/{id}/events | Capture significant outcome | M |
| Save state | PUT /sessions/{id}/state | Persist checkpoint | M |
| Restore state | GET /sessions/{id}/state | Retrieve checkpoint | M |
| Complete | POST /sessions/{id}/complete | Close session with outcome | M |
| Feedback | POST /feedback | Report usefulness or error | M |
| Export/import | POST /exports; POST /imports | Authorized portable data transfer | M |
| Management | /namespaces; /projects; /principals; /grants | Provision and authorize resources | M (API or secure configuration) |
| Health | GET /health/live; GET /health/ready | Operational status | M |
| Reflect | POST /sessions/{id}/reflect | AI-assisted lesson extraction | L |
| Relate | POST /relate | Propose graph relationship | L |
| Traverse | POST /graph/traverse | Bounded relationship exploration | L |
{
"namespace_id": "ns-development",
"type": "procedural",
"title": "Check runtime compatibility",
"content": "Verify the target runtime of an assembly before loading it.",
"tags": ["compatibility", "development"],
"evidence": [{"kind": "experience", "id": "exp-001"}]
}
Response (201 when created):
{
"id": "mem-001",
"revision": 1,
"status": "active",
"verification_status": "unverified",
"indexing_status": "queued"
}
Ordinary observations may be stored as active but unverified. Proposed rules or reusable lessons submitted through Learn remain candidates until accepted. Default trusted-context retrieval excludes unverified content; authorized callers can explicitly request it with labels. Exact retries return the original result; conflicting reuse of an idempotency key fails.
{
"query": "Why might a legacy assembly fail in a modern runtime?",
"namespace_ids": ["ns-development"],
"types": ["semantic", "procedural", "lesson"],
"strategy": "hybrid",
"verification_filter": "verified_only",
"max_results": 10,
"max_context_tokens": 1500,
"detail_level": "summary"
}
{
"query_id": "qry-001",
"results": [{
"id": "mem-001",
"revision": 2,
"type": "procedural",
"title": "Check runtime compatibility",
"content": "Inspect the assembly target and verify API availability.",
"verification_status": "verified",
"relevance_score": 0.92,
"sources": [{"kind": "experience", "id": "exp-001"}]
}],
"context": {"estimated_tokens": 95, "truncated": false},
"warnings": []
}
IDs, scores and token estimates are illustrative. Scores are ranking signals, not truth probabilities.
{
"project_id": "proj-001",
"task": "Implement a customer repository",
"session_id": "sess-001",
"environment": {"domain": "software-development"},
"include": ["constraints", "decisions", "preferences", "lessons", "references", "working_state"],
"max_context_tokens": 4000,
"format": "structured"
}
Response shall separate applicable authoritative policies, verified knowledge, unverified observations (if requested), relevant source passages, session state, conflicts and warnings. Each included item carries a revision and provenance. Enforced policies are loaded by deterministic authorization/scope rules, not solely similarity. If required constraints do not fit, return an explicit budget error or incomplete-context warning that prevents the caller from treating the briefing as complete.
Retrieval must work without a generative LLM. A semantic embedding provider is required for vector retrieval, but lexical retrieval and exact lookups should remain available when it fails, with an explicit degradation warning. Token budgets apply to the assembled context rather than HTTP metadata; use the selected consumer tokenizer when available, otherwise label estimates and document the counting method. No claim of exact token limits across all models is made.
Source adapters shall normalize input into versioned documents and chunks, preserving source locators. MVP supports UTF-8 text and Markdown; later adapters cover PDFs, HTML, structured records and code. Validate format and size; reject or quarantine unsafe content. Remote fetch adapters must restrict destinations, credentials, redirects and network access to prevent SSRF; repositories must exclude secrets and unapproved paths.
Jobs shall be durable, observable, idempotent and retryable with bounded attempts. New revisions are published only after required indexing succeeds or are marked explicitly incomplete. Previous valid indexed revisions remain available according to policy. Deletion, corrections and source updates invalidate affected derived embeddings, caches and graph data. Model migrations create compatible indexes before switching active model configuration.
Experience capture records the task, environment, attempted action, observed outcome and evidence. An agent can submit a reusable candidate without server-side generative inference. Optional inference may extract candidates from sessions, but cannot grant itself approval authority.
Candidate lifecycle: proposed -> under review -> accepted/rejected. Acceptance creates or revises a memory. Memory lifecycle: active -> superseded/retired -> deleted under retention rules. Verification is independent: unverified, verified, disputed or rejected. Verification can apply only to a specific revision and scope. Confidence and user approval do not establish universal truth.
A curator or authorized automated verifier records the method and evidence; test-based verification is limited to what the test establishes. Conflicting claims must be visible to authorized reviewers and never silently overwritten. Promotion from project-specific scope to shared organization knowledge requires authorization and review for confidentiality and generalizability. Failed approaches remain distinguishable from successful solutions.
A checkpoint stores objective, task ID, completed and remaining steps, relevant decisions, changed files or resources, open issues, next action and evidence references. Session state shall support conditional updates and recovery after interruption. Agents may resume only authorized sessions; they must verify checkpoint assumptions against current external state.
Recommended agent protocol:
Provide a concise agent integration guide and example skills usable from an AGENTS.md or equivalent instruction file. Command-line clients and SDKs are optional adapters, not requirements for accessing the core API. No MCP dependency is required.
The graph module supports canonical entities, aliases, typed directed relationships, provenance, temporal validity and bounded traversal. Example relations: IS_A, PART_OF, DEPENDS_ON, IMPLEMENTS, CALLS, SOLVES, CONTRADICTS, SUPERSEDES, VERIFIED_BY. Graph assertions require evidence and independent access checks; inferred links are labeled as such.
Coding adapters shall preserve repository identity, branch or commit, file path, language, symbol signature and source ranges. Prefer language-aware chunks, such as methods and classes, over arbitrary splits. Support exact symbol lookup and dependency traversal where analysis can establish relationships. Clearly label incomplete or inferred static analysis; current repository source outranks stale indexed summaries for code behavior.
| Port | Responsibility |
|---|---|
| Memory store | Canonical records, revisions and consistency |
| Source store | Original documents and versioned references |
| Lexical index | Keyword and exact-term search |
| Vector index | Model-compatible similarity search |
| Embedding provider | Text-to-vector conversion and model metadata |
| Inference provider (optional) | Structured candidate extraction and summarization |
| Parser | Format detection, extraction, chunking and locators |
| Relationship store (later) | Typed edges and bounded traversal |
| Job store/executor | Durable job lifecycle and recovery |
| Identity/authorization | Trusted principal and resource access decisions |
| Token estimator | Consumer-specific or documented approximate token counting |
| Audit/telemetry | Security events and operational metrics |
Provider failures shall be typed, observable and subject to timeout/retry policy. Storage and model providers must not change domain-level semantics. Migration between providers may require rebuilding derived indexes; portability does not promise effortless database replacement. Model credentials are server-managed and never returned to clients.
| ID | Requirement |
|---|---|
| NFR-001 | Core operations remain available without optional generative inference. |
| NFR-002 | Acknowledged canonical writes survive process restart; failed jobs are recoverable. |
| NFR-003 | Concurrent edits detect stale revisions and prevent silent lost updates. |
| NFR-004 | Provide health checks, structured logs, metrics and correlation IDs. |
| NFR-005 | Publish deployment instructions, migration procedure, configuration reference and backup/restore procedure. |
| NFR-006 | Maintain backward-compatible API evolution within a major version or document breaking migrations. |
| NFR-007 | Support portable canonical export with schema version and integrity validation. |
| NFR-008 | Indexing and retrieval respect configurable resource and timeout limits. |
| NFR-009 | No unauthorized resource content or existence disclosure in search, traversal, direct access or export. |
| NFR-010 | Benchmark retrieval relevance, latency, context cost and downstream task success against lexical-only and no-memory baselines. |
Proposed initial performance targets, not validated commitments: p95 recall <= 2 seconds for a warm single-query workload with 100,000 indexed chunks, five concurrent clients, 10 returned results, including embedding and hybrid retrieval but excluding optional generative enrichment; p95 exact lookup <= 300 ms. Record hardware, model, corpus and cache conditions. Initial backup recovery targets for managed hosting (proposed): RPO <= 24 hours, RTO <= 4 hours. Approve targets and test environment before implementation acceptance.
| ID | Given / when / then |
|---|---|
| AC-01 | Given an authorized namespace, when a memory is stored and the service restarts, then the same content and revision are retrievable. |
| AC-02 | Given a repeated idempotent write, when replayed, then one logical memory exists and the original result is returned. |
| AC-03 | Given a text/Markdown document, when ingestion succeeds, then searchable chunks reference its exact revision and locator. |
| AC-04 | Given a corpus with exact technical terms and paraphrases, when hybrid recall runs, then the predefined relevant fixtures are retrieved and evidence is returned. |
| AC-05 | Given a context budget, when context is assembled, then included content fits the declared counting method or an explicit incomplete/budget response is returned. |
| AC-06 | Given two tenants, when one requests the other's direct IDs, chunks, search results, jobs or exports, then no unauthorized information is disclosed. |
| AC-07 | Given a verified revision, when it is corrected, then the new revision is unverified unless separately verified and history remains traceable. |
| AC-08 | Given an unverified candidate, when ordinary trusted recall runs, then it is not presented as verified active knowledge. |
| AC-09 | Given a saved checkpoint, when a different authorized agent resumes, then the last accepted revision and next steps are available. |
| AC-10 | Given simultaneous checkpoint or memory updates, when stale revisions are submitted, then conflicts are reported and accepted updates are preserved. |
| AC-11 | Given an embedding provider outage, when recall runs, then lexical fallback is labeled or a typed error is returned according to policy. |
| AC-12 | Given interrupted ingestion, when processing restarts, then it resumes/retries without duplicate published chunks. |
| AC-13 | Given a deleted memory, when ordinary retrieval and direct access run after deletion completion, then content is absent and derived data is invalidated. |
| AC-14 | Given canonical export, when imported into a clean authorized installation, then content, provenance and relationships supported by that version remain intact. |
| AC-15 | Given malicious instructions in a reference document, when retrieved, then they remain untrusted data and cannot alter permissions or enforced policy. |
| AC-16 | Given no generative inference configured, when the core workflow runs, then ingestion, remember, recall, context and manual candidate review still function. |
| AC-17 | Given a backup, when restored into an isolated environment, then integrity and configured recovery objectives are demonstrably met. |
| AC-18 | Given a retrieval result, when feedback is submitted, then it is associated with the correct query and revision. |
Each feature shall include automated tests, a reproducible manual verification procedure, expected results and evidence of execution. Tests not executed must be identified explicitly. Establish benchmark fixtures and quantitative relevance thresholds before implementation; the present spec does not claim measured performance.
| Phase | Scope | Exit condition |
|---|---|---|
| 0 | Requirements review, threat model, provider evaluation, architecture decisions, benchmark fixtures | Approved contracts, risks and technology choices |
| 1 | Identity/scopes, canonical memory, revisions, direct retrieval, session checkpoints | Persistence and isolation tests pass |
| 2 | Text/Markdown ingestion, durable jobs, embeddings, lexical/hybrid recall, context | Retrieval and recovery acceptance tests pass |
| 3 | Experiences, candidate review, evidence, feedback, import/export, operational hardening | All MVP acceptance criteria pass |
| 4 | Additional document adapters, administration UI, graph relationships | Module-specific security and retrieval tests pass |
| 5 | Code indexing, optional AI-assisted learning, advanced retrieval evaluation | Demonstrated benefit against MVP baseline |
| 6 | Managed hosting, quotas, billing and operational scaling | Hosting security, recovery and service readiness approved |
For every task: define acceptance criteria and dependencies first; implement only approved scope; run automated tests; provide explicit manual validation steps and expected outcomes; record results and obtain required acceptance before marking complete. Maintain architecture decisions and update the specification when requirements change.
The following are intentionally unresolved and shall be evaluated in Phase 0, using representative workloads rather than preference alone:
Selection criteria: correctness, security, portability, operational simplicity, ecosystem maturity, retrieval quality, latency, resource consumption, cost, licensing and maintainability. Record each consequential choice in an architecture decision record with alternatives and trade-offs.
An authorized agent can start a session, ingest a reference document, remember information, retrieve relevant evidence through hybrid search, request a bounded task briefing, save and restore progress, propose a lesson, have it reviewed and reuse the verified lesson in a later session. The system survives restart, enforces isolation, supports correction/deletion, exposes documented contracts and operates without a generative model. All mandatory acceptance criteria must be demonstrated before release.
This is a proposed requirements baseline, not an implemented or benchmarked system. Technology choices, numerical targets and later-phase capabilities require stakeholder review.
Powered by TurnKey Linux.