Skip to content

Design the greenfield Go modules and execution slices #155

Closed

Description

@KalebCole

Question

Given the approved remote API and CLI product contracts, where should the Go module seams live, what implementation slices are independently complete, and which dependency graph gets from an empty Go module to verified cutover without speculative foundations?

Activity

  1. added
    wayfinder:grilling
    on Aug 10, 2026
  2. KalebCole commented on Aug 10, 2026

    @KalebCole
    OwnerAuthor

    The product-contract prerequisite is now approved and merged in PR 159. The authoritative inputs for this design are docs/CLI-PRODUCT-CONTRACT.md, CONTEXT.md, and remote contract revision 2026-08-10.1. This issue is now unblocked.

  3. self-assigned this
    on Aug 10, 2026
  4. KalebCole commented on Aug 10, 2026

    @KalebCole
    OwnerAuthor

    Proposed architecture

    The proposed ADR is open for review in
    PR #160.

    This proposal uses one Go module, not a workspace of independently
    versioned modules. A module below means an interface plus its implementation.
    Only cmd/partiful is public to Go tooling; all product implementation remains
    under internal/.

    Seams and ownership

    cmd/partiful
        |
        v
    internal/app --------------> internal/auth
        |                       internal/mutation
        +----------------------> internal/remote
                                          |
                             net/http and scripted adapters
    

    cmd/partiful: composition only

    Construct production adapters, call app.Execute, write the already-complete
    stdout/stderr results, and exit. It contains no command, domain, safety, auth,
    or transport behavior.

    internal/app: the deep product module

    Its external interface is intentionally narrow:

    type Invocation struct {
        Args  []string
        Stdin io.Reader
    }
    
    type Result struct {
        Stdout   []byte
        Stderr   []byte
        ExitCode int
    }
    
    func (a *App) Execute(context.Context, Invocation) Result

    Execute buffers the complete result before stdout, so failures cannot leave
    partial JSON. The module owns:

    • interpretation and normalization of argv, flags, structured input, RFC 3339
      values, IANA timezones, collection limits, and opaque cursors;
    • one typed command-definition catalog from which both execution and
      schema [command.path] are projected;
    • success/failure envelopes, metadata, warnings, safe details, and the stable
      exit mapping;
    • redacted doctor reports assembled from safe facts returned by dependencies;
    • the event, guest, RSVP, contact, cohost, blast, and poster capabilities,
      organized as implementation files rather than exported per-command modules;
    • permission checks, privacy-safe contact matching, pagination orchestration,
      domain output mapping, and deterministic failure precedence.

    A command definition cannot enter the releasable catalog unless its input,
    output, failures, safety kind, required remote mappings, and schema projection
    are complete. This keeps schema and execution on one source of truth without
    inventing an unimplemented runtime failure.

    internal/auth: authentication and private credential state

    The interface offers human-attended login, session acquisition, status,
    logout, and safe diagnostic facts. The implementation owns private terminal
    input, atomic credential persistence, refresh, expiry classification, custom
    token exchange, account lookup, and a private stable account fingerprint.
    Tokens, phone numbers, verification codes, email addresses, and Partiful user
    IDs cannot cross the interface into output.

    Other commands may request a valid session but cannot trigger login or prompt.
    OS credential storage and an in-memory test store are adapters at the local
    state seam.

    internal/mutation: mutation authority

    One operation owns the full plan/apply state machine rather than exposing
    independent helpers:

    func (m *Authority) Execute(
        context.Context,
        Intent,
        Observe,
        Apply,
    ) Outcome

    The implementation normalizes and binds the operation, input, observed
    preconditions, signed-in account fingerprint, and any private resolved contact
    identity. It persists those facts behind a random opaque token, enforces the
    five-minute lifetime for consequential plans, re-observes preconditions,
    rejects changed/expired/reused plans, consumes the token before dispatch, and
    permits at most one local apply attempt. An uncertain transport outcome requires
    a new plan; the CLI never retries a mutation automatically. Standard mutations
    accept the token through --plan; consequential actions accept it through
    --confirm. The stored plan, not a second contact lookup, supplies a
    consequential action's private target.

    The production plan vault and an in-memory test vault are adapters at the
    local-state seam. The interface never exposes account or contact identifiers.

    internal/remote: reviewed protocol module

    The interface accepts only closed, compiled operation requests used by
    internal/app and internal/auth; it is not a generic raw HTTP escape hatch.
    The implementation owns host selection, request encoding, authorization
    placement, response size/time limits, and operation-specific response/failure
    validation. Callable, Firestore, Firebase identity/token, and poster transports
    are private implementations selected inside this module. Upload remains
    unregistered in v1.

    Every shipped operation has an exhaustive reviewed mapping for accepted
    statuses, bodies, required fields, and typed failures. A network failure maps
    to the reviewed remote failure taxonomy. Any unrecognized released status,
    body, or required field maps to contract.protocol_changed; raw response
    bodies never escape. Missing evidence prevents compilation into the releasable
    catalog and is not a runtime branch.

    The real net/http adapter and a scripted transcript adapter form the true
    external seam. Tests assert through app.Execute, not through transport
    internals.

    Why these seams

    • Depth: one application interface exercises parsing, schema, privacy,
      safety, domain orchestration, output, and failures.
    • Locality: credential rules live in auth, plan binding lives in mutation,
      and wire drift lives in remote; fixing each changes one module.
    • No shallow wrappers: command groups and the 27 remote operations do not
      become exported packages with pass-through methods.
    • No speculative foundation: shared behavior enters through the first
      vertical slice that needs it, then is reused.

    The proposed ADR is docs/adr/0001-greenfield-go-module-seams.md. It records
    only the hard-to-reverse seam decision; this issue remains the decision thread
    for the execution graph.

    Evidence prerequisites

    All 27 current response status/body mappings are explicit unknowns. Therefore
    remote slices have an evidence node that must complete before Go coding for
    that slice:

    1. gather privacy-safe evidence for every required success and failure mapping;
    2. update spec/partiful.openapi.json and
      spec/partiful.api-evidence.json;
    3. obtain owner review of the contract revision;
    4. then implement against committed fixtures.

    Evidence work belongs to #157/#158 where applicable. The Go CLI never probes
    for unknown behavior at runtime. Mutation implementation is verified with
    reviewed fixture replay, never by issuing a live mutation from tests.

    Vertical implementation slices

    S0 — Local executable, discovery, and diagnostics

    • Contract surface: --version, schema for the currently completed
      catalog, auth status, auth logout, and redacted local doctor; complete
      envelopes and exit behavior.
    • Evidence: no remote evidence.
    • Dependencies: empty go.mod.
    • Safe verification: black-box execution with temporary credential/plan
      stores, fixed clock/entropy, schema consistency tests, and privacy scans.
    • Complete when: every path emits one complete contract envelope; schema
      is generated from executable definitions; logout is atomic; diagnostics
      cannot reveal secret-file contents or private identifiers.

    S1 — Poster discovery and bounded collections

    • Contract surface: posters list, posters search, collection metadata,
      limits, --all, and opaque resumable cursors.
    • Evidence gate: getPosterCatalog success statuses/body, every required
      Poster field, failure mapping, catalog completeness, and behavior needed
      for safe local pagination.
    • Dependencies: S0.
    • Safe verification: replay an approved public catalog fixture through the
      scripted remote adapter; test cursor/filter binding and maximum limits.
    • Complete when: list/search populate every documented field, pagination
      resumes exactly, and malformed released responses fail with
      contract.protocol_changed.

    S2 — Human authentication and session lifecycle

    • Contract surface: auth login/status/logout; protected-command
      auth.required, auth.expired, and auth.human_required.
    • Evidence gate: reviewed success/failure/status mappings for
      sendAuthCodeTrusted, getLoginToken, signInWithCustomToken,
      refreshToken, and any required lookupFirebaseUser behavior.
    • Dependencies: S0 and the human-authentication approval gate.
    • Safe verification: scripted remote transcripts, fake private terminal,
      temporary credential store, refresh/expiry tests, and redaction assertions.
      Any evidence capture is owner-attended; automation does not enter
      credentials.
    • Complete when: login only works on a private terminal, protected commands
      never prompt, refresh is deterministic, persistence is atomic, and no
      identity or credential reaches stdout/stderr.

    S3 — Event reads

    • Contract surface: events list --when upcoming|past, events get,
      EventSummary, Event, roles, RSVP projection, and bounded pagination.
    • Evidence gate: reviewed mappings and failures for
      getMyUpcomingEventsForHomePage, getMyPastEventsForHomePage,
      getEventInfo, firestoreGetEvent, and any supporting guest read needed to
      populate myRsvp and userRole; pagination facts must support the product
      cursor contract.
    • Dependencies: S1 collection behavior and S2 session acquisition.
    • Safe verification: privacy-redacted, read-only approved fixtures and
      scripted pages; no authenticated live probe in Go tests.
    • Complete when: every required field is populated or explicit null,
      permissions/not-found/drift are distinguishable, and cursors are bound to
      command and filters.

    S4 — Contacts and private resolution

    • Contract surface: contacts list [--query] and the private exact-match
      resolver later used by guest/cohost plans.
    • Evidence gate: getContacts success/body/failures, safe display fields,
      private stable identity, shared-event count, pagination, and ambiguity
      behavior. Determine whether filtering and pagination are remote or must be
      performed over a safely bounded complete catalog; if client-side, evidence
      must establish that the product collection contract can be synthesized
      without an unbounded fetch.
    • Dependencies: S1 collection behavior and S2 session acquisition.
    • Safe verification: privacy-redacted fixtures containing synthetic
      ambiguous and duplicate-name cases; assert that no private identity can
      enter envelopes or errors.
    • Complete when: public output contains only display name/shared-event
      count and the private resolver deterministically returns no match, one bound
      identity, or match.ambiguous.

    S5 — RSVP read/write and standard mutation authority

    • Contract surface: rsvp get, rsvp set, exact product status values,
      questionnaire shape, plan-only default, and --apply --plan.
    • Evidence gate: reviewed status/body/failure/precondition mappings for
      getCurrentGuest, addGuest, markEventInterest,
      firestoreGetGuest, and any operation required for all three product RSVP
      statuses.
    • Dependencies: S2 sessions, S3 event facts, and the first implementation
      of internal/mutation.
    • Safe verification: scripted plans and applies with fixed clock/entropy;
      fixture replay covers changed input/account/precondition, expiry, and reuse.
      No live RSVP mutation.
    • Complete when: the transport mapping for going, not-going, and
      interested is exact; no-plan execution has no remote effect; a matching
      live token applies once; every stale case returns safety.plan_stale.

    S6 — Event writes and consequential confirmation

    • Contract surface: events create, events update, events cancel;
      standard planning for create/update and confirmed planning for cancel.
    • Evidence gate: reviewed mappings and failures for createEvent,
      firestorePatchEvent, cancelEvent, and supporting event reads; field-level
      update-mask and post-write complete-Event behavior; poster ID handling;
      and the exact reviewed value for required remote fields such as
      EventDraft.displaySettings that are not public product input.
    • Dependencies: S1 posters, S3 event reads, S5 mutation authority.
    • Safe verification: scripted remote fixtures prove exact requests,
      precondition rebinding, field allowlists, plan expiry/reuse, and response
      validation. No live create/update/cancel.
    • Complete when: arbitrary Firestore fields cannot be patched, applied
      create/update return complete Event, cancel requires a matching
      --confirm token, and unknown released responses stop at exit 9.

    S7 — Guest visibility and invitation

    • Contract surface: host-only guests list; consequential
      guests invite --contact; privacy-safe guest/contact output.
    • Evidence gate: reviewed mappings and failures for
      firestoreListDocuments, supporting guest reads,
      addInvitedGuestsAsHost, and contact resolution; evidence must distinguish
      attendee denial from an empty guest list.
    • Dependencies: S3 events, S4 contacts, S6 consequential authority.
    • Safe verification: synthetic host/attendee, empty, paginated, ambiguous,
      and stale-contact fixtures; no live invitation.
    • Complete when: attendee access is permission.denied, no guest/contact
      identity leaks, and apply uses the identity stored by the reviewed plan
      rather than resolving the name again.

    S8 — Cohost lifecycle and access links

    • Contract surface: cohost invite/revoke-invite/remove and link
      create/revoke, all as host-only consequential actions.
    • Evidence gate: reviewed mappings and failures for
      createCohostRequest, deleteCohostRequest, removeCohost,
      generateEventCohostLink, and revokeEventCohostLink, including observable
      preconditions and exact success shapes.
    • Dependencies: S3 events, S4 contacts, S6 consequential authority.
    • Safe verification: scripted synthetic contact/link lifecycle fixtures,
      including changed role, link state, contact, account, expiry, and replay.
      No live cohost or access-link mutation.
    • Complete when: each command returns its documented state, link URLs are
      emitted only where the contract permits, and all five actions require the
      exact confirmed plan.

    S9 — Text blasts

    • Contract surface: host-only blasts send, file/stdin-only private
      message input, all-guests, page-display flag, and confirmed plan.
    • Evidence gate: retain the dated createTextBlast request mapping and add
      reviewed success status/body, failures, preconditions, and the meaning of
      submitted; establish the exact message.to representation for
      all-guests rather than guessing an empty array, sentinel, or expanded
      identity list; do not infer delivery.
    • Dependencies: S3 events and S6 consequential authority.
    • Safe verification: synthetic message fixtures and scripted responses;
      assert message text never appears in argv, output, diagnostics, plan token,
      or persisted metadata available to other users. No live blast.
    • Complete when: only the reviewed nested request is sent, confirmation is
      exact/single-use, and success reports recipientStatus: "not-reported".

    S10 — Native release verification

    • Contract surface: the complete approved command catalog, --version
      revisions, native archives for macOS/Linux/Windows on AMD64/ARM64, and
      SHA-256 checksums.
    • Evidence: every S1-S9 evidence gate closed in approved remote contract
      revisions.
    • Dependencies: S0-S9.
    • Safe verification: black-box contract suite through app.Execute,
      fixture replay for every remote mapping/failure, race/static analysis,
      GoReleaser snapshot build, archive inspection, checksum verification, and
      local version/schema/doctor smoke tests only.
    • Complete when: every approved command definition has a complete reviewed
      remote mapping, all target archives run where available, and no release path
      requires Node/npm.

    S11 — Cutover

    • Contract surface: the Go binary becomes partiful; repository,
      installation, runtime, development, CI, docs, and release flow become
      Node/npm-free.
    • Evidence: no new remote evidence.
    • Dependencies: S10 plus explicit cutover/release approval.
    • Safe verification: fresh-clone Go-only build/test/release rehearsal,
      repository scans for Node/npm machinery, archive/checksum re-verification,
      and non-mutating local command smoke tests.
    • Complete when: TypeScript, Node/npm manifests/loaders/tests/workflows and
      compatibility machinery are removed, docs describe only the native CLI, and
      the first approved native release is published.

    Dependency graph

    empty Go module
          |
          v
         S0 local runtime
    
    S0 -> S1 posters/collections
    S0 -> S2 auth/session
    S1 + S2 -> S3 event reads
    S1 + S2 -> S4 contacts
    S2 + S3 -> S5 RSVP + standard plans
    S1 + S3 + S5 -> S6 event writes + confirmation
    S3 + S4 + S6 -> S7 guests
    S3 + S4 + S6 -> S8 cohosts
    S3 + S6 -> S9 blasts
    S0..S9 -> S10 native release verification
    S10 + owner cutover/release approval -> S11 cutover
    

    S3 and S4 can proceed in parallel after S1/S2. S7-S9 can proceed in parallel
    after their prerequisites. Each remote slice starts with its evidence node;
    an evidence-blocked slice stays blocked rather than substituting guessed Go
    behavior.

    Decision requested

    Approve or reject:

    1. the four-module shape (app, auth, mutation, remote) behind one
      executable-facing interface;
    2. command definitions as the single source for interpretation, execution,
      and schema;
    3. evidence-complete registration rather than a runtime “unknown mapping”
      fallback;
    4. the S0-S11 dependency graph and cutover gate.

    No Go implementation or downstream implementation issue creation begins until
    this architecture is approved.

  5. KalebCole commented on Aug 11, 2026

    @KalebCole
    OwnerAuthor

    Resolution

    Owner-approved and merged in PR #160, merge commit 8f4d3da7d3ddae31754074be7ead66f844ce0dc7.

    • One Go module uses internal/app as the executable-facing deep module, with
      internal/auth, internal/mutation, and internal/remote as the only
      separate deep internal modules.
    • One typed command catalog drives interpretation, normalization, execution,
      schema discovery, declared failures, and safety metadata.
    • Commands enter the releasable catalog only when their approved product
      surface and required remote mappings are evidence-complete. Missing evidence
      remains an implementation gate; later drift is
      contract.protocol_changed.
    • The approved vertical graph is tracked by Establish the local Go executable, discovery, and diagnostics #161 through Cut over to Go and remove TypeScript, Node, and npm #172. Remote slices
      carry explicit evidence prerequisites and use fixture replay rather than live
      mutation verification.
    • ADR 0001 records the hard-to-reverse seam decision.

    The new frontier is #161, the local executable, discovery, and diagnostics
    slice. It is assigned and unblocked. No remote evidence or live Partiful
    operation is required for that slice.

  6. KalebCole commented on Aug 11, 2026

    @KalebCole
    OwnerAuthor

    Sequencing clarification under the issue #114 delegation: S2/#163 cannot end-to-end test a protected command without either registering an evidence-incomplete S3 command or incorrectly protecting a public/local S0-S2 command. S2 therefore ends at the complete authentication lifecycle. S3/#164 owns the first definition-driven protected-command tracer through app.Execute: missing credentials -> auth.required, expired credentials -> auth.expired, expiring credentials -> one refresh, and no terminal prompt. Dependencies and module seams are unchanged; this preserves the evidence-complete catalog and no-speculative-foundation rules.

  7. KalebCole commented on Aug 11, 2026

    @KalebCole
    OwnerAuthor

    Follow-up seam allocation: the protected session acquisition API materializes with #164's first evidence-complete protected command. The private stable account fingerprint materializes with #166, its first actual consumer in mutation-plan account binding. #163 retains only executable S2 lifecycle behavior; this avoids dead exported seams while preserving the approved module ownership.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

wayfinder:grilling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions