Skip to content

refactor: loosen operation_context to a key allowlist + safe-value validation - #209

Open
arorashivam96 wants to merge 2 commits into
mainfrom
u/shivamarora/operation-context-agent-host-suffix
Open

arorashivam96 wants to merge 2 commits into
mainfrom
u/shivamarora/operation-context-agent-host-suffix

Conversation

@arorashivam96

@arorashivam96 arorashivam96 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Loosens OperationContext validation: skill and agent values are no longer checked against closed allowlists. The validator now enforces only:

  • the key allowlist — app, skill, agent (unknown keys rejected)
  • the safe-character pattern — alphanumerics, -, _, ., / (still excludes spaces, control characters, and the punctuation PII such as emails would need)
  • the app <name>/<version> format guard

Why

New agents and skills are added constantly. Enumerating their values server-side means every new agent or skill forces an SDK release before it can be attributed — and the enums had already drifted out of sync with the plugin (_ALLOWED_SKILLS was missing erp-xpp/dv-overview; _ALLOWED_AGENTS was missing gemini-cli/antigravity-cli). Validating the key is present and the value is safe keeps the PII/injection protection that matters, without the maintenance treadmill. This also means an agent/<surface> suffix like codex/jetbrains (used for JetBrains attribution in the companion dataverse-skills PR) is accepted with no further SDK change.

Change

OperationContext.__post_init__ drops _ALLOWED_SKILLS, _ALLOWED_AGENTS, _ALLOWED_HOSTS and their per-value checks. Key allowlist, safe-character regex, and app-format guard are unchanged.

Backward compatible: every string that was valid before is still valid. Only previously-rejected shapes (an unenumerated agent/skill, or an agent/<surface> suffix) now pass. Unknown keys, spaces, control characters, and emails are still rejected.

Tests

tests/unit/test_operation_context.py:

  • Replaced test_reject_unknown_skill / test_reject_unknown_agent (and the earlier host-suffix reject tests) with test_accepts_any_safe_skill_value and test_accepts_any_safe_agent_value (covering erp-xpp, future skills, gemini-cli, future agents, and codex/jetbrains).
  • Kept all PII / structural rejection tests (empty, email, spaces, control chars, unknown key, invalid app format).
  • pytest tests/unit/test_operation_context.py — 25 passed.

Version

1.0.1 → 1.1.0, changelog updated.

OperationContext now accepts an optional IDE-surface suffix on the agent value, written as agent/<host> (e.g. codex/jetbrains), drawn from a new closed host allowlist (jetbrains, vscode, cli). The agent value is split on '/': the base is validated against the agent allowlist and the optional suffix against the host allowlist; unknown bases and unknown suffixes are still rejected. Enables plugin/tool attribution to record the IDE surface while preserving the closed key/value allowlist model. Bumped 1.0.1 -> 1.1.0.
@arorashivam96
arorashivam96 requested a review from a team as a code owner October 9, 2026 23:01
Copilot AI balanced review requested due to automatic review settings October 9, 2026 23:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new changelog release lacks an accurate comparison reference and leaves the Unreleased link stale.

1 open finding
What changed in this PR

Adds optional allowlisted host suffixes to OperationContext agent values.

Changes:

  • Validates agent bases and optional host suffixes separately.
  • Adds validation tests.
  • Bumps version to 1.1.0 and updates the changelog.
File Description
src/​PowerPlatform/​Dataverse/​core/​config.py Adds host-suffix validation.
tests/​unit/​test_operation_context.py Tests accepted and rejected suffixes.
pyproject.toml Bumps package version.
CHANGELOG.md Documents the feature release.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2026-08-24
Drop the closed skill/agent/host value allowlists. New agents and skills are added constantly, so enumerating values forces an SDK release for every addition and the enums had already drifted. The validator now enforces the key allowlist (app/skill/agent), the safe-character pattern (still excludes spaces/control chars/PII), and the app <name>/<version> format. Any safe-charset agent/skill value is accepted, including an agent/<surface> suffix like codex/jetbrains. Unknown keys and unsafe characters are still rejected.
@arorashivam96 arorashivam96 changed the title feat: accept optional agent/<host> suffix in OperationContext refactor: loosen operation_context to a key allowlist + safe-value validation Oct 9, 2026
@arorashivam96
arorashivam96 requested a balanced review from Copilot October 9, 2026 23:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Arbitrary safe-character values can contain PII despite the documented protection guarantee.

2 open findings

🧠 Review effort: Balanced

Comment on lines +75 to +77
# Key allowlist + safe-value validation. Values are not enumerated (new
# agents/skills are added constantly); the _CONTEXT_PATTERN charset above
# already guards against spaces/control characters/PII.
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