Skip to main content

Maintenance guide

This document is the operational guide for updating, validating, and releasing the SDK.

Principles​

  • Treat src/sasvi/_generated as generated output, not as source of truth.
  • Make source-of-truth changes in openapi_definitions, tools/generate_sdk/, or the handwritten runtime under src/sasvi.
  • Keep regeneration deterministic.
  • Run the full verification flow before shipping any API or runtime change.

Prerequisites​

uv sync --frozen

What to edit​

Edit these locations depending on the type of change:

  • OpenAPI service changes: the spec lock in tools/generate_sdk/_specs.py (the spec files themselves are downloaded, not committed)
  • Generation behavior changes: tools/generate_sdk/
  • Raw binding and client wiring: src/sasvi/api, src/sasvi/_client.py, src/sasvi/_runtime.py
  • Runtime, auth, and config behavior: src/sasvi/auth.py, src/sasvi/config.py
  • Capability and object layer: src/sasvi/documents, src/sasvi/alerts, src/sasvi/reference_lists, src/sasvi/search, src/sasvi/workflows, src/sasvi/entities
  • User-facing docs: README.md, website/docs/*.md, examples/*
  • Version numbers: pyproject.toml, src/sasvi/_version.py

Do not manually edit src/sasvi/_generated/* or the generated service facade files in src/sasvi/api/*.py.

Standard update workflow​

Updating to a new API version? Follow the dedicated API version-update runbook. It covers spec provenance, diffing the new spec with tools.spec_diff, the patch-failure triage guide, and the verification checklist. The steps below are the general regeneration mechanics.

1. Update the source specs​

Update the spec lock in tools/generate_sdk/_specs.py and openapi_definitions/SOURCES.md as described in API version updates. Diff the new spec against the pinned one first:

.venv/bin/python -m tools.spec_diff openapi_definitions/<old>.yml build/spec_refresh/<new>.yml

2. Regenerate the SDK​

Regenerate everything:

.venv/bin/python -m tools.generate_sdk

Or regenerate selected services only:

.venv/bin/python -m tools.generate_sdk --service alerts --service workflows

Generation writes transient artifacts into:

  • build/sdk_codegen/generate/<service>/normalized.yml
  • build/sdk_codegen/generate/<service>/openapi-python-client.json
  • build/sdk_codegen/generate/<service>/output/

Then it syncs the generated output into src/sasvi/_generated/<service>/ and the generated raw facade into src/sasvi/api/<service>.py.

3. Review the generated result​

Review both the normalized spec and the synced generated tree.

Focus on:

  • operation ID changes
  • removed or added endpoints
  • media type override changes
  • schema renames or collisions
  • request and response typing regressions
  • unexpected file churn across unrelated services

If the generated result looks wrong, fix the normalization logic rather than patching the generated output by hand.

4. Adjust the handwritten layer if needed​

Regeneration can require follow-up changes in handwritten code when:

  • new services or service paths are introduced
  • public raw binding needs to expose regenerated services under client.api
  • a feature module depends on renamed raw operations
  • auth or request semantics changed in a way the runtime should absorb
  • README or examples need new guidance

Common handwritten follow-up locations:

  • src/sasvi/api
  • src/sasvi/_client.py
  • src/sasvi/auth.py
  • src/sasvi/config.py
  • src/sasvi/documents
  • src/sasvi/alerts
  • src/sasvi/reference_lists
  • src/sasvi/search
  • src/sasvi/workflows
  • src/sasvi/entities

5. Run the full verification suite​

.venv/bin/python -m tools.verify

This performs, in order:

  • spec download and SHA-256 check (tools.generate_sdk --fetch)
  • generated drift check (tools.generate_sdk --check)
  • CI action pinning (tools.check_actions_pinned)
  • Copyright and license header on every source file (tools.check_source_headers)
  • Ruff lint
  • Ruff format check
  • docstring coverage (tools.check_docstrings)
  • sync/async twin parity (tools.check_twins, see Sync and async twins)
  • public API snapshot (tools.api_snapshot --check, see Public API snapshot)
  • CLI --json schemas (tools.build_cli_schemas --check): the JSON Schema files in src/sasvi/cli/schemas/json/ match the pydantic models. After changing a model or a version, run .venv/bin/python -m tools.build_cli_schemas and commit the files.
  • mypy on src/sasvi and tests/type_checks
  • non-live pytest with coverage enforcement and coverage.xml output
  • package build

It then prints two report-only advisories that never change the exit code: the live-coverage surface check (exported symbols with no live test and no # live-waiver:) and API-reference drift.

Additional validation commands​

Run non-live tests with enforced coverage directly:

.venv/bin/python -m tools.coverage_check

Live test suite​

The live suite (tests/live) runs against a real tenant and is opt-in (pytest --run-live). All the fixture configuration it needs (the entity types, relationships, and reference lists in the reserved sdt_ namespace) is declared in tests/live_fixtures/manifest.yaml and provisioned or verified automatically at session start.

Tiers​

Every live test carries a tier marker (live_read, live_data, or live_config); the session tier caps what may run. Tests above the session tier are skipped with an explicit tier-gated: reason.

TierAliasMarkerThe session may
1readlive_readread only
2datalive_datawrite data-plane records against the provisioned sdt_ fixtures
3configlive_configprovision config-plane objects (entity types, relationships, reference lists)

Set the session tier with SASVI_TEST_TIER, which accepts 1/2/3 or the aliases read/data/config (default: 2). At tier 2 the fixture namespace is only verified. If it does not match the manifest, the session fails with the residual plan: every fixture-bound test errors, the report records the drifted or missing objects, and the exit status is non-zero. A tenant that was never provisioned cannot produce a green tier-2 run. Tier 3 provisions any missing or drifted objects before the run; set SASVI_TEST_ALLOW_PROVISION=0 to forbid applying changes (the session then fails with the pending plan instead of mutating the tenant).

One test is opt-in on top of the tier: the tenant self-import (test_live_tenant_self_import_round_trips) sends the tenant's own transport archive and SDK bundle back into it. That rewrites every configuration provider with no dry run, so it skips unless SASVI_TEST_ALLOW_TENANT_IMPORT=1 is set, and it belongs on a throwaway tenant only.

Tenant prerequisites​

  • The test user must be a member of the standard sviusrs group, which is the only principal the manifest grants CRUD on every fixture entity. A user outside it sees the sdt_ types in the config plane while every data-plane call answers "entity type not found or no permission" (53 red tests with one cause on a blank tenant), so apply now refuses to provision until the membership exists: PUT /identities/groups/sviusrs/userMembers/<user>.
  • Tier 3 also requires config-plane administration rights (creating and altering entity types, relationships, and reference lists).
  • The workflow lifecycle test needs SASVI_WORKFLOW_TASK_ASSIGNEE=<user> (no default); it skips when unset.
  • The image tests need one image (file) category on sdt_person and on the sdt_note child. The manifest declares them (file_categories), and a tier-3 session or tools.live_provision apply creates them. At tier 3 the image tests fail when one is absent; below tier 3 they skip with the reason residual-missing: image-category.

The manifest provisions the sdt_ namespace and nothing else. The tests below discover what they need at session start and skip with a named residual-missing: reason when the tenant lacks it, so a blank tenant produces skips, not failures. Read the skipped outcomes of a report against this list:

TestsThe tenant must have
alert testsat least one alert; an alert domain with an active queue; at least one alert disposition, one of which prompts for a note, a reason or a document; an investigation entity type for the prompted-document flow
scenario testsa strategy with a scenario, or an alert that carries a scenario-fired event
workflow testsan enabled workflow definition bound to a listable, writable entity type; SASVI_WORKFLOW_TASK_ASSIGNEE
routing testsat least one alert routing rule
transport teststhe svi-transport service deployed
search teststhe SAND search index for sdt_person (below tier 2 the suite falls back to any indexed type with two readable documents)
validation teststhe SAND validation endpoint
identity tests/identities reachable by the test user
reference-list testsa tenant that supports the en-US locale

Connection settings come from the standard flags, the environment (SASVI_BASE_URL, SASVI_USERNAME, SASVI_PASSWORD, SASVI_VERIFY_SSL, SASVI_TIMEOUT), or a repo-root .env (autoloaded).

Writes outside the sdt_ namespace​

Most writes go to documents of the sdt_ types, which the per-test cleanup registry deletes and tools.live_janitor sweeps. A few tests change tenant objects the manifest does not own. Each restores what it changed at teardown, but a killed run or a tenant outage between the write and the teardown leaves the change behind, and no sweep reclaims it:

TestWhat it changesHow to undo it by hand
routing-rule tests in test_config_live.pyattaches a logic expression to the tenant's first alert routing ruleremove the currentScore EQ 2 expression from the rule
suppressed-scenario test in test_config_live.pysuppresses a scenario of a suite-created alert for 24 hoursdelete the suppression, or wait for it to expire
alert-domain test in test_config_live.pycreates an alert domain whose id starts with sdt_tools.live_janitor --yes sweeps it once its token has expired
workflow-definition test in test_workflows_live.pyrenames a workflow definition, then renames it backrestore the original name
alert tests in test_alerts_live.pychecks out and checks in alerts the suite created; dispositions them at teardowndisposition the alert

Timeouts​

Every live test gets a 1800-second timeout unless it sets its own. Live tests use pytest-timeout's signal method where SIGALRM exists (Linux, macOS), so an overrun raises inside the test and the fixtures tear down, including the cleanup registry. The offline suite keeps the thread method, which ends the whole process; on Windows live tests fall back to it, and a timed-out live test there leaves its documents for the janitor.

Commands​

Run the quick live smoke subset:

.venv/bin/python -m tools.live_run --smoke

Run the full live suite at a given tier (--fresh destroys and re-provisions the sdt_ namespace first; needs tier 3):

.venv/bin/python -m tools.live_run --tier 3
.venv/bin/python -m tools.live_run --tier 3 --fresh

Manage the sdt_ fixture namespace directly (plan/verify are read-only; destroy requires --yes; gc removes config-plane sdt_ orphans not in the manifest and is dry-run unless --yes):

.venv/bin/python -m tools.live_provision plan
.venv/bin/python -m tools.live_provision apply
.venv/bin/python -m tools.live_provision verify
.venv/bin/python -m tools.live_provision destroy --yes
.venv/bin/python -m tools.live_provision gc

Inspect the tenant catalogue and sdt_ namespace drift (read-only):

.venv/bin/python -m tools.live_drift

Sweep expired live-test documents (dry-run unless --yes):

.venv/bin/python -m tools.live_janitor --ttl-hours 24

Measure the live suite under coverage without enforcing a live-only threshold:

.venv/bin/python -m tools.live_coverage_check

This reports tenant-only coverage from .coverage.live. Add --include-offline to also run the offline suite into .coverage.offline and print the union; the two figures are always labelled, because only the first is tenant evidence.

Release runbook​

One ordered list. tools.verify proves the source tree is sound; the rest proves the artifact is, that a tenant has run the code, and that what gets published is what was tested. Keep the order: the API baseline has to be in the release commit, and the live report has to cite a commit that is not dirty.

  1. Check that the specs are current. python -m tools.release_check fails when developer.sas.com no longer serves a pinned spec. tools.verify does not notice, because it reuses local copies. Refresh the specs before anything else. Bump the version in pyproject.toml and src/sasvi/_version.py. They are two copies of one value; tests/test_wheel_smoke.py checks they agree.

  2. Move ## Unreleased in CHANGELOG.md under a ## <version> heading with today's date.

  3. Rewrite the API baseline in the same change: python -m tools.api_snapshot --write-baseline. The next release's breaking changes are measured from this baseline. Written after publishing, it absorbs every change that is still pending and hides it from the next release's check.

  4. The gate. python -m tools.verify exits 0, with no new advisory warnings.

  5. Every supported Python. python -m tools.verify_matrix --lowest. The gate runs on one interpreter, and CI only runs where GitHub Actions does. This syncs the locked dev environment for each of Python 3.11 to 3.14 and runs the offline suite, then installs the declared minimum core and CLI requirements with the built wheel and runs the CLI from outside the tree. A defect that only an older interpreter hits, or a lower bound nobody installs, fails here. It needs uv and network access.

  6. Performance budgets. python -m tools.perf_check --enforce-budgets. The micro baselines are machine-specific: compare on the machine and interpreter named under [provenance.micro] in perf/budgets.toml. A run on a slower machine is not a regression, and refreshing the baselines to make a red run green is not a fix. --refresh-baselines rewrites that provenance from the current environment, and the check prints a warning when the running machine, interpreter or Python version differs from that provenance. The allowed median delta is the larger of median_pct of the baseline and an absolute floor of median_ms, and the floor is capped at median_floor_pct of the baseline (1.0 for the micro suite), so a doubling fails for every benchmark while timer jitter on a 3 us function still passes. The check fails on a measurement that is not a finite, non-negative duration, and on a live benchmark with a p95 budget whose run has no per-round samples or fewer than five rounds; a refresh records no p95 for such a run, which is why the write benchmarks carry none.

  7. Wheel smoke. python -m tools.wheel_smoke on the oldest and newest supported Python. It builds the wheel, installs it into a clean venv, and imports it from a directory holding no source, so a module missing from the wheel or a broken entry point fails here rather than on a user's machine. It is opt-in because it needs a build and network access.

  8. Dependency and website checks. uvx pip-audit --path .venv --progress-spinner off, then (cd website && npm audit --json) > npm-audit.json; python -m tools.check_npm_audit npm-audit.json, which fails on any advisory without a current entry in website/audit-exceptions.json (each entry gives a reason and a review_by date; renew one only after checking that no patched release fits the Docusaurus ranges). Then npm run typecheck and npm run build from website/ on Node 22.12 or later.

  9. Commit the release candidate. Set live_verified_on in the compatibility metadata to today's date, the day of the live run below. git status --short shows only the version, changelog, baseline, that date and any intentional source, test, docs and lockfile changes. Commit them; the live run must test this commit, and nothing under src/ or tests/ may change after it.

  10. A full tier-3 live run with evidence on a tenant provisioned from tests/live_fixtures/manifest.yaml:

    SASVI_TEST_VIYA_CADENCE=<cadence> python -m tools.live_run --tier 3 --evidence

    --evidence refuses a dirty tree, a narrowed run (-k, -m, a test path) and any tier but 3. After a clean run it writes release-evidence/v<version>.json: the counts, the API versions each service reported, and the git tree hashes of src/ and tests/. It never records the tenant's host name. GitHub's runners cannot reach a tenant, so this file is how the release workflow knows the code it publishes was run against one.

    Then read artifacts/live/capability_report-<run_id>.json and check:

    • exit_status is 0 and failed is empty (failed also lists any fixture object that was drifted or failed, as kind:name)
    • git_commit is the candidate commit from step 9 and git_dirty is false
    • sdk_version matches the version being released
    • declared_viya_cadence names the cadence the release claims
    • exercised is non-zero, and outcomes shows the tier-3 capabilities as verified/passed rather than tier-gated
    • every skipped record is explained line by line: each reason names a tenant prerequisite from the table under Tenant prerequisites that the tenant lacks, or an opt-in the run did not set. A skip with no such explanation is a test that did not run for a reason nobody has looked at.

    A report whose git_dirty is true proves nothing about the release: it cannot be tied to a commit.

  11. Commit the evidence file. This is the release commit. It differs from the candidate only by release-evidence/, so the tree hashes still match. To release without a live run, commit {"waived": "<reason>"} as that file instead. The release notes then say so, and the decision stays in the history.

  12. Open the release pull request from the branch that holds the release commit, against main. CI runs on it.

  13. Merge the pull request (squash). Merging publishes nothing.

  14. Tag the merge commit and push the tag. Pushing it starts the release:

    git switch main && git pull --ff-only
    git log -1 # the release commit
    git tag -a v<version> -m "sasvi <version>"
    git push origin v<version>

    The release workflow refuses a tag that is not v<version> as pyproject.toml declares it, or whose commit is not on main. Then it runs release_check and the gate, one build smoke-tested and attested, an upload to TestPyPI, and an install of that upload on Python 3.11 and 3.14. If those pass, it uploads to PyPI, creates the GitHub release with the CHANGELOG section as notes, and deploys the docs. If the pypi environment has a required reviewer, the workflow waits for their approval before the PyPI upload. Without one, pushing the tag is the last decision.

When a release fails​

  • Before the PyPI upload (a check, the build, TestPyPI): for a temporary error, use Re-run failed jobs. Otherwise fix the cause in a new pull request and merge it. If TestPyPI does not hold the version yet, move the tag: git push origin :refs/tags/v<version>, git tag -d v<version>, then tag the new commit. If TestPyPI holds it, bump the version, because TestPyPI, like PyPI, never accepts a version twice. A change under src/ or tests/ needs a new live run, or a waiver.
  • After the PyPI upload (GitHub release, docs): use Re-run failed jobs. Do not re-run the whole workflow: release_check fails once the version is on PyPI. If the re-run does not help, create the release with gh release create v<version> --verify-tag, and run the deploy-doc workflow for the site. Never move the tag of a published version.

One-time setup for publishing​

The owner of the PyPI and TestPyPI projects adds the publishers. The release switch needs write access to the GitHub repository, and the rest needs admin.

  • PyPI and TestPyPI: add a trusted publisher for sasvi (a pending publisher until the first upload creates the project): owner sassoftware, repository SASVI, workflow release.yml, environment pypi on PyPI and testpypi on TestPyPI. No API token exists anywhere.
  • Release switch: the repository variable SASVI_RELEASE_ENABLED is true. Any other value makes a pushed tag publish nothing.
  • GitHub environments: the workflow uses testpypi and pypi. GitHub creates them the first time a job names them, without protection rules. An admin then limits both to v* tags and gives pypi the release maintainers as required reviewers.
  • Branch protection on main: changes only through pull requests, every verify, package, cli-highest and docs job from ci.yml as a required check, linear history (squash merges), and no direct pushes, including for admins.

Reading the capability report​

records[] holds one entry per test and per fixture object. kind is one of:

kindOne record per
testcollected live test (node id)
entity, child_entity, relationship, reference_list, permissionmanifest object, after the session verified it
provisionprovisioning step that failed (apply, destroy)

status depends on the kind:

statusKindMeaning
passed, failed, skippedtestthe pytest outcome; a teardown failure after a passing call records failed
tier-gatedtestskipped because the test's tier is above the session tier
verifiedobjectpresent and matching the manifest at tier 2
provisionedobjectwritten by this session at tier 3; reason says created or updated
reusedobjectpresent at tier 3 with nothing to change
driftedobjectpresent but different from the manifest
failedobject or provisionmissing from the tenant, or the step that failed; reason says which

Drift checking​

To verify that committed generated output matches what the current generator would produce:

.venv/bin/python -m tools.generate_sdk --check

Regeneration invariants​

These properties should continue to hold after maintenance changes:

  • generated output is deterministic between runs
  • internal SAS operations marked with x-sas-internal are excluded
  • weak or duplicate operation IDs are normalized into unique names
  • bearer auth security metadata is injected into normalized specs
  • unsupported media types are rewritten into forms the generator handles
  • _operation_index.py exists for every generated service
  • a generated concrete raw facade exists for each public raw service under src/sasvi/api
  • every facade method carries the generated operation's parameter and return types, and those annotations resolve at runtime (get_type_hints works)
  • no two operations claim the same facade method name, unless the name is in ALLOWED_OPERATION_NAME_COLLISIONS with its reason
  • importing a facade loads no operation module and no model. Each facade alias is _op_<operation module> bound to a _LazyOp, and each generated models/__init__.py imports a model when it is named (tests/test_lazy_generated_imports.py). Two operation modules with one name stop generation
  • SVIClient still exposes one raw facade per generated service: client.api.alerts, client.api.datahub, client.api.files, client.api.folders, client.api.sand, client.api.transport and client.api.workflows

The tests in tests/test_generation.py and tests/test_normalize.py exist primarily to protect those invariants.

Changing the generator​

When you modify tools/generate_sdk/ (module map in its in-repo README.md):

  1. regenerate the affected services
  2. inspect build/sdk_codegen/generate/*/normalized.yml
  3. review the generated file churn carefully
  4. add or update tests in tests/test_generation.py or tests/test_normalize.py
  5. run tools.verify

The custom endpoint template​

tools/generate_sdk/templates/endpoint_module.py.jinja replaces the generator's own endpoint template. It is the upstream file plus two blocks marked sasvi-stream. They give every operation with a binary 2xx response a stream() and a stream_async() function. These open the response with its body unread. The handwritten layer reads the body through sasvi._streaming, which applies max_response_bytes and maps transport failures, because a stream skips the retry loop that does both. The stream functions are not on the client.api facades.

The upstream template has no blocks to extend, so the file is a full copy. tests/test_generator_templates.py strips the two sasvi-stream blocks and compares the rest with the installed generator's template. After a generator upgrade that changes the template, that test fails. To fix it:

  1. copy the new upstream endpoint_module.py.jinja over ours
  2. put the two sasvi-stream blocks back: the first after the from ... import errors line, the second at the end of the file
  3. regenerate every service and check that only the binary operations gained stream() (the same test lists them)

Keep the _build_response body as upstream writes it: patch P-46 rewrites it and expects it exactly once per operation module.

Changing the handwritten runtime​

When you modify handwritten behavior:

  • add or update focused tests in tests/test_runtime.py
  • preserve the raw client.api.* coverage
  • avoid coupling handwritten behavior to unstable generated filenames unless the operation index already provides that contract
  • keep generated-vs-handwritten boundaries explicit
  • send every request through the hardened client (get_httpx_client() / get_async_httpx_client()). tests/test_raw_http_inventory.py parses every handwritten module and fails on one that builds or subclasses an httpx2 client, calls httpx2.get() and its siblings, or imports requests, urllib.request, urllib3, aiohttp or http.client. An exemption goes in that test's _ALLOWED with its reason

The handwritten layer should stay generic unless it is implementing a real feature module. Raw operation facades are generated artifacts; do not hand-write or hand-edit method-by-method aliases for generated operations.

Calling a generated operation from an admin service​

Admin services never name a generated operation in a string. They pass the bound facade method to _invoke, and its ParamSpec lets mypy check the operation name, the keywords, their types and the required arguments:

CallUse
self._invoke(self._api.op, **kw)raises the Admin* error on failure
self._invoke_or_none(self._api.op, **kw)returns None on a 404
await self._invoke_async(self._api.op_async, **kw)the generated _async twin
await self._invoke_or_none_async(self._api.op_async, **kw)the twin, None on a 404

Wrap the result in pythonize(...), bind_one(..., Record) or bind_many(..., Record) from sasvi._service_utils when the method returns plain Python or a record.

For a new service:

  1. Annotate the facade on the service class: _api: AlertsAPI, imported under TYPE_CHECKING from ..api. Without it _api is Any and mypy checks nothing. admin_scoped() keeps the facade type, and the runtime object stays the scoped proxy, so failures still raise Admin* errors. A class that calls two facades holds one small _AdminServiceBase subclass per facade, each with its own annotation (see IndexingService).
  2. Import UNSET from the same service's generated types module. Each service has its own Unset class, and mypy rejects the wrong one.
  3. Write an optional argument as start=_given(start, UNSET). Use _given_header(accept_item, UNSET) for an accept_item override: the facade types it as an enum, the public method takes any str, and the wire value is str(value).
  4. Sometimes the spec declares a type the public method does not take. Convert to the declared type only when the request stays byte-for-byte the same, and pin the request in tests/test_admin_typed_dispatch.py. Otherwise pass the value through a named helper whose docstring says why the facade's str() keeps the wire unchanged. _sand_if_match does this for SAND's integer-typed If-Match.
  5. Add a wrong-keyword case with # type: ignore[call-arg] to tests/type_checks/admin_typed_dispatch.py. warn_unused_ignores fails the gate if typing regresses.

Do not call self._api.op(start=UNSET) directly. _invoke drops UNSET keywords, so the facade's own defaults apply (start=0, limit=10, sortBy=creationTimeStamp:descending on get_queues). Passing UNSET through replaces those defaults and removes the parameters from the request.

tests/test_admin_operation_names.py keeps string dispatch from coming back. It parses every admin module and fails on:

  • a call whose first argument is a string naming a facade operation, whatever the helper is called
  • getattr or hasattr with a string naming an operation, and getattr on a facade with a name computed at runtime
  • an _AdminServiceBase subclass that calls self._api.<operation> without an _api: <Facade>API annotation, and a bare _AdminServiceBase(api=...)
  • a string dispatcher (_call, _python_call, _bind_one and the rest) reappearing on _AdminServiceBase

A hasattr probe that only picks between two calls written out in full goes in _NAME_PROBES_ALLOWED with a reason. An entry that no longer matches fails the run.

Sync and async twins​

Nearly every public sync method that does I/O has an _async twin, and the two are written by hand. Insight-cell and workspace-node editing are sync-only. tools.check_twins runs in the gate right after the docstring check. It pairs functions in one module by normalized qualified name (Alert.refresh with Alert.refresh_async, __enter__ with __aenter__), strips await, async def/for/with, the _async and Async name tokens, docstrings, decorators and annotations, and compares what is left.

  • An identical pair passes.
  • A pair whose async twin calls asyncio.to_thread is a thread bridge. The check reports it and does not fail.
  • A differing pair fails unless tools/twins_allowlist.json lists it under "module:Qual.name" with the sha of its normalized diff and a reason.
  • A listed pair whose sha no longer matches fails, so a second change to an allowlisted pair gets read again.
  • A stale entry fails: the pair is now identical, is now a thread bridge, or no longer exists.

When the step fails, first make the twins match. Add an entry only when the difference cannot change behaviour (log text, a lambda against an async def, list() against a comprehension, time.sleep against asyncio.sleep, a construct that exists only in native async). The reason names that difference for that pair. "Cosmetic" is not a reason.

.venv/bin/python -m tools.check_twins # the gate step
.venv/bin/python -m tools.check_twins --list # every differing pair and its sha
.venv/bin/python -m tools.check_twins --show sasvi.auth:ClientCredentialsTokenProvider.get_token

Public API snapshot​

tests/snapshots/public_api.json records the public surface: every name in the __all__ of sasvi, sasvi.errors, sasvi.admin, sasvi.search, sasvi.documents, sasvi.alerts, sasvi.workflows, sasvi.reference_lists, sasvi.types and sasvi.cli, the public classes and functions of sasvi.auth and sasvi.config, each class's bases, constructor, methods, properties and annotated attributes with their signatures, every sasvi.api.*API facade method with its signature, and the names each sasvi.types.<service> module exports. A class lists what it defines, not what it inherits. The tool reads no docstring.

tools.api_snapshot --check runs in the gate after the twin check. It prints what was added, removed and changed, and fails on any difference, an addition included, so the file always shows the surface a reviewer is approving.

When you change the surface on purpose:

  1. Run .venv/bin/python -m tools.api_snapshot --write.
  2. Review the diff of public_api.json with the code. Every line of it is a change a caller can see.
  3. Give a removal or a signature change a Changed (breaking). entry under "Unreleased" in CHANGELOG.md, with a **Migration:** line. An addition needs no entry for this check.

tests/test_public_api_snapshot.py enforces step 3. It compares public_api.json with public_api_baseline.json, the surface at the last release, and fails when a removed or changed entry is not named under "Unreleased". These spellings name sasvi.documents.Document.update: the full path, or Document.update. Document names the class entry and its constructor. A facade method is also named by its bare name (get_alert), a model by its bare name. A regeneration that changes a facade wholesale can name a parent with a wildcard instead, such as sasvi.api.AlertsAPI.*.

Signatures are rendered by the tool, not by str(inspect.signature()), and the file is identical on Python 3.11, 3.12, 3.13 and 3.14. Importing sasvi.cli needs the cli extra, which the dev extra includes.

.venv/bin/python -m tools.api_snapshot --check # the gate step
.venv/bin/python -m tools.api_snapshot --write # after an intended change
.venv/bin/python -m tools.api_snapshot --write-baseline # when a release is cut

Deprecating a public name​

Every deprecated alias goes through sasvi._deprecation. Do not call warnings.warn(..., DeprecationWarning) by hand, because a bare warning names no removal release and nothing holds a release to it. tests/test_deprecation.py rejects one.

from .._deprecation import deprecated


@deprecated(since="1.1.0", removed_in="1.3.0", replacement="HistoryManager.actions()")
def summary(self, *, start: int = 0, limit: int = 10) -> list[ActionSummaryRecord]:
return self.actions(start=start, limit=limit)

The decorator works on functions, methods and async def. The warning points at the caller's line, and the callable carries __deprecated__ = (since, removed_in, replacement). For a property or a deprecated keyword argument, record it at module level with register_deprecation(name, since=..., removed_in=..., replacement=...) and call .warn() on the returned entry where the name is used.

Each alias lands in a registry, and its name goes into the _ALIASES table in tests/test_deprecation.py; the test fails until the table and the registry agree. Every alias deprecated in 0.1.0 is now removed, so the table is empty. The test imports every handwritten module and fails once sasvi.__version__ reaches an entry's removed_in. When that test goes red on a version bump, delete the alias, give the removal a Changed (breaking). changelog entry with a **Migration:** line, and update the guides that mention it. Give a new alias at least two minor releases: an alias deprecated in 0.1.0 is removed in 0.3.0.

Versioning and release​

Publishing is automated: pushing a v<version> tag on main runs the release workflow, which uploads to TestPyPI, installs that upload, and then uploads to PyPI, creates the GitHub release and deploys the docs.

Releasing​

Follow the release runbook in full. It covers the version bump, the changelog and API-baseline change, every gate, the live run and its evidence, the release pull request, and the tag that publishes it. For a release that goes to a critical environment there is no extra list: the dependency and website checks (step 8) and the tier-3 live run (step 10) are part of the runbook, and tools.live_run --smoke is not a substitute for the latter.

Maintaining the Viya compatibility matrix​

The package is the source of truth for the current release. sasvi.compatibility() reads service API majors from the generator manifest and Viya cadences from _VIYA_CADENCES in src/sasvi/_compatibility.py. The matrix in website/docs/concepts/compatibility-and-viya-cadence.md and the README table repeat those values for readers, and tests/test_compatibility_docs.py fails when the current release's rows disagree with the package. List several cadences in one cell separated by , , and write None yet for an empty cell.

Monthly cadence update workflow​

  1. When SAS publishes a new monthly cadence, run python -m tools.generate_sdk --fetch --force. It downloads every pinned spec again and reports each one developer.sas.com has changed, keeping the new file under build/spec_refresh/ (see where specs come from). Check the service pages for a new major version too; --fetch only sees the majors it pins.
  2. Compare each changed file to the pinned one with python -m tools.spec_diff openapi_definitions/<old>.yml build/spec_refresh/<new>.yml.
  3. If there is no effective SDK or user-visible API change:
    • keep the current package version
    • append the new Stable yyyy.mm cadence to _VIYA_CADENCES and to the existing matrix row
    • append the matching LTS yyyy.mm cadence when applicable
    • when a live run passed on that cadence, set live_verified_on to the run date
    • add a note such as No SDK changes required; OpenAPI monthly refresh produced no user-visible delta
  4. If there is an SDK-relevant change:
    • update the spec lock (_specs.py and SOURCES.md)
    • regenerate and update the SDK using the standard workflow above
    • create a new compatibility row for the new package release, and reset _VIYA_CADENCES to the cadences that release was built and verified against
  5. Update the README compatibility summary so it still reflects the currently relevant release rows.

Compatibility matrix rules​

  • key compatibility by the pinned OpenAPI spec set, not by Python package version shape
  • document every verified monthly cadence explicitly, even when it reuses an existing SDK release
  • do not imply support for unverified Stable or LTS cadences
  • do not backfill historical cadence rows unless there is evidence for the exact mapping