Repository navigation
feat(platform-api-and-sdk): first-party logging namespaces and complete ledger service outcomes (XWING-2440) - #320
Conversation
PR Summary by QodoSupport first-party logging roots and safe ledger outcomes
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
View medium (5)🟠 **Medium** 1. Failed signing looks like a routine append
|
| def _log_outcome( | ||
| operation: str, | ||
| outcome: str, | ||
| duration_ms: float, | ||
| *, | ||
| level: int = logging.INFO, | ||
| **fields: object, |
There was a problem hiding this comment.
🟠 Medium
2. Ledger outcomes accept unchecked names 📜 Skill insight ≡ Correctness
The new _log_outcome helper accepts the finite operation and outcome values as plain str parameters instead of typed enums. Every append, seal, audit, checkpoint and verify record passes one of these closed sets through this helper, so misspelled values can reach structured logs without validation.
Agent Prompt
Issue description
`_log_outcome` represents the finite ledger operation and outcome sets as unrestricted strings, allowing invalid values to reach structured logs.
Fix Focus Areas
- src/traust_core/v1/services/ledger.py[60-66]
- src/traust_core/v1/services/ledger.py[156-164]
- src/traust_core/v1/services/ledger.py[183-191]
- src/traust_core/v1/services/ledger.py[221-228]
- src/traust_core/v1/services/ledger.py[271-279]
- src/traust_core/v1/services/ledger.py[289-297]
Recommended Fix
Define StrEnum types for the finite ledger operation and outcome values, annotate `_log_outcome` with those enums, and pass enum members at each call site. Serialize the enum values when constructing the log message and structured fields.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
769e47e to
f415aec
Compare
Plan:
plans/traust-standardization/8-platform-api-and-sdk/18-shaun-first-party-logging-namespaces.mdWhat
Context.configure_logging(...)register explicit first-party logger roots while keepingtraust_coremandatory and leaving Python's root and third-party loggers untouchedtraust_core.v1.contextAPI for consumer entry pointsReview resolutions
Three independent read-only reviews covered handler lifecycle/security, ledger transaction semantics, and regressions/tests.
Verification
make lint-fixmake test: 8,155 passed, 1 skippedReviewer checks (from the plan)
Quality checklist
Legacy files
Changed tests
test_default_info_and_project_only_level_overridestraust_core.*level overrides were accepted → renamed for first-party overrides and provestraust_engine.*is accepted while dependencies remain rejectedDependencies
This is the first PR in the logging follow-up chain. Ledger provider diagnostics and their Core integration are separate reviewable PRs; this PR does not pin or depend on those changes.