Interfaces and versions¶
interface
¶
The semantic interface of a package version.
What dependents of a package rely on is more than the names its modules
export. A PackageInterface lists one InterfaceSymbol per exported
declaration, per constructor, per sample site of an exported program, and
per data parameter of an exported program, each with:
- a path, how dependents spell it (
worlds.boolean.World,worlds.boolean.model.prior); - an identity that no spelling enters: the declaration's content hash
(
quivers.qiec.content_hash), a constructor's family hash and ordinal, a site's identity (quivers.dsl.modules.sites), or a data parameter's program hash and ordinal, so a renamed symbol keeps its identity; - facts dependents can observe, each a digest in which references to other
declarations are their content hashes, so renaming a family does not
change the type of a computation over it: the
type(a computation's parameter and result types, a family's shape, a program's arguments), theeffectsrow, a site'ssupport(its family, plate, and axes), and a data parameter'sindextype; - the
body, the declaration's whole content hash, which a change to a body alone moves.
qvr bump compares two interfaces symbol by symbol; the dependency lenses
(quivers.packages.lenses) map one onto the other.
DATA_ROLES
module-attribute
¶
Program parameter roles a dependent binds to data rather than passes.
SIGNATURE_KINDS
module-attribute
¶
Declaration kinds with a signature apart from their body: a change to the body alone keeps their interface. Any change to a declaration of another kind changes its shape, which dependents see.
InterfaceSymbol
didactic-model
¶
InterfaceSymbol(*, path: str, kind: str, module: str, identity: str, origin: str = '', type: str = '', effects: str = '', support: str = '', index: str = '', body: str = '', fitted: bool = False, display: str = '')
Bases: Model
One thing a dependent of a package can name or rely on.
| ATTRIBUTE | DESCRIPTION |
|---|---|
path |
How dependents spell it: the exposing module's path, then the name, then (for a site or data parameter) its label.
TYPE:
|
kind |
TYPE:
|
module |
The exposing module.
TYPE:
|
origin |
The declaring module's path and the name there, as name resolution reports it (empty for a site or data parameter).
TYPE:
|
identity |
The rename-stable identity.
TYPE:
|
type |
The digest of its type or shape.
TYPE:
|
effects |
The digest of its effect row (computations).
TYPE:
|
support |
What fixes a site's support: its family, plate, and axes.
TYPE:
|
index |
The digest of a data parameter's index type and axes.
TYPE:
|
body |
The declaration's whole content hash.
TYPE:
|
fitted |
For a program: whether it is fit to data (it observes, or takes data parameters).
TYPE:
|
display |
How messages show it: the declaring line, or a site's family.
TYPE:
|
PackageInterface
didactic-model
¶
PackageInterface(*, package: str, version: Version, symbols: tuple[InterfaceSymbol, ...] = ())
Bases: Model
The semantic interface of one package version.
| ATTRIBUTE | DESCRIPTION |
|---|---|
package |
The package.
TYPE:
|
version |
The version.
TYPE:
|
symbols |
Every symbol, by path.
TYPE:
|
symbol
¶
symbol(path: str) -> InterfaceSymbol | None
The symbol at a path.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
A symbol path.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
InterfaceSymbol | None
|
The symbol, or |
Source code in src/quivers/packages/interface.py
to_data
¶
The interface as JSON-compatible data.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, object]
|
The package, version, and symbols. |
Source code in src/quivers/packages/interface.py
package_interface
¶
package_interface(package: str, version: Version, modules: Iterable[BuiltModule]) -> PackageInterface
The semantic interface of a package's exposed modules.
| PARAMETER | DESCRIPTION |
|---|---|
package
|
The package's name.
TYPE:
|
version
|
Its version.
TYPE:
|
modules
|
Its exposed modules, checked.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PackageInterface
|
Every symbol of every module, by path. |
Source code in src/quivers/packages/interface.py
bump
¶
Semantic versions computed from interface diffs.
A package's version says how a dependent is affected by moving to it, so it
is computed rather than chosen [@lam2020putting]. diff_interfaces compares
the interfaces of two versions (quivers.packages.interface) symbol by
symbol and classifies every change:
| change | level |
|---|---|
| an export or sample site removed or renamed | major |
| a type, a family's shape, a support, an effect row, or a data parameter's index type changed | major |
| a symbol's kind changed | major |
| a site added that must be observed, or a data parameter added | major |
| an export added, or a sample site added (it has a default: its prior) | minor |
| the body of an exported program fit to data changed | minor |
| a body changed under an unchanged interface | patch |
The version a change needs is the old version bumped at the largest level
(Version.bumped). InterfaceDiff.check refuses a proposed version that
understates the change, naming every change it understates.
ChangeCategory
¶
ChangeCategory = Literal['removed', 'renamed', 'added', 'added-site', 'kind', 'type', 'effects', 'support', 'index', 'fitted-body', 'body']
What kind of change one InterfaceChange is.
BumpError
¶
Bases: ValueError
A proposed version that understates its interface change.
Its message says the proposed and required versions, and the changes that require more.
InterfaceChange
didactic-model
¶
InterfaceChange(*, level: ChangeLevel, category: ChangeCategory, symbol: str, renamed_to: str = '', detail: str)
Bases: Model
One change between two interfaces.
| ATTRIBUTE | DESCRIPTION |
|---|---|
level |
How much it moves the version.
TYPE:
|
category |
What changed.
TYPE:
|
symbol |
The symbol's old path (its new path for an addition).
TYPE:
|
renamed_to |
For a rename, the new path.
TYPE:
|
detail |
A sentence describing the change.
TYPE:
|
render
¶
InterfaceDiff
didactic-model
¶
InterfaceDiff(*, package: str, old_version: Version, changes: tuple[InterfaceChange, ...] = (), lens: DependencyLens)
Bases: Model
The changes from one version of a package's interface to another.
| ATTRIBUTE | DESCRIPTION |
|---|---|
package |
The package.
TYPE:
|
old_version |
The version compared against.
TYPE:
|
changes |
Every change, by symbol.
TYPE:
|
lens |
The lens dependents migrate along.
TYPE:
|
level
property
¶
level: ChangeLevel
The largest change.
| RETURNS | DESCRIPTION |
|---|---|
ChangeLevel
|
|
required
¶
required() -> Version
The smallest version that publishes the change.
| RETURNS | DESCRIPTION |
|---|---|
Version
|
The old version bumped at the largest change's level. |
check
¶
check(proposed: Version) -> None
Refuse a version that understates the change.
| PARAMETER | DESCRIPTION |
|---|---|
proposed
|
The version to publish.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
BumpError
|
If |
Source code in src/quivers/packages/bump.py
diff_interfaces
¶
diff_interfaces(old: PackageInterface, new: PackageInterface) -> InterfaceDiff
Classify every change from one interface to another.
| PARAMETER | DESCRIPTION |
|---|---|
old
|
The interface compared against.
TYPE:
|
new
|
The new interface.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
InterfaceDiff
|
The changes and the lens dependents migrate along. |
| RAISES | DESCRIPTION |
|---|---|
LensError
|
If panproto cannot derive the lens. |
Source code in src/quivers/packages/bump.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
release
¶
Releasing package versions: interfaces, version bumps, lenses, publishing.
package_version_interface checks a package's exposed modules and computes
its semantic interface. previous_version finds the version to compare
against: a directory, or a git revision of the repository holding the
package (extracted into the project cache). bump diffs the two
interfaces and, when the change is breaking, writes the dependency lens
into the package's lenses/ directory, where qvr migrate --dependency
finds it in the new version's source. publish adds a version to an index
repository, refusing a version that understates its change from the newest
version the index already lists.
LENS_DIRECTORY
module-attribute
¶
Where a package keeps the lenses its breaking releases emit.
ReleaseError
¶
Bases: ValueError
A release that cannot be made.
Its message says what prevents it.
VersionInterface
didactic-model
¶
VersionInterface(*, interface: PackageInterface, modules: tuple[BuiltModule, ...] = ())
Bases: Model
A package version's interface and the modules it was computed from.
| ATTRIBUTE | DESCRIPTION |
|---|---|
interface |
The interface.
TYPE:
|
modules |
Its exposed modules, checked.
TYPE:
|
lens_file
¶
The file name a lens between two versions is emitted under.
| PARAMETER | DESCRIPTION |
|---|---|
package
|
The package.
TYPE:
|
old
|
The versions.
TYPE:
|
new
|
The versions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/packages/release.py
package_version_interface
¶
package_version_interface(directory: Path, cache: GitCache) -> VersionInterface
Check a package's exposed modules and compute its interface.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The package's directory.
TYPE:
|
cache
|
The cache its git and indexed dependencies are read through.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VersionInterface
|
The interface and the checked modules. |
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If the manifest is malformed. |
ResolutionError
|
If its dependencies do not resolve. |
PackageError
|
If a module violates a package rule. |
ModuleError
|
If a module does not load or resolve. |
CompileError
|
If a module does not compile. |
Source code in src/quivers/packages/release.py
repository_of
¶
The git repository holding a directory, and the directory's place in it.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
A directory inside a git working tree.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Path, str]
|
The working tree's top and the directory relative to it (POSIX). |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If the directory is in no git working tree. |
Source code in src/quivers/packages/release.py
previous_version
¶
previous_version(directory: Path, against: str, cache: GitCache) -> Path
The directory of the package version to compare against.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The package's current directory.
TYPE:
|
against
|
A directory holding the previous version, or a git revision (a tag
such as
TYPE:
|
cache
|
Where a revision is extracted.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
The previous version's package directory. |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If |
ReleaseError
|
If the revision has no manifest at the package's place. |
Source code in src/quivers/packages/release.py
bump
¶
bump(directory: Path, against: Path, cache: GitCache, *, proposed: Version | None = None, write: bool = False, emit_lens: bool = True) -> InterfaceDiff
Diff a package against a previous version and check its version.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The package's directory.
TYPE:
|
against
|
The previous version's directory.
TYPE:
|
cache
|
The project cache.
TYPE:
|
proposed
|
The version to publish; the manifest's version when it differs from the previous one.
TYPE:
|
write
|
Write the required version into the manifest when the manifest still has the previous version.
TYPE:
|
emit_lens
|
Write the dependency lens of a breaking change into
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
InterfaceDiff
|
The classified changes. |
| RAISES | DESCRIPTION |
|---|---|
BumpError
|
If the proposed version understates the change. |
ReleaseError
|
If the previous version is another package. |
Source code in src/quivers/packages/release.py
set_manifest_version
¶
set_manifest_version(directory: Path, version: Version) -> None
Rewrite the version in a manifest, leaving the rest of it as written.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The package's directory.
TYPE:
|
version
|
The new version.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If the manifest has no version line in its [package] table. |
Source code in src/quivers/packages/release.py
publish
¶
publish(index_checkout: Path, url: str, revision: str, cache: GitCache) -> IndexEntry
Add a package version to an index.
The version is read from a commit of its repository, so what is published is exactly what dependents will fetch. Its modules are checked and pinned; its interface is compared with the newest version the index lists, and a version that understates the change, or that the index already lists, is refused. The entry is written into the index checkout and committed there; pushing it is left to the caller.
| PARAMETER | DESCRIPTION |
|---|---|
index_checkout
|
A git working tree of the index repository.
TYPE:
|
url
|
The package's repository.
TYPE:
|
revision
|
The commit, tag, or branch to publish.
TYPE:
|
cache
|
The project cache.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
IndexEntry
|
The published entry. |
| RAISES | DESCRIPTION |
|---|---|
ReleaseError
|
If the package depends on anything but packages of this index, or the version is already published. |
BumpError
|
If the version understates its change. |
GitError
|
If a repository cannot be read or the commit cannot be made. |
Source code in src/quivers/packages/release.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
read_emitted_lens
¶
read_emitted_lens(directory: Path, package: str, old: Version, new: Version) -> DependencyLens | None
The lens a package version emitted for its move from an older one.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The new version's package directory.
TYPE:
|
package
|
The package.
TYPE:
|
old
|
The versions.
TYPE:
|
new
|
The versions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DependencyLens | None
|
The emitted lens, or |