Skip to content

Stabilize modern client compatibility and promote .github/agent.md to agent source of truth#71

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/integrate-upstream-agent-skill
Open

Stabilize modern client compatibility and promote .github/agent.md to agent source of truth#71
Copilot wants to merge 5 commits into
mainfrom
copilot/integrate-upstream-agent-skill

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

This change addresses two gaps in the repo’s current state: the repository agent configuration was split between reference and active files, and the modern client path advertised capabilities that were not reliable at runtime. The update makes .github/agent.md the canonical agent definition and fixes the highest-severity compatibility issues in CMSClient, transport handling, auth parsing, and REST defaults.

  • Agent source of truth

    • Promote /home/runner/work/CMS-NBI-Client/CMS-NBI-Client/.github/agent.md to the canonical repository agent definition
    • Record upstream nullroute-commits/agency-agents provenance, adopted skill families, and sync policy
    • Clarify that downstream agent bootstrap files are derived from this source
  • Modern client runtime compatibility

    • Reintroduce CMSClient.e7 through a compatibility facade over the legacy E7 operation modules
    • Add legacy-compatible client fields (cms_nbi_config, cms_netconf_url, session_id, cms_user_nm) so shared modules can operate against CMSClient
    • Expose e7 and rest through SyncCMSClient after connection
  • Transport and auth correctness

    • Fix AsyncHTTPTransport to return a live response object instead of one closed by an async with scope
    • Map transport failures into project exceptions for timeout/network/HTTP failures
    • Replace auth response string matching with secure XML parsing and typed auth failures
    • Ensure response resources are explicitly consumed or released on client auth/logout paths
  • REST compatibility

    • Fix REST query default resolution for both legacy and modern clients
    • Support observed CMS response envelopes that return either data or devices
    • Preserve compatibility for callers while allowing config-driven defaults from CMSClient
  • Security and package behavior

    • Add safe XML building support to the secure XML handler
    • Reuse a shared secure XML handler for parsing helpers
    • Remove import-time logging initialization from package import side effects
    • Allow legacy login/logout requests to use HTTPS code paths instead of leaving them unimplemented
  • Docs alignment

    • Update README.md to reflect the actual current API surface and transition status
    • Remove claims that implied complete async E7 parity or fully finished legacy migration
  • Regression coverage

    • Add focused tests for:
      • modern client compatibility surface
      • transport response lifecycle
      • XML auth parsing
      • REST defaults for CMSClient
      • secure XML helper behavior

Example of the restored compatibility surface:

from cmsnbiclient import CMSClient, Config

config = Config(
    credentials={"username": "user", "password": "pass"},
    connection={"protocol": "http", "host": "cms.example.com", "verify_ssl": False},
)

async with CMSClient(config) as client:
    devices = client.rest.query.device(device_type="e7")
    onts = client.e7.query.system(network_nm="NTWK-1")

Copilot AI and others added 5 commits May 19, 2026 15:54
Agent-Logs-Url: https://github.com/nullroute-commits/CMS-NBI-Client/sessions/564b3bc0-18f8-4f1d-92df-55912d6ca1f0

Co-authored-by: nullroute-commits <59403925+nullroute-commits@users.noreply.github.com>
Agent-Logs-Url: https://github.com/nullroute-commits/CMS-NBI-Client/sessions/564b3bc0-18f8-4f1d-92df-55912d6ca1f0

Co-authored-by: nullroute-commits <59403925+nullroute-commits@users.noreply.github.com>
Agent-Logs-Url: https://github.com/nullroute-commits/CMS-NBI-Client/sessions/564b3bc0-18f8-4f1d-92df-55912d6ca1f0

Co-authored-by: nullroute-commits <59403925+nullroute-commits@users.noreply.github.com>
Agent-Logs-Url: https://github.com/nullroute-commits/CMS-NBI-Client/sessions/564b3bc0-18f8-4f1d-92df-55912d6ca1f0

Co-authored-by: nullroute-commits <59403925+nullroute-commits@users.noreply.github.com>
Agent-Logs-Url: https://github.com/nullroute-commits/CMS-NBI-Client/sessions/564b3bc0-18f8-4f1d-92df-55912d6ca1f0

Co-authored-by: nullroute-commits <59403925+nullroute-commits@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

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 consolidates the repository’s agent configuration by promoting .github/agent.md as the canonical source, and stabilizes the “modern” CMSClient runtime compatibility layer by restoring legacy E7 and REST behaviors, improving transport response lifecycles, and tightening XML auth parsing.

Changes:

  • Promote .github/agent.md as the agent source of truth and align docs to the current transitional API surface.
  • Restore modern-client compatibility by adding legacy fields/facades (e7, REST defaults, compatibility config fields) and exposing e7/rest via SyncCMSClient.
  • Fix transport/auth correctness with live response returns, exception mapping, safer XML parsing, and added regression tests.

Reviewed changes

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

Show a summary per file
File Description
tests/unit/test_modern_client.py Adds regression tests covering transport lifecycle, XML auth parsing, REST defaults, and secure XML helpers.
tests/unit/test_imports.py Ensures CMSClient exposes the documented legacy-compatibility surface.
src/cmsnbiclient/security/xml.py Implements XML building and introduces a shared safe-parse helper.
src/cmsnbiclient/REST/query.py Resolves REST defaults for legacy vs modern clients and supports multiple response envelopes.
src/cmsnbiclient/core/transport.py Returns live aiohttp responses and maps transport failures to project exceptions.
src/cmsnbiclient/client.py Enables legacy login/logout code paths for both HTTP and HTTPS without stubs.
src/cmsnbiclient/client_v2.py Reintroduces e7 via a legacy facade, adds legacy-compatible fields, improves auth parsing, and exposes e7/rest on SyncCMSClient.
src/cmsnbiclient/__init__.py Removes import-time logging initialization side effects.
README.md Updates documentation to reflect the current transitional status and compatibility surface.
.github/agent.md Establishes canonical agent definition plus provenance and sync policy.

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

default_node = config["cms_nodes"]["default"]
connection = default_node["connection"]
credentials = default_node["cms_creds"]
protocol = connection["protocol"]["http"]
Comment on lines 111 to +118
response.raise_for_status()
return response
except asyncio.TimeoutError as exc:
raise TimeoutError(f"Request timed out for {method} {url}") from exc
except aiohttp.ClientResponseError as exc:
raise ConnectionError(
f"HTTP {exc.status} error for {method} {url}: {exc.message}"
) from exc
Comment on lines +84 to +90
def _build_element(self, name: str, value: Any) -> str:
"""Recursively build a safely escaped XML element string."""
if isinstance(value, dict):
attributes = value.get("@attributes", {})
attr_text = "".join(
f" {key}={quoteattr(str(attr_value))}" for key, attr_value in attributes.items()
)
Comment thread README.md
admin_state="enabled"
)
print(result)
devices = client.rest.query.device(device_type="e7")
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.

3 participants