Skip to content

docs: add plans/ directory for design and implementation plans#3317

Closed
martin-belanger wants to merge 1 commit intolinux-nvme:masterfrom
martin-belanger:add-plans
Closed

docs: add plans/ directory for design and implementation plans#3317
martin-belanger wants to merge 1 commit intolinux-nvme:masterfrom
martin-belanger:add-plans

Conversation

@martin-belanger
Copy link
Copy Markdown

@martin-belanger martin-belanger commented Apr 24, 2026

Add initial design plan (v10) under plans/

This adds the current design/implementation plan for the Python bindings + accessor refactor under plans/.

@dwsuse - You previously reviewed an earlier version (v6). This update reflects a few targeted refinements rather than a redesign:


Key changes from v6 → v10

1) SWIG Access model (main change)

  • v6: all access via accessors
  • v10: per-field access
    • generated → direct struct access (p->member)
    • custom → accessor function
    • none → no access

Rationale: generated accessors are trivial; custom accessors handle the real logic.


2) Removed !access:nested

  • No longer needed
  • Nested structs accessed directly (e.g. &fctx->cfg)

3) Generated setter semantics (updated)

  • write=generated is allowed for all supported types
  • Behavior is type-aware:
    • scalar → direct assignment
    • char *free + strdup

Rationale: allows safe generation while keeping special cases in custom when needed.


4) Lifecycle annotation (new)

  • Added struct-level lifecycle control:

    • !generate-lifecycle=generated
    • !generate-lifecycle=custom
    • (absence ⇒ no lifecycle)
  • Generated lifecycle:

    • constructor: alloc + init + apply defaults
    • destructor: free owned members (e.g. char *) + struct

Rationale: makes ownership and allocation explicit and generator-driven.


5) Generator + typemap alignment

  • Direct access for generated
  • Accessors only for custom
  • %immutable for write=none

6) Invariants clarified
A field is exposable if it has a usable access path:
read != none or write != none


Everything else (dict-based API, callbacks, lifetime model, generator structure, etc.) remains unchanged.


The goal of these changes is to simplify the bindings, reduce unnecessary indirection, and make the generator behavior more explicit and predictable.


Happy to adjust anything if you think this is going in the wrong direction.

@martin-belanger martin-belanger force-pushed the add-plans branch 2 times, most recently from aaa2232 to a992ae8 Compare April 24, 2026 15:09
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Apr 27, 2026

Does it make sense to name the document “Implementation plan — libnvme Python bindings redesign”? I was under the impression this plan describes how to “write” the Python generator from scratch. Sure, the whole API is still moving around a bit, but we are slowly getting there, I think. From then on, it should just document the requirements and design decisions needed to be able to “re-write” the generator.

Introduce a new top-level `plans/` directory to host design and
implementation plans for larger refactoring efforts.

These documents capture the rationale, architecture, and step-by-step
implementation strategy for non-trivial changes before code is written.

Many of these plans are developed with the assistance of AI tools
(e.g. ChatGPT for prompt refinement/review and Claude for code analysis
and plan drafting), and then reviewed/edited by maintainers.

The goal is to:
- make design intent explicit and reviewable
- reduce iteration during implementation
- provide a reference for future contributors
- allow the flexibility of having one person draft a plan
  and pass it on to another to execute it.

No functional changes.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
@martin-belanger
Copy link
Copy Markdown
Author

Good point on the naming. The "Implementation plan" framing is intentional here, though: this document is specifically structured to be fed to an AI assistant (e.g. Claude) to carry out the work phase by phase. Each phase is a discrete session — the level of detail (invariants, truth tables, code snippets) is there to give the AI enough context to implement correctly without needing a human to re-explain things at every step.

I've added a short preface to the document making this explicit. Happy to also rename it to something like "Design & implementation plan" if that reads better, but I'd like to keep the phased structure since that's what drives the AI workflow.

@martin-belanger
Copy link
Copy Markdown
Author

Closing. This is an AI-specific plan and as we just discussed does not belong in the main nvme-cli repo. A separate repo (e.g. nvme-cli-ai) would be a better place for this.

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