Export the loaded manifest type as Manifest, or an interface in front of it? #236

Closed
opened 2026-10-19 03:57:00 +02:00 by clawbot · 4 comments
Collaborator

Split out of #83 (sneak, 2026-10-19: questions should be one issue each); its other questions are settled there.

Package mfer hands out a loaded manifest as the unexported type manifest, so other programs that use the library cannot name it, store it in a struct field, or pass it to their own functions.

Question for sneak: export it as Manifest, or put an exported interface in front of it?

Recommendation: export the type as Manifest, with its fields kept private. Only its methods become the library's API, which commits to no more than an interface would, and it is the usual Go shape. Either choice is part of the 1.0 API and hard to change after it.

Model: opus-5-5

Split out of https://git.eeqj.de/sneak/mfer/issues/83 (sneak, 2026-10-19: questions should be one issue each); its other questions are settled there. Package `mfer` hands out a loaded manifest as the unexported type `manifest`, so other programs that use the library cannot name it, store it in a struct field, or pass it to their own functions. **Question for sneak:** export it as `Manifest`, or put an exported interface in front of it? **Recommendation:** export the type as `Manifest`, with its fields kept private. Only its methods become the library's API, which commits to no more than an interface would, and it is the usual Go shape. Either choice is part of the 1.0 API and hard to change after it. Model: opus-5-5
sneak was assigned by clawbot 2026-10-19 03:57:00 +02:00
Owner

approved.

approved.
Author
Collaborator

Recorded: export the loaded manifest type as Manifest, fields private (the recommendation). It is built as one reviewed change on next when an account has room; both worker accounts are at their week limit now (sneak/project-management#37).

Model: opus-5-5

Recorded: export the loaded manifest type as `Manifest`, fields private (the recommendation). It is built as one reviewed change on `next` when an account has room; both worker accounts are at their week limit now (https://git.eeqj.de/sneak/project-management/issues/37). Model: opus-5-5
sneak was unassigned by clawbot 2026-10-21 06:09:08 +02:00
clawbot self-assigned this 2026-10-21 06:09:08 +02:00
Author
Collaborator

Plan (implementer's brief), as approved in #236 (comment):

  • In package mfer (mfer/), rename the type manifest to Manifest and update every use: mfer/manifest.go, mfer/builder.go, mfer/checker.go, mfer/deserialize.go, mfer/serialize.go, and the in-package tests mfer/errmsg_test.go and mfer/manifest_test.go. NewManifestFromReader and NewManifestFromFile return *Manifest. No new package.
  • Fields stay private. No new exported fields or methods; the existing methods (Files, Signer, CreatedAt, String) are the type's API.
  • Rewrite the type's doc comment to say what it is (a manifest loaded by NewManifestFromFile or NewManifestFromReader, or made by Builder; its fields are private and its methods are the API) and drop the paragraph about an open design question and "README design question 13". Give String a doc comment.
  • Remove the two //nolint:revive // unexported-return lines on the loaders in mfer/deserialize.go; they no longer apply.
  • Add a test in package mfer_test, in the new file mfer/manifest_external_test.go, that names *mfer.Manifest from outside the package: stores a loaded manifest in a struct field of that type and passes it to a function taking *mfer.Manifest, then reads it through its methods. Small and plain; load the manifest from bytes a Builder wrote.
  • No other changes: no doc or CLI edits beyond comments naming the type.

Done when: the PR on next titled ending (closes #236) has script/cibuild green on a fresh clone and an independent review passed.

Model: opus-5-5

Plan (implementer's brief), as approved in https://git.eeqj.de/sneak/mfer/issues/236#issuecomment-153278: - In package `mfer` (`mfer/`), rename the type `manifest` to `Manifest` and update every use: `mfer/manifest.go`, `mfer/builder.go`, `mfer/checker.go`, `mfer/deserialize.go`, `mfer/serialize.go`, and the in-package tests `mfer/errmsg_test.go` and `mfer/manifest_test.go`. `NewManifestFromReader` and `NewManifestFromFile` return `*Manifest`. No new package. - Fields stay private. No new exported fields or methods; the existing methods (`Files`, `Signer`, `CreatedAt`, `String`) are the type's API. - Rewrite the type's doc comment to say what it is (a manifest loaded by `NewManifestFromFile` or `NewManifestFromReader`, or made by `Builder`; its fields are private and its methods are the API) and drop the paragraph about an open design question and "README design question 13". Give `String` a doc comment. - Remove the two `//nolint:revive // unexported-return` lines on the loaders in `mfer/deserialize.go`; they no longer apply. - Add a test in package `mfer_test`, in the new file `mfer/manifest_external_test.go`, that names `*mfer.Manifest` from outside the package: stores a loaded manifest in a struct field of that type and passes it to a function taking `*mfer.Manifest`, then reads it through its methods. Small and plain; load the manifest from bytes a `Builder` wrote. - No other changes: no doc or CLI edits beyond comments naming the type. Done when: the PR on `next` titled ending `(closes #236)` has `script/cibuild` green on a fresh clone and an independent review passed. Model: opus-5-5
Author
Collaborator

Built as planned above in #238: the loaded manifest type is exported as Manifest with its fields private, and the loaders return *Manifest. It waits for review there.

Model: opus-5-5

Built as planned above in https://git.eeqj.de/sneak/mfer/pulls/238: the loaded manifest type is exported as `Manifest` with its fields private, and the loaders return `*Manifest`. It waits for review there. Model: opus-5-5
Sign in to join this conversation.