Skip to content

Codemap shared tools - #52

Draft
rahmans1 wants to merge 2 commits into
PanDAWMS:masterfrom
rahmans1:codemap-tools
Draft

rahmans1 wants to merge 2 commits into
PanDAWMS:masterfrom
rahmans1:codemap-tools

Conversation

@rahmans1

@rahmans1 rahmans1 commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge order

Order PR Needs
1 #52 shared tools nothing
2, any order #50 swf-epicprod, #51 swf-monitor, #54 panda-client #52
any time #53 bind-maps nothing

This PR: merge first. It needs nothing. #50, #51 and #54 are built on it and carry its two commits until it is merged. #53 does not depend on it.

Merging one of #50, #51, #54 before #52 would bring #52's commits in with it; the rest then still merge cleanly. All five were merged together in a scratch branch with no conflict.

Summary

What a second and a third map need that a first one's plugin would otherwise hold alone. Follows the shared ORM recognizers (#37): tools apart from any plugin.

orm.plugin.DjangoCodeMapPlugin — the walk

Reads the packages, takes models, writes, values and conditions from bamboo.codemap.orm, maps raw UPDATE text to a model by its table, assembles. A subclass states its map id, where a checkout keeps each package, and its own boundaries through module_context / visit_module / visit_node / finish. A package under src/ is still spelled <package>/<path>, as calls.Types spells a file.

The walk also reads the rows other systems declare:

  • NEIGHBOURS, package → system. A model imported from a neighbour's models module is known by the import: its class and module, not its fields or table. A write of it is an outbound shared_table boundary named by the class (ai.models.Proposal) with the fields written. Before, such a write read as ?.status, unresolved.
  • SCHEMAS, schema → system. A statement naming a table of a schema another system owns (FROM "{PANDA_SCHEMA}"."jobsactive4") is an outbound shared_table boundary schema.table with the verbs used and the columns the text quotes.

msgdispatch — messages told apart by a type they carry

A send to a /queue/ or /topic/ is an outbound message boundary named by the destination, with a MessageEdge per type sent. A class that hands a message to _handle_<msg_type> is an inbound one named by the queue its module declares, with a MessageReceiver per type and its handler. The names are a Convention, so code with other names is read by the same rule.

factory — a plugin package declares itself

CODE_MAP_PLUGIN = ("<map id>", "<module>:<class>")

in a package's __init__ under bamboo.codemap is found on first lookup; the class is imported only when that map is asked for. Two maps added apart touch no file in common. PanDA's plugin is registered as before.

Everything is recorded in the fields a map already has (BoundaryNode, MessageEdge, MessageReceiver), so another system's map can be bound to it without knowing these tools.

Changes

  • bamboo/codemap/orm/plugin.py (new), orm/schema.py (DjangoModel.elsewhere, models_declared_elsewhere), orm/writes.py (a model declared elsewhere takes fields named like a state)
  • bamboo/codemap/msgdispatch.py (new)
  • bamboo/codemap/factory.py
  • tests/test_codemap_django_walk.py

Test plan

  • pytest tests/test_codemap_django_walk.py tests/test_codemap_orm.py — 27 passed
  • scripts/mypy_ratchet.py check — 0 errors; black and ruff clean on the touched files
  • Full test suite (left to CI)

🤖 Generated with Claude Code

Sakib Rahman and others added 2 commits November 24, 2026 08:52
…ms declare, typed messages

A second and a third Django project need what a first one's plugin would
otherwise hold alone, so it is here, apart from any of them.

orm.plugin.DjangoCodeMapPlugin is the walk: read the packages, take models,
writes, values and conditions from bamboo.codemap.orm, map raw UPDATE text to
a model by its table, assemble.  A subclass states its map id, where a
checkout keeps each package (a package under src/ is still spelled
<package>/<path>, as calls.Types spells a file) and its own boundaries
through module_context / visit_module / visit_node / finish.

The walk also reads the rows other systems declare:

* NEIGHBOURS, package -> system.  A model a module imports from a neighbour's
  models module (orm.schema.models_declared_elsewhere) is known by the import
  -- its class and module, not its fields or table.  The write forms attribute
  to it as to any model, taking only a field named like a state and only where
  the class is certain, and the write is an outbound shared_table boundary
  named by the class, ai.models.Proposal, with the fields written.  Before,
  such a write read as "?.status", unresolved.
* SCHEMAS, schema -> system.  A statement's text naming a table of a schema
  another system owns, FROM "{PANDA_SCHEMA}"."jobsactive4", is an outbound
  shared_table boundary schema.table with the verbs used and the columns the
  text quotes.  The schema an f-string fills in is the one value its name has
  in the module, else in the corpus.

msgdispatch reads messages told apart by a type they carry: a send to a
/queue/ or /topic/ is an outbound message boundary named by the destination
with a MessageEdge per type sent; a class that hands a message to
_handle_<msg_type> is an inbound one named by the queue its module declares,
with a MessageReceiver per type and its handler.  The names are a Convention,
so code with other names is read by the same rule.

Everything is recorded in the fields a map is made of -- BoundaryNode's
interface, calls_out, handed_over, carried_values and operations,
MessageEdge, MessageReceiver -- and nothing of it in a convention of its own,
so the map of another system can be bound to it without knowing these tools.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A plugin shipped with bamboo was registered by a branch of _register_builtins,
so two maps added apart both edited the same lines of the factory.  A package
whose __init__ holds

    CODE_MAP_PLUGIN = ("<map id>", "<module>:<class>")

is now found on first lookup, and its class is imported only when that map is
asked for.  Adding a map is adding its package.  The PanDA plugin is
registered as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant