Skip to content

Refactor for Identity-Aware Optimization#44

Merged
gitvishalshetty merged 8 commits into
commit01from
identity-aware-optimization-9012995880739134422
Jan 29, 2026
Merged

Refactor for Identity-Aware Optimization#44
gitvishalshetty merged 8 commits into
commit01from
identity-aware-optimization-9012995880739134422

Conversation

@gowthamrao
Copy link
Copy Markdown
Contributor

This PR refactors the coreason-optimizer package to implement "Identity-Aware Optimization" by mandating UserContext for key operations.

Key changes:

  1. Dependencies: Added coreason-identity.
  2. OptimizationClient: Created a new client class to manage optimization studies (stub/in-memory implementation) with strict identity auditing.
  3. StrategySelector: Created a new selector to validate optimization strategies against the user context.
  4. Data Loader: Updated Dataset.from_csv and from_jsonl to require UserContext and audit data access.
  5. CLI: Updated main.py to establish a system identity context and propagate it through the stack.
  6. Tests: Updated regression tests and added new tests to verify identity enforcement.

Note: UserContext.user_id is treated as a string based on the installed library version (0.4.2), deviating slightly from the prompt's get_secret_value() instruction which was incompatible with the library. Audit logs capture the user ID directly.


PR created automatically by Jules for task 9012995880739134422 started by @gowthamrao

- Added `coreason-identity` dependency.
- Implemented `OptimizationClient` in `src/coreason_optimizer/core/client.py` with in-memory state and audit logging.
- Added `StrategySelector` in `src/coreason_optimizer/strategies/selector.py` for identity-aware strategy selection.
- Updated `Dataset` loader in `src/coreason_optimizer/data/loader.py` to enforce `UserContext` and log data access.
- Updated CLI in `src/coreason_optimizer/main.py` to use `UserContext` and the new components.
- Updated existing tests and added `tests/test_identity_enforcement.py` to ensure 100% coverage and compliance.

Co-authored-by: gowthamrao <13936600+gowthamrao@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 3 commits January 29, 2026 00:47
- Added `coreason-identity` dependency.
- Implemented `OptimizationClient` in `src/coreason_optimizer/core/client.py` with in-memory state and audit logging.
- Added `StrategySelector` in `src/coreason_optimizer/strategies/selector.py` for identity-aware strategy selection.
- Updated `Dataset` loader in `src/coreason_optimizer/data/loader.py` to enforce `UserContext` and log data access.
- Updated CLI in `src/coreason_optimizer/main.py` to use `UserContext` and the new components.
- Updated existing tests and added `tests/test_identity_enforcement.py` to ensure 100% coverage and compliance.
- Fixed linting and type checking errors in tests.

Co-authored-by: gowthamrao <13936600+gowthamrao@users.noreply.github.com>
Updated `pyproject.toml` and `src/coreason_optimizer/__init__.py` to version 0.2.0.

Co-authored-by: gowthamrao <13936600+gowthamrao@users.noreply.github.com>
- Updated `pyproject.toml` and `src/coreason_optimizer/__init__.py` to version 0.2.0.
- Fixed linting error in `src/coreason_optimizer/main.py` (unused import).

Co-authored-by: gowthamrao <13936600+gowthamrao@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

google-labs-jules Bot and others added 4 commits January 29, 2026 01:09
- Updated `tests/test_logger_coverage.py` to correctly test the directory creation logic in `src/coreason_optimizer/utils/logger.py` by reloading the module after clearing the `logs` directory.
- Achieved 100% test coverage.

Co-authored-by: gowthamrao <13936600+gowthamrao@users.noreply.github.com>
- Updated `tests/test_logger_coverage.py` to correctly test the directory creation logic in `src/coreason_optimizer/utils/logger.py` by reloading the module after clearing the `logs` directory.
- Fixed linting error in `tests/test_logger_coverage.py` (unused imports).
- Achieved 100% test coverage.

Co-authored-by: gowthamrao <13936600+gowthamrao@users.noreply.github.com>
- Updated `tests/test_logger_coverage.py` to correctly test the directory creation logic in `src/coreason_optimizer/utils/logger.py` by reloading the module after clearing the `logs` directory.
- Fixed linting error in `tests/test_logger_coverage.py` (unused imports).
- Fixed `AttributeError` in test by using `logger.logger.remove()` to properly access the underlying loguru object.
- Achieved 100% test coverage.

Co-authored-by: gowthamrao <13936600+gowthamrao@users.noreply.github.com>
- Updated `tests/test_logger_coverage.py` to correctly test the directory creation logic in `src/coreason_optimizer/utils/logger.py` by reloading the module after clearing the `logs` directory.
- Fixed linting error in `tests/test_logger_coverage.py` (unused imports).
- Fixed `AttributeError` and Windows `PermissionError` in test by using `logger.logger.remove()` to properly access the underlying loguru object and release file handles.
- Achieved 100% test coverage.
@gitvishalshetty gitvishalshetty merged commit 950c331 into commit01 Jan 29, 2026
10 checks passed
@gitvishalshetty gitvishalshetty deleted the identity-aware-optimization-9012995880739134422 branch January 29, 2026 01:43
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