Skip to content

feat: add chain component as alternative forward-chaining engine - #104

Merged
hzhangxyz merged 1 commit into
mainfrom
dev/chain
Mar 12, 2026
Merged

feat: add chain component as alternative forward-chaining engine#104
hzhangxyz merged 1 commit into
mainfrom
dev/chain

Conversation

@hzhangxyz

Copy link
Copy Markdown
Member
  • Create ddss/chain.py and ddss/chain.ts using Chain API from apyds/atsds
  • Add chain component to main.ts and main.py component maps (not in default list)
  • Add tests: tests/test_chain.py and tests/test_chain.ts
  • Update README.md and documentation (docs/en/.md, docs/zh/.md)

- Create ddss/chain.py and ddss/chain.ts using Chain API from apyds/atsds
- Add chain component to main.ts and main.py component maps (not in default list)
- Add tests: tests/test_chain.py and tests/test_chain.ts
- Update README.md and documentation (docs/en/*.md, docs/zh/*.md)
Copilot AI review requested due to automatic review settings March 12, 2026 08:46
@hzhangxyz
hzhangxyz merged commit 9e786e2 into main Mar 12, 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

Adds a new “chain” component that uses the apyds/atsds Chain API as an alternative forward-chaining engine, wired into both the Python and TypeScript CLIs and documented alongside existing components.

Changes:

  • Introduce ddss/chain.py and ddss/chain.ts implementing the new Chain-based engine.
  • Register chain in the Python/TS component maps (while keeping defaults unchanged) and add corresponding tests.
  • Bump apyds/atsds dependency versions and update README + docs (EN/ZH) to mention the new component.

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ddss/chain.py New Chain-based forward-chaining component for Python
ddss/chain.ts New Chain-based forward-chaining component for TypeScript
ddss/main.py Adds chain to the component map
ddss/main.ts Adds chain to the component map
tests/test_chain.py New Python tests for chain inference behavior
tests/test_chain.ts New TS tests for chain inference behavior
pyproject.toml Bumps apyds* dependencies to ~0.0.18
uv.lock Lockfile update for apyds* to 0.0.18
package.json Bumps atsds* dependencies to ^0.0.18
package-lock.json Lockfile update for atsds* to 0.0.18
README.md Documents the new chain component
docs/en/usage.md Adds chain to available components
docs/en/modules.md Adds Chain module listing
docs/zh/usage.md Adds chain to available components (ZH)
docs/zh/modules.md Adds Chain module listing (ZH)

💡 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/chain.ts
Comment on lines +24 to +29
const ds = rule.toString();
tasks.push(insertOrIgnore(Fact, ds));
const idea = strRuleGetStrIdea(ds);
if (idea) {
tasks.push(insertOrIgnore(Idea, idea));
}

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

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

The new code inserts derived ideas via strRuleGetStrIdea(ds) and insertOrIgnore(Idea, ...), but the added Chain tests only assert inferred facts. Add at least one test case that exercises and verifies idea creation (similar to the existing Search test that expects an Ideas row) so this behavior is protected for the Chain engine too.

Copilot uses AI. Check for mistakes.
Comment thread ddss/chain.py
Comment on lines +22 to +26
ds = str(rule)
tasks.append(asyncio.create_task(insert_or_ignore(sess, Facts, ds)))
if idea := str_rule_get_str_idea(ds):
tasks.append(asyncio.create_task(insert_or_ignore(sess, Ideas, idea)))
return False

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

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

ddss.chain.main creates Ideas rows when str_rule_get_str_idea(ds) returns a value, but the newly added Chain tests never assert that ideas are created. Add a test that triggers idea generation and verifies an Ideas record is inserted, mirroring the coverage that exists for the Search engine.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_chain.py
Comment on lines +161 to +166
# Add facts that will produce a duplicate: a => b twice with => a
async with session() as sess:
sess.add(Facts(data="a\n----\nc\n"))
sess.add(Facts(data="b\n----\nc\n"))
sess.add(Facts(data="----\na\n"))
sess.add(Facts(data="----\nb\n"))

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

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

The test comment says this scenario is "a => b twice with => a", but the actual inserted rules are a => c, b => c, => a, => b (deriving => c). Update the comment/docstring to match the setup so the test intent stays clear.

Copilot uses AI. Check for mistakes.
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