Skip to content

feat: Use pull mode generator for search and chain. - #110

Merged
hzhangxyz merged 1 commit into
mainfrom
dev/use-generator
Mar 15, 2026
Merged

feat: Use pull mode generator for search and chain.#110
hzhangxyz merged 1 commit into
mainfrom
dev/use-generator

Conversation

@hzhangxyz

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings March 15, 2026 11:03
@hzhangxyz
hzhangxyz merged commit 1c4d87c into main Mar 15, 2026
28 checks passed

Copilot AI 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.

Pull request overview

This PR updates the DDSS “search” and “chain” loops to use a pull-based generator/iterator style rather than a callback-based execute(handler) style, simplifying control flow in both the TypeScript and Python implementations.

Changes:

  • Replace callback-based execute(handler) usage with direct iteration (for ... of / for ... in) over Search and Chain.
  • Remove task aggregation (Promise.all / asyncio.gather) in favor of awaiting inserts inline.
  • Keep the per-tick yielding behavior (setTimeout(0) / asyncio.sleep(0)) after processing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
ddss/search.ts Switches search rule processing to iterator-based loop and performs inserts inline.
ddss/search.py Switches search rule processing to iterator-based loop and performs inserts inline.
ddss/chain.ts Switches chain rule processing to iterator-based loop and performs inserts inline.
ddss/chain.py Switches chain rule processing to iterator-based loop and performs inserts inline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread ddss/search.ts
Comment on lines +21 to +23
for (const rule of search) {
const ds = rule.toString();
tasks.push(insertOrIgnore(Fact, ds));
await insertOrIgnore(Fact, ds);
Comment thread ddss/search.ts
Comment on lines +21 to 27
for (const rule of search) {
const ds = rule.toString();
tasks.push(insertOrIgnore(Fact, ds));
await insertOrIgnore(Fact, ds);
const idea = strRuleGetStrIdea(ds);
if (idea) {
tasks.push(insertOrIgnore(Idea, idea));
await insertOrIgnore(Idea, idea);
}
Comment thread ddss/chain.ts
Comment on lines +21 to +25
for (const rule of chain) {
const ds = rule.toString();
const idea = strRuleGetStrIdea(ds);
if (idea) {
tasks.push(insertOrIgnore(Idea, idea));
await insertOrIgnore(Idea, idea);
Comment thread ddss/chain.ts
Comment on lines +21 to 28
for (const rule of chain) {
const ds = rule.toString();
const idea = strRuleGetStrIdea(ds);
if (idea) {
tasks.push(insertOrIgnore(Idea, idea));
await insertOrIgnore(Idea, idea);
} else {
tasks.push(insertOrIgnore(Fact, ds));
await insertOrIgnore(Fact, ds);
}
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.

2 participants