fix: Add UI fields to PendingDeferral schema (fixes #514)#517
fix: Add UI fields to PendingDeferral schema (fixes #514)#517
Conversation
…reSQL support
This patch release fixes critical database path resolution issues in the
setup wizard that prevented users from persisting correctly in both SQLite
and PostgreSQL deployments.
### Changes
- **Fixed setup wizard database path bug** - Users created during setup now persist correctly
- Modified `_create_setup_users()` to accept `auth_db_path` parameter from running application
- Previously created new `EssentialConfig()` which defaulted to CWD-relative paths
- Now uses runtime's resolved database path ensuring consistency
- **Fixed central path resolution in EssentialConfig** - All database paths now use centralized path_resolution.py
- Added `default_factory` functions that call `get_data_dir()`
- Ensures correct paths across all three deployment modes:
- Managed/Docker mode: `/app/data/`
- Development mode: `<git_repo>/data/`
- Installed mode: `~/ciris/data/`
- **Fixed PostgreSQL backend support in setup wizard** - Uses `get_audit_db_full_path()`
- Setup wizard now correctly creates users in PostgreSQL when configured
- Previously only worked with SQLite deployments
- Matches the database resolution logic used by AuthenticationService
- **Fixed test suite** - Updated test signatures and fixtures
- Added `client_with_runtime` fixture for proper runtime mocking
- Updated 4 tests to match new `_create_setup_users()` signature
- All tests passing (6,675 passed, 38 skipped)
### Version
- Bumped to 1.6.5.3-stable
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add three UI compatibility fields directly to the PendingDeferral schema: - question: Optional display text for UI (defaults to None) - context: Additional context as JSONDict (defaults to empty dict) - timeout_at: ISO format timeout string (defaults to None) Simplify API route by removing transformation code - the schema now includes these fields natively, eliminating the need for runtime transformation. This fixes deferral details not being visible in the UI by ensuring the TypeScript SDK receives the expected fields from the API. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ 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".
| # Get pending deferrals (UI fields now included in PendingDeferral schema) | ||
| deferrals = await wa_service.get_pending_deferrals(wa_id=wa_id) | ||
|
|
||
| # Transform PendingDeferral to include question from reason for UI compatibility | ||
| # The TypeScript SDK expects a 'question' field | ||
| transformed_deferrals = [] | ||
| for d in deferrals: | ||
| # Create a dict representation and add the question field | ||
| deferral_dict = d.model_dump() | ||
| deferral_dict["question"] = d.reason # Use reason as the question | ||
| deferral_dict["context"] = {} # Add empty context for compatibility | ||
| deferral_dict["timeout_at"] = (d.created_at + timedelta(days=7)).isoformat() # Default 7 day timeout | ||
| transformed_deferrals.append(deferral_dict) | ||
|
|
||
| response = DeferralListResponse(deferrals=transformed_deferrals, total=len(transformed_deferrals)) | ||
| response = DeferralListResponse(deferrals=deferrals, total=len(deferrals)) |
There was a problem hiding this comment.
Pending deferral UI fields still empty
GET /v1/wa/deferrals now returns the raw PendingDeferral objects without the transformation that populated question, context, and timeout_at, but get_pending_deferrals constructs each PendingDeferral without setting those new fields (logic/services/governance/wise_authority/service.py lines 387-401). As a result the response still contains null/empty values for the UI-specific fields, so the WA dashboard will continue to miss the question/timeout details this fix targets.
Useful? React with 👍 / 👎.
The PendingDeferral schema was updated with question, context, and timeout_at fields, but the service method wasn't populating them. This caused the UI to continue showing empty values. Changes: - Populate question field from reason (for UI display) - Build rich context from deferral data including: - task_description: Full task description (up to 500 chars) - Any context fields from deferral_info (user_id, etc.) - original_message if available - Calculate timeout_at as created_at + 7 days (ISO format) This completes the fix for issue #514 - deferral details now visible in UI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
10df8c8 to
bd999f1
Compare
Release 1.6.6 includes: - PR #517: Fix deferral UI fields (issue #514) - PR #518: Fix setup display name (issue #515) - PR #519: Add Ally personal assistant template + consolidate templates folder 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Added release notes for: - PostgreSQL dialect odict_keys fix (#521, #522) - Deferral UI fields empty fix (#517) - DEBUG log level fixes (39 statements across 10 files) - Template consolidation (#519) - Wise Authority service refactoring - QA runner setup tests with template validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…#520) * Release v1.6.5.3: Fix setup wizard database path resolution and PostgreSQL support This patch release fixes critical database path resolution issues in the setup wizard that prevented users from persisting correctly in both SQLite and PostgreSQL deployments. ### Changes - **Fixed setup wizard database path bug** - Users created during setup now persist correctly - Modified `_create_setup_users()` to accept `auth_db_path` parameter from running application - Previously created new `EssentialConfig()` which defaulted to CWD-relative paths - Now uses runtime's resolved database path ensuring consistency - **Fixed central path resolution in EssentialConfig** - All database paths now use centralized path_resolution.py - Added `default_factory` functions that call `get_data_dir()` - Ensures correct paths across all three deployment modes: - Managed/Docker mode: `/app/data/` - Development mode: `<git_repo>/data/` - Installed mode: `~/ciris/data/` - **Fixed PostgreSQL backend support in setup wizard** - Uses `get_audit_db_full_path()` - Setup wizard now correctly creates users in PostgreSQL when configured - Previously only worked with SQLite deployments - Matches the database resolution logic used by AuthenticationService - **Fixed test suite** - Updated test signatures and fixtures - Added `client_with_runtime` fixture for proper runtime mocking - Updated 4 tests to match new `_create_setup_users()` signature - All tests passing (6,675 passed, 38 skipped) ### Version - Bumped to 1.6.5.3-stable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Add UI fields to PendingDeferral schema for issue #514 Add three UI compatibility fields directly to the PendingDeferral schema: - question: Optional display text for UI (defaults to None) - context: Additional context as JSONDict (defaults to empty dict) - timeout_at: ISO format timeout string (defaults to None) Simplify API route by removing transformation code - the schema now includes these fields natively, eliminating the need for runtime transformation. This fixes deferral details not being visible in the UI by ensuring the TypeScript SDK receives the expected fields from the API. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Use actual username in /auth/me endpoint for issue #515 The /auth/me endpoint was returning the wa-date format user_id (e.g., "wa-2025-11-24-03-40-04-427473") as the username, which was displayed in the setup wizard's welcome message. This fix fetches the actual username from the auth service. Changes: - Modified get_current_user() to inject auth_service dependency - Fetch user object via auth_service.get_user(auth.user_id) - Use user.name if available, fallback to auth.user_id if not found - Maintains type safety (mypy passes) Fixes #515 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: Add Ally personal assistant template and consolidate templates folder This commit introduces the Ally agent template and consolidates all templates to a single authoritative location for improved maintainability. Changes: - Add new Ally template (personal thriving assistant) - Evidence-based ethics (Google DeepMind 2024 autonomy principles) - California SB 243 compliant crisis response - TaskSchedulerService integration for reminders and goal tracking - Comprehensive SOPs for personal assistance, decision support, and crisis handling - Consolidate templates to single location - Remove root /ciris_templates/ folder (9 files) - Keep only ciris_engine/ciris_templates/ as authoritative source - Update generate_manifest.py to use consolidated path - Update signed manifest - All 7 production templates signed with Ed25519 - Manifest includes Ally with checksum sha256:381e5e96e5a6612d0f3ff225c20101c431e832c4dbe2dd04c00302a070001f8c - Root signature: Sr4Fc4KRLFieAaFy6zkCogl62nG93bzfAtzcYpdQa+K7FmmVPHnSustmM4LQ+5ZFRq+21Ms0SwJSc+Yr6gObCg== Verification: - Path resolution works correctly with consolidated folder - All templates load and validate successfully - Manifest signing tool updated and tested 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Populate UI fields in WiseAuthorityService.get_pending_deferrals The PendingDeferral schema was updated with question, context, and timeout_at fields, but the service method wasn't populating them. This caused the UI to continue showing empty values. Changes: - Populate question field from reason (for UI display) - Build rich context from deferral data including: - task_description: Full task description (up to 500 chars) - Any context fields from deferral_info (user_id, etc.) - original_message if available - Calculate timeout_at as created_at + 7 days (ISO format) This completes the fix for issue #514 - deferral details now visible in UI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Update tools/generate_template_manifest.py for consolidated templates Address PR review comment - update the unified manifest generator to: - Add ally template to TEMPLATES dict - Point to consolidated ciris_engine/ciris_templates path This ensures both manifest generators (tools/generate_template_manifest.py and tools/templates/generate_manifest.py) are in sync with the template consolidation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: Bump version to 1.6.6 Release 1.6.6 includes: - PR #517: Fix deferral UI fields (issue #514) - PR #518: Fix setup display name (issue #515) - PR #519: Add Ally personal assistant template + consolidate templates folder 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: PostgreSQL dialect extract_scalar odict_keys subscript error Convert keys() result to list before indexing since dict_keys/odict_keys view objects don't support subscripting with [0]. Fixes #521 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Change DEBUG info logged at INFO level to DEBUG level Reduces log noise in production by moving debug-level messages from INFO to DEBUG level across multiple files: - graph.py: add_graph_node debug messages - memory_service.py: LocalGraphMemoryService init debug - audit_service/service.py: audit entry creation debug - action_dispatcher.py: tool audit parameter debug - wakeup_processor.py: wakeup step processing debug - setup.py: auth database path debug - audit.py routes: audit entry conversion debug - mock_llm responses: message processing debug - main.py: exit point tracking debug 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: Reduce cognitive complexity in get_pending_deferrals Extract helper methods to reduce cognitive complexity from 24 to ~10: - _parse_deferral_context: Parse context JSON and extract deferral info - _priority_to_string: Convert integer priority to string representation - _build_ui_context: Build UI context dictionary from deferral data - _create_pending_deferral: Create PendingDeferral from parsed data Added 19 unit tests covering all helper methods with edge cases: - JSON parsing (valid, invalid, None, missing keys) - Priority conversion (high, medium, low, edge values) - UI context building (truncation, None handling, field extraction) - PendingDeferral creation (defaults, user_id extraction, timeout calc) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * test: Add template validation to setup QA tests Add custom validation for /v1/setup/templates endpoint to ensure: - default template (Datum) is present - ally template is present - At least 5 templates are returned - Template names match expected values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: QA runner template validation now parses Response object The custom_validation callback receives requests.Response, not parsed JSON. Fixed _validate_templates_response to call .json() on the response. Also added INFO level debug logging to setup routes _get_agent_templates() to help diagnose template loading issues in production. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Add type parameters to _parse_deferral_context return type 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: Update CHANGELOG for v1.6.6 release Added release notes for: - PostgreSQL dialect odict_keys fix (#521, #522) - Deferral UI fields empty fix (#517) - DEBUG log level fixes (39 statements across 10 files) - Template consolidation (#519) - Wise Authority service refactoring - QA runner setup tests with template validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: API adapter now respects --port CLI argument over .env values - Remove load_env_vars() calls after config is set from dict/object - CLI args should take precedence over .env file values - Also fix setup_tests.py to keep default admin password The adapter was calling load_env_vars() after applying the config dict, which caused .env values to override CLI args. Now the precedence is: 1. Defaults (lowest) 2. .env file 3. Environment variables 4. CLI arguments (highest) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>



Summary
Fixes #514 - Deferral details not visible in UI when logged in as admin
Problem
The WA Dashboard UI was unable to display deferral details because the
question,context, andtimeout_atfields were being stripped out during Pydantic validation.Root Cause
In commit
4bc9a338, the/deferralsendpoint was changed from returning raw dicts to using typedDeferralListResponse. The code added UI fields via runtime transformation, but thePendingDeferralschema didn't include these fields, so Pydantic silently dropped them during validation.Solution
Added UI fields to
PendingDeferralschema:question: Optional[str]- Question/description for UI displaycontext: JSONDict- Additional context for UItimeout_at: Optional[str]- ISO format timeout timestampSimplified API route:
Changes
ciris_engine/schemas/services/authority/wise_authority.py- Added 3 UI fieldsciris_engine/logic/adapters/api/routes/wa.py- Removed transformation logicTesting
Impact
🤖 Generated with Claude Code