# mark-sdk - Doramagic AI Context Pack

> Positioning: a pre-install experience and judgment asset. It helps the host AI get off to a good start, but it does not mean the project has already been installed, run, or validated.

## Sufficiency Principle

- **Sufficiency over compression**: The AI Context Pack should be sufficient for the host AI to understand the project's value, capability boundaries, entrypoints, risks, and evidence sources before starting work; it may be layered, but it does not aim for the shortest possible summary.
- **Compression policy**: Compress only noise and duplication, never context that affects judgment or the quality of the work.

## How the Host AI Should Use This

You are reading the AI Context Pack that Doramagic compiled for mark-sdk. Treat it as pre-work context: help the user understand who it fits, what it can do, how to start, what must be verified after install, and where the risks are. Do not claim that you have already installed, run, or executed the target project.

## Claim Consumption Rules

- **Fact source**: Repo Evidence + Claim/Evidence Graph; the Human Wiki only supplies salience, terminology, and narrative structure.
- **Minimum status for a fact**: `supported`
- `supported`: May be used as a project fact, but the answer must cite the claim_id and evidence path.
- `weak`: Usable only as a low-confidence lead; the user must be asked to keep verifying.
- `inferred`: Usable only for risk notes or open questions; must not be packaged as a project fact.
- `unverified`: Must not be used as fact; state clearly that evidence is insufficient.
- `contradicted`: Must show the conflicting sources and must not force a single version on the user's behalf.

## Who It Fits Best

- **Users who want to bring professional workflows into a host AI**: The repo contains Skill documents. Evidence: `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`, `src/mark/middlewares/skills/mark-usage/SKILL.md` Claim: `clm_0003` supported 0.86

## What It Can Do

- **AI Skill / Agent Instruction Asset Library** (Previewable before install): The project contains Skill or Agent instruction files that a host AI can read, useful for bringing professional workflows into hosts like Claude, Codex, or Cursor. Evidence: `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`, `src/mark/middlewares/skills/mark-usage/SKILL.md` Claim: `clm_0001` supported 0.86
- **Command-Line Startup or Install Flow** (Verify after install): The project documentation contains runnable commands; real use requires running them in a local or host environment. Evidence: `README.md` Claim: `clm_0002` supported 0.86

## How to Start

- `pip install mark-sdk` Evidence: `README.md` Claim: `clm_0004` supported 0.86, `clm_0005` supported 0.86, `clm_0006` supported 0.86, `clm_0007` supported 0.86 et al.
- `pip install "mark-sdk[langchain]"   # LangChain tools + agent middleware` Evidence: `README.md` Claim: `clm_0005` supported 0.86
- `pip install "mark-sdk[mcp]"        # MCP server over MARK memory` Evidence: `README.md` Claim: `clm_0006` supported 0.86
- `pip install "mark-sdk[adapters]"   # both of the above` Evidence: `README.md` Claim: `clm_0007` supported 0.86
- `pip install "mark-sdk[middleware]" # all local middleware batteries` Evidence: `README.md` Claim: `clm_0008` supported 0.86

## Continue-or-Stop Decision Card

- **Current recommendation**: Sandbox trial only
- **Why**: The project has signals of install commands, host configuration, or local writes; do not go straight into your primary environment—trial it in isolation first.

### 30-Second Read

- **What to do now**: Sandbox trial only
- **Minimum safe next step**: Run Prompt Preview first; if you still want to install, trial only in an isolated environment
- **Do not trust yet**: Real output quality cannot be trusted before install.
- **Continuing will touch**: Command execution, Host AI configuration, Local environment or project files

### What You Can Trust Now

- **Target-audience signal: Users who want to bring professional workflows into a host AI** (supported): Backed by a supported claim or project evidence, but that still is not the same as real install results. Evidence: `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`, `src/mark/middlewares/skills/mark-usage/SKILL.md` Claim: `clm_0003` supported 0.86
- **Capability exists: AI Skill / Agent Instruction Asset Library** (supported): You can trust that the project contains signals of this capability; whether it fits your specific task still needs trial or after-install verification. Evidence: `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`, `src/mark/middlewares/skills/mark-usage/SKILL.md` Claim: `clm_0001` supported 0.86
- **Capability exists: Command-Line Startup or Install Flow** (supported): You can trust that the project contains signals of this capability; whether it fits your specific task still needs trial or after-install verification. Evidence: `README.md` Claim: `clm_0002` supported 0.86
- **There are Quick Start / install-command signals** (supported): You can trust that the docs mention a startup or install entrypoint; do not run it directly in your primary environment because of that. Evidence: `README.md` Claim: `clm_0004` supported 0.86, `clm_0005` supported 0.86, `clm_0006` supported 0.86, `clm_0007` supported 0.86

### What You Cannot Trust Yet

- **Real output quality cannot be trusted before install.** (unverified): Prompt Preview can only show how it guides you; it cannot prove result quality in the real project.
- **Host AI version compatibility cannot be trusted before install.** (unverified): Host loading rules and version differences across Claude, Cursor, Codex, Gemini, and others must be verified in a real environment.
- **That it will not pollute your existing host AI's behavior cannot be trusted directly.** (inferred): Skill, plugin, and AGENTS/CLAUDE/GEMINI instructions may change the host AI's default behavior. Evidence: `AGENTS.md`, `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`, `src/mark/middlewares/skills/mark-usage/SKILL.md`
- **Safe rollback cannot be assumed by default.** (unverified): Unless the project clearly provides uninstall and recovery instructions, verify in an isolated environment first.
- **After a real install, is it compatible with the user's current host AI version?** (unverified): Compatibility can only be verified in the actual host environment.
- **Does the project's output quality meet the user's specific task?** (unverified): The pre-install preview can only show flow and boundaries; it cannot replace real evaluation.
- **Do the install commands require network access, permissions, or global writes?** (unverified): This affects install risk in both enterprise and personal environments. Evidence: `README.md`

### What Continuing Will Touch

- **Command execution**: Package managers, network downloads, the local plugin directory, project config, or the user's home directory. Why: Running the very first command can already change your environment; decide whether it is worth running first. Evidence: `README.md`
- **Host AI configuration**: The plugin, Skill, or rule-loading config of hosts like Claude/Codex/Cursor/Gemini/OpenCode. Why: Host configuration changes how the AI works afterward and may conflict with the user's existing rules. Evidence: `AGENTS.md`, `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`, `src/mark/middlewares/skills/mark-usage/SKILL.md`
- **Local environment or project files**: Install results, plugin caches, project config, or local dependency directories. Why: The write scope and rollback path cannot be proven before install and need isolated verification. Evidence: `README.md`
- **Host AI context**: The AI Context Pack, Prompt Preview, Skill routing, risk rules, and project facts. Why: Importing context affects the host AI's later judgment, so avoid packaging unverified items as facts.

### Minimum Safe Next Steps

- **Run Prompt Preview first**: Use a pre-install interactive trial to judge whether the way of working fits; it needs no authorization or environment change. (applies when: Applies to any project, especially when output quality is unknown.)
- **Trial-install only in an isolated directory or a test account**: Avoid letting install commands pollute your primary host AI, real projects, or home directory. (applies when: When there are signals of command execution, plugin config, or local writes.)
- **Back up your host AI configuration first**: Skill, plugin, and rule files may change the default behavior of Claude/Cursor/Codex. (applies when: When there is a plugin manifest, a Skill, or a host rule entrypoint.)
- **After install, verify just one minimal task**: Verify loading, compatibility, output quality, and rollback first, then decide whether to use it deeply. (applies when: When moving from a trial into a real workflow.)

### Exit Plan

- **Preserve the pre-install state**: Record the original host config and project state so you can later judge whether it is recoverable.
- **Be ready to remove the host plugin / Skill / rule entrypoint**: If behavior is off after the trial install, you can restore the host AI to its pre-trial state.
- **Record the install commands and written paths**: Without clear uninstall instructions, you at least need to know which directories or configs to clean up manually.
- **If there is no rollback path, do not enter your primary environment**: No rollback is a blocker before continuing; do not proceed on trust or luck.

## What Can Only Be Previewed

- Explain who the project fits and what it can do
- Demonstrate a typical conversation flow based on project docs
- Help the user decide whether it is worth installing or researching further

## What Must Be Verified After Install

- Actually installing the Skill, plugin, or CLI
- Running scripts, modifying local files, or accessing external services
- Verifying real output quality, performance, and compatibility

## Boundary & Risk Decision Card

- **Mistaking the pre-install preview for a real run**: The user may overestimate how much configuration, permission, and compatibility verification the project has already done. Mitigation: Clearly separate prompt_preview_can_do from runtime_required. Claim: `clm_0009` inferred 0.45
- **Command execution will modify the local environment**: Install commands may write to the user's home directory, the host plugin directory, or project configuration. Mitigation: Run in an isolated environment or a test account first. Evidence: `README.md` Claim: `clm_0010` supported 0.86
- **To confirm**: After a real install, is it compatible with the user's current host AI version?. Why: Compatibility can only be verified in the actual host environment.
- **To confirm**: Does the project's output quality meet the user's specific task?. Why: The pre-install preview can only show flow and boundaries; it cannot replace real evaluation.
- **To confirm**: Do the install commands require network access, permissions, or global writes?. Why: This affects install risk in both enterprise and personal environments.

## Pre-Work Working Context

### Loading Order

- First read how_to_use.host_ai_instruction to establish the boundaries of this pre-install judgment asset.
- Read claim_graph_summary to confirm facts come from the Claim/Evidence Graph, not the Human Wiki narrative.
- Then read intended_users, capabilities, and quick_start_candidates to judge whether the user is a match.
- When you need to carry out a concrete task, check role_skill_index first, then evidence_index.
- For real install, file modification, network access, performance, or compatibility questions, turn to risk_card and boundaries.runtime_required.

### Task Routes

- **AI Skill / Agent Instruction Asset Library**: Use role_skill_index / evidence_index to help the user pick a usable role, Skill, or workflow first. Boundary: Can be experienced via a pre-install Prompt. Evidence: `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`, `src/mark/middlewares/skills/mark-usage/SKILL.md` Claim: `clm_0001` supported 0.86
- **Command-Line Startup or Install Flow**: State that this is an after-install capability first, then give a pre-install checklist. Boundary: Must be verified after a real install or run. Evidence: `README.md` Claim: `clm_0002` supported 0.86

### Context Scale

- Total files: 158
- Important-file coverage: 40/158
- Evidence index entries: 79
- Role / Skill entries: 2

### Handling Insufficient Evidence

- **missing_evidence**: State that evidence is insufficient and ask the user for the target file, a README section, or after-install verification records; do not fill in facts.
- **out_of_scope_request**: State that the task is beyond the current AI Context Pack's evidence scope and suggest the user check the Human Manual or verify after a real install.
- **runtime_request**: Provide a pre-install checklist and command sources, but do not run commands for the user or claim they have been run.
- **source_conflict**: Show the conflicting sources side by side, mark them as unverified, and do not force a single version.

## Prompt Recipes

### Fit assessment

- Goal: Judge whether this project fits the user's current task.
- Expected output: A fit conclusion, key reasons, evidence citations, what can be previewed before install, what must be verified after install, and a next-step recommendation.

```text
Based on the AI Context Pack for mark-sdk, ask me 3 necessary questions first, then judge whether it fits my task. The answer must cover: who it fits, what it can do, what it cannot do, whether it is worth installing, and where the evidence comes from. Every project fact must cite evidence_refs, source_paths, or a claim_id.
```

### Pre-install experience

- Goal: Let the user feel the core workflow before installing, while avoiding packaging the preview as real capability or a marketing promise.
- Expected output: An experience script with boundary labels, an after-install verification checklist, and a cautious recommendation; with no real-run promises or strong marketing language.

```text
Treat mark-sdk as a pre-install experience asset, not an already-installed tool or a real runtime environment.

Output exactly four parts:
1. Ask me 3 necessary questions first.
2. Give an "experience script": use the three labels [Previewable before install], [Must verify after install], and [Insufficient evidence] to show how it might guide the workflow.
3. Give an after-install verification checklist: list which capabilities can only be confirmed after a real install, real host loading, and a real project run.
4. Give a cautious recommendation: only "worth researching/trialing further", "add information before deciding", or "not recommended to continue"; do not endorse the project.

Hard boundaries:
- Do not claim you have installed, run, executed tests, modified files, or produced real results.
- Do not write promise-like phrasing such as "auto-adapts", "guarantees passing", "perfect fit", or "strongly recommend installing".
- If you describe how it works after install, you must use a conditional such as "if installed successfully and the host loads the Skill correctly, it might...".
- The experience script may only be written as "example lines / hypothetical flow": use "might ask / might suggest / might show", not "has written, has generated, has passed, is running, is generating".
- Prompt Preview does not hand out install commands; if the user is ready to trial, only prompt them to read Quick Start and the Risk Card first and to verify in an isolated environment.
- Every project fact must come from a supported claim, evidence_refs, or source_paths; inferred/unverified items can only be risks or open questions.

```

### Role / Skill selection

- Goal: Pick the best-matching asset from the project's roles or Skills.
- Expected output: A list of candidate roles or Skills, each with an applicable scenario, evidence paths, risk boundary, and whether after-install verification is needed.

```text
Read role_skill_index and recommend 3-5 of the most relevant roles or Skills for my target task. For each recommendation, state the applicable scenario, likely output, risk boundary, and evidence_refs.
```

### Risk pre-check

- Goal: Identify environment, permission, rule-conflict, and quality risks before installing or adopting.
- Expected output: A checklist of environment, permission, dependency, license, host-conflict, quality risk, and unknown items.

```text
Based on risk_card, boundaries, and quick_start_candidates, give me a pre-install risk pre-check list. Do not run commands for me; only explain what I should check, why, and what impact a failure would have.
```

### Host AI kickoff instruction

- Goal: Turn the project context into a host AI instruction for the start of a conversation.
- Expected output: A pre-work instruction with clear boundaries and clear evidence citations, suitable to copy to a host AI.

```text
Based on the AI Context Pack for mark-sdk, generate a pre-work instruction I can paste to my host AI. This instruction must obey not_runtime=true and must not claim the project has been installed, run, or produced real results.
```

## Role / Skill Index

- Indexed 2 role / Skill / project-doc entries.

- **mark-memory-middleware** (skill): Use when a LangChain agent is wrapped with MARK middleware and should treat MARK as fast, transparent project memory for recall, grounding, and durable observation. Activation hint: When the user's task is highly relevant to the workflow described by “mark-memory-middleware”, use it for a pre-install experience first, then decide whether to install. Evidence: `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`
- **mark-usage** (skill): Use when an agent should adopt MARK as its persistent memory, context, reflection, and continuity layer. Activation hint: When the user's task is highly relevant to the workflow described by “mark-usage”, use it for a pre-install experience first, then decide whether to install. Evidence: `src/mark/middlewares/skills/mark-usage/SKILL.md`

## Evidence Index

- Indexed 79 evidence entries.

- **MARK Memory-Augmented Agent Recall Kit Python SDK** (documentation): MARK Memory-Augmented Agent Recall Kit Python SDK Evidence: `README.md`
- **MARK SDK Examples** (documentation): These examples are developer usage tests and public proof points for MARK as an agent memory runtime. They show the SDK doing more than storing facts: injecting context into work, preserving session continuity, preparing safe sync envelopes, and exposing the same memory through agent integrations. Evidence: `examples/README.md`
- **MARK Python SDK Agent Guide** (documentation): This package implements the local-first MARK SDK. When working in this package, treat MARK as the agent cognitive runtime: local memory, context assembly, policies, skills, and agent wrapping. Evidence: `AGENTS.md`
- **Contributing to MARK SDK** (documentation): Thanks for your interest in making agent memory better. Contributions of all sizes are welcome — bug reports, docs fixes, tests, and features. Evidence: `CONTRIBUTING.md`
- **MARK Memory Middleware** (skill_instruction): Use this skill when MARK middleware injects a MARK project memory block or records middleware diagnostics. Evidence: `src/mark/middlewares/skills/mark-memory-middleware/SKILL.md`
- **MARK Usage Skill** (skill_instruction): Use MARK as your persistent cognitive companion. MARK is not a tool you occasionally call after you get lost. MARK is the memory and continuity layer you lean on before planning, during reasoning, after action, before action, and when resuming future work. Evidence: `src/mark/middlewares/skills/mark-usage/SKILL.md`
- **License** (source_file): Apache License Version 2.0, January 2004 https://www.apache.org/licenses/ Evidence: `LICENSE`
- **Incomplete adapter namespaces stay out of shipped distributions until they** (source_file): build-system requires = "hatchling =1.25" build-backend = "hatchling.build" Evidence: `pyproject.toml`
- **Init** (source_file): LAZY EXPORTS = { ⋮---- def getattr name: str ⋮---- module = import module LAZY EXPORTS name value = getattr module, name ⋮---- all = Evidence: `src/mark/__init__.py`
- **Version** (source_file): version = "0.2.0a6" Evidence: `src/mark/_version.py`
- **Init** (source_file): all = "BackendResult", "LocalMarkBackend", "MarkBackend" Evidence: `src/mark/adapters/__init__.py`
- **Init** (source_file): all = "MarkAgentMiddleware", "MarkMemoryMiddleware", "create mark tools" ⋮---- def create mark tools args, kwargs Evidence: `src/mark/adapters/langchain/__init__.py`
- **Thinking model — initialised lazily from string if needed** (source_file): LANGCHAIN AVAILABLE = True ⋮---- AgentMiddlewareBase = object AgentState = dict SystemMessage = None LANGCHAIN AVAILABLE = False ⋮---- class MarkAgentState AgentState ⋮---- mark context: NotRequired str mark context meta: NotRequired dict str, Any ⋮---- SYNC EXECUTOR: ThreadPoolExecutor None = None SYNC EXECUTOR LOCK = threading.Lock ⋮---- def run sync coro: Any - Any ⋮---- SYNC EXECUTOR = ThreadPoolExecutor ⋮---- class MarkAgentMiddleware AgentMiddlewareBase ⋮---- state schema = MarkAgentState ⋮---- THINKING TRIGGERS: tuple str, ... = ⋮---- Thinking model — initialised lazily from string if needed ⋮---- from langchain.chat models import init chat model type: ignore import ⋮---- ── backgrou… Evidence: `src/mark/adapters/langchain/middleware.py`
- **Init** (source_file): all = "MarkState" Evidence: `src/mark/adapters/langgraph/__init__.py`
- **Init** (source_file): def require mcp - Any ⋮---- FastMCP = require mcp server = FastMCP name ⋮---- server = create mark mcp server from local mark Evidence: `src/mark/adapters/mcp/__init__.py`
- **Agent** (source_file): @dataclass class AgentRun ⋮---- prompt: str blocks: list str None = None policy: str None = None skills: list str None = None skill inputs: dict str, dict str, Any = field default factory=dict metadata: dict str, Any = field default factory=dict retrieve: bool None = None store output: bool None = None top k: int None = None max context chars: int = 6000 session id: str None = None output block: str = "agent-output" ⋮---- @dataclass frozen=True class AgentResult ⋮---- output: str context: ContextBundle events: list dict str, Any = field default factory=list rendered prompt: str = "" decision: PolicyDecision None = None skill results: dict str, SkillResult = field default factory=dict stored… Evidence: `src/mark/agent.py`
- **Init** (source_file): all = "ContextBuilder", "ContextBundle", "within char budget" Evidence: `src/mark/context/__init__.py`
- **Init** (source_file): all = "CachedEmbeddingProvider", "EmbeddingProvider", "HashEmbeddingProvider" Evidence: `src/mark/embeddings/__init__.py`
- **Base** (source_file): class EmbeddingProvider ABC ⋮---- @abstractmethod def embed self, text: str - list float ⋮---- def embed batch self, texts: list str - list list float ⋮---- @property @abstractmethod def dim self - int None ⋮---- class HashEmbeddingProvider EmbeddingProvider ⋮---- def init self, dim: int = 128 - None ⋮---- def embed self, text: str - list float ⋮---- vector = 0.0 self. dim ⋮---- digest = int hashlib.sha256 token.encode "utf-8" .hexdigest , 16 ⋮---- norm = math.sqrt sum value value for value in vector ⋮---- @property def dim self - int Evidence: `src/mark/embeddings/base.py`
- **Init** (source_file): all = "VectorIndex", "VectorSearchResult" Evidence: `src/mark/index/__init__.py`
- **Init** (source_file): all = Evidence: `src/mark/intelligence/__init__.py`
- **Init** (source_file): LAZY EXPORTS = { ⋮---- def getattr name: str ⋮---- module = import module LAZY EXPORTS name value = getattr module, name ⋮---- all = Evidence: `src/mark/memory/__init__.py`
- **Block** (source_file): class BlockStore Protocol ⋮---- def write record self, record: MemoryRecord - MemoryRecord def list records self, block id: str None = None - list MemoryRecord ⋮---- @dataclass frozen=True class MemoryBlock ⋮---- id: str label: str kind: str = "custom" description: str = "" active: bool = True metadata: dict str, Any = field default factory=dict created at: datetime = field default factory=lambda: datetime.now timezone.utc updated at: datetime = field default factory=lambda: datetime.now timezone.utc store: BlockStore None = field default=None, repr=False, compare=False ⋮---- record = MemoryRecord ⋮---- def records self - list MemoryRecord ⋮---- """Return this block's records.""" ⋮---- def… Evidence: `src/mark/memory/block.py`
- **Block Chain** (source_file): MEMBER HASHES KEY = "mark member hashes" ⋮---- @dataclass frozen=True class BlockVerification ⋮---- valid: bool block id: str corrupted member ids: list str = field default factory=list missing member ids: list str = field default factory=list added member ids: list str = field default factory=list reason: str = "ok" ⋮---- @dataclass frozen=True class ChainVerification ⋮---- checked: int broken block ids: list str = field default factory=list broken links: list tuple str, str = field default factory=list ⋮---- class BlockChain ⋮---- def init self, store: LocalMemoryStore, agent id: str - None ⋮---- def seal self, block id: str - MemoryBlock ⋮---- block = self. store.get block block id ⋮----… Evidence: `src/mark/memory/block_chain.py`
- **── block links inter-block graph ───────────────────────────────────────** (source_file): class BlockGraph ⋮---- def init self, store: LocalMemoryStore, agent id: str - None ⋮---- block = MemoryBlock ⋮---- def get self, block id: str - MemoryBlock None ⋮---- def by name self, name: str - MemoryBlock None ⋮---- def list self, , status: BlockStatus None = None - list MemoryBlock ⋮---- def add fragment self, block id: str, fragment id: str - None ⋮---- def add node self, block id: str, node id: str - None ⋮---- def add nodes self, block id: str, node ids: list str - None ⋮---- def remove node self, block id: str, node id: str - bool ⋮---- def nodes self, block id: str - list MemoryNode ⋮---- def blocks for node self, node id: str - list MemoryBlock ⋮---- blocks = ⋮---- block = self… Evidence: `src/mark/memory/block_graph.py`
- **Outgoing edges** (source_file): NODE TYPE ALIASES: dict str, str = { ⋮---- @dataclass frozen=True class MemoryWriteRejection ⋮---- fragment id: str reason: str content: str ⋮---- def resolve node type node type: NodeType str - NodeType ⋮---- normalized = node type.lower canonical = NODE TYPE ALIASES.get normalized, normalized ⋮---- class MarkMemory ⋮---- loop = asyncio.get running loop ⋮---- indexed = await loop.run in executor self. executor, self. pipeline.index fragment, fragment ⋮---- meta = { fragment = self. fragment ⋮---- @property def last rejection self - MemoryWriteRejection None ⋮---- def quarantined self, , limit: int = 100 - list MemoryFragment ⋮---- fragment id = self. store sync impl hook = self. pipeline.… Evidence: `src/mark/memory/mark_memory.py`
- **Runtime** (source_file): class MarkRuntime ⋮---- registry = PluginRegistry runtime = cls ⋮---- def configure llm self, llm: LLMProvider - None ⋮---- def configure compressor self, compressor: ContextualCompressor - None ⋮---- def configure query expander self, expander: QueryExpander - None ⋮---- def configure retrieval top k self, top k: int - None ⋮---- def add middleware self, middleware: MarkMiddleware - MarkMiddleware ⋮---- def use self, middleware: MarkMiddleware - "MarkRuntime" ⋮---- def session log self, agent id: str, session id: str None = None - "SessionActivityLog" ⋮---- def tracer self ⋮---- def session trace self, session id: str ⋮---- def governance audit log self ⋮---- def memory self, agent id: str… Evidence: `src/mark/memory/runtime.py`
- **Store** (source_file): class MemoryStore Protocol ⋮---- def create block self, block: MemoryBlock - MemoryBlock def get block by label self, label: str - MemoryBlock None def list blocks self - list MemoryBlock def write record self, record: MemoryRecord - MemoryRecord def list records self, block id: str None = None - list MemoryRecord def update record self, record: MemoryRecord - MemoryRecord ⋮---- class MemoryManager ⋮---- """Return creating if needed the named block.""" existing = self. store.get block by label label ⋮---- block = MemoryBlock ⋮---- """Return all blocks.""" ⋮---- """Keyword-retrieve scored records across all blocks.""" records = self. records for blocks blocks scored = self. retriever.retriev… Evidence: `src/mark/memory/store.py`
- **Init** (source_file): LAZY EXPORTS = { ⋮---- def getattr name: str ⋮---- module = import module LAZY EXPORTS name value = getattr module, name ⋮---- all = Evidence: `src/mark/middlewares/__init__.py`
- **Base** (source_file): @dataclass class MiddlewareContext ⋮---- operation: str runtime: Any agent id: str None = None payload: dict str, Any = field default factory=dict result: Any = None metadata: dict str, Any = field default factory=dict stopped: bool = False ⋮---- def stop self, result: Any = None - None ⋮---- class MarkMiddleware Protocol ⋮---- name: str ⋮---- def bind self, runtime: Any - None ⋮---- def before self, context: MiddlewareContext - None ⋮---- def after self, context: MiddlewareContext - None ⋮---- class BaseMiddleware ⋮---- name = "base" ⋮---- class MiddlewareStack ⋮---- def init self, middleware: Iterable MarkMiddleware None = None - None ⋮---- def add self, middleware: MarkMiddleware - MarkM… Evidence: `src/mark/middlewares/base.py`
- **Init** (source_file): all = "CompressionMiddleware" Evidence: `src/mark/middlewares/compression/__init__.py`
- **Middleware** (source_file): @dataclass class CompressionMiddleware BaseMiddleware ⋮---- compressor: Any enabled by default: bool = True name: str = "compression" ⋮---- def bind self, runtime: Any - None ⋮---- def before self, context: MiddlewareContext - None ⋮---- all = "CompressionMiddleware" Evidence: `src/mark/middlewares/compression/middleware.py`
- **Init** (source_file): all = "GapHealingMiddleware" Evidence: `src/mark/middlewares/gap_healing/__init__.py`
- **Middleware** (source_file): @dataclass class GapHealingMiddleware BaseMiddleware ⋮---- heal gaps: bool = True escalate on gap: bool = True web skill: Any = None name: str = "gap healing" ⋮---- def before self, context: MiddlewareContext - None ⋮---- all = "GapHealingMiddleware" Evidence: `src/mark/middlewares/gap_healing/middleware.py`
- **Init** (source_file): all = Evidence: `src/mark/middlewares/governance/__init__.py`
- **Middleware** (source_file): @dataclass class GovernanceMiddleware BaseMiddleware ⋮---- gate: ConsolidationGate = field default factory=ConsolidationGate quarantine on reject: bool = True name: str = "governance" ⋮---- def before self, context: MiddlewareContext - None ⋮---- key = "text" if context.operation == "observe" else "content" content = str context.payload.get key or "" confidence = float context.payload.get "confidence", 1.0 result = self.gate.check content, confidence=confidence ⋮---- metadata = dict context.payload.get "metadata" or {} ⋮---- tags = list context.payload.get "tags" or ⋮---- all = "GovernanceMiddleware" Evidence: `src/mark/middlewares/governance/middleware.py`
- **Init** (source_file): all = "LifecycleMiddleware" Evidence: `src/mark/middlewares/lifecycle/__init__.py`
- **Middleware** (source_file): @dataclass class LifecycleMiddleware BaseMiddleware ⋮---- every n writes: int = 0 promote threshold: float = 0.7 name: str = "lifecycle" write count: int = 0 ⋮---- def after self, context: MiddlewareContext - None ⋮---- all = "LifecycleMiddleware" Evidence: `src/mark/middlewares/lifecycle/middleware.py`
- **Init** (source_file): all = Evidence: `src/mark/middlewares/media_continuity/__init__.py`
- **Middleware** (source_file): @dataclass class MediaContinuityMiddleware BaseMiddleware ⋮---- memory type: str = "scene" tags: list str = field default factory=list retrieve with expansion: bool = True name: str = "media continuity" ⋮---- def before self, context: MiddlewareContext - None ⋮---- incoming = list context.payload.get "tags" or ⋮---- metadata = dict context.payload.get "metadata" or {} ⋮---- all = "MediaContinuityMiddleware" Evidence: `src/mark/middlewares/media_continuity/middleware.py`
- **Init** (source_file): all = Evidence: `src/mark/middlewares/observability/__init__.py`
- **Middleware** (source_file): @dataclass class ObservabilityMiddleware BaseMiddleware ⋮---- event prefix: str = "middleware" name: str = "observability" ⋮---- def before self, context: MiddlewareContext - None ⋮---- tracer = context.runtime.tracer if hasattr context.runtime, "tracer" else None ⋮---- def after self, context: MiddlewareContext - None ⋮---- all = "ObservabilityMiddleware" Evidence: `src/mark/middlewares/observability/middleware.py`
- **Init** (source_file): all = "ObserveMiddleware" Evidence: `src/mark/middlewares/observe/__init__.py`
- **Middleware** (source_file): @dataclass class ObserveMiddleware BaseMiddleware ⋮---- source: str None = None tags: list str = field default factory=list metadata: dict str, Any = field default factory=dict auto structure: bool = True name: str = "observe" ⋮---- def before self, context: MiddlewareContext - None ⋮---- incoming = list context.payload.get "tags" or ⋮---- incoming meta = dict context.payload.get "metadata" or {} ⋮---- all = "ObserveMiddleware" Evidence: `src/mark/middlewares/observe/middleware.py`
- **Init** (source_file): all = "QueryExpansionMiddleware" Evidence: `src/mark/middlewares/query_expansion/__init__.py`
- **Middleware** (source_file): @dataclass class QueryExpansionMiddleware BaseMiddleware ⋮---- expander: Any enabled by default: bool = True name: str = "query expansion" ⋮---- def bind self, runtime: Any - None ⋮---- def before self, context: MiddlewareContext - None ⋮---- all = "QueryExpansionMiddleware" Evidence: `src/mark/middlewares/query_expansion/middleware.py`
- **Init** (source_file): all = "RecallMiddleware" Evidence: `src/mark/middlewares/recall/__init__.py`
- **Middleware** (source_file): @dataclass class RecallMiddleware BaseMiddleware ⋮---- compress: bool None = None expand: bool None = None heal gaps: bool None = None escalate on gap: bool None = None name: str = "recall" ⋮---- def before self, context: MiddlewareContext - None ⋮---- defaults = { ⋮---- all = "RecallMiddleware" Evidence: `src/mark/middlewares/recall/middleware.py`
- **Init** (source_file): all = Evidence: `src/mark/middlewares/sandbox/__init__.py`
- **Middleware** (source_file): @dataclass class SandboxMiddleware BaseMiddleware ⋮---- sandbox: Any = None enabled: bool = False name: str = "sandbox" last result: Any = None ⋮---- def bind self, runtime: Any - None ⋮---- def before self, context: MiddlewareContext - None ⋮---- code = str context.payload.get "code" or "" timeout = context.payload.get "timeout" workspace = context.payload.get "workspace" env = context.payload.get "env" ⋮---- all = "SandboxMiddleware" Evidence: `src/mark/middlewares/sandbox/middleware.py`
- **Init** (source_file): all = Evidence: `src/mark/middlewares/skills/__init__.py`
- **── MarkdownSkill ─────────────────────────────────────────────────────────────** (source_file): SkillInput = Dict str, Any SkillContext = Dict str, Any ⋮---- def parse frontmatter text: str - Tuple Dict str, Any , str ⋮---- end = text.find "\n---", 3 ⋮---- front = text 3:end .strip body = text end + 4: .strip ⋮---- meta = yaml.safe load front or {} ⋮---- meta: Dict str, Any = {} ⋮---- k = k.strip ; v = v.strip .strip "'\"" ⋮---- @dataclass class SkillManifest ⋮---- name: str description: str version: str = "0.1.0" author: str = "" permissions: List str = field default factory=list tags: List str = field default factory=list install hint: str = "" ⋮---- def to dict self - Dict str, Any ⋮---- """Serialize to a plain dictionary.""" ⋮---- @dataclass class SkillResult ⋮---- content: str at… Evidence: `src/mark/middlewares/skills/base.py`
- **Middleware** (source_file): @dataclass class SkillMiddleware BaseMiddleware ⋮---- skills: list str = field default factory=list packaged skills name: str = "skills" texts: dict str, str = field default factory=dict, repr=False ⋮---- def bind self, runtime: Any - None ⋮---- registry = getattr runtime, "skills", None ⋮---- def prompt self - str ⋮---- def texts self - dict str, str ⋮---- """Mapping of skill name to its SKILL.md text.""" ⋮---- def before self, context: MiddlewareContext - None ⋮---- """Stamp which skills were available onto retrieval operations.""" ⋮---- all = "SkillMiddleware" Evidence: `src/mark/middlewares/skills/middleware.py`
- **Init** (source_file): all = Evidence: `src/mark/middlewares/sync/__init__.py`
- **Middleware** (source_file): @dataclass class SyncMiddleware BaseMiddleware ⋮---- options: Any = None cloud: Any = None upload: bool = False name: str = "sync" last delta: Any = None last stats: Any = None ⋮---- def after self, context: MiddlewareContext - None ⋮---- sync = CloudSync ⋮---- all = "SyncMiddleware" Evidence: `src/mark/middlewares/sync/middleware.py`
- **Init** (source_file): all = Evidence: `src/mark/middlewares/trust_bus/__init__.py`
- **Middleware** (source_file): @dataclass class TrustBusMiddleware BaseMiddleware ⋮---- publisher: str None = None trust: Any = "raw agent" tags: list str = field default factory=list publish observations: bool = True publish writes: bool = False name: str = "trust bus" last message: Any = None ⋮---- def after self, context: MiddlewareContext - None ⋮---- should publish = ⋮---- key = "text" if context.operation == "observe" else "content" content = str context.payload.get key or "" ⋮---- publisher = self.publisher or context.agent id or "mark" payload tags = list context.payload.get "tags" or metadata = { ⋮---- trust = self.trust if isinstance self.trust, PublisherTrust else PublisherTrust str self.trust ⋮---- all = "Tru… Evidence: `src/mark/middlewares/trust_bus/middleware.py`
- **Init** (source_file): all = Evidence: `src/mark/plasticity/__init__.py`
- **Init** (source_file): all = Evidence: `src/mark/plugins/__init__.py`
- **Init** (source_file): all = Evidence: `src/mark/policies/__init__.py`
- The remaining 19 evidence entries are in `AI_CONTEXT_PACK.json` or `EVIDENCE_INDEX.json`.

## Rules the Host AI Must Follow

- **Treat this asset as pre-work context, not a runtime environment.**: The AI Context Pack contains only an evidence-backed understanding of the project, not the project's executable state. Evidence: `README.md`, `examples/README.md`, `AGENTS.md`
- **When answering the user, distinguish what can be previewed from what can only be verified after install.**: The consumer value of the pre-install experience comes from reducing bad installs and misjudgments, not from pretending to be a real run. Evidence: `README.md`, `examples/README.md`, `AGENTS.md`

## Questions the User Should Answer First

- Which host AI or local environment do you plan to use it in?
- Do you just want to experience the workflow first, or are you ready to actually install?
- What matters most to you: install cost, output quality, or conflicts with your existing rules?

## Acceptance Checks

- Every capability claim can be traced back to a file path in evidence_refs.
- AI_CONTEXT_PACK.md does not package previews as a real run.
- The user can understand who it fits, what it can do, how to start, and the risk boundaries within 3 minutes.

---

## Doramagic Context Augmentation

The following sections strengthen the repository context for a host AI. Human Manual data is a reading route, and pitfall notes become operating constraints.

## Human Manual Outline

Usage rule: this is only a reading route and salience signal, not factual authority. Concrete claims must still return to repo evidence or Claim Graph.

Host AI hard rules:
- Do not treat page titles, section order, summaries, or importance values as factual project evidence.
- When explaining the Human Manual outline, state that it is only a reading route or salience signal.
- Capability, installation, compatibility, runtime state, and risk claims must cite repo evidence, source paths, or Claim Graph.

- **Getting Started with MARK SDK**: importance `high`
  - source_paths: README.md, pyproject.toml, src/mark/__init__.py, src/mark/_version.py, src/mark/runtime.py
- **Core Memory System, Blocks, and Provenance**: importance `high`
  - source_paths: src/mark/memory/__init__.py, src/mark/memory/mark_memory.py, src/mark/memory/block.py, src/mark/memory/block_graph.py, src/mark/memory/block_chain.py
- **Middleware System and Batteries**: importance `high`
  - source_paths: src/mark/middlewares/__init__.py, src/mark/middlewares/base.py, src/mark/middlewares/recall/middleware.py, src/mark/middlewares/observe/middleware.py, src/mark/middlewares/compression/middleware.py
- **Framework Adapters, Integrations, and Storage Backends**: importance `high`
  - source_paths: src/mark/adapters/__init__.py, src/mark/adapters/backend.py, src/mark/adapters/langchain/__init__.py, src/mark/adapters/langchain/middleware.py, src/mark/adapters/langchain/tools.py

## Repo Inspection Evidence

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `5b00fadcdda18b481980936c6b828c9c2e7be55c`
- inspected_files: `README.md`, `pyproject.toml`, `uv.lock`, `examples/01_local_memory_live.py`, `examples/02_agent_ab_live.py`, `examples/03_sessions_and_observe_live.py`, `examples/04_sync_envelope_live.py`, `examples/README.md`, `examples/run_live_examples.py`, `src/mark/__init__.py`, `src/mark/_version.py`, `src/mark/adapters/__init__.py`, `src/mark/adapters/backend.py`, `src/mark/adapters/langchain/__init__.py`, `src/mark/adapters/langchain/middleware.py`, `src/mark/adapters/langchain/tools.py`, `src/mark/adapters/langgraph/__init__.py`, `src/mark/adapters/langgraph/state.py`, `src/mark/adapters/mcp/__init__.py`, `src/mark/agent.py`

Host AI hard rules:
- Without repo_clone_verified=true, do not claim that the source code has been read.
- Without repo_inspection_verified=true, do not write README, docs, or package-file conclusions as facts.
- Without quick_start_verified=true, do not claim that the Quick Start path has run successfully.

## Doramagic Pitfall Constraints

These rules come from Doramagic discovery, validation, or compilation findings. The host AI must treat them as operating constraints, not background notes.

### Constraint 1: Capability evidence risk requires verification

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: capability.assumptions | https://github.com/emsoftanalytics/MARK-SDK
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 2: Security or permission risk requires verification

- Trigger: no_demo
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: downstream_validation.risk_items | https://github.com/emsoftanalytics/MARK-SDK
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 3: Security or permission risk requires verification

- Trigger: no_demo
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: risks.scoring_risks | https://github.com/emsoftanalytics/MARK-SDK
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 4: Maintenance risk requires verification

- Trigger: issue_or_pr_quality=unknown。
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: evidence.maintainer_signals | https://github.com/emsoftanalytics/MARK-SDK
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.

### Constraint 5: Maintenance risk requires verification

- Trigger: release_recency=unknown。
- Host AI rule: Reproduce the official install and quickstart path in an isolated environment.
- Why it matters: May increase setup, validation, or first-run risk for the user.
- Evidence: evidence.maintainer_signals | https://github.com/emsoftanalytics/MARK-SDK
- Hard boundary: Do not present this pitfall as solved, verified, or ignorable unless later evidence explicitly closes it.
