Skip to content

Add helpers for detecting open-ended activations (#26) - #65

Merged
craigmcchesney merged 2 commits into
mainfrom
fix/26-open-activation-helpers
Sep 26, 2026
Merged

craigmcchesney merged 2 commits into
mainfrom
fix/26-open-activation-helpers

Conversation

@craigmcchesney

@craigmcchesney craigmcchesney commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Implements the plan merged in #64 (plan/tickets/26/plan.md).

Helpers — activation_is_open() and activation_end_time() in machine_config_client, exported from dp_python_lib.client. Module-level so they cover get, query, iterate, and get_active_configurations() alike (D1). Reading .endTime directly on an open activation silently yields a zero Timestamp (1970); activation_end_time() returns None instead, which also makes end_time=activation_end_time(current) the correct carry-forward in a full-replace re-save (D3). Presence is the only test: an endTime present with value 0 is closed (D5).

Tests — new TestActivationOpenEndedHelpers (open, bounded, epoch-zero, reading .endTime does not set presence, re-save round trip, open record carried forward stays open, filtering a mixed query page). The integration open-ended round trip asserts the helpers beside the existing raw HasField checks, which remain the wire verification.

Cookbook (doc/cookbook/machine-configuration.md)

  • "Open-ended activations" uses the helpers and warns about the 1970 value.
  • "Copy every field forward" covers end_time.
  • New "When you do not have the activation's id" recipe: finds the activation to close at a changeover by the incoming configuration's category plus CA.timestamp(changeover), the same terms as the server's overlap check (category as well as name). Deliberately not narrowed to open records, since a bounded activation ending after the changeover blocks the next save just as an open one does. Handles zero / one / more-than-one results. (Revised in review; the plan carries a dated note.)
  • get_active_configurations() match rule now includes an absent endTime.
  • "Every interval a configuration was in effect" no longer prints 0 for an open interval.

Also — CLAUDE.md, doc/release-notes/NEXT.md section, cookbook checker preamble.

Verification — pytest tests/unit/ (746 passed), ruff check ., ruff format --check ., mypy src/, cookbook snippet checker, release-notes checker all clean. tests/integration/test_machine_config_client_integration.py against a live stack: 3 passed, including the open-ended round trip with the new helper assertions. The revised recipe was also exercised against the live stack with a throwaway script: an empty result with nothing in effect, an open activation of a different configuration found through the category, the next save rejected while it stays open, a bounded activation ending after the changeover still found, and the next save succeeding once it is closed.

Closes #26

🤖 Generated with Claude Code

https://claude.ai/code/session_01PgJ3cRwMrh8UzxzZwraLCT

activation_is_open() and activation_end_time() read an activation saved
without end_time back.  Reading endTime directly on an open record does
not fail but yields a zero Timestamp (1970), and carrying that forward
as end_time= in a re-save gets the save rejected.  activation_end_time()
returns None instead, so it is also the correct carry-forward.

Module-level functions rather than a result property, so they cover
get, query, iterate, and get_active_configurations() alike.  Presence
is the only test: an endTime present with value 0 is closed, not open.

The cookbook adopts them, fixes the recipe that printed 0 for an open
interval, completes the getActiveConfigurations match rule, and adds a
recipe for finding the open activation without its id.

Closes #26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PgJ3cRwMrh8UzxzZwraLCT
Copilot AI lite review requested due to automatic review settings September 26, 2026 17:26

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.

Copilot review overview

🟢 Approval recommended

No unresolved review comments remain, and all approval-readiness assessments approve the changes.

Review effort: Lite
Findings: None

What changed in this PR

Adds public helpers for detecting open-ended activations and safely retrieving optional end times.

Changes:

  • Adds and exports activation_is_open() and activation_end_time().
  • Adds unit and integration coverage for presence and epoch-zero behavior.
  • Updates documentation, release notes, guidance, and snippet checks.
File Summary
tests/​unit/​test_machine_config_activation_client.py Tests helper behavior and edge cases.
tests/​integration/​test_machine_config_client_integration.py Adds round-trip assertions.
src/​dp_python_lib/​client/​machine_config_client.py Implements activation helpers.
src/​dp_python_lib/​client/​__init__.py Exports the helpers.
doc/​release-notes/​NEXT.md Documents the user-visible change.
doc/​cookbook/​machine-configuration.md Documents safe activation handling.
CLAUDE.md Updates project guidance.
.dev/​tools/​check-cookbook-snippets.py Makes helpers available to snippet checks.

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

- Cookbook: the "no activation id" recipe now queries by the incoming
  configuration's category plus CA.timestamp(changeover), instead of
  paging a configuration's whole history by name and filtering to open
  records.  That matches the server's overlap check, which is by
  category as well as name, and also catches a bounded activation whose
  scheduled end is after the changeover.
- CLAUDE.md: carry-forward snippet narrows activation_end_time() with
  `is not None`, so it stays clean once typed stubs land.
- NEXT.md: correct the description of the rejected re-save.
- Rewrap the get_active_configurations() paragraph; note the recipe
  revision in plan/tickets/26/plan.md; fix a test docstring.

Refs #26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PgJ3cRwMrh8UzxzZwraLCT
@craigmcchesney
craigmcchesney merged commit b11ff12 into main Sep 26, 2026
6 checks passed
@craigmcchesney
craigmcchesney deleted the fix/26-open-activation-helpers branch September 26, 2026 19:32
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.

Add helpers for detecting open-ended configuration activations

2 participants