Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .copilot-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# RAGfish / Noesis Noema – Context Index

This document defines the authoritative design entry points and the formal Question model.
All implementation must comply with these definitions.

---

# 1. Product Constitution
- docs/constitution/
- ADR-0000 (Human Sovereignty Principle)
Comment on lines +9 to +10
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs/constitution/ is referenced as the Product Constitution location, but that directory does not exist in the repo. Please update this reference to the actual constitution source (e.g., the ADR-0000 document) or add the missing directory so links are not broken.

Suggested change
- docs/constitution/
- ADR-0000 (Human Sovereignty Principle)
- ADR-0000 (Human Sovereignty Principle) — authoritative Product Constitution

Copilot uses AI. Check for mistakes.

---

# 2. Question Schema (Formal Definition)

A Question is not a raw string.
It is a structured object governed by human sovereignty.

## 2.1 Logical Model

A Question MUST contain:

- id (UUID)
- timestamp (ISO 8601)
- origin ("human" only)
- intent (short semantic label)
- content (primary user text)
- privacy_level ("local" | "cloud" | "auto")
- constraints (optional structured hints)

## 2.2 JSON Schema (Normative)

```json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "NoemaQuestion",
"type": "object",
"required": [
"id",
"timestamp",
"origin",
"intent",
"content",
"privacy_level"
],
Comment on lines +38 to +45
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normative NoemaQuestion schema here conflicts with design/context-index.md: this file makes intent required and omits session_id, while design/context-index.md lists session_id as required and intent as optional. Please reconcile these documents so there is a single consistent Question contract for implementation and validation.

Copilot uses AI. Check for mistakes.
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"timestamp": {
"type": "string",
"format": "date-time"
},
"origin": {
"type": "string",
"enum": ["human"]
},
"intent": {
"type": "string",
"minLength": 1
},
"content": {
"type": "string",
"minLength": 1
},
"privacy_level": {
"type": "string",
"enum": ["local", "cloud", "auto"]
},
"constraints": {
"type": "object",
"additionalProperties": true
}
},
"additionalProperties": false
}
```

## 2.3 Enforcement Rules

- Router decisions MUST operate on this structured object.
- Raw string prompts are forbidden at invocation boundary.
- origin MUST never be mutated by AI.
- privacy_level MUST be respected by routing layer.

---

# 3. AI Agent Instruction

Before implementing any feature:

1. Read this file.
2. Validate compliance with Question Schema.
3. Do not introduce raw string prompt execution.
4. Do not bypass privacy_level routing.

Violation requires ADR update.
66 changes: 66 additions & 0 deletions design/context-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# RAGfish / Noesis Noema – Context Index

This file defines the authoritative entry points for all design decisions.

## 1. Product Constitution
- docs/constitution/ (Human Sovereignty Principle)
- ADR-0000 (Governing architecture constraints)

## 2. Architecture Decisions
- docs/adr/ (All binding architectural decisions)

## 3. Contracts
- contracts/ (Schema, invocation boundaries, routing constraints)

## 4. RAGpack Definition
- DesignDoc.md (High-level architecture narrative)
- docs/architecture/ (If exists)
Comment on lines +6 to +17
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several references here point to paths that do not exist in the repo (docs/constitution/, contracts/, and DesignDoc.md at repo root). Please update these to the correct existing locations (e.g., docs/adr/adr-0000-product-constitution.md, docs/contracts/, docs/designs/DesignDoc.md) so the context index remains an accurate entry point.

Suggested change
- docs/constitution/ (Human Sovereignty Principle)
- ADR-0000 (Governing architecture constraints)
## 2. Architecture Decisions
- docs/adr/ (All binding architectural decisions)
## 3. Contracts
- contracts/ (Schema, invocation boundaries, routing constraints)
## 4. RAGpack Definition
- DesignDoc.md (High-level architecture narrative)
- docs/architecture/ (If exists)
- docs/adr/adr-0000-product-constitution.md (Human Sovereignty Principle)
- ADR-0000 (Governing architecture constraints)
## 2. Architecture Decisions
- docs/adr/ (All binding architectural decisions)
## 3. Contracts
- docs/contracts/ (Schema, invocation boundaries, routing constraints)
## 4. RAGpack Definition
- docs/designs/DesignDoc.md (High-level architecture narrative)
- docs/designs/ (If exists)

Copilot uses AI. Check for mistakes.

## 5. Implementation Constraints
- No hidden autonomous execution
- No implicit routing escalation
- All model invocation must respect invocation boundary

## 6. Core Schemas

### NoemaQuestion

The structured input object for all Invocations.

Required fields:
- `id` (UUID) — Question identifier
- `session_id` (UUID) — Associated session
- `content` (string) — User-provided prompt
- `privacy_level` (enum: "local" | "cloud" | "auto") — Privacy constraint
- `timestamp` (ISO-8601) — Submission time

Optional fields:
- `intent` (enum: "informational" | "analytical" | "retrieval") — Intent classification
- `constraints` (object) — Execution constraints

Schema must be validated before routing.

### NoemaResponse

The structured output object for all successful Invocations.

Required fields:
- `id` (UUID) — Response identifier
- `question_id` (UUID) — Associated Question
- `session_id` (UUID) — Associated session
- `content` (string) — Generated response
- `model` (string) — Model used
- `route` (enum: "local" | "cloud") — Execution route
- `trace_id` (UUID) — Traceability identifier
- `timestamp` (ISO-8601) — Response generation time
- `fallback_used` (boolean) — Whether fallback occurred

Optional fields:
- `confidence` (float) — Model confidence (if available)
- `uncertainty_reason` (string) — Explanation if confidence is low

## 7. Instruction to AI Agents
Before implementing any feature:
1. Read this file.
2. Read ADR-0000.
3. Do not violate Constitution or contracts.
Comment on lines +26 to +66
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NoemaQuestion/NoemaResponse schemas introduced here appear to diverge from the repo’s existing locked API contract (docs/contracts/api-schema.md) which defines InvocationRequest/InvocationResponse and an ExecutionError shape. Please clarify the relationship (mapping/migration) and ensure only one canonical external contract is presented to implementers.

Suggested change
### NoemaQuestion
The structured input object for all Invocations.
Required fields:
- `id` (UUID) — Question identifier
- `session_id` (UUID) — Associated session
- `content` (string) — User-provided prompt
- `privacy_level` (enum: "local" | "cloud" | "auto") — Privacy constraint
- `timestamp` (ISO-8601) — Submission time
Optional fields:
- `intent` (enum: "informational" | "analytical" | "retrieval") — Intent classification
- `constraints` (object) — Execution constraints
Schema must be validated before routing.
### NoemaResponse
The structured output object for all successful Invocations.
Required fields:
- `id` (UUID) — Response identifier
- `question_id` (UUID) — Associated Question
- `session_id` (UUID) — Associated session
- `content` (string) — Generated response
- `model` (string) — Model used
- `route` (enum: "local" | "cloud") — Execution route
- `trace_id` (UUID) — Traceability identifier
- `timestamp` (ISO-8601) — Response generation time
- `fallback_used` (boolean) — Whether fallback occurred
Optional fields:
- `confidence` (float) — Model confidence (if available)
- `uncertainty_reason` (string) — Explanation if confidence is low
## 7. Instruction to AI Agents
Before implementing any feature:
1. Read this file.
2. Read ADR-0000.
3. Do not violate Constitution or contracts.
The canonical external API contract for this system is defined in:
- `docs/contracts/api-schema.md`
That document specifies the locked wire-level schemas:
- `InvocationRequest` — canonical request shape
- `InvocationResponse` — canonical success response shape
- `ExecutionError` — canonical error shape
All external implementers **must** treat `docs/contracts/api-schema.md` as the single source of truth for:
- Field names and types
- Required vs. optional properties
- Error envelopes and failure semantics
This file uses the following conceptual names when discussing architecture:
### NoemaQuestion (conceptual)
- Conceptual role: "The question being asked of the system."
- **Maps to**: `InvocationRequest` as defined in `docs/contracts/api-schema.md`.
- Usage: architectural and design discussions only; not a separate wire schema.
### NoemaResponse (conceptual)
- Conceptual role: "The system's answer to a NoemaQuestion."
- **Maps to**: `InvocationResponse` as defined in `docs/contracts/api-schema.md`.
- Usage: architectural and design discussions only; not a separate wire schema.
Errors, including partial failures, routing failures, or model execution problems, **must** be represented using the `ExecutionError` shape from `docs/contracts/api-schema.md`. No alternative external error envelope is permitted.
If there is any discrepancy between terminology or examples in this file and `docs/contracts/api-schema.md`, the contract in `docs/contracts/api-schema.md` prevails.
## 7. Instruction to AI Agents
Before implementing any feature:
1. Read this file.
2. Read ADR-0000.
3. Do not violate Constitution or contracts.
4. Treat `docs/contracts/api-schema.md` as the only canonical external API schema.

Copilot uses AI. Check for mistakes.
164 changes: 164 additions & 0 deletions design/error-doctrine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@


# Error Doctrine

## Status
Draft

---

# 1. Purpose

The Error Doctrine defines how failures are classified, surfaced, and handled.

The system must:
- Fail explicitly
- Fail deterministically
- Never hide uncertainty
- Never silently recover

AI systems must not conceal errors behind probabilistic output.

---

# 2. Error Classification

All errors must belong to a typed category.

## 2.1 Routing Errors

- E-ROUTE-001 — RoutingFailure
- E-ROUTE-002 — InvalidPrivacyConstraint

## 2.2 Execution Errors

- E-LOCAL-001 — LocalModelFailure
- E-CLOUD-001 — CloudModelFailure
- E-TIMEOUT-001 — InvocationTimeout

## 2.3 Validation Errors

- E-VALID-001 — SchemaValidationFailure
- E-VALID-002 — InvocationBoundaryViolation

## 2.4 Session Errors

- E-SESSION-001 — SessionExpired
- E-SESSION-002 — InvalidSessionID

## 2.5 Network Errors

- E-NET-001 — NetworkUnavailable
- E-NET-002 — CloudEndpointUnreachable

Each error must be uniquely identifiable and stable across versions.

---

# 3. Structured Error Response

All failures must return a structured error object.

```json
{
"status": "error",
"error_code": "E-LOCAL-001",
"message": "Local model execution failed.",
"recoverable": false,
"session_id": "uuid",
"question_id": "uuid",
"timestamp": "ISO8601"
}
Comment on lines +62 to +71
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Error Doctrine’s structured error response omits trace_id, but other documents require trace_id propagation and user-visible errors including trace_id (e.g., observability standard, UAT). Please include trace_id in the normative error schema (and keep it consistent with the external error envelope used elsewhere).

Copilot uses AI. Check for mistakes.
```

Rules:

- No raw string errors
- No stack traces exposed to user
- No fallback without explicit rule
- recoverable must be deterministic

---

# 4. Fail-Fast Policy

The system must terminate execution immediately when an error occurs.

Prohibited behaviors:

- Silent retry (retry without logging or without explicit retry flag)
- Implicit prompt rewriting
- Hidden model escalation
- Recursive execution loops

Fallback is allowed only if explicitly defined in Router rules.

### Exception: Explicit Network Retry

Retry is permitted ONLY under these strict conditions:

- Error type is network timeout
- Explicit retry flag is set
- Maximum 1 retry attempt
- Retry is logged with trace_id
- Never silent

All other retry scenarios are forbidden.

---

# 5. Uncertainty Policy

If a response is produced but uncertainty is high, the response must include structured confidence metadata.

Example:

```json
{
"status": "success",
"confidence": 0.68,
"uncertainty_reason": "Insufficient context",
"response": { ... }
}
```

Confidence must never trigger autonomous retry.

---

# 6. Observability Requirements

Every error must be logged with:

- error_code
- session_id
- question_id
- routing_decision
- model_used
- timestamp
Comment on lines +131 to +138
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, every error is required to be logged with the full session_id, even though session_id functions as a secret session identifier elsewhere in the design. Storing that token verbatim in logs means any unauthorized log access can yield active session_id values for replay or fine-grained tracking of user behavior. Prefer logging only trace_id or a derived, non-replayable representation of session_id so that logs remain useful for debugging without exposing bearer tokens.

Copilot uses AI. Check for mistakes.

Logs must be inspectable.

---

# 7. No Autonomous Recovery Rule

The system must never attempt self-correction without human intervention.

This includes:

- Automatic summarization to compensate for failure
- Silent cloud fallback outside Router policy
- Memory mutation to mask inconsistency

---

# 8. Governance

Error handling must comply with:

- ADR-0000 (Human Sovereignty Principle)
- Invocation Boundary
- Router Decision Matrix

Any deviation requires explicit ADR amendment.
Loading