diff --git a/.gitignore b/.gitignore index 534f481..ab1f938 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ sds.nims nimble.develop nimble.paths nimbledeps +.claude/** diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..84d8372 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,43 @@ + +# GitNexus — Code Intelligence + +This project is indexed by GitNexus as **nim-sds** (889 symbols, 1437 relationships, 45 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. + +> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first. + +## Always Do + +- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run `gitnexus_impact({target: "symbolName", direction: "upstream"})` and report the blast radius (direct callers, affected processes, risk level) to the user. +- **MUST run `gitnexus_detect_changes()` before committing** to verify your changes only affect expected symbols and execution flows. +- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits. +- When exploring unfamiliar code, use `gitnexus_query({query: "concept"})` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance. +- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use `gitnexus_context({name: "symbolName"})`. + +## Never Do + +- NEVER edit a function, class, or method without first running `gitnexus_impact` on it. +- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis. +- NEVER rename symbols with find-and-replace — use `gitnexus_rename` which understands the call graph. +- NEVER commit changes without running `gitnexus_detect_changes()` to check affected scope. + +## Resources + +| Resource | Use for | +|----------|---------| +| `gitnexus://repo/nim-sds/context` | Codebase overview, check index freshness | +| `gitnexus://repo/nim-sds/clusters` | All functional areas | +| `gitnexus://repo/nim-sds/processes` | All execution flows | +| `gitnexus://repo/nim-sds/process/{name}` | Step-by-step execution trace | + +## CLI + +| Task | Read this skill file | +|------|---------------------| +| Understand architecture / "How does X work?" | `.claude/skills/gitnexus/gitnexus-exploring/SKILL.md` | +| Blast radius / "What breaks if I change X?" | `.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md` | +| Trace bugs / "Why is X failing?" | `.claude/skills/gitnexus/gitnexus-debugging/SKILL.md` | +| Rename / extract / split / refactor | `.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md` | +| Tools, resources, schema reference | `.claude/skills/gitnexus/gitnexus-guide/SKILL.md` | +| Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus/gitnexus-cli/SKILL.md` | + + \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 0c6c90a..1df91d7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -162,3 +162,47 @@ nimble lock # update lock after changing sds.nimble ``` If using Nix, also recalculate the fixed-output hash in `nix/deps.nix` after updating `nimble.lock` (run `nix build`, copy the expected hash from the error, paste into `outputHash`). + + +# GitNexus — Code Intelligence + +This project is indexed by GitNexus as **nim-sds** (889 symbols, 1437 relationships, 45 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. + +> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first. + +## Always Do + +- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run `gitnexus_impact({target: "symbolName", direction: "upstream"})` and report the blast radius (direct callers, affected processes, risk level) to the user. +- **MUST run `gitnexus_detect_changes()` before committing** to verify your changes only affect expected symbols and execution flows. +- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits. +- When exploring unfamiliar code, use `gitnexus_query({query: "concept"})` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance. +- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use `gitnexus_context({name: "symbolName"})`. + +## Never Do + +- NEVER edit a function, class, or method without first running `gitnexus_impact` on it. +- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis. +- NEVER rename symbols with find-and-replace — use `gitnexus_rename` which understands the call graph. +- NEVER commit changes without running `gitnexus_detect_changes()` to check affected scope. + +## Resources + +| Resource | Use for | +|----------|---------| +| `gitnexus://repo/nim-sds/context` | Codebase overview, check index freshness | +| `gitnexus://repo/nim-sds/clusters` | All functional areas | +| `gitnexus://repo/nim-sds/processes` | All execution flows | +| `gitnexus://repo/nim-sds/process/{name}` | Step-by-step execution trace | + +## CLI + +| Task | Read this skill file | +|------|---------------------| +| Understand architecture / "How does X work?" | `.claude/skills/gitnexus/gitnexus-exploring/SKILL.md` | +| Blast radius / "What breaks if I change X?" | `.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md` | +| Trace bugs / "Why is X failing?" | `.claude/skills/gitnexus/gitnexus-debugging/SKILL.md` | +| Rename / extract / split / refactor | `.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md` | +| Tools, resources, schema reference | `.claude/skills/gitnexus/gitnexus-guide/SKILL.md` | +| Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus/gitnexus-cli/SKILL.md` | + + diff --git a/sds.nim b/sds.nim index 29e4a2f..2e16c74 100644 --- a/sds.nim +++ b/sds.nim @@ -35,7 +35,7 @@ proc isAcknowledged*( proc reviewAckStatus( rm: ReliabilityManager, msg: SdsMessage -): Future[void] {.async: (raises: []), gcsafe.} = +): Future[void] {.async: (raises: [CatchableError]), gcsafe.} = try: var rbf: Option[RollingBloomFilter] if msg.bloomFilter.len > 0: @@ -76,8 +76,9 @@ proc reviewAckStatus( let (idx, ackedId) = toDelete[k] channel.outgoingBuffer.delete(idx) await rm.persistence.removeOutgoing(msg.channelId, ackedId) - except CatchableError: + except CatchableError as e: error "Failed to review ack status", msg = getCurrentExceptionMsg() + raise e proc wrapOutgoingMessage*( rm: ReliabilityManager, @@ -162,7 +163,7 @@ proc wrapOutgoingMessage*( proc processIncomingBuffer( rm: ReliabilityManager, channelId: SdsChannelID -): Future[void] {.async: (raises: []), gcsafe.} = +): Future[void] {.async: (raises: [CatchableError]), gcsafe.} = try: await rm.lock.acquire() try: @@ -208,9 +209,10 @@ proc processIncomingBuffer( await rm.persistence.removeIncoming(channelId, msgId) finally: rm.lock.release() - except CatchableError: + except CatchableError as e: error "Failed to process incoming buffer", channelId = channelId, msg = getCurrentExceptionMsg() + raise e proc unwrapReceivedMessage*( rm: ReliabilityManager, message: seq[byte] diff --git a/tests/test_bloom b/tests/test_bloom new file mode 100755 index 0000000..ed43b69 Binary files /dev/null and b/tests/test_bloom differ diff --git a/tests/test_persistence b/tests/test_persistence new file mode 100755 index 0000000..69d512c Binary files /dev/null and b/tests/test_persistence differ