Skip to content

Commit 465eb80

Browse files
committed
Updates Agent_Contract.md
1 parent 62a0b47 commit 465eb80

6 files changed

Lines changed: 1314 additions & 114 deletions

File tree

AGENTS.md

Lines changed: 219 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,233 @@
1-
# TINYMEM CONTROL PROTOCOL (Condensed)
1+
# TINYMEM CONTROL PROTOCOL
22

33
## Hard Enforcement Specification for Repository-Aware AI Agents
44

5-
This protocol governs **all repository-related behavior**. It is **authoritative**, **mandatory**, and **self-validating**.
5+
This protocol governs **all repository-related behavior**.
6+
7+
It is **authoritative**, **mandatory**, and **self-validating**.
8+
Non-compliance invalidates the response by definition.
9+
10+
---
11+
12+
## 0. Binding Definitions
13+
14+
**Repository-related request**
15+
Any request that touches code, files, documentation, architecture, configuration, tasks, planning, or repository state.
16+
17+
**TinyMem command**
18+
A real, externally executed memory tool invocation (`memory_query`, `memory_recent`, etc.).
19+
Internal recall, inference, or chat reconstruction does **not** qualify.
20+
21+
**Valid response**
22+
A response that demonstrates protocol compliance through observable actions and explicit declarations.
23+
24+
---
25+
26+
## 1. Absolute Precondition (Hard Gate)
27+
28+
**Before producing ANY repository-related response, the agent MUST execute at least one TinyMem command.**
29+
30+
This is a hard gate.
31+
32+
If no TinyMem command is executed:
33+
34+
* The response is invalid
35+
* The agent must not proceed
36+
* Partial or “best-effort” responses are forbidden
37+
38+
There are no exceptions.
39+
40+
---
41+
42+
## 2. Proof-of-Execution Requirement (Anti-Circumvention)
43+
44+
Every valid repository-related response MUST include **explicit proof** of TinyMem execution.
45+
46+
Acceptable proof consists of one of the following:
47+
48+
* A visible TinyMem tool invocation in the response
49+
* A verifiable execution record emitted by the environment
50+
51+
Silent execution is forbidden.
52+
Missing proof invalidates the response.
53+
54+
---
55+
56+
## 3. Mandatory Execution Order (Non-Reorderable)
57+
58+
The following steps MUST be executed **in strict order**.
59+
Skipping, merging, or reordering steps is a violation.
60+
61+
---
62+
63+
### Step 1: Memory Recall (MANDATORY, FIRST)
64+
65+
The agent MUST execute **at least one** of the following **before any reasoning**:
66+
67+
```
68+
memory_query("")
69+
memory_recent()
70+
memory_query("<specific topic>")
71+
```
72+
73+
Rules:
74+
75+
* This must be a real tool execution
76+
* Assumed recall is forbidden
77+
* Chat history does not count
78+
* “No relevant memory” is illegal unless a query was executed
79+
80+
No recall → stop immediately.
81+
82+
---
83+
84+
### Step 2: Memory Acknowledgement (MANDATORY)
85+
86+
Immediately after recall, the agent MUST explicitly state **one and only one** of the following:
87+
88+
* **“Relevant memory found and applied.”**
89+
* **“Memory queried. No relevant memory found.”**
90+
91+
Omission or paraphrasing invalidates the response.
92+
93+
---
94+
95+
### Step 3: Task Authority Lock (MANDATORY WHEN APPLICABLE)
96+
97+
If `tinyTasks.md` exists, it is **exclusive and authoritative**.
98+
99+
Rules:
100+
101+
* The file MUST be read before any action
102+
* Memory MUST NOT override task state
103+
* Task state MUST NOT be inferred
104+
105+
For any non-trivial, multi-step, or stateful request, the agent MUST:
106+
107+
1. Create or update `tinyTasks.md`
108+
2. Resume from the **first unchecked subtask**
109+
3. Update tasks **as execution progresses**
110+
4. Mark tasks complete **only when actually finished**
111+
112+
Required structure (no deviations allowed):
113+
114+
```md
115+
# Tasks – <Goal>
116+
117+
- [ ] Top-level task
118+
- [ ] Atomic subtask
119+
- [ ] Atomic subtask
120+
```
121+
122+
Failure to update tasks is a protocol failure.
123+
124+
---
125+
126+
### Step 3.5: Autonomous Repair (The Ralph Loop)
127+
128+
For complex, iterative tasks requiring verification (e.g., fixing failing tests), the agent SHOULD invoke `memory_ralph`.
129+
130+
**Control Transfer Contract:**
131+
1. Once `memory_ralph` is invoked, control transfers to tinyMem.
132+
2. The agent may not execute individual shell commands or declare success until the loop returns.
133+
3. Termination is controlled solely by **Evidence Evaluation**.
134+
135+
**Execution Phases:**
136+
- **Execute**: tinyMem runs the verification command (e.g., `go test`).
137+
- **Recall**: On failure, tinyMem retrieves relevant memories and failure patterns.
138+
- **Repair**: tinyMem uses its internal LLM to apply code fixes based on context.
139+
- **Evidence**: Success is declared only if all evidence predicates pass.
140+
141+
**Safety Rules:**
142+
- Agents MUST provide `forbid_paths` for sensitive directories.
143+
- Agents SHOULD set `max_iterations` to prevent runaway token usage.
144+
145+
---
146+
147+
### Step 4: Execution Phase
148+
149+
Only after Steps 1–3 are complete may the agent:
150+
151+
* Perform the requested work
152+
* Modify code, documentation, or plans
153+
* Propose or apply decisions
154+
155+
Any execution before this point invalidates the response.
156+
157+
---
158+
159+
### Step 5: Durable Memory Writeback (MANDATORY WHEN APPLICABLE)
160+
161+
If the response introduces, confirms, or corrects **durable knowledge**, the agent MUST write it to TinyMem **before concluding**.
162+
163+
Durable knowledge includes:
164+
165+
* Decisions
166+
* Constraints or invariants
167+
* Architectural rules
168+
* Corrections to assumptions
169+
* Explicit user confirmations
170+
* Non-obvious conclusions
171+
172+
If and only if no durable knowledge was produced, the agent MUST state verbatim:
173+
174+
> No durable memory write required for this response.
175+
176+
Missing or altered wording invalidates the response.
177+
178+
---
179+
180+
### Step 6: End-of-Response Self-Validation (MANDATORY)
181+
182+
The response MUST end with an explicit checklist confirming all of the following:
183+
184+
* TinyMem command executed
185+
* Memory integrated or explicitly confirmed empty
186+
* `tinyTasks.md` read and updated if applicable
187+
* No completed tasks left unchecked
188+
* No unchecked tasks remain unless explicitly blocked
189+
190+
If any item cannot be affirmed, the agent MUST continue execution.
191+
The response may not terminate.
6192

7193
---
8194

9-
## 1. Mandatory Workflow (Strict Order)
195+
## 4. Error Handling (Fail Closed)
10196

11-
### Step 1: Memory Recall & Acknowledgement
12-
**BEFORE reasoning**, execute `memory_query("")` or `memory_recent()`.
13-
Immediately state verbatim: **“Relevant memory found and applied.”** OR **“Memory queried. No relevant memory found.”**
197+
If any TinyMem operation fails:
14198

15-
### Step 2: Task Authority (`tinyTasks.md`)
16-
If it exists, you **must** read it before acting. Update subtasks as you progress. Resume from the first unchecked subtask.
199+
* The failure MUST be explicitly declared
200+
* Memory guarantees are considered degraded
201+
* Planning, restructuring, or irreversible changes are forbidden
202+
* Only safe, local, reversible actions are allowed
203+
204+
Silent failure is a critical violation.
205+
206+
---
17207

18-
### Step 3: Execution & Repair (The Ralph Loop)
19-
Perform work. For complex iterative fixes, invoke `memory_ralph`. Success is defined solely by **Evidence Evaluation**.
208+
## 5. Invalid Actions (Automatic Failure)
20209

21-
### Step 4: Durable Knowledge & Self-Validation
22-
If new durable knowledge (decisions, invariants) is produced, write it to memory. Otherwise, state: **"No durable memory write required."**
23-
**EVERY response MUST end with this status line:**
24-
`TM: [Query: OK] [Tasks: OK] [Knowledge: OK/None]`
210+
Any of the following immediately invalidate the response:
211+
212+
* No TinyMem command executed
213+
* No proof of execution shown
214+
* Claiming memory state without querying
215+
* Inferring task state
216+
* Ignoring `tinyTasks.md`
217+
* Declaring completion with unchecked tasks
218+
* Writing speculative, temporary, or reversible information to memory
219+
* Ending the response without explicit self-validation
25220

26221
---
27222

28-
## 2. Enforcement Invariants
29-
- **No Tool, No Response:** A response without a tinyMem tool call is a failure.
30-
- **Fail Closed:** If memory tools fail, declare it and stop irreversible changes.
31-
- **Proof of Execution:** Tool calls must be visible.
223+
## 6. Enforcement Invariant (Unbreakable)
224+
225+
> A repository-related response without a TinyMem tool invocation is not a response. It is a failure.
226+
227+
Memory is mandatory.
228+
Inference is failure.
229+
Execution state lives in files.
230+
231+
---
32232

33-
**End of Protocol**
233+
**End of Protocol**

0 commit comments

Comments
 (0)