Skip to content

[#1208] WIP Added basic skeleton for the new LCA processor and proxy - #1217

Open
andre-senna wants to merge 11 commits into
masterfrom
senna-1208-1
Open

[#1208] WIP Added basic skeleton for the new LCA processor and proxy#1217
andre-senna wants to merge 11 commits into
masterfrom
senna-1208-1

Conversation

@andre-senna

Copy link
Copy Markdown
Contributor

WIP towards #1208

This is just the skeleton of the processor/proxy classes. I added the basic functionalities to select link creation function and basic proxy commands but didn't brought the new link creation algorithm yet.

@andre-senna andre-senna self-assigned this Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@andre-senna, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b59c471d-5def-4178-9302-aa343f78ddc1

📥 Commits

Reviewing files that changed from the base of the PR and between 90ef6ec and 67289a6.

📒 Files selected for processing (1)
  • src/agents/link_creation_agent/LinkCreationProxy.cc
  • Replaces the legacy link-creation agent, service, templates, and processors with LinkCreationProxy, LinkCreationProcessor, and the LinkCreator registry. The new link-creation algorithm remains a stub.
  • Adds local and remote creator selection, proxy serialization, command validation, threaded command execution, and stop criteria. Review correctness risks in thread cleanup, shared state synchronization, exception propagation, and placeholder query handling.
  • Adds creator tracking with std::set state. Review hot paths for repeated proxy serialization, tokenization, query-answer handling, and potential copies or allocations during remote operations.
  • Updates integration tests for registry lookup, local and remote fitness computation, proxy tokenization, and round-tripping. The tests do not cover processor thread lifecycle, concurrent access, command failures, stop criteria, or the stubbed query path.

Walkthrough

The legacy link-creation agent, service, templates, and request processors are removed. New LinkCreationProxy, LinkCreationProcessor, and link-creator registry components provide local and remote command handling. Factories, Bazel targets, and integration tests are updated.

Changes

Link creation transition

Layer / File(s) Summary
Link creator contracts
src/agents/link_creation_agent/link_creators/*
Adds the abstract LinkCreator, registry initialization and lookup, visitation tracking, a test creator, and the link_creators_lib target.
Proxy command and remote flow
src/agents/link_creation_agent/LinkCreationProxy.*
Adds local and remote link creation, tokenization, stop criteria, peer-command handling, result validation, and remote-operation state.
Processor execution and factory wiring
src/agents/link_creation_agent/LinkCreationProcessor.*, src/agents/link_creation_agent/BUILD, src/main/helpers/*, src/main/bus_node.cc, src/commons/Utils.h
Adds service-bus command processing with worker-thread tracking and exception handling. Factory branches now create the new processor and proxy. Build targets and Utils::split are updated.
Integration validation and legacy removal
src/tests/cpp/link_creation_agent_test.cc, src/tests/cpp/BUILD, src/agents/link_creation_agent/*
Replaces legacy agent tests with proxy and link-creator integration tests. Removes the former agent, service, template, request, queue, and processor implementations and documentation.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • singnet/das#1171: Adds related glibc heap trimming and self-reaping thread cleanup.
  • singnet/das#1205: Modifies the deleted MettaTemplateProcessor.cc AtomDB link-creation logic.

Sequence Diagram(s)

sequenceDiagram
  participant ProxyFactory
  participant LinkCreationProxy
  participant LinkCreationProcessor
  participant LinkCreatorRegistry
  participant LinkCreator
  ProxyFactory->>LinkCreatorRegistry: initialize statics
  ProxyFactory->>LinkCreationProxy: create default proxy
  LinkCreationProcessor->>LinkCreationProxy: execute link-creation command
  LinkCreationProxy->>LinkCreatorRegistry: resolve creator tag
  LinkCreationRegistry->>LinkCreator: return creator
  LinkCreationProxy->>LinkCreator: create links from query answers
  LinkCreationProxy->>LinkCreationProcessor: return link statistics
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the basic Link Creation Agent processor and proxy skeleton added for issue #1208.
Description check ✅ Passed The description accurately states that the pull request adds a processor and proxy skeleton with function selection and basic commands.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Tests For Behavior Changes ✅ Passed Production LCA proxy, processor, and registry logic changed, and src/tests/cpp/link_creation_agent_test.cc was updated with proxy, creator-selection, tokenization, and remote-call tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch senna-1208-1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 14

🧹 Nitpick comments (11)
src/agents/link_creation_agent/link_creators/LinkCreator.h (1)

20-21: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Make the destructor virtual.

LinkCreator is a polymorphic base with a pure virtual create. The destructor is non-virtual. If any code deletes a derived creator through a LinkCreator*, the behavior is undefined and the derived state leaks. shared_ptr<LinkCreator> built by make_shared<Derived> stays safe, but the class should not depend on that call site detail.

♻️ Proposed fix
     LinkCreator();
-    ~LinkCreator();
+    virtual ~LinkCreator();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/link_creators/LinkCreator.h` around lines 20 -
21, Update the LinkCreator destructor declaration to be virtual, preserving its
role as a safe polymorphic base for deletion through LinkCreator pointers.
src/agents/link_creation_agent/link_creators/LinkCreator.cc (1)

16-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use this-> for the member read.

Line 17 reads _visited_at_least_one_in_last_create directly while the next line uses this->. Keep member access consistent.

♻️ Proposed fix
-    bool answer = _visited_at_least_one_in_last_create;
+    bool answer = this->_visited_at_least_one_in_last_create;

As per coding guidelines: "Access class members with this->field consistently in C++".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/link_creators/LinkCreator.cc` around lines 16
- 20, Update LinkCreator::get_and_reset_visited to access
_visited_at_least_one_in_last_create through this-> for the initial member read,
matching the existing qualified access when resetting it.

Source: Coding guidelines

src/tests/cpp/link_creation_agent_test.cc (2)

64-65: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the debug output or route it through the logger.

The cout lines print on every run and add nothing to the assertion on line 66. Use LOG_DEBUG if the token dump helps during failures.

♻️ Proposed fix
-    cout << "tokens1: " << Utils::join(tokens1) << endl;
-    cout << "tokens3: " << Utils::join(tokens3) << endl;
-    EXPECT_EQ(tokens1, tokens3);
+    EXPECT_EQ(tokens1, tokens3) << "tokens1: " << Utils::join(tokens1)
+                               << " tokens3: " << Utils::join(tokens3);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/cpp/link_creation_agent_test.cc` around lines 64 - 65, Remove the
unconditional cout token dumps around the assertions in
link_creation_agent_test, or replace them with LOG_DEBUG so output is emitted
only through the established logging path while preserving the assertion
behavior.

22-41: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Add coverage for the new command surface, and free the bus resources.

The test exercises only local creation and token round-trip. The PR adds a proxy/processor split, so the behavior-relevant paths are untested: stop_criteria_met() against MAX_ROUNDS and MAX_VISITS_PER_ROUND, remote_link_creation() plus remote_link_creation_finished(), process_query_answer_response() merging into get_remotely_created_links(), and the error path through raise_error_on_peer. Add cases for an unknown creator tag reaching LinkCreatorRegistry::function() and for a second initialize_statics() call, since both raise.

The two Utils::sleep(1000) calls also make this a slow size = "small" test with timing-dependent registration. Prefer a polled wait on processor readiness if a helper exists in the sibling tests.

Do you want me to draft these test cases?

As per path instructions: "Behavior changes here should have matching *_test.cc updates; suggest concrete test cases (edge cases, error paths, concurrency) not trivial assertions."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/cpp/link_creation_agent_test.cc` around lines 22 - 41, Expand
link_creator_function to cover stop_criteria_met at MAX_ROUNDS and
MAX_VISITS_PER_ROUND, remote_link_creation with remote_link_creation_finished,
process_query_answer_response merging into get_remotely_created_links, and
raise_error_on_peer failures. Add assertions for an unknown creator tag passed
to LinkCreatorRegistry::function and a second initialize_statics call raising.
Replace fixed Utils::sleep delays with the existing sibling-test readiness
polling helper, and explicitly stop or release the ServiceBus instances before
the test exits.

Source: Path instructions

src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.h (1)

20-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add brief Doxygen blocks for the public API, and drop <mutex> or use it.

function() and initialize_statics() are the public surface and have no /** ... */ blocks. Also, the header includes <mutex> but the class declares no mutex, which hints at synchronization that was planned and not added. See the thread-safety note on LinkCreatorRegistry.cc.

As per coding guidelines: "Use brief Doxygen /** ... */ blocks above public API methods in C++ header files".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.h` around
lines 20 - 30, Update LinkCreatorRegistry.h by adding brief Doxygen blocks above
the public static methods function() and initialize_statics(), and remove the
unused <mutex> include unless the registry implementation actually adds and uses
a mutex for the documented synchronization requirement.

Source: Coding guidelines

src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.cc (1)

34-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use one map lookup, and document the initialization contract.

function() calls find() and then FUNCTION[tag], which hashes twice and can insert on a typo path if the branch ever changes. Use the iterator from find(). Separately, FUNCTION is a mutable static touched by initialize_statics() with no lock, so all registration must complete before any worker thread calls function(). State that contract in the header comment, or guard both methods with a static mutex.

♻️ Proposed fix
-        if (FUNCTION.find(tag) != FUNCTION.end()) {
-            return FUNCTION[tag];
-        } else {
-            RAISE_ERROR("Unkown link creation function: " + tag);
-        }
+        auto iterator = FUNCTION.find(tag);
+        if (iterator != FUNCTION.end()) {
+            return iterator->second;
+        } else {
+            RAISE_ERROR("Unknown link creation function: " + tag);
+        }

Note the typo fix: "Unkown" → "Unknown".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.cc` around
lines 34 - 50, Update LinkCreatorRegistry::function to perform a single
FUNCTION.find(tag) lookup and return the found iterator’s value, avoiding
FUNCTION[tag]; correct the error text from “Unkown” to “Unknown”. Document in
the LinkCreatorRegistry header that initialize_statics() and all registration
must complete before worker threads call function(), unless synchronization is
added to both methods.
src/agents/link_creation_agent/LinkCreationProcessor.cc (2)

54-70: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Collapse the duplicate catch blocks and remove the dead code marker.

std::runtime_error derives from std::exception, and both handlers run the same statement. Keep only the std::exception handler. Also remove the commented-out AttentionBrokerClient::health_check(true); at Line 20.

♻️ Proposed change
-    } catch (const std::runtime_error& exception) {
-        proxy->raise_error_on_peer(exception.what());
     } catch (const std::exception& exception) {
         proxy->raise_error_on_peer(exception.what());
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/LinkCreationProcessor.cc` around lines 54 -
70, In the exception handling around the command processing flow, remove the
redundant std::runtime_error catch and retain the std::exception handler that
calls proxy->raise_error_on_peer(exception.what()). Also delete the
commented-out AttentionBrokerClient::health_check(true) marker near the
processor setup.

19-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add processor tests for the paths that already have behavior.

link_creation() and issue_link_creation_query() are TBD, and that is fine for a skeleton. run_command() and thread_process_one_query() are not. Add src/tests/cpp/*_test.cc cases for: a duplicate thread_id raising an error, a non-LinkCreationProxy argument, args.size() < 2 propagating through raise_error_on_peer, and query_threads returning to empty after a command finishes.

Do you want me to draft these test cases?

As per path instructions: "Behavior changes here should have matching *_test.cc updates; suggest concrete test cases (edge cases, error paths, concurrency) not trivial assertions."

Also applies to: 86-101

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/LinkCreationProcessor.cc` around lines 19 -
21, Add focused *_test.cc coverage for the existing run_command() and
thread_process_one_query() behavior in LinkCreationProcessor: verify duplicate
thread_id input raises an error, non-LinkCreationProxy arguments are rejected,
args.size() < 2 propagates through raise_error_on_peer, and query_threads is
empty after command completion. Leave the TBD link_creation() and
issue_link_creation_query() paths unchanged.

Source: Path instructions

src/agents/link_creation_agent/LinkCreationProcessor.h (1)

39-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Drop the per-command proxy member and add override.

One LinkCreationProcessor instance serves every LINK_CREATION command. A shared_ptr<LinkCreationProxy> proxy member invites shared per-command state across concurrent threads. LinkCreationProcessor.cc never uses it. Remove it now, while the class is still a skeleton.

Mark factory_empty_proxy() and run_command() with override so a future signature change in BusCommandProcessor fails at compile time.

♻️ Proposed change
-    virtual shared_ptr<BusCommandProxy> factory_empty_proxy();
+    virtual shared_ptr<BusCommandProxy> factory_empty_proxy() override;
@@
-    virtual void run_command(shared_ptr<BusCommandProxy> proxy);
+    virtual void run_command(shared_ptr<BusCommandProxy> proxy) override;
@@
     map<string, shared_ptr<StoppableThread>> query_threads;
     mutex query_threads_mutex;
-    shared_ptr<LinkCreationProxy> proxy;
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/LinkCreationProcessor.h` around lines 39 - 47,
Remove the unused per-command proxy member from LinkCreationProcessor and ensure
its methods do not depend on that shared state. Mark factory_empty_proxy() and
run_command() with override in the class declaration so signature changes in
BusCommandProcessor are caught at compile time.
src/agents/link_creation_agent/LinkCreationProxy.h (1)

40-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align the constructor parameter names with the implementation.

The header declares link_creator_tag and link_creator. LinkCreationProxy.cc uses link_creator_tag and link_creation_function, and the member is link_creation_function_tag. This divergence hides the argument bug flagged in LinkCreationProxy.cc (Line 39). Pick one name per concept.

Also applies to: 147-158

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/LinkCreationProxy.h` around lines 40 - 44,
Align the LinkCreationProxy constructor declaration with its implementation by
using consistent parameter names for the creator tag and creator callback across
LinkCreationProxy.h, LinkCreationProxy.cc, and the member
link_creation_function_tag. Rename link_creator and any mismatched callback
references to the established link_creation_function concept, ensuring the
constructor forwards each argument to the corresponding member correctly.
src/agents/link_creation_agent/LinkCreationProxy.cc (1)

126-131: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Do not hold api_mutex across to_remote_peer().

Both methods send to the peer while the mutex is held. to_remote_peer() performs network work, so every other proxy call (to_string, stop_criteria_met, get_remotely_created_links) blocks for that duration. process_query_answer also runs the whole link-creation loop under the lock.

Reduce the scope: mutate the state under the lock, release it, then send. In process_query_answer, also bundle.reserve(args.size()) and iterate with const string& tokens to avoid one string copy per answer.

As per path instructions: "Avoid heap allocations in hot paths and while holding api_mutex. Minimize lock scope."

Also applies to: 164-180

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/LinkCreationProxy.cc` around lines 126 - 131,
Reduce api_mutex scope in remote_link_creation and process_query_answer: update
shared state while locked, release the lock before calling to_remote_peer(), and
keep the link-creation loop outside the mutex. In process_query_answer, reserve
args.size() capacity for bundle and iterate answers as const string& tokens to
avoid copies and hot-path allocations.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/agents/link_creation_agent/link_creators/BUILD`:
- Around line 11-13: Add //commons:commons_lib to the deps of the
link_creators_lib target in BUILD, alongside the existing query_answer
dependency, so LinkCreatorRegistry.cc can resolve Utils.h and RAISE_ERROR.

In `@src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.cc`:
- Around line 6-9: Provide the missing UnitTestLinkCreator implementation and
corresponding declarations required by LinkCreatorRegistry.cc, including the
LinkCreator behavior used by FUNCTION["unit_test"], or remove the unit_test
registration and preserve the existing link-creation path. Ensure the registry’s
include and unit_test-based tests resolve to a valid implementation.

In `@src/agents/link_creation_agent/LinkCreationProcessor.cc`:
- Around line 92-95: Update LinkCreationProcessor::remove_query_thread to remove
entries by key using the container’s safe key-based erase operation, so missing
stoppable_thread_id values are handled without erasing end().
- Around line 33-47: Validate the dynamic_pointer_cast result in
LinkCreationProcessor::run_command before creating or attaching the
StoppableThread. If link_creation_proxy is null, raise the existing error and
return without starting a thread; otherwise preserve the current thread
registration and execution flow.

In `@src/agents/link_creation_agent/LinkCreationProxy.cc`:
- Around line 147-162: Update the LinkCreationProxy test methods in
link_creation_agent_test.cc to call the currently exposed
is_link_creation_function_remote() API instead of the obsolete
is_fitness_function_remote() name, and ensure link creation calls match the
current proxy API. Keep the integration test behavior unchanged while aligning
all references with LinkCreationProxy’s declared methods.
- Around line 78-82: Update LinkCreationProxy::untokenize after
BaseQueryProxy::untokenize(tokens) to verify that tokens still contains the
link-creation function tag before accessing tokens[0] or erasing the first
element; report the malformed or truncated payload through the existing
error-handling mechanism and return without performing either operation when no
token remains.
- Around line 84-98: Update LinkCreationProxy::link_creation to read
link_creation_function_tag and link_creation_function_object under api_mutex at
the start, using the protected values for subsequent checks and invocation to
avoid races with set_link_creation_function_tag(). Remove the post-RAISE_ERROR
return make_pair(0, 0) statements, since those branches already terminate
through RAISE_ERROR.
- Around line 29-40: Update LinkCreationProxy::LinkCreationProxy to pass the
link_creator_tag parameter to set_link_creation_function_tag instead of the
uninitialized member. Set the tag before assigning the creator, and preserve the
caller-supplied link_creation_function when it is non-null rather than replacing
it with the registry instance.

In `@src/agents/link_creation_agent/LinkCreationProxy.h`:
- Around line 88-106: Update the Doxygen comments for remote_link_creation,
get_remotely_created_links, and remote_link_creation_finished to describe remote
link creation rather than fitness evaluation, and correct the copied typos
“aswer” and “Remotelly.” Keep the documented return behavior accurate for each
method.

In `@src/main/bus_node.cc`:
- Line 17: Initialize LinkCreatorRegistry for ProcessorType::LINK_CREATION_AGENT
alongside the existing FitnessFunctionRegistry startup initialization, ensuring
it runs before the processor is created. Use
LinkCreatorRegistry::initialize_statics() and leave initialization for other
processor types unchanged.

In `@src/main/helpers/ProxyFactory.h`:
- Around line 161-163: The LINK_CREATION_AGENT branch in ProxyFactory must not
return a default LinkCreationProxy without required client context, tokens,
creator tag, and params. Construct the proxy using the client-side
initialization path and forward params so LINK_CREATION requests are executable;
if that path is unsupported, explicitly reject the request in this branch
instead of returning an invalid proxy.

In `@src/tests/cpp/BUILD`:
- Around line 614-637: Update the cc_test target link_creation_agent_test to
compile srcs = ["link_creation_agent_test.cc"] instead of
query_evolution_test.cc, and replace or augment its deps with the LCA-specific
libraries required by that source while preserving the existing test
configuration.

In `@src/tests/cpp/link_creation_agent_test.cc`:
- Around line 12-20: Update the namespace qualification in this test translation
unit to use link_creators, so LinkCreator in TestLinkCreator and
LinkCreatorRegistry at the existing call sites resolve to their declared
namespace. Replace the incorrect link_creation_agent namespace reference while
preserving the test implementation and registry usage.
- Around line 42-53: Update the remaining LinkCreationProxy test calls to use
the link-creation API: replace proxy2.compute_fitness(...) with
proxy2.link_creation(...), rename the remote-status assertions for proxy1,
proxy2, and proxy3 to is_link_creation_function_remote(), and replace
proxy3.compute_fitness(...) in EXPECT_THROW with proxy3.link_creation(...).

---

Nitpick comments:
In `@src/agents/link_creation_agent/link_creators/LinkCreator.cc`:
- Around line 16-20: Update LinkCreator::get_and_reset_visited to access
_visited_at_least_one_in_last_create through this-> for the initial member read,
matching the existing qualified access when resetting it.

In `@src/agents/link_creation_agent/link_creators/LinkCreator.h`:
- Around line 20-21: Update the LinkCreator destructor declaration to be
virtual, preserving its role as a safe polymorphic base for deletion through
LinkCreator pointers.

In `@src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.cc`:
- Around line 34-50: Update LinkCreatorRegistry::function to perform a single
FUNCTION.find(tag) lookup and return the found iterator’s value, avoiding
FUNCTION[tag]; correct the error text from “Unkown” to “Unknown”. Document in
the LinkCreatorRegistry header that initialize_statics() and all registration
must complete before worker threads call function(), unless synchronization is
added to both methods.

In `@src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.h`:
- Around line 20-30: Update LinkCreatorRegistry.h by adding brief Doxygen blocks
above the public static methods function() and initialize_statics(), and remove
the unused <mutex> include unless the registry implementation actually adds and
uses a mutex for the documented synchronization requirement.

In `@src/agents/link_creation_agent/LinkCreationProcessor.cc`:
- Around line 54-70: In the exception handling around the command processing
flow, remove the redundant std::runtime_error catch and retain the
std::exception handler that calls proxy->raise_error_on_peer(exception.what()).
Also delete the commented-out AttentionBrokerClient::health_check(true) marker
near the processor setup.
- Around line 19-21: Add focused *_test.cc coverage for the existing
run_command() and thread_process_one_query() behavior in LinkCreationProcessor:
verify duplicate thread_id input raises an error, non-LinkCreationProxy
arguments are rejected, args.size() < 2 propagates through raise_error_on_peer,
and query_threads is empty after command completion. Leave the TBD
link_creation() and issue_link_creation_query() paths unchanged.

In `@src/agents/link_creation_agent/LinkCreationProcessor.h`:
- Around line 39-47: Remove the unused per-command proxy member from
LinkCreationProcessor and ensure its methods do not depend on that shared state.
Mark factory_empty_proxy() and run_command() with override in the class
declaration so signature changes in BusCommandProcessor are caught at compile
time.

In `@src/agents/link_creation_agent/LinkCreationProxy.cc`:
- Around line 126-131: Reduce api_mutex scope in remote_link_creation and
process_query_answer: update shared state while locked, release the lock before
calling to_remote_peer(), and keep the link-creation loop outside the mutex. In
process_query_answer, reserve args.size() capacity for bundle and iterate
answers as const string& tokens to avoid copies and hot-path allocations.

In `@src/agents/link_creation_agent/LinkCreationProxy.h`:
- Around line 40-44: Align the LinkCreationProxy constructor declaration with
its implementation by using consistent parameter names for the creator tag and
creator callback across LinkCreationProxy.h, LinkCreationProxy.cc, and the
member link_creation_function_tag. Rename link_creator and any mismatched
callback references to the established link_creation_function concept, ensuring
the constructor forwards each argument to the corresponding member correctly.

In `@src/tests/cpp/link_creation_agent_test.cc`:
- Around line 64-65: Remove the unconditional cout token dumps around the
assertions in link_creation_agent_test, or replace them with LOG_DEBUG so output
is emitted only through the established logging path while preserving the
assertion behavior.
- Around line 22-41: Expand link_creator_function to cover stop_criteria_met at
MAX_ROUNDS and MAX_VISITS_PER_ROUND, remote_link_creation with
remote_link_creation_finished, process_query_answer_response merging into
get_remotely_created_links, and raise_error_on_peer failures. Add assertions for
an unknown creator tag passed to LinkCreatorRegistry::function and a second
initialize_statics call raising. Replace fixed Utils::sleep delays with the
existing sibling-test readiness polling helper, and explicitly stop or release
the ServiceBus instances before the test exits.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ea3fa05f-d5e9-4515-a697-07696ccd87f7

📥 Commits

Reviewing files that changed from the base of the PR and between e49e9e6 and 96b8991.

📒 Files selected for processing (38)
  • src/agents/link_creation_agent/BUILD
  • src/agents/link_creation_agent/EquivalenceProcessor.cc
  • src/agents/link_creation_agent/EquivalenceProcessor.h
  • src/agents/link_creation_agent/ImplicationProcessor.cc
  • src/agents/link_creation_agent/ImplicationProcessor.h
  • src/agents/link_creation_agent/LCAQueue.h
  • src/agents/link_creation_agent/LinkCreateTemplate.cc
  • src/agents/link_creation_agent/LinkCreateTemplate.h
  • src/agents/link_creation_agent/LinkCreationAgent.cc
  • src/agents/link_creation_agent/LinkCreationAgent.h
  • src/agents/link_creation_agent/LinkCreationAgentRequest.h
  • src/agents/link_creation_agent/LinkCreationProcessor.cc
  • src/agents/link_creation_agent/LinkCreationProcessor.h
  • src/agents/link_creation_agent/LinkCreationProxy.cc
  • src/agents/link_creation_agent/LinkCreationProxy.h
  • src/agents/link_creation_agent/LinkCreationRequestProcessor.cc
  • src/agents/link_creation_agent/LinkCreationRequestProcessor.h
  • src/agents/link_creation_agent/LinkCreationRequestProxy.cc
  • src/agents/link_creation_agent/LinkCreationRequestProxy.h
  • src/agents/link_creation_agent/LinkCreationService.cc
  • src/agents/link_creation_agent/LinkCreationService.h
  • src/agents/link_creation_agent/LinkProcessor.h
  • src/agents/link_creation_agent/MettaTemplateProcessor.cc
  • src/agents/link_creation_agent/MettaTemplateProcessor.h
  • src/agents/link_creation_agent/README.md
  • src/agents/link_creation_agent/TemplateProcessor.cc
  • src/agents/link_creation_agent/TemplateProcessor.h
  • src/agents/link_creation_agent/link_creators/BUILD
  • src/agents/link_creation_agent/link_creators/LinkCreator.cc
  • src/agents/link_creation_agent/link_creators/LinkCreator.h
  • src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.cc
  • src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.h
  • src/commons/Utils.h
  • src/main/bus_node.cc
  • src/main/helpers/ProcessorFactory.h
  • src/main/helpers/ProxyFactory.h
  • src/tests/cpp/BUILD
  • src/tests/cpp/link_creation_agent_test.cc
💤 Files with no reviewable changes (22)
  • src/agents/link_creation_agent/TemplateProcessor.h
  • src/agents/link_creation_agent/LinkCreationAgentRequest.h
  • src/agents/link_creation_agent/EquivalenceProcessor.h
  • src/agents/link_creation_agent/LinkCreationRequestProcessor.h
  • src/agents/link_creation_agent/LinkCreateTemplate.h
  • src/agents/link_creation_agent/LinkCreationRequestProxy.cc
  • src/agents/link_creation_agent/README.md
  • src/agents/link_creation_agent/MettaTemplateProcessor.h
  • src/agents/link_creation_agent/TemplateProcessor.cc
  • src/agents/link_creation_agent/LinkCreationAgent.h
  • src/agents/link_creation_agent/LinkCreateTemplate.cc
  • src/agents/link_creation_agent/ImplicationProcessor.h
  • src/agents/link_creation_agent/LCAQueue.h
  • src/agents/link_creation_agent/EquivalenceProcessor.cc
  • src/agents/link_creation_agent/LinkProcessor.h
  • src/agents/link_creation_agent/LinkCreationAgent.cc
  • src/agents/link_creation_agent/LinkCreationRequestProcessor.cc
  • src/agents/link_creation_agent/LinkCreationRequestProxy.h
  • src/agents/link_creation_agent/ImplicationProcessor.cc
  • src/agents/link_creation_agent/LinkCreationService.cc
  • src/agents/link_creation_agent/MettaTemplateProcessor.cc
  • src/agents/link_creation_agent/LinkCreationService.h

Comment thread src/agents/link_creation_agent/link_creators/BUILD
Comment thread src/agents/link_creation_agent/link_creators/LinkCreatorRegistry.cc
Comment thread src/agents/link_creation_agent/LinkCreationProcessor.cc
Comment thread src/agents/link_creation_agent/LinkCreationProcessor.cc
Comment thread src/agents/link_creation_agent/LinkCreationProxy.cc Outdated
Comment thread src/main/bus_node.cc
Comment thread src/main/helpers/ProxyFactory.h
Comment thread src/tests/cpp/BUILD
Comment thread src/tests/cpp/link_creation_agent_test.cc
Comment thread src/tests/cpp/link_creation_agent_test.cc Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/agents/link_creation_agent/link_creators/UnitTestLinkCreator.h (1)

15-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the public create method.

The method returns the first handle's size in both result values. Add a brief Doxygen block that documents this behavior and the required QueryAnswer shape.

As per coding guidelines, “Use brief Doxygen /** ... */ blocks above public API methods in C++ header files.” As per path instructions, “Public API in headers uses brief Doxygen comments only for public non-obvious APIs.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agents/link_creation_agent/link_creators/UnitTestLinkCreator.h` around
lines 15 - 19, Document the public create method with a brief Doxygen block
immediately above its declaration, stating that it returns the first handle’s
size in both result values and requires a QueryAnswer containing at least one
handle.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/agents/link_creation_agent/link_creators/LinkCreator.h`:
- Around line 59-65: Update visit() so _visited_at_least_one_in_last_create is
set only when _visited.insert(key).second indicates a newly inserted key;
duplicate visits must not mark a new creation before get_and_reset_visited()
reads the flag.
- Around line 64-66: The `LinkCreator` class has mutable fields `_visited` and
`_visited_at_least_one_in_last_create` that are modified by methods like
`create`, `visit`, `visited`, and `get_and_reset_visited` without any
synchronization mechanism. Since `LinkCreator` instances can be shared across
threads via `LinkCreationProxy`'s shared_ptr pattern, add a mutex member
variable to `LinkCreator` and protect all accesses to these mutable fields with
appropriate locking in each method that reads or modifies them to prevent race
conditions.

In `@src/agents/link_creation_agent/link_creators/UnitTestLinkCreator.h`:
- Line 3: Replace the self-include in UnitTestLinkCreator with the base
LinkCreator.h include so LinkCreator is declared before the derived class
declaration. If LinkCreator.h only forward-declares QueryAnswer, add the
complete QueryAnswer definition required by this header.
- Around line 15-18: Clarify the precondition in UnitTestLinkCreator::create
that query_answer must be non-null and contain at least one handle group before
calling get(0). Document this contract or add a guard that handles null and
empty inputs consistently with the LinkCreator interface.

---

Nitpick comments:
In `@src/agents/link_creation_agent/link_creators/UnitTestLinkCreator.h`:
- Around line 15-19: Document the public create method with a brief Doxygen
block immediately above its declaration, stating that it returns the first
handle’s size in both result values and requires a QueryAnswer containing at
least one handle.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 669e55ad-d3d9-4b3c-b0e8-83fbcab039bc

📥 Commits

Reviewing files that changed from the base of the PR and between 96b8991 and 4f8ead5.

📒 Files selected for processing (12)
  • src/agents/link_creation_agent/LinkCreationProcessor.cc
  • src/agents/link_creation_agent/LinkCreationProxy.cc
  • src/agents/link_creation_agent/LinkCreationProxy.h
  • src/agents/link_creation_agent/link_creators/BUILD
  • src/agents/link_creation_agent/link_creators/LinkCreator.cc
  • src/agents/link_creation_agent/link_creators/LinkCreator.h
  • src/agents/link_creation_agent/link_creators/UnitTestLinkCreator.h
  • src/docker/Dockerfile
  • src/main/bus_node.cc
  • src/main/helpers/ProxyFactory.h
  • src/tests/cpp/BUILD
  • src/tests/cpp/link_creation_agent_test.cc
🚧 Files skipped from review as they are similar to previous changes (8)
  • src/agents/link_creation_agent/link_creators/BUILD
  • src/agents/link_creation_agent/link_creators/LinkCreator.cc
  • src/main/helpers/ProxyFactory.h
  • src/agents/link_creation_agent/LinkCreationProxy.cc
  • src/agents/link_creation_agent/LinkCreationProcessor.cc
  • src/agents/link_creation_agent/LinkCreationProxy.h
  • src/tests/cpp/link_creation_agent_test.cc
  • src/main/bus_node.cc

Comment thread src/agents/link_creation_agent/link_creators/LinkCreator.h
Comment thread src/agents/link_creation_agent/link_creators/LinkCreator.h
Comment thread src/agents/link_creation_agent/link_creators/UnitTestLinkCreator.h Outdated
Comment thread src/agents/link_creation_agent/link_creators/UnitTestLinkCreator.h
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