Skip to content

feat(config): add typed PolylogueConfig, consolidate env reads (#829) - #910

Merged
Sinity merged 3 commits into
masterfrom
feature/fix/finish-829
May 7, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/fix/finish-829

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026

Copy link
Copy Markdown
Owner

Typed PolylogueConfig dataclass. load_polylogue_config() returns PolylogueConfig. Consolidated 6 env reads through config.

Sinity and others added 3 commits May 7, 2026 15:23
)

Add PolylogueConfig dataclass with typed attribute access for all
known config keys. load_polylogue_config() now returns PolylogueConfig
instead of a plain dict. Consolidate 7 remaining os.environ.get()
calls through the shared config layer.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
- Add PolylogueConfig dataclass with typed attribute access
- load_polylogue_config() returns PolylogueConfig instead of dict
- Consolidate 6 POLYLOGUE_* env reads through shared config
- Export PolylogueConfig, load_polylogue_config, format_config_toml

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Copilot AI review requested due to automatic review settings May 7, 2026 13:30
@Sinity
Sinity merged commit c85d130 into master May 7, 2026
@Sinity
Sinity deleted the feature/fix/finish-829 branch May 7, 2026 13:30
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 55 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b95b872e-7818-4379-8614-a7b24bf7e69f

📥 Commits

Reviewing files that changed from the base of the PR and between fb9ee8d and 7185e8f.

📒 Files selected for processing (11)
  • polylogue/cli/query_progress.py
  • polylogue/cli/shared/formatting.py
  • polylogue/config.py
  • polylogue/daemon/status.py
  • polylogue/logging.py
  • polylogue/paths/_roots.py
  • polylogue/pipeline/services/ingest_worker.py
  • polylogue/pipeline/services/validation_flow.py
  • polylogue/readiness/__init__.py
  • polylogue/sources/drive/auth.py
  • polylogue/storage/sqlite/schema_bootstrap.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/finish-829

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7185e8fd8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/config.py Resolved
Comment thread polylogue/sources/drive/auth.py Resolved
Comment on lines 27 to 29
if env_var == "POLYLOGUE_SCHEMA_VALIDATION":
raw = str(load_polylogue_config().get("schema_validation", default))
raw = load_polylogue_config().schema_validation
else:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Respect provided default in schema_validation_mode

For POLYLOGUE_SCHEMA_VALIDATION, this path now reads load_polylogue_config().schema_validation, and the config loader seeds that key to 'advisory'. As a result, callers that pass default=ValidationMode.STRICT (e.g., ValidationService) no longer get strict mode when env/config are unset, silently weakening validation behavior and allowing payloads that should fail strict checks.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a typed PolylogueConfig layer and updates several components to read configuration via load_polylogue_config() instead of directly reading environment variables.

Changes:

  • Add PolylogueConfig dataclass and change load_polylogue_config() to return it.
  • Update multiple call sites (Drive auth, readiness, validation, CLI formatting, logging) to read config through the shared config layer.
  • Minor refactors/formatting adjustments in a few modules.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
polylogue/config.py Adds PolylogueConfig and changes load_polylogue_config() return type; adds schema_validation default.
polylogue/sources/drive/auth.py Switches Drive credential/token path resolution to use load_polylogue_config().
polylogue/readiness/init.py Uses typed force_plain from config when reporting terminal readiness.
polylogue/pipeline/services/validation_flow.py Reads schema validation mode from typed config.
polylogue/cli/shared/formatting.py Switches plain-mode forcing logic to use load_polylogue_config().
polylogue/logging.py Adjusts imports around load_polylogue_config() usage for console rendering.
polylogue/cli/query_progress.py Cleans up imports; adds a # noqa: E402 mid-file import.
polylogue/daemon/status.py Refactors detection-warnings count query error handling.
polylogue/paths/_roots.py Documents why XDG/legacy env reads remain for bootstrapping.
polylogue/pipeline/services/ingest_worker.py Formatting-only: wraps long tuple type aliases.
polylogue/storage/sqlite/schema_bootstrap.py Whitespace-only change (extra blank line).
Comments suppressed due to low confidence (1)

polylogue/readiness/init.py:483

  • term_detail appends POLYLOGUE_FORCE_PLAIN=1 based on load_polylogue_config().force_plain, which may be set via TOML/CLI rather than the env var. This makes the readiness report misleading. Consider reporting a source-agnostic flag (e.g. force_plain=1) or only mentioning POLYLOGUE_FORCE_PLAIN when the env var is actually present.
    force_plain = "1" if load_polylogue_config().force_plain else ""

    term_detail = f"TERM={term}, {cols}x{rows}, tty={is_tty}"
    if force_plain:
        term_detail += ", POLYLOGUE_FORCE_PLAIN=1"
    checks.append(ReadinessCheck("terminal", VerifyStatus.OK, summary=term_detail))

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

Comment on lines +63 to 66
env_path = load_polylogue_config().get("drive_credentials_path") or str(drive_credentials_path())
if env_path:
return Path(env_path).expanduser()

Comment on lines +92 to 95
env_path = load_polylogue_config().get("drive_token_path") or str(drive_token_path())
if env_path:
return Path(env_path).expanduser()

Comment thread polylogue/config.py
Comment on lines 270 to 279
def load_polylogue_config(
*,
config_path: Path | None = None,
cli_overrides: dict[str, object] | None = None,
) -> dict[str, object]:
) -> PolylogueConfig:
"""Load resolved Polylogue config with four-layer precedence.

Returns a dict suitable for constructing typed config models.
The dict always has all known keys with defaults applied.
Returns a typed ``PolylogueConfig`` with attribute access for
known keys and ``.get()`` / ``.raw`` for everything else.
"""
Comment thread polylogue/config.py
Comment on lines 280 to 293
@@ -213,6 +289,7 @@
"hooks_enabled": False,
"log_level": "INFO",
"force_plain": False,
"schema_validation": "advisory",
}
"""Return configured schema validation mode."""
if env_var == "POLYLOGUE_SCHEMA_VALIDATION":
raw = str(load_polylogue_config().get("schema_validation", default))
raw = load_polylogue_config().schema_validation
Comment on lines +9 to 10
from polylogue.config import Source, load_polylogue_config
from polylogue.core.timestamps import format_timestamp
Comment thread polylogue/logging.py
Comment on lines +14 to +15
from polylogue.config import load_polylogue_config

Comment on lines 19 to 22
logger = logging.getLogger(__name__)

if TYPE_CHECKING:
from polylogue.config import load_polylogue_config
from polylogue.storage.action_events.artifacts import ActionEventArtifactState
from polylogue.storage.action_events.artifacts import ActionEventArtifactState # noqa: E402

Comment on lines +927 to 930

_DETECTION_WARNINGS_COLUMN_DDL = "ALTER TABLE raw_conversations ADD COLUMN detection_warnings TEXT"


Comment on lines 314 to +323
try:
detection_warnings_count = int(
conn.execute(
"SELECT COUNT(*) FROM raw_conversations WHERE detection_warnings IS NOT NULL"
).fetchone()[0]
or 0
)
except sqlite3.OperationalError:
pass # Column may not exist yet (pre-migration)
with contextlib.suppress(sqlite3.OperationalError):
detection_warnings_count = int(
conn.execute(
"SELECT COUNT(*) FROM raw_conversations WHERE detection_warnings IS NOT NULL"
).fetchone()[0]
or 0
)
except Exception:
pass
Sinity added a commit that referenced this pull request May 7, 2026
Two acceptance-criteria leftovers.

- #839 (semantic artifacts): adds the resilience-fallback section
  to `polylogue/archive/message/model_runtime.py` documenting
  when the runtime classifier falls back from stored
  `message_type` to inline-text inspection — a behavior PR #836
  introduced but had not yet documented in code comments.
- #829 (config): consolidates four remaining
  `os.environ.get()` calls in `cli/query_progress.py`,
  `cli/shared/formatting.py`, `logging.py`, and
  `pipeline/services/validation_flow.py` through
  `load_polylogue_config()`, finishing the env-consolidation
  pass started in PR #910.

Refs #829, #839
Sinity added a commit that referenced this pull request May 7, 2026
Foundation slice for #829. Polylogue mixed hardcoded defaults,
scattered `os.environ.get()` calls, CLI flags, and partial
dataclasses; after #847 daemon convergence, embeddings, hook
install, auth, and health all need one config contract.

- `polylogue/config.py`: introduces `PolylogueConfig` dataclass
  with typed fields covering archive root, daemon settings,
  watch sources, embedding settings, and notification backend.
  `load_polylogue_config()` returns the typed instance and
  applies the four-layer precedence (defaults → TOML → env →
  flags) introduced in PR #889.
- Six previously direct `os.environ.get()` reads under
  `cli/query_progress.py`, `cli/shared/formatting.py`,
  `daemon/status.py`, `logging.py`, `paths/_roots.py`,
  `pipeline/services/{ingest_worker,validation_flow}.py` now go
  through the config object so future env additions land in one
  place.

Refs #829
Sinity added a commit that referenced this pull request May 7, 2026
Two acceptance-criteria leftovers.

- #839 (semantic artifacts): adds the resilience-fallback section
  to `polylogue/archive/message/model_runtime.py` documenting
  when the runtime classifier falls back from stored
  `message_type` to inline-text inspection — a behavior PR #836
  introduced but had not yet documented in code comments.
- #829 (config): consolidates four remaining
  `os.environ.get()` calls in `cli/query_progress.py`,
  `cli/shared/formatting.py`, `logging.py`, and
  `pipeline/services/validation_flow.py` through
  `load_polylogue_config()`, finishing the env-consolidation
  pass started in PR #910.

Refs #829, #839
Sinity added a commit that referenced this pull request May 7, 2026
Foundation slice for #829. Polylogue mixed hardcoded defaults,
scattered `os.environ.get()` calls, CLI flags, and partial
dataclasses; after #847 daemon convergence, embeddings, hook
install, auth, and health all need one config contract.

- `polylogue/config.py`: introduces `PolylogueConfig` dataclass
  with typed fields covering archive root, daemon settings,
  watch sources, embedding settings, and notification backend.
  `load_polylogue_config()` returns the typed instance and
  applies the four-layer precedence (defaults → TOML → env →
  flags) introduced in PR #889.
- Six previously direct `os.environ.get()` reads under
  `cli/query_progress.py`, `cli/shared/formatting.py`,
  `daemon/status.py`, `logging.py`, `paths/_roots.py`,
  `pipeline/services/{ingest_worker,validation_flow}.py` now go
  through the config object so future env additions land in one
  place.

Refs #829
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 60.F066 / P1: fixed-already at the checked revision: polylogue/cli/commands/config.py:80 builds the JSON-ready effective_config_payload from the typed configuration, while line 123 passes cfg.raw to the mapping-based TOML formatter. Neither output path treats PolylogueConfig itself as a dictionary.

Only the rows listed above are dispositioned. Held findings remain open.

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 70.F042 / P1: refuted at the checked revision: Current credential authority is the typed DriveConfig or canonical location, not the retired POLYLOGUE_CREDENTIAL_PATH interface. polylogue/sources/drive/auth.py:59 honors the configured path and lines 63-68 preserve the missing-default prompt; restoring the predecessor environment alias would contradict the compatibility-path rule at AGENTS.md:192-194.

Only the rows listed above are dispositioned. Held findings remain open.

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