Skip to content

refactor(training): T-CONTEXTS partial — KnnTransferContext#80

Merged
frapercan merged 1 commit intodevelopfrom
feat/t-contexts-knn-transfer
May 8, 2026
Merged

refactor(training): T-CONTEXTS partial — KnnTransferContext#80
frapercan merged 1 commit intodevelopfrom
feat/t-contexts-knn-transfer

Conversation

@frapercan
Copy link
Copy Markdown
Owner

Acceptance criteria (master plan §24 Fase 1 — T-CONTEXTS partial)

Fifth incremental Parameter Object slice. Tackles the remaining 16-arg offender in core training pipeline.

Changes

  • protea/core/training_dump_helpers.py:
    • New KnnTransferContext frozen dataclass bundling the 12 per-call data inputs (queries, references, ontology maps, optional enrichment helpers).
    • _knn_transfer_and_label signature collapses 16 args → 5 (session, p, ctx, plus existing sequence_context / stream_output).
    • Two production call sites updated (train branch + test-stream branch).
  • tests/test_knn_streaming_smoke.py: shared test runner updated.

Smell budget

77 → 75 offenders. params>6: 22 → 20 (_knn_transfer_and_label retired plus 1 knock-on).

Test plan

  • poetry run ruff check protea scripts
  • poetry run flake8 protea/
  • poetry run pytest tests/ --ignore=tests/test_jobs_pg.py (1163 passed, 11 skipped)
  • poetry run python scripts/check_smells.py (75 known, none new)

T-CONTEXTS progress (5 slices total, 4 in flight pending CI)

Combined: 69 args → 15 across the 5 entry points.

@frapercan frapercan enabled auto-merge (squash) May 8, 2026 16:05
Introduces ``KnnTransferContext`` frozen dataclass in
``training_dump_helpers.py`` bundling the 12 per-call data inputs
(queries, references, ontology maps, optional enrichment helpers)
that ``_knn_transfer_and_label`` consumes.

Signature collapses 16 args → 5: ``session``, ``p``, ``ctx``,
``sequence_context`` (existing), ``stream_output`` (existing).
``session`` and payload ``p`` stay separate as configuration; the
existing ``SequenceContext`` and ``StreamOutput`` helpers continue
to handle their orthogonal concerns.

Three call sites updated:
- ``training_dump_helpers.py`` train branch (line ~1515)
- ``training_dump_helpers.py`` test stream branch (line ~1747)
- ``tests/test_knn_streaming_smoke.py`` shared test runner

Body destructures the context once at the top so the rest of the
implementation stays diff-minimal.

Sizes:
- training_dump_helpers.py: +35 LOC (dataclass + destructuring)
- Smell baseline: 77 → 75 (params>6: 22 → 20:
  ``_knn_transfer_and_label`` retired plus 1 knock-on improvement)

Local-first 5 verde (ruff + flake8 + pytest 1163 + check_smells).
@frapercan frapercan force-pushed the feat/t-contexts-knn-transfer branch from 355f58d to 51e481d Compare May 8, 2026 16:15
@frapercan frapercan merged commit e7268b2 into develop May 8, 2026
13 checks passed
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