This is the right philosophy. We don't invent new formats when a 30-year-old
Internet Engineering Task Force (IETF) standard already solves the problem
perfectly. We just adapt it to our specific Swarm AST context.
By keeping it explicit, uppercase, and header-driven, it feels like an actual
network protocol.
Here is the final, standardized `Surgeon-TXT` (MIME-AST) format, utilizing the
`URL-HEX` encoding flag to guarantee that any quotation mark, backtick, or
newline survives the journey through any web chat UI or intermediary parser.
### The Standard Swarm Protocol (Surgeon-TXT)
```text
[SURGEON-START]
TARGET: /opt/hauki-gem/routes/records.py
ENCODING: URL-HEX
[M:4 | S:1 | I:0]
import%20sqlite3
[/BLOCK]
[M:4 | S:2 | I:4]
payload.pop%28%22actor%22%2C%20None%29
[/BLOCK]
[SURGEON-END]
```
### The CRM Mirroring Task (Delegation)
Now, let's formally assign the Shadow Write task to the CRM Dev Chat using
this exact protocol.
Copy this entire block and paste it into your **CRM Dev Chat**. This instructs
that specific AI to become a Swarm Agent and generate the precise URL-encoded
AST instructions needed to safely mirror the data to MeshFS.
---
**[START OF PROMPT TO COPY]**
**SYSTEM ARCHITECTURE UPDATE & CRITICAL DIRECTIVE**
The Hauki-GEM ecosystem has been upgraded to a V2 Swarm Architecture. The
Nordic CRM Core running on your node (`hauki-crm`) is now a Swarm-capable
entity.
**CRITICAL RULES OF ENGAGEMENT:**
1. You must never output raw Python files for manual copy-pasting.
2. A live `x-surgeon` endpoint has been injected into your system at `POST
http://127.0.0.1:8000/api/evolve`.
3. From now on, you must output file mutations strictly using the
**Surgeon-TXT** protocol.
**THE SURGEON-TXT PROTOCOL:**
To ensure 100% 7-bit transmission safety through web UIs, you must URL-encode
the payload content (e.g., spaces become `%20`, quotes become `%22`, newlines
become `%0A`). You must use explicit indentation values.
*Example Format:*
```text
[SURGEON-START]
TARGET: /opt/hauki-gem/routes/target_file.py
ENCODING: URL-HEX
[M:10 | S:0 | I:4]
print%28%22New%20line%20added%20at%20line%2010%20with%204%20spaces%22%29
[/BLOCK]
[SURGEON-END]
```
**YOUR CURRENT TASK: MESHFS SHADOW WRITING (MIRRORING)**
The Universal API Hub V2 has a new distributed filesystem (MeshFS) running on
`http://hauki-teacher:8881/api/v2/meshfs/write`. We need to test its
reliability without risking CRM data.
Analyze your `routes/records.py` file and generate a `Surgeon-TXT` block to
implement a shadow write.
* **Requirement 1:** Locate your existing `create_record` logic (around line
52) and `update_record` logic (around line 73).
* **Requirement 2:** Maintain the existing local SQLite saving mechanism
exactly as it is (this is our 100% reliable source of truth).
* **Requirement 3:** Add an asynchronous "fire-and-forget" HTTP POST request
(e.g., using `httpx.AsyncClient` or a background task) that sends a copy of
the newly saved record payload to the MeshFS.
* **MeshFS Payload Format:** `{"pointer": "gem-pointer://crm_records/{schema_na
me}/{record_id}", "content": "<JSON string of the record>"}`.
Provide **only** the `Surgeon-TXT` block containing the URL-encoded
instructions.
**[END OF PROMPT TO COPY]**
---
By establishing this protocol, you have completely eliminated the risk of
mangled code. Once the CRM chat provides the `Surgeon-TXT` response, you can
feed it directly to your Tampermonkey parser (or a quick bash script) to
execute the mutation flawlessly.