Anonymous View
Skip to content

server/backend: replace local scoring module with cq.scoring from the SDK #332

@peteski22

Description

@peteski22

Context

PR for #330 unified scoring constants across the canonical schema and both SDKs by extracting them into the cq-schema package (schema/scoring.values.json is the single source of truth). The Go and Python SDKs both now read constants directly from cq-schema, and cq.scoring (in cq-sdk) is the canonical Python implementation of the relevance and confidence-adjustment functions.

server/backend/src/cq_server/scoring.py is currently a hand-mirrored copy of the same logic (constants and calculate_relevance body), drifting independently from the SDK. It exists in the server purely as duplication, not as deliberate divergence.

Task

Delete server/backend/src/cq_server/scoring.py and have the server import from the SDK directly.

  1. Update server/backend/src/cq_server/app.py (and any other server modules) to import apply_confirmation, apply_flag, and calculate_relevance from cq.scoring instead of .scoring.
  2. Delete server/backend/src/cq_server/scoring.py.
  3. Bump cq-sdk dependency in server/backend/pyproject.toml to a version that exposes the cq-schema-backed constants.
  4. Add a schema-oracle test under server/backend/tests/ that validates server-serialised KnowledgeUnits against cq_schema.load_schema("knowledge_unit") — same pattern as sdk/python/tests/test_schema_oracle.py.
  5. Run make test-server-backend and make lint-server-backend.

Out of scope

  • The first cq-schema PyPI release and the subsequent cq-sdk release that depends on it; this issue depends on both happening first.
  • Any change to scoring algorithm semantics.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions