Skip to content

Conversation

@rkaminsk
Copy link
Member

@rkaminsk rkaminsk commented Jan 26, 2026

Pull request overview

Refactors backend handling to support additional backends by targeting a more generic/abstract program interface and refining step vs. grounding boundaries.

Changes

  • Introduces begin_step(), end_ground(), and end_step() to separate “grounding step” from “solver step”.
  • Updates output and parsing layers to use the new end_ground() lifecycle hook.
  • Refactors solver backend implementation to forward to Potassco::AbstractProgram and updates theory backend wiring.

Changed Files

File Description
lib/output/src/text.cc Renames output lifecycle hook from do_end_step to do_end_ground.
lib/output/src/backend.cc Renames lifecycle hook and performs end-of-ground translations for backend output.
lib/output/include/clingo/output/backend.hh Changes TheoryData to reference a TheoryBackend instead of owning it.
lib/input/src/parse/aspif.cc Updates aspif parsing to explicitly manage begin_step / end_ground / end_step.
lib/ground/tests/matcher.cc Updates test stub output implementation for renamed hook.
lib/core/include/clingo/core/output.hh Renames OutputStm::end_step() to end_ground() and updates virtual API.
lib/core/include/clingo/core/backend.hh Splits backend finalization into begin_step, end_ground, and end_step; removes TheoryBackend::end().
lib/control/src/solver.cc Refactors backend implementation to forward to Potassco::AbstractProgram and adapts solver/aspif integration to new lifecycle.
lib/control/src/grounder.cc Switches grounder to call end_ground() after grounding.
lib/input/tests/aspif.cc Adds tests for aspif parsing.

@rkaminsk rkaminsk added this to the 6.0.0 milestone Jan 26, 2026
rkaminsk and others added 2 commits January 26, 2026 20:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors backend handling to support additional backends by targeting a more generic/abstract program interface and refining step vs. grounding boundaries.

Changes:

  • Introduces begin_step(), end_ground(), and end_step() to separate “grounding step” from “solver step”.
  • Updates output and parsing layers to use the new end_ground() lifecycle hook.
  • Refactors solver backend implementation to forward to Potassco::AbstractProgram and updates theory backend wiring.

Reviewed changes

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

Show a summary per file
File Description
lib/output/src/text.cc Renames output lifecycle hook from do_end_step to do_end_ground.
lib/output/src/backend.cc Renames lifecycle hook and performs end-of-ground translations for backend output.
lib/output/include/clingo/output/backend.hh Changes TheoryData to reference a TheoryBackend instead of owning it.
lib/input/src/parse/aspif.cc Updates aspif parsing to explicitly manage begin_step / end_ground / end_step.
lib/ground/tests/matcher.cc Updates test stub output implementation for renamed hook.
lib/core/include/clingo/core/output.hh Renames OutputStm::end_step() to end_ground() and updates virtual API.
lib/core/include/clingo/core/backend.hh Splits backend finalization into begin_step, end_ground, and end_step; removes TheoryBackend::end().
lib/control/src/solver.cc Refactors backend implementation to forward to Potassco::AbstractProgram and adapts solver/aspif integration to new lifecycle.
lib/control/src/grounder.cc Switches grounder to call end_ground() after grounding.
Comments suppressed due to low confidence (1)

lib/output/src/backend.cc:1623

  • OutputBackend::do_end_ground() finishes internal translations but never calls ProgramBackend::end_ground(). With the new backend interface, this means backends will not be notified when a grounding step completes. Call the underlying backend's end_ground() as part of this method (likely after the translations are flushed).
    void do_end_ground() override {
        bld_.compute_sccs();
        minimize_.tr(bld_);
        cond_lit_.tr(bld_);
        disjunction_.tr(bld_);
        min_.tr(bld_);
        max_.tr(bld_);
        sum_.tr(bld_);
        bld_.tr();
    }

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

Copy link

Copilot AI commented Jan 27, 2026

@rkaminsk I've opened a new pull request, #597, to work on those changes. Once the pull request is ready, I'll request review from you.

@rkaminsk rkaminsk requested a review from Copilot January 30, 2026 08:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (1)

lib/output/include/clingo/output/backend.hh:142

  • With the switch from std::unique_ptr<TheoryBackend> to TheoryBackend*, TheoryData becomes implicitly copyable again. Copying a TheoryData duplicates its internal id-generation state and caches, which can lead to duplicated ids being emitted to the same backend. Consider explicitly deleting the copy constructor/assignment (and possibly defining move semantics) to prevent accidental copies.
    SymbolStore *store_;
    TheoryBackend *backend_;
    Util::OutputBuffer buf_;
    StringMap strings_;
    NumMap nums_;
    FunMap funs_;
    TupMap tups_;
    ElemMap elems_;
    AtomMap atoms_;
    prg_id_t ids_ = 0;

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

Copy link

Copilot AI commented Jan 30, 2026

@rkaminsk I've opened a new pull request, #598, to work on those changes. Once the pull request is ready, I'll request review from you.

@rkaminsk rkaminsk merged commit 449010b into wip-20 Jan 30, 2026
9 checks passed
@rkaminsk rkaminsk deleted the refactor/backend branch January 30, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants