Skip to content

Add worker attribution and independent operating records - #11

Merged
cirsteve merged 2 commits into
mainfrom
economic-fitness-records
Sep 4, 2026
Merged

cirsteve merged 2 commits into
mainfrom
economic-fitness-records

Conversation

@cirsteve

@cirsteve cirsteve commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Second PR in the economic-fitness work following https://github.com/RankOneLabs/paa_site/pull/115.

  • Add optional worker {id, version, configuration_ref} to paa-evidence-record/0.2.0-draft. Existing 0.1.0 records remain valid without worker attribution and retain their exact content addresses.
  • Add the optional paa-operating-record/0.1.0-draft contract, with open usage/component vocabulary, explicit unavailable measurements, price bases, exact subject/task/scope/configuration attribution, and retained constituent source references.
  • Add named Python wire types, an IO decoder, and an independent append-only OperatingRecordStore / SqliteOperatingRecordStore, retrievable by exact subject kind and ID. Duplicate record IDs and storage-level mutation are rejected.
  • Extend the published fixture/accessor registry and structural conformance corpus: four operating fixtures, one worker-attributed evidence fixture, 43 operating negative cases and nine worker negative cases.
  • Prepare contracts 0.2.0 (Python/npm) and runtime 0.4.0, with lockfiles and documentation. No publication workflow is dispatched.

Confirmed storage decision

The runtime currently retains evidence as content-addressed files, not a database evidence-record log. This PR therefore adds a separate operating-record store, which may use a sibling table in the existing database or a separate database. The existing evidence storage, EventStore protocol, and motion service remain unchanged.

Boundaries

  • No transition rule reads cost or worker configuration. A conformance test inserts changed configurations and different cost coverage into the same database during an open motion, verifies unchanged state, and then independently approves the motion.
  • No aggregation, pricing, model selection, automatic demotion, or economic eligibility policy is added. Single-configuration windows and configuration-change demotion are documented as future declaration rules only.
  • Consumers retain failed/retried attempts and constituent usage/model/rate identities, reconcile overlapping task/pipeline summaries, and distinguish measured prices from estimates in source provenance. Schema/store validation checks structure, not external source accuracy or coverage.
  • Effective cost is reader-derived from matching configuration/population/window costs and accepted outcomes, never a stored field. Missing cost is not zero; zero accepted outcomes means undefined effective cost.
  • Fixtures are illustrative, not production measurements. Scout alignment and site adoption follow the contract release.

Verification

  • 716 runtime/conformance tests and 89 contract-package tests pass (805 total).
  • Ruff and strict mypy pass for runtime and contract package.
  • uv sync --locked --extra conformance succeeds.
  • Python source distributions and wheels build; contract wheel carries all 37 artifacts byte-identically.
  • Isolated installed-wheel operating-record round-trip succeeds using packaged fixtures.
  • npm pack succeeds and includes all new operating artifacts; Ajv validates the operating fixtures.
  • git diff --check passes.

Summary by CodeRabbit

  • New Features

    • Added PAA Operating Records for worker activity, usage, pricing, timestamps, components, and source references.
    • Added operating-record validation, decoding, and detailed field-level errors.
    • Added independent, append-only SQLite storage with subject-based retrieval and duplicate protection.
    • Added worker attribution to supported evidence records while preserving compatibility with earlier records.
    • Added operating-record examples and expanded conformance coverage.
  • Documentation

    • Documented operating-record storage, pricing, usage, and runtime boundaries.
    • Published the fifth normative schema and updated package versions to 0.4.0 / 0.2.0.

@cirsteve
cirsteve requested a lite review from Copilot September 4, 2026 22:40
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Essentials

Run ID: a0e031a0-a1a1-42b2-aa10-20ed3f489833

📥 Commits

Reviewing files that changed from the base of the PR and between 5181c5e and 22e63ac.

📒 Files selected for processing (2)
  • src/paa_runtime/operating.py
  • tests/test_operating_store.py

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.


📝 Walkthrough

Walkthrough

The change adds the PAA Operating Record schema, runtime decoder, append-only SQLite store, conformance fixtures, validation cases, public exports, and documentation. Evidence records gain optional worker attribution with compatibility for the previous schema version.

Changes

Operating record contract and conformance

Layer / File(s) Summary
Contract and conformance corpus
schemas/*, packages/paa-contracts/..., examples/runtime-conformance/..., conformance/...
Adds the operating-record schema, evidence worker compatibility, fixture accessors, positive fixtures, invalid cases, and updated corpus assertions.

Runtime decoding

Layer / File(s) Summary
Runtime models and decoding
src/paa_runtime/__init__.py, src/paa_runtime/operating.py, conformance/test_operating_records.py
Adds public operating-record types, decoding, structured validation errors, and conformance tests for valid and invalid records.

Persistence

Layer / File(s) Summary
Append-only SQLite storage
src/paa_runtime/operating_store.py, tests/test_operating_store.py, conformance/test_operating_records.py
Adds transactional append, immutable SQLite rows, duplicate-ID protection, subject queries, error wrapping, and persistence tests.

Documentation and release metadata

Layer / File(s) Summary
Documentation and release metadata
README.md, PAA.md, packages/paa-contracts/README.md, package.json, pyproject.toml, packages/paa-contracts/pyproject.toml
Documents operating-record accounting, worker attribution, storage semantics, runtime boundaries, schema counts, and version updates.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 22e63

The change adds validated operating records and append-only storage while retaining evidence-record compatibility. No current merge-blocking risk is identified.

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant Decoder
  participant OperatingStore
  participant SQLite
  Application->>Decoder: Decode operating-record JSON
  Application->>OperatingStore: Append validated record
  OperatingStore->>SQLite: Store immutable record
  Application->>OperatingStore: Query by exact subject
  OperatingStore->>SQLite: Read records in insertion order
  OperatingStore->>Decoder: Validate stored JSON
  OperatingStore-->>Application: Return operating records
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 49 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the two primary changes: worker attribution and independent operating records.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch economic-fitness-records

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The operating-record decoder has contract/behavior mismatches (timestamp error path context and integer-vs-float handling) that should be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR extends the PAA contract and runtime to support optional worker attribution on evidence records and introduces an independent, append-only operating-record mechanism for subject-linked usage and pricing data that explicitly remains outside authority/motion policy.

Changes:

  • Add paa-operating-record/0.1.0-draft schema + fixtures/invalid-case corpus and runtime decoding + SQLite append-only store.
  • Extend paa-evidence-record to 0.2.0-draft with optional worker {id, version, configuration_ref} while preserving validity of 0.1.0-draft records.
  • Bump package versions / exports and expand conformance + contract-package tests for new artifacts and corpus counts.
File summaries
File Description
uv.lock Updates workspace package versions for runtime/contracts.
tests/test_operating_store.py Adds unit tests for append-only SQLite operating-record store behavior.
src/paa_runtime/operating.py Introduces typed wire shapes and a structural JSON decoder for operating records.
src/paa_runtime/operating_store.py Adds SqliteOperatingRecordStore with append-only enforcement via SQLite triggers.
src/paa_runtime/init.py Exposes operating record/store APIs from the runtime top-level and bumps runtime version.
schemas/paa-operating-record.schema.json Adds the new operating-record JSON Schema.
schemas/paa-evidence-record.schema.json Adds evidence schema v0.2.0 with optional worker attribution and backward compatibility.
README.md Documents operating records and clarifies worker/cost boundaries.
pyproject.toml Bumps runtime version and pins paa-contracts>=0.2.0 for conformance extra.
packages/paa-contracts/uv.lock Bumps contract package version to 0.2.0.
packages/paa-contracts/tests/test_contracts.py Updates schema/fixture/case-count assertions to include operating records and worker negatives.
packages/paa-contracts/src/paa_contracts/init.py Adds operating schema ID, fixtures accessor, case-kind, and bumps contract package version.
packages/paa-contracts/README.md Updates contract package docs for the new schema and revised evidence record.
packages/paa-contracts/pyproject.toml Bumps contracts version/description to reflect five schemas.
package.json Bumps npm contracts package version/description to 0.2.0.
PAA.md Updates architecture doc to include operating accounting and worker attribution context.
examples/runtime-conformance/operating-records/zero-price.json Adds an operating-record positive fixture (explicit zero price).
examples/runtime-conformance/operating-records/task-priced.json Adds an operating-record positive fixture (task attempt).
examples/runtime-conformance/operating-records/pipeline-summary.json Adds an operating-record positive fixture (summary + components).
examples/runtime-conformance/operating-records/failed-unavailable.json Adds an operating-record positive fixture (unavailable usage/price).
examples/runtime-conformance/invalid/operating-cases.json Adds operating-record structural invalid-case table.
examples/runtime-conformance/invalid/evidence-cases.json Extends evidence invalid-case table with worker-related negatives and formatting updates.
examples/runtime-conformance/evidence-records/evidence/paa/421d1e7672aa1fa96ff2426a4b242d711a25cf23f27160accabcca25abc515fa/evidence.json Adds a worker-attributed evidence fixture under v0.2.0-draft.
conformance/test_operating_records.py Adds conformance checks for operating records + worker schema alignment + motion independence.
conformance/test_evidence_integrity.py Updates evidence fixture discovery count.
conformance/test_corpus_integrity.py Updates corpus enumeration and pinned counts to include operating cases/fixtures.
conformance/_corpus.py Registers operating invalid-case kind -> schema mapping.
Review details

Suppressed comments (1)

src/paa_runtime/operating.py:168

  • declaration_version is defined as an integer in the JSON Schema, but the decoder currently accepts floats like 1.0 and silently coerces them to int. This diverges from the contract and can make the decoder/store behavior non-lossless (e.g., storing 1.0 but returning 1). Require an actual JSON integer (Python int, excluding bool) instead of accepting float.
    version = record["declaration_version"]
    _quantity(version, "/declaration_version")
    if not isinstance(version, (int, float)) or version < 1 or int(version) != version:
        _fail("/declaration_version", "expected a positive integer")
    record["declaration_version"] = int(version)
  • Files reviewed: 25/27 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread src/paa_runtime/operating.py Outdated
Comment on lines +127 to +135
def _timestamp(value: object, path: str) -> None:
stamp = _text(value, path)
pattern = (
r"[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt](?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]"
r"(?:\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])"
)
if re.fullmatch(pattern, stamp) is None:
_fail(path, "expected an RFC 3339 date-time with timezone")
datetime.fromisoformat(stamp.upper().replace("Z", "+00:00"))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 22e63ac. Calendar-date parsing errors now retain the exact /timestamps/ path. Regression coverage checks malformed offsets, invalid times, and impossible calendar dates across started_at, completed_at, and recorded_at. All 811 tests, Ruff, and strict mypy pass locally.

@cirsteve
cirsteve merged commit 281e42a into main Sep 4, 2026
9 checks passed
@cirsteve
cirsteve deleted the economic-fitness-records branch September 4, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants