Repository navigation
Closed
Labels
Description
Scope
Composite issue for compacting runtime/support code by retiring small bespoke frameworks, using already-declared dependencies where appropriate, and deleting surface-naming ceremony.
Problem
Several parts of Polylogue duplicate functionality already available from dependencies or from nearby shared abstractions:
pydantic-settingsis declared but config/env handling is handwritten in dataclasses and directos.environreads;- XDG/platform path resolution is hand-rolled instead of using a standard platform path helper;
- JSON serialization has a canonical wrapper, but strict typed boundaries still use forgiving recursive guards in places where Pydantic/TypeAdapter should fail loudly;
- MCP payload modules re-alias shared surface payloads under MCP-prefixed names without adding behavior;
- HTML code highlighting regexes generated Markdown HTML instead of using markdown-it renderer rules;
- path/token sanitization policy is spread across display paths, source-root materialization, browser tokens, blob hashes, and semantic referenced paths;
- some runtime dependencies are declared but not used.
Already completed
lib→core: Generic primitives (JSON, hashing, time, security, payload coercion, outcome grammar, metrics) moved topolylogue/core/(refactor(core): move JSON utilities out of lib #659–refactor(core): move pipeline metrics out of lib #665).polylogue/lib/no longer exists.lib→archive: Archive-domain semantics moved topolylogue/archive/(refactor(archive): move query semantics out of lib #636–refactor(storage): move embedding helpers out of lib #658, refactor(archive): move stats and coverage out of lib #666–refactor(archive): own tail overlay metadata #669).
Remaining
- Config: Either consume
pydantic-settingsthrough a typed settings adapter or remove it from dependencies. Currentpolylogue/config.pyuses dataclass config and direct env reads; no imports ofpydantic_settings/BaseSettingsexist in the codebase. - Platform paths: Either adopt
platformdirsfor config/data/cache/state roots, or document why the local XDG helper inpolylogue/paths/_roots.pyis deliberately retained. - JSON boundary policy: Direct stdlib
jsonis allowed only for explicitly allowlisted compatibility cases. Machine output, proof evidence, manifests, browser capture, and schemas go through typed/canonical boundaries. Many directjson.dump(s)/json.load(s)call sites still exist. - MCP payload aliases: Delete MCP-prefixed aliases around shared surface payload models (
polylogue/mcp/payloads.py:47-51). MCP modules should contain only real MCP-specific wrappers/helpers. - Markdown highlighting: Use markdown-it token renderer rules, not regex post-processing over generated HTML.
- Path/token policies: Named by trust boundary — display path, source-root materialization, filename token, blob hash, referenced path, browser token. See fix(semantic): preserve parser drift, action paths, and source paths #623.
- Unused dependencies:
glomis declared inpyproject.toml:43-46but has no imports in the codebase. Either adopt it to delete local extraction code, or remove with evidence.
Policy
- Prefer third-party wheels and existing typed boundaries.
- Do not collapse distinct boundary policies into one generic helper.
- No import shims or compatibility aliases for moved helpers.
productsterminology →insightswhen touching derived read-model helpers or registries.
Consolidated findings
This issue absorbs and supersedes:
- refactor(config): use pydantic-settings and platformdirs #628 pydantic-settings/platformdirs config refactor.
- refactor(json): centralize serialization through the JSON wrapper #616 JSON wrapper/strict-boundary cleanup.
- refactor(mcp): remove payload alias layer around shared surface models #631 MCP payload alias removal.
- refactor(rendering): use markdown-it renderer rules for code highlighting #632 markdown-it renderer-rule highlighting.
- docs(config): reconcile runtime env vars with supported overrides #582 runtime env var docs/config reconciliation.
Related but kept separate:
- refactor(manifests): type repo-control manifests and schema catalogs #629 typed repo-control manifests and schema package catalogs.
- fix(semantic): preserve parser drift, action paths, and source paths #623 source/path trust-boundary semantics.
Activity
[-]refactor(deps): use or remove unused glom dependency[/-][+]refactor(deps): use or remove unused runtime dependencies[/+][-]refactor(deps): use or remove unused runtime dependencies[/-][+]refactor(runtime): retire bespoke config, JSON, payload, and path helpers[/+]Sinity commentedon May 1, 2026
Compactness guard: this should prefer third-party wheels and existing typed boundaries, but not collapse distinct boundary policies into one helper layer.
Suggested classification per candidate:
pydantic-settingsor a typed settings model where runtime configuration is the contract; directos.environreads should become rare and owned;glom: either adopt them to delete local extraction code, or remove them with evidence.The success metric should be fewer policies and less local parsing code, not a new
helpers.pythat every subsystem depends on.Sinity commentedon May 1, 2026
Implementation anchors and acceptance additions from the 2026-05-01 follow-up audit.
Code/dependency anchors:
pyproject.toml:43-46: declared runtime dependencies includepydantic-settingsandglom.pydantic_settings/BaseSettings; no imports ofplatformdirs; no imports ofglomoutside packaging metadata.polylogue/config.py:29-151: dataclass config and direct env reads.polylogue/paths/_roots.py:9-33: hand-rolled XDG fallback.polylogue/lib/json.py: central JSON wrapper exists, but there are many directjson.dump(s)/json.load(s)call sites acrosspolylogueanddevtools.polylogue/mcp/payloads.py:47-51: MCP-prefixed aliases around shared surface payload models.Acceptance additions:
pydantic-settingsthrough a typed settings adapter or remove it from dependencies.platformdirsfor config/data/cache/state roots or document why the local XDG helper is deliberately retained.jsonis allowed only for explicitly allowlisted compatibility cases; machine output, proof evidence, manifests, browser capture, and schemas go through typed/canonical boundaries.Sinity commentedon May 1, 2026
Compactness/package-boundary integration from 2026-05-01 bundle
The downloaded decision bundle reinforces the compactness direction here, but also clarifies the alias policy:
core,archive,storage/sqlite,pipeline,insights,surfaces;pydantic-settings, typed Pydantic/TypeAdapter boundaries, markdown-it renderer rules, shared surface payloads), but do not collapse distinct trust-boundary policies into one generic helper;productsterminology should becomeinsightswhen this issue touches derived read-model helpers or registries.Already-covered compactness work from the naming stream should not be reopened here: JSON, hashing, time, security, payload coercion, outcome grammar, and metrics have moved to
polylogue.corein #659-#665.Remaining compactness slices still owned here include settings/platform paths, MCP payload alias removal, markdown renderer-rule highlighting, path policy naming, and declared-but-unused dependency decisions.
Ref #635
Sinity commentedon May 2, 2026
Current targets for the "bespoke helpers" retirement
Based on the issue title's scope:
Config:
polylogue/config.py— runtime config/XDG resolution. Check if it's using custom path construction thatplatformdirsalready covers.JSON:
polylogue/lib/json.pywas referenced butpolylogue/lib/no longer exists. The JSON helpers likely moved topolylogue/core/orpolylogue/archive/. Find the current module:It wraps
orjsonwith Decimal → float conversion. If this is the only caller, consider whetherorjson.dumpswith a custom default is simpler than a dedicated wrapper.Payload helpers: check
polylogue/archive/raw_payload.py— payload type detection/normalization. These may duplicate what the schema/property-test infrastructure already covers.Path helpers: check
polylogue/sources/source.pyandpolylogue/archive/attachment.py— path resolution and sanitization. The attachment path sanitization ordering issue from #623 may surface path helpers that can be unified.Approach
Grep for each category, list every function, check whether a standard library or upstream dependency already does the same thing. Delete if yes, narrow the contract if no.
Sinity commentedon May 3, 2026
All three acceptance criteria are already satisfied in the current codebase:
The remaining items from the original scope (JSON boundary policy, markdown highlighting, path/token policies) are tracked in #623 and #723 respectively.