Maintenance guide
This document is the operational guide for updating, validating, and releasing the SDK.
Principles
- Treat
src/sasvi/_generatedas generated output, not as source of truth. - Make source-of-truth changes in
openapi_definitions,tools/generate_sdk/, or the handwritten runtime undersrc/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.ymlbuild/sdk_codegen/generate/<service>/openapi-python-client.jsonbuild/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/apisrc/sasvi/_client.pysrc/sasvi/auth.pysrc/sasvi/config.pysrc/sasvi/documentssrc/sasvi/alertssrc/sasvi/reference_listssrc/sasvi/searchsrc/sasvi/workflowssrc/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
--jsonschemas (tools.build_cli_schemas --check): the JSON Schema files insrc/sasvi/cli/schemas/json/match the pydantic models. After changing a model or a version, run.venv/bin/python -m tools.build_cli_schemasand commit the files. - mypy on
src/sasviandtests/type_checks - non-live pytest with coverage enforcement and
coverage.xmloutput - 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.
| Tier | Alias | Marker | The session may |
|---|---|---|---|
| 1 | read | live_read | read only |
| 2 | data | live_data | write data-plane records against the provisioned sdt_ fixtures |
| 3 | config | live_config | provision 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
sviusrsgroup, which is the only principal the manifest grants CRUD on every fixture entity. A user outside it sees thesdt_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), soapplynow 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_personand on thesdt_notechild. The manifest declares them (file_categories), and a tier-3 session ortools.live_provision applycreates them. At tier 3 the image tests fail when one is absent; below tier 3 they skip with the reasonresidual-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:
| Tests | The tenant must have |
|---|---|
| alert tests | at 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 tests | a strategy with a scenario, or an alert that carries a scenario-fired event |
| workflow tests | an enabled workflow definition bound to a listable, writable entity type; SASVI_WORKFLOW_TASK_ASSIGNEE |
| routing tests | at least one alert routing rule |
| transport tests | the svi-transport service deployed |
| search tests | the SAND search index for sdt_person (below tier 2 the suite falls back to any indexed type with two readable documents) |
| validation tests | the SAND validation endpoint |
| identity tests | /identities reachable by the test user |
| reference-list tests | a 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:
| Test | What it changes | How to undo it by hand |
|---|---|---|
routing-rule tests in test_config_live.py | attaches a logic expression to the tenant's first alert routing rule | remove the currentScore EQ 2 expression from the rule |
suppressed-scenario test in test_config_live.py | suppresses a scenario of a suite-created alert for 24 hours | delete the suppression, or wait for it to expire |
alert-domain test in test_config_live.py | creates 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.py | renames a workflow definition, then renames it back | restore the original name |
alert tests in test_alerts_live.py | checks out and checks in alerts the suite created; dispositions them at teardown | disposition 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.
-
Check that the specs are current.
python -m tools.release_checkfails when developer.sas.com no longer serves a pinned spec.tools.verifydoes not notice, because it reuses local copies. Refresh the specs before anything else. Bump the version inpyproject.tomlandsrc/sasvi/_version.py. They are two copies of one value;tests/test_wheel_smoke.pychecks they agree. -
Move
## UnreleasedinCHANGELOG.mdunder a## <version>heading with today's date. -
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. -
The gate.
python -m tools.verifyexits 0, with no new advisory warnings. -
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 needsuvand network access. -
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]inperf/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-baselinesrewrites 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 ofmedian_pctof the baseline and an absolute floor ofmedian_ms, and the floor is capped atmedian_floor_pctof 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. -
Wheel smoke.
python -m tools.wheel_smokeon 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. -
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 inwebsite/audit-exceptions.json(each entry gives a reason and areview_bydate; renew one only after checking that no patched release fits the Docusaurus ranges). Thennpm run typecheckandnpm run buildfromwebsite/on Node 22.12 or later. -
Commit the release candidate. Set
live_verified_onin the compatibility metadata to today's date, the day of the live run below.git status --shortshows 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 undersrc/ortests/may change after it. -
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--evidencerefuses a dirty tree, a narrowed run (-k,-m, a test path) and any tier but 3. After a clean run it writesrelease-evidence/v<version>.json: the counts, the API versions each service reported, and the git tree hashes ofsrc/andtests/. 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>.jsonand check:exit_statusis0andfailedis empty (failedalso lists any fixture object that wasdriftedorfailed, askind:name)git_commitis the candidate commit from step 9 andgit_dirtyisfalsesdk_versionmatches the version being releaseddeclared_viya_cadencenames the cadence the release claimsexercisedis non-zero, andoutcomesshows the tier-3 capabilities asverified/passedrather thantier-gated- every
skippedrecord is explained line by line: eachreasonnames 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_dirtyistrueproves nothing about the release: it cannot be tied to a commit. -
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. -
Open the release pull request from the branch that holds the release commit, against
main. CI runs on it. -
Merge the pull request (squash). Merging publishes nothing.
-
Tag the merge commit and push the tag. Pushing it starts the release:
git switch main && git pull --ff-onlygit log -1 # the release commitgit tag -a v<version> -m "sasvi <version>"git push origin v<version>The
releaseworkflow refuses a tag that is notv<version>aspyproject.tomldeclares it, or whose commit is not onmain. Then it runsrelease_checkand 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 thepypienvironment 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 undersrc/ortests/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_checkfails once the version is on PyPI. If the re-run does not help, create the release withgh release create v<version> --verify-tag, and run thedeploy-docworkflow 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): ownersassoftware, repositorySASVI, workflowrelease.yml, environmentpypion PyPI andtestpypion TestPyPI. No API token exists anywhere. - Release switch: the repository variable
SASVI_RELEASE_ENABLEDistrue. Any other value makes a pushed tag publish nothing. - GitHub environments: the workflow uses
testpypiandpypi. GitHub creates them the first time a job names them, without protection rules. An admin then limits both tov*tags and givespypithe release maintainers as required reviewers. - Branch protection on
main: changes only through pull requests, everyverify,package,cli-highestanddocsjob fromci.ymlas 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:
kind | One record per |
|---|---|
test | collected live test (node id) |
entity, child_entity, relationship, reference_list, permission | manifest object, after the session verified it |
provision | provisioning step that failed (apply, destroy) |
status depends on the kind:
status | Kind | Meaning |
|---|---|---|
passed, failed, skipped | test | the pytest outcome; a teardown failure after a passing call records failed |
tier-gated | test | skipped because the test's tier is above the session tier |
verified | object | present and matching the manifest at tier 2 |
provisioned | object | written by this session at tier 3; reason says created or updated |
reused | object | present at tier 3 with nothing to change |
drifted | object | present but different from the manifest |
failed | object or provision | missing 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-internalare 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.pyexists 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_hintsworks) - no two operations claim the same facade method name, unless the name is in
ALLOWED_OPERATION_NAME_COLLISIONSwith 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 generatedmodels/__init__.pyimports a model when it is named (tests/test_lazy_generated_imports.py). Two operation modules with one name stop generation SVIClientstill exposes one raw facade per generated service:client.api.alerts,client.api.datahub,client.api.files,client.api.folders,client.api.sand,client.api.transportandclient.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):
- regenerate the affected services
- inspect
build/sdk_codegen/generate/*/normalized.yml - review the generated file churn carefully
- add or update tests in
tests/test_generation.pyortests/test_normalize.py - 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:
- copy the new upstream
endpoint_module.py.jinjaover ours - put the two
sasvi-streamblocks back: the first after thefrom ... import errorsline, the second at the end of the file - 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.pyparses every handwritten module and fails on one that builds or subclasses anhttpx2client, callshttpx2.get()and its siblings, or importsrequests,urllib.request,urllib3,aiohttporhttp.client. An exemption goes in that test's_ALLOWEDwith 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:
| Call | Use |
|---|---|
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:
- Annotate the facade on the service class:
_api: AlertsAPI, imported underTYPE_CHECKINGfrom..api. Without it_apiisAnyand mypy checks nothing.admin_scoped()keeps the facade type, and the runtime object stays the scoped proxy, so failures still raiseAdmin*errors. A class that calls two facades holds one small_AdminServiceBasesubclass per facade, each with its own annotation (seeIndexingService). - Import
UNSETfrom the same service's generatedtypesmodule. Each service has its ownUnsetclass, and mypy rejects the wrong one. - Write an optional argument as
start=_given(start, UNSET). Use_given_header(accept_item, UNSET)for anaccept_itemoverride: the facade types it as an enum, the public method takes anystr, and the wire value isstr(value). - 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'sstr()keeps the wire unchanged._sand_if_matchdoes this for SAND's integer-typedIf-Match. - Add a wrong-keyword case with
# type: ignore[call-arg]totests/type_checks/admin_typed_dispatch.py.warn_unused_ignoresfails 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
getattrorhasattrwith a string naming an operation, andgetattron a facade with a name computed at runtime- an
_AdminServiceBasesubclass that callsself._api.<operation>without an_api: <Facade>APIannotation, and a bare_AdminServiceBase(api=...) - a string dispatcher (
_call,_python_call,_bind_oneand 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_threadis a thread bridge. The check reports it and does not fail. - A differing pair fails unless
tools/twins_allowlist.jsonlists it under"module:Qual.name"with theshaof its normalized diff and areason. - A listed pair whose
shano 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:
- Run
.venv/bin/python -m tools.api_snapshot --write. - Review the diff of
public_api.jsonwith the code. Every line of it is a change a caller can see. - Give a removal or a signature change a
Changed (breaking).entry under "Unreleased" inCHANGELOG.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
- 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 underbuild/spec_refresh/(see where specs come from). Check the service pages for a new major version too;--fetchonly sees the majors it pins. - Compare each changed file to the pinned one with
python -m tools.spec_diff openapi_definitions/<old>.yml build/spec_refresh/<new>.yml. - If there is no effective SDK or user-visible API change:
- keep the current package version
- append the new
Stable yyyy.mmcadence to_VIYA_CADENCESand to the existing matrix row - append the matching
LTS yyyy.mmcadence when applicable - when a live run passed on that cadence, set
live_verified_onto the run date - add a note such as
No SDK changes required; OpenAPI monthly refresh produced no user-visible delta
- If there is an SDK-relevant change:
- update the spec lock (
_specs.pyandSOURCES.md) - regenerate and update the SDK using the standard workflow above
- create a new compatibility row for the new package release, and reset
_VIYA_CADENCESto the cadences that release was built and verified against
- update the spec lock (
- 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