|
1 | | -# Repository Guidelines |
2 | | - |
3 | | -## Project Structure & Module Organization |
4 | | -- Runtime entrypoints live in `device.py` and `constants.py`, orchestrating Ratio1 pipelines implemented in the upstream `naeural_core` package. |
5 | | -- Domain extensions under `extensions/` (`business/`, `data/`, `serving/`) wrap `naeural_core` plugins and configs; mirror their folder names when porting modules from `naeural_core`. |
6 | | -- Tutorials and sample engines are in `plugins/`; use `plugins/business/tutorials/` alongside the `ratio1_sdk/tutorials/` repository samples when validating workflows. |
7 | | -- Operational helpers sit in `cmds/`, container specs live in `docker/` and `docker-compose/`, and research spikes belong in `xperimental/`. |
8 | | - |
9 | | -## Build, Test, and Development Commands |
10 | | -- `./debug.sh` builds `Dockerfile_devnet` and launches the node; sync `.env` with secrets documented in `ratio1_sdk/template.env` before running. |
11 | | -- `docker compose -f docker-compose/debug-docker-compose.yaml up -d` provisions the full dev stack; use `docker compose down` to clean up. |
12 | | -- `pip install -r requirements.txt` inside a virtualenv prepares local dependencies; add `pip install -e ../naeural_core ../ratio1_sdk` when testing cross-repo changes. |
13 | | -- `python -m unittest discover -s plugins -p "*test*.py"` executes tutorial regressions; mirror failing cases in `ratio1_sdk/tutorials/` as needed. |
14 | | - |
15 | | -## Coding Style & Naming Conventions |
16 | | -- Python files use 2-space indentation, `snake_case` function names, and explicit `__VER__` constants (aligned with `naeural_core/__init__.__VER__`). |
17 | | -- Extend configuration via dict unpacking (`CONFIG = {**BASE_CONFIG, **local_overrides}`) and keep environment keys uppercase. |
18 | | -- Log through `self.P(...)`, matching `naeural_core.manager.ManagerMixin` patterns; run `sqlfluff` on SQL assets before committing. |
19 | | - |
20 | | -## Testing Guidelines |
21 | | -- Prioritize business workflows in `plugins/business/tutorials/` and Oracle sync checks in `extensions/business/oracle_sync/`. |
22 | | -- Name new regression files `*test*.py` so they are auto-discovered; when editing shared pipeline logic, also run `pytest` (or `python3 -m unittest`) inside cloned `naeural_core` and targeted SDK tutorials. |
23 | | -- Prefer lightweight mocks to live services; for container checks, attach with `docker exec -it r1node /bin/bash` and replay scripts from `cmds/`. |
24 | | - |
25 | | -## Commit & Pull Request Guidelines |
26 | | -- Follow Conventional Commits (`feat:`, `fix:`, `chore:`); keep subjects under 72 characters and describe intent in the body when needed. |
27 | | -- Group related module edits, note which services or SDK tutorials are impacted, and link Jira/GitHub issues across repositories. |
28 | | -- Provide evidence of manual or automated runs (command output, compose logs, SDK tutorial snippets) so reviewers can reproduce results quickly. |
29 | | - |
30 | | -## Security & Configuration Tips |
31 | | -- Never commit populated `.env` files; document required secrets instead and re-use `ratio1_sdk/template.env` as reference. |
32 | | -- Validate tunnel and storage credentials with `cmds/get_config_app` helpers. |
33 | | -- When editing `constants.py`, keep sensitive env vars templated (`$VAR`) so container deployments inject values securely. |
| 1 | +# Edge Node Agent Manual + Long-Term Memory |
| 2 | + |
| 3 | +This file is the durable operating manual for future agents working in `/edge_node`. |
| 4 | +It has two goals: |
| 5 | +1. Stable reference information that should remain useful across sessions. |
| 6 | +2. Append-only memory of important discoveries, decisions, and changes. |
| 7 | + |
| 8 | +## Hard Rules |
| 9 | +- Treat this file as append-only memory for the `Memory Log` section. |
| 10 | +- Never delete or rewrite prior memory entries. |
| 11 | +- If an older entry is wrong, add a new correction entry that references the old entry ID. |
| 12 | +- Use UTC timestamps in ISO-8601 format: `YYYY-MM-DDTHH:MM:SSZ`. |
| 13 | +- Keep shell examples copy-pasteable. |
| 14 | + |
| 15 | +## Stable Reference |
| 16 | + |
| 17 | +### How To Run |
| 18 | +- Local dev (single node, local image): |
| 19 | + - `./debug.sh` |
| 20 | + - Builds `Dockerfile_devnet` and runs with `--env-file=.env`. |
| 21 | +- Local dev (compose, 3 local containers): |
| 22 | + - Build expected image tag first: `docker build -t local_edge_node -f Dockerfile_devnet .` |
| 23 | + - Start stack: `docker-compose -f docker-compose/debug-docker-compose.yaml up -d` |
| 24 | + - Stop stack: `docker-compose -f docker-compose/debug-docker-compose.yaml down` |
| 25 | + - Equivalent on Compose v2 setups: replace `docker-compose` with `docker compose`. |
| 26 | +- Public image (single node): |
| 27 | + - `docker run -d --rm --name r1node --pull=always -v r1vol:/edge_node/_local_cache/ ratio1/edge_node:devnet` |
| 28 | + - For GPU hosts: add `--gpus all`. |
| 29 | + |
| 30 | +### How To Inspect and Operate |
| 31 | +- Node info: `docker exec r1node get_node_info` |
| 32 | +- Node history: `docker exec r1node get_node_history` |
| 33 | +- Current whitelist: `docker exec r1node get_allowed` |
| 34 | +- Add allowed address: `docker exec r1node add_allowed <address> [alias]` |
| 35 | +- Change alias: `docker exec r1node change_alias <new_alias>` then `docker restart r1node` |
| 36 | +- Reset keys (interactive): `docker exec -it r1node reset_node_keys` |
| 37 | + |
| 38 | +### How To Test |
| 39 | +- Tutorial-oriented unittest discovery (repo-local): |
| 40 | + - `python3 -m unittest discover -s plugins -p "*test*.py"` |
| 41 | +- Focused cybersecurity tests: |
| 42 | + - `python3 -m unittest extensions.business.cybersec.red_mesh.test_redmesh` |
| 43 | +- When touching cross-repo integration (`naeural_core`, `ratio1_sdk`), also run targeted tests in those sibling repos. |
| 44 | + |
| 45 | +### Repo Map |
| 46 | +- Runtime entrypoints: |
| 47 | + - `device.py`: delegates execution to `naeural_core.main.entrypoint.main(...)`. |
| 48 | + - `constants.py`: extends upstream admin pipeline and environment-driven config. |
| 49 | +- Extensions: |
| 50 | + - `extensions/business/`: operational APIs and supervisors (deeploy, dauth, oracle sync, tunnels, r1fs, container apps, cybersec). |
| 51 | + - `extensions/data/`: listener/capture extensions (Jeeves listeners). |
| 52 | + - `extensions/serving/`: serving backends, LLM/document embedding infrastructure, default inference adapters. |
| 53 | + - `extensions/utils/`: utility helpers. |
| 54 | +- Plugins: |
| 55 | + - `plugins/business/tutorials/`: examples/regressions for common pipeline behaviors. |
| 56 | + - `plugins/data/tutorials/`: capture stream examples. |
| 57 | + - `plugins/serving/`: serving pipeline/inference examples and test scaffolding. |
| 58 | +- Operations: |
| 59 | + - `cmds/`: in-container operational commands (`get_node_info`, `add_allowed`, `reset_node_keys`, etc.). |
| 60 | + - `docker-compose/`: debug/prod multi-container compose files and Windows helpers. |
| 61 | + - `docker/`: alternative Dockerfiles for CPU/RPi/Tegra variants. |
| 62 | + - `k8s/`: Kubernetes manifests. |
| 63 | +- Research and spikes: |
| 64 | + - `xperimental/`: non-production exploratory scripts and notes. |
| 65 | + |
| 66 | +### Conventions |
| 67 | +- Python style in this repo commonly uses 2-space indentation and `snake_case` names. |
| 68 | +- Keep module-level `__VER__` where applicable to plugin-style modules. |
| 69 | +- Extend configs via dict merge patterns, e.g. `CONFIG = {**BASE, **overrides}`. |
| 70 | +- Keep sensitive values env-driven (`$EE_*`) in config JSON/Python defaults. |
| 71 | +- Use `self.P(...)` logging style in plugin classes. |
| 72 | +- Commit style expectation: Conventional Commits (`feat:`, `fix:`, `chore:`). |
| 73 | + |
| 74 | +### Known Pitfalls |
| 75 | +- Image tag mismatch: |
| 76 | + - `debug.sh` builds `local_node`, while `docker-compose/debug-docker-compose.yaml` expects `local_edge_node`. |
| 77 | +- Stale Windows helper: |
| 78 | + - `docker-compose/debug_start.bat` references `Dockerfile_dev`, which does not exist (available: `Dockerfile_devnet`, `Dockerfile_mainnet`, `Dockerfile_testnet`). |
| 79 | +- Kubernetes inconsistencies to verify before use: |
| 80 | + - `k8s/README.md` says `edgenode-deployment.yaml`, file is `k8s/edgenode-deploy.yaml`. |
| 81 | + - `k8s/edgenode-sa.yaml` binds ServiceAccount namespace `hyfy` while resources are under `ratio1`. |
| 82 | + - `k8s/edgenode-deploy.yaml` uses `claimName: edgenode-supervisor-pvc`, but `k8s/edgenode-storage.yaml` defines `edgenode-pvc`. |
| 83 | + - `k8s/edgenode-deploy.yaml` mounts `/edgenode/_local_cache` (note missing underscore compared to `/edge_node/...` used elsewhere). |
| 84 | +- Legacy workflow folder: |
| 85 | + - `.github/workflows/` is active for GitHub Actions. |
| 86 | + - `github_workflows/` appears legacy and references filenames/paths that may be stale. |
| 87 | + |
| 88 | +## Mandatory BUILDER-CRITIC Loop (Required) |
| 89 | + |
| 90 | +Run this loop for every meaningful modification (code, config, docs, infra, tests). |
| 91 | +A "meaningful modification" is any change beyond trivial typo-only edits. |
| 92 | + |
| 93 | +### Step 1: BUILDER |
| 94 | +BUILDER must state: |
| 95 | +- Intent: what is being changed and why. |
| 96 | +- Change scope: files/paths touched. |
| 97 | +- Assumptions: dependencies, environment, invariants. |
| 98 | + |
| 99 | +### Step 2: CRITIC (Adversarial) |
| 100 | +CRITIC must try to break the change by checking: |
| 101 | +- Assumption failures. |
| 102 | +- Behavioral regressions. |
| 103 | +- Security/privacy risks. |
| 104 | +- Edge cases and failure modes. |
| 105 | +- Missing docs/tests or operational runbook impact. |
| 106 | + |
| 107 | +### Step 3: BUILDER Response |
| 108 | +BUILDER must: |
| 109 | +- Address CRITIC findings or justify accepted risk. |
| 110 | +- Refine the change if needed. |
| 111 | +- List verification commands run and observed results (pass/fail + short evidence). |
| 112 | + |
| 113 | +### Step 4: Log It |
| 114 | +Append a `Memory Log` entry with: |
| 115 | +- Timestamp and entry ID. |
| 116 | +- Summary of change and decision. |
| 117 | +- CRITIC findings summary. |
| 118 | +- Verification commands and outcomes. |
| 119 | +- If correction: `Correction of: <entry_id>`. |
| 120 | + |
| 121 | +## Memory Log (append-only) |
| 122 | + |
| 123 | +Entry format: |
| 124 | +- `ID`: `ML-YYYYMMDD-###` |
| 125 | +- `Timestamp`: UTC ISO-8601 |
| 126 | +- `Type`: discovery | decision | change | correction |
| 127 | +- `Summary`: |
| 128 | +- `Details`: |
| 129 | +- `Verification`: |
| 130 | +- `Links`: |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +- ID: `ML-20260211-001` |
| 135 | +- Timestamp: `2026-02-11T09:13:34Z` |
| 136 | +- Type: `discovery` |
| 137 | +- Summary: Repo-wide docs/ops audit performed to ground AGENTS/README rewrite. |
| 138 | +- Details: Confirmed runtime entrypoints (`device.py`, `constants.py`), operational scripts (`cmds/`), compose variants (`docker-compose/`), and deployment artifacts (`docker/`, `k8s/`). |
| 139 | +- Verification: `pwd && ls -la`; `find . -maxdepth 2 -type d | sort`; `find extensions -type f`; `find plugins -type f` |
| 140 | +- Links: `device.py`, `constants.py`, `docker-compose/debug-docker-compose.yaml`, `cmds/get_node_info` |
| 141 | + |
| 142 | +- ID: `ML-20260211-002` |
| 143 | +- Timestamp: `2026-02-11T09:13:34Z` |
| 144 | +- Type: `discovery` |
| 145 | +- Summary: Found operational mismatches that can break onboarding. |
| 146 | +- Details: `debug.sh` builds `local_node` while debug compose expects `local_edge_node`; `docker-compose/debug_start.bat` references missing `Dockerfile_dev`; multiple `k8s/` naming/namespace/PVC path mismatches exist. |
| 147 | +- Verification: `rg -n "local_edge_node|local_node" -S`; `sed -n '1,120p' debug.sh`; `sed -n '1,160p' docker-compose/debug_start.bat`; `sed -n '1,220p' k8s/README.md`; `sed -n '1,220p' k8s/edgenode-deploy.yaml`; `sed -n '1,220p' k8s/edgenode-sa.yaml`; `sed -n '1,220p' k8s/edgenode-storage.yaml` |
| 148 | +- Links: `debug.sh`, `docker-compose/debug-docker-compose.yaml`, `docker-compose/debug_start.bat`, `k8s/README.md`, `k8s/edgenode-deploy.yaml` |
| 149 | + |
| 150 | +- ID: `ML-20260211-003` |
| 151 | +- Timestamp: `2026-02-11T09:13:34Z` |
| 152 | +- Type: `change` |
| 153 | +- Summary: Replaced prior short AGENTS guidance with durable long-term memory structure and mandatory BUILDER-CRITIC loop. |
| 154 | +- Details: Added stable sections for run/test, repo map, conventions, pitfalls; established append-only log protocol with correction semantics. |
| 155 | +- Verification: `sed -n '1,260p' AGENTS.md` |
| 156 | +- Links: `AGENTS.md` |
| 157 | + |
| 158 | +- ID: `ML-20260211-004` |
| 159 | +- Timestamp: `2026-02-11T09:19:14Z` |
| 160 | +- Type: `change` |
| 161 | +- Summary: Rewrote `README.md` to prioritize operator usability and ordered sections as requested. |
| 162 | +- Details: Added explicit Need/Objective/Purpose, moved all practical usage content under `Usability & Features` (quickstart/examples/config/outputs/troubleshooting), and placed architecture/modules/deps/testing/security under `Technical Details`. |
| 163 | +- Verification: `git diff -- README.md`; `sed -n '1,320p' README.md` |
| 164 | +- Links: `README.md` |
| 165 | + |
| 166 | +- ID: `ML-20260211-005` |
| 167 | +- Timestamp: `2026-02-11T09:19:14Z` |
| 168 | +- Type: `discovery` |
| 169 | +- Summary: Verification run identified environment/tooling limits and current test signal. |
| 170 | +- Details: In this workspace, `docker` exists but neither `docker compose` plugin nor `docker-compose` binary is available; compose syntax could not be validated by execution. `python3 -m unittest discover -s plugins -p "*test*.py"` returns `Ran 0 tests`. Focused RedMesh suite runs but currently fails (`34` tests run, `1` failure, `3` errors with missing `service_info`/`web_tests_info` keys). |
| 171 | +- Verification: `command -v docker || true; command -v python3 || true`; `docker compose -f docker-compose/debug-docker-compose.yaml config`; `docker-compose -f docker-compose/debug-docker-compose.yaml config`; `python3 -m unittest discover -s plugins -p "*test*.py"`; `python3 -m unittest extensions.business.cybersec.red_mesh.test_redmesh` |
| 172 | +- Links: `README.md`, `AGENTS.md`, `extensions/business/cybersec/red_mesh/test_redmesh.py` |
| 173 | + |
| 174 | +- ID: `ML-20260211-006` |
| 175 | +- Timestamp: `2026-02-11T09:20:06Z` |
| 176 | +- Type: `change` |
| 177 | +- Summary: Added Compose command compatibility note (`docker-compose` and Compose v2 `docker compose`) in stable docs. |
| 178 | +- Details: Kept primary examples aligned to repo scripts (`docker-compose`) while explicitly documenting the Compose v2 equivalent to reduce operator ambiguity. |
| 179 | +- Verification: `rg -n "docker-compose|docker compose" AGENTS.md README.md` |
| 180 | +- Links: `AGENTS.md`, `README.md` |
0 commit comments