Skip to content

feat: Re-implement STAN Stigmergic A* Navigation (Resolves #258 feedback) - #272

Closed
web3guru888 wants to merge 1 commit into
MemPalace:mainfrom
web3guru888:feature/stan-stigmergy-integration
Closed

feat: Re-implement STAN Stigmergic A* Navigation (Resolves #258 feedback)#272
web3guru888 wants to merge 1 commit into
MemPalace:mainfrom
web3guru888:feature/stan-stigmergy-integration

Conversation

@web3guru888

Copy link
Copy Markdown

Fixes previously reverted Feature: Implement STAN (Stigmergic A* Navigation) into Knowledge Graph

This PR successfully re-implements the Stigmergic A* Navigation capabilities originally proposed in #258, but definitively resolves all critical flaws pointed out by maintainers via a direct port mapping from the tested architecture of the STAN research paper by VBRL.ai.

What's Fixed:

🔴 1. Schema Migration No Longer Breaks Existing DBs:
A safe _apply_migrations method was incorporated which conditionally handles ALTER TABLE triples ADD COLUMN pheromone_level REAL DEFAULT 0.0. It correctly ignores the operation if older nodes are already populated with schemas locally.

🔴 2. Entity ID Double-Normalization Erased:
In STAN's modified A*, we query using get_neighbors_with_pheromones, returning correctly formatted semantic ids. We no longer force double conversions for path output/input looping calls.

🔴 3. Evaporation (Decay) Routines Built In:
Unlike the initial proposal which only deposited pheromones continuously leading to full network "lock-in," STAN actively includes 10% evaporation (rho=0.1). I added evaporate_pheromones(decay_rate=0.1) dropping paths uniformly, keeping learning strictly elastic.

🔴 4. Pathfinding O(n^2) Scaling Fixed:
Instead of repeatedly deep copying path matrices through $A^*$ states, segments are captured as raw (from, to, predicate, direction, cost, tau) dict instances inside heapq.

🔴 5. Active Execution Engine (MCP Handlers):
This code is fully active, with two new endpoints injected directly into your mcp_server.py:

  • mempalace_kg_stigmergic_astar: Retrieves discounted route patterns.
  • mempalace_kg_deposit_pheromone: Registers pheromones with an underlying modular tick constraint (evaporate operations trigger unconditionally at % 50 == 0 internal MCP calls).

Local Testing Completed 🟢:

Using rigorous unit tests natively extending MemPalace dependencies, we successfully mapped that route selections switch to longer graph distances accurately when underlying stigmergic weights reduce the calculation below base defaults without edge leaks.

(Replaces reverted Pull Request #259).

@bensig

bensig commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Appreciate the thoroughness here — addressing all the feedback from #259 shows real effort. The stigmergic pathfinding concept is interesting.

However we're focused on stabilizing the core right now (search, mining, MCP reliability) and this adds significant complexity to the KG with new schema migrations, MCP endpoints, and a novel algorithm. We'd rather get the foundation solid before adding research-grade features.

Would you consider publishing this as a standalone extension or plugin? That way people can opt in without it being in the core package. And we'd value your help reviewing PRs — you clearly understand graph algorithms well.

@bensig bensig closed this Apr 8, 2026
web3guru888 added a commit to web3guru888/mempalace that referenced this pull request Apr 9, 2026
Add a link to the standalone STAN (Stigmergic A* Navigation) extension
in a new Community Extensions section of the README, per maintainer
feedback on PR MemPalace#272 to keep the core lean and publish STAN as an
opt-in plugin.
web3guru888 added a commit to web3guru888/mempalace that referenced this pull request Apr 12, 2026
Add a link to the standalone STAN (Stigmergic A* Navigation) extension
in a new Community Extensions section of the README, per maintainer
feedback on PR MemPalace#272 to keep the core lean and publish STAN as an
opt-in plugin.
jphein added a commit to techempower-org/mempalace that referenced this pull request May 28, 2026
* docs: document mcp_mode CLI-only mode

palace-daemon#58 (proxy gate) shipped via PR #59, so the MemPalace#272
leftover — documenting the flag — is unblocked. The proxy reads
``mcp_mode`` from ``~/.mempalace/config.json`` (env override
``PALACE_MCP_MODE``) and, when set to ``cli-only``, short-circuits
``tools/list`` to empty and rejects ``tools/call`` with a CLI-pointing
error. Fail-open on bad config so a typo never silently disables tools.

Document the surface in three places, scoped to where readers find it:
- ``website/guide/mcp-integration.md`` gets a full ``## CLI-only mode``
  section with the config shape, the env override, fail-open behavior,
  what changes (tools/list empty), what stays (hooks + skills), and
  the reconnect requirement for the tool list to refresh.
- ``.claude-plugin/README.md`` gets a concise ``### CLI-only mode``
  subsection under MCP Server with a link to the guide.
- ``.codex-plugin/README.md`` gets a one-liner near the header pointing
  at the guide.

Fixes #272

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs(codex-plugin): show mcp_mode in proper JSON syntax

Addresses Gemini review on #280: the codex README wrote
``mcp_mode: cli-only`` (YAML-shorthand) inline. ``config.json`` is JSON,
so a user pasting that verbatim would hit a JSON parse error. Switch to
``"mcp_mode": "cli-only"`` — proper JSON syntax, matches the .claude-plugin
README's snippet form.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants