Skip to content

generate: require Debian codename, strict Debian incremental restore; map Plan 0007 R1–R5 - #67

Merged
bketelsen merged 1 commit into
mainfrom
owners/w-request-r-20261002-ac50b8
Oct 2, 2026
Merged

bketelsen merged 1 commit into
mainfrom
owners/w-request-r-20261002-ac50b8

Conversation

@bketelsen

Copy link
Copy Markdown

Finish core Plan 0007's R1–R5 in repogen. Most of it already landed in #62/#64/#66. This closes the remaining gaps: the generic --codename stable default, the Debian incremental restore fallbacks, and a README map from each R item to its code and tests.

Reviewed by github-copilot/gpt-6-sol.

Review

approve after 1 round: Both prior blockers are resolved: invalid or negative Size now fails parsing, and Lstat catches dangling index symlinks. The decoded-byte comparison and new tests support the stated strict-restore behavior. No owner/person process narration was found in changed documents. Package and CLI tests and go vet passed; the full local suite could not complete because integration tests need to write under a read-only workspace. Host checks do not establish that the PR CI is green; a passing PR workflow run is still needed for that acceptance criterion.

Approved plan

Repogen R1–R5 completion Implementation Plan

For the execution session: Use executing-plans locally or subagent-driven-development when delegation helps. Implementation and task-review dispatch are optional per task. Run this approved plan task by task, then end with onionsoup_propose_changes for this item; host verification and the one final independent-family publication review remain required. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Every R1–R5 item of core Plan 0007 (https://github.com/frostyard/core/blob/main/docs/plans/0007-support-suites-in-repogen.md, table lines 172–176) is implemented and tested in repogen, or is explicitly mapped to existing code and tests.

Architecture: Repogen ADR-0013 already splits generic generate from a strict production path (validate-production, internal/generator/deb/production_restore.go, pool.go, production_transaction.go, internal/objectstore/r2, reconcile-production, which accepts only trixie). This change closes the last two code gaps, both in the generic Debian path that Plan 0007 names (internal/cli/generate.go, internal/generator/deb/parser.go), and adds a README map.

Tech Stack: Go, cobra, logrus.

Verification: git diff --check, sh -c 'test -z "$(git ls-files "*.go" | xargs -r gofmt -l)"', go test ./..., go vet ./...

Global Constraints

  • Do not change sysext or non-Debian generator behaviour. publish-to-r2's sysext callers (snosi) must keep working.
  • Keep the generic generate command able to emit arbitrary codenames for non-Frostyard use (ADR-0013). Production strictness stays in the production path.
  • Make no workflow, release, credential or R2 changes. Write no production data.
  • Leave accepted ADRs unchanged. Do not change ADR-0013's status.

Assumptions

  • Already landed and only mapped here: R2 production validation (validate-production, internal/cli/production.go rejects stable); R3 strict signed restore and explicit initialize; R4 digest-aware conditional-create pool; R5 transaction, R2 adapter and read-back. The evidence is at 841aa82, where go test ./... passes.
  • Remaining gap R2: generate --codename defaults to stable. Fix: remove the default, and when Debian packages are scanned, require an explicit --codename. A non-empty --suite must equal --codename. Generic generate still allows a local stable codename, because it cannot reach R2 (publish-to-r2 refuses deb and the stable suite since publish-to-r2: refuse the stable suite and drop the implicit stable default #66; reconcile-production accepts only trixie). If the approver wants generic generate to refuse stable for Debian too, that is a one-line addition in Task 1.
  • Remaining gap R3: in incremental mode, generate falls back to a non-incremental run (dropping existing packages) on any parse error, and deb ParseExistingMetadata skips an arch whose Packages/Packages.gz is corrupt. Fix, Debian only: fall back only when no metadata exists at all. Fail when an index exists but is unreadable, when one arch is good and another is corrupt, and when a stanza is malformed.
  • The "explicit initialize" and "signed prior verification" parts of R3 are met by the production entry point (validate-production --operation initialize|reconcile). Generic incremental stays unsigned-capable, per ADR-0013.
  • "Repogen CI green" is shown by the PR's checks. The canary publish itself is outside this item and needs Brian's separate authorization.

Review Focus

  • generate given only sysext/rpm input and no --codename: must succeed as before. Test in Task 1.
  • generate given a .deb and no --codename: must fail before the output dir is created. Test in Task 1.
  • Incremental deb run against an empty output dir: still succeeds (fresh repo). Test in Task 2.
  • Incremental deb run where binary-amd64/Packages is garbage but binary-all is fine: fails, and prior files are unchanged. Test in Task 2.
  • Packages.gz present but Packages missing (gzip only): still parses. Test in Task 2.

Task 1: R2 – no implicit codename for Debian in generic generate

Files:

  • Modify: internal/cli/generate.go (flag at line 66; validateConfig lines 88–124)
  • Test: internal/cli/generate_test.go

Interfaces: Produces validateConfig behaviour only. No new exported names.

  • Step 1: Write failing tests in internal/cli/generate_test.go:
    • TestGenerateDebianRequiresExplicitCodename: copy a fixture .deb from test/fixtures into a temp input dir (find one with ls test/fixtures; if none exists, build one the way test/integration_test.go does). Run NewGenerateCmd() with only --input-dir/--output-dir. Expect an error containing --codename is required for Debian, and expect the output dir not to exist.
    • TestGenerateDebianRejectsSuiteDifferentFromCodename: --codename trixie --suite stable gives an error containing --suite must equal --codename.
    • TestGenerateSysextNeedsNoCodename: a sysext .raw input (as in the existing sysext test) with --base-url and no --codename succeeds.
  • Step 2: go test ./internal/cli -run 'TestGenerate(Debian|SysextNeeds)'. Expect the Debian tests to FAIL.
  • Step 3: Implement. Change the flag default to "", with help text "Codename for Debian repos (required when Debian packages are present)". Add hasDebianPackages(inputDir string) (bool, error), which scans with scanner.NewFileSystemScanner().Scan(context.Background(), inputDir) and checks for scanner.TypeDeb (use the scanner's real type constant). In validateConfig, when Debian packages are present: trim spaces; an empty codename returns RepoGenError{Type: models.ErrInvalidConfig, Err: fmt.Errorf("--codename is required for Debian repositories")}. Keep the existing behaviour that an empty suite becomes the codename; otherwise, if suite != codename, return --suite must equal --codename. Do this before any output is written.
  • Step 4: Update every existing test or fixture that runs Debian generate without --codename. Grep for NewGenerateCmd and "generate" in internal/ and test/; test/integration_test.go already passes --codename testing. Run go test ./.... Expect PASS.

Task 2: R3 – strict Debian incremental restore

Files:

  • Modify: internal/generator/deb/parser.go:235-369, internal/cli/generate.go:236-245, internal/generator/generator.go (sentinel)
  • Test: internal/generator/deb/parser_test.go (create), internal/cli/generate_test.go

Interfaces: Produces var ErrNoExistingMetadata = errors.New("no existing repository metadata") in package generator. Deb ParseExistingMetadata wraps it (fmt.Errorf("...: %w", generator.ErrNoExistingMetadata)) only when no Packages or Packages.gz exists for any arch/component. Check for an import cycle first: deb imports generator? If generator imports deb, put the sentinel in internal/models/errors.go as models.ErrNoExistingMetadata instead and use it consistently.

  • Step 1: Write failing tests in parser_test.go:
    • absent output dir returns an error that errors.Is matches to the sentinel;
    • all/amd64 both valid (write Packages stanzas by hand) returns both packages;
    • amd64 Packages holds garbage without colon\n\n while all is valid: the error names binary-amd64 and is NOT the sentinel;
    • Packages missing but a valid Packages.gz present parses; Packages.gz that is not gzip errors (not the sentinel);
    • a stanza missing Filename or SHA256 errors.
  • Step 2: go test ./internal/generator/deb -run ParseExisting. Expect FAIL.
  • Step 3: Implement. For each arch/comp, os.Stat Packages and then Packages.gz. If neither exists, skip that arch. If one exists, any parse error returns fmt.Errorf("parse %s: %w", path, err). If no index file is found anywhere, return the sentinel. In parsePackagesReader, inside a stanza, a non-empty line that is not Key: value and not a continuation line (leading space/tab) is an error. At stanza end, a stanza missing Package, Version, Architecture, Filename or SHA256 is an error.
  • Step 4: In generate.go, for pkgType == scanner.TypeDeb, fall back to non-incremental only when errors.Is(err, <sentinel>). Any other error returns RepoGenError{Type: models.ErrPackageParse, Err: fmt.Errorf("incremental deb restore: %w", err)} before any output is written. Leave non-deb types exactly as they are.
  • Step 5: Add TestGenerateIncrementalDebianFailsOnCorruptArchWithoutMutation in internal/cli/generate_test.go: generate a deb repo with --codename testing --arch all,amd64, snapshot the tree (with the existing snapshotGenerateTree helper), corrupt dists/testing/main/binary-amd64/Packages and re-snapshot, rerun with --incremental, and expect an error and the tree unchanged. Add TestGenerateIncrementalDebianInitializesEmptyOutput, which expects success.
  • Step 6: go test ./.... Expect PASS.

Task 3: R1 – document the canary subset and the evidence map

Files: Modify README.md (the "Frostyard Production Validation" section, lines ~70–215), and docs/specs/production-r2-reconciliation.md only if a link is needed.

  • Step 1: At the top of that README section, add a subsection "Plan 0007 canary subset (R1–R5)". It states: core ADR-0048 and Plan 0007 govern; R1–R5 alone gate the single trixie canary, and R6–R10 gate closure expansion; one codename per transaction; component main only; shared immutable pool/main; fixed Origin/Label; no Valid-Until (asserted in production_restore.go and the transaction tests); strict reconcile versus explicit initialize; the Debian publisher is separate from sysext and the composite action. It says the canary is not yet published and needs separate authorization.

  • Step 2: Add a table with columns item | code | tests:

    • R1: README, ADR-0013, docs/org-adrs.md.
    • R2: internal/cli/production.go, internal/production/config.go, generic codename requirement / TestValidateProductionCommandRejectsInputBeforeOutputMutation, TestValidateProductionDebianPackage, TestGenerateDebianRequiresExplicitCodename.
    • R3: production_restore.go, parser.go / TestRestoreProductionStateFailsClosedWithoutChangingPriorBytes, TestVerifyProductionInitializationRequiresAuthoritativeAbsence, TestValidateProductionInitializeRequiresAbsentTarget, the Task 2 tests.
    • R4: pool.go, internal/utils/package_identity.go / the TestSharedPoolFakeS3* tests (ETag ignored, conditional create, collision fails).
    • R5: production_transaction.go, internal/objectstore/r2, reconcile_production.go / TestProductionTransactionPublishesScopedObjectsWithInReleaseLast, TestProductionTransactionFailureInjectionNeverExposesIncompleteGeneration, TestProductionTransactionPreservesStableTreeByteForByte, TestProductionTransactionRealGPGVAndAPTFixture, TestPublicationStoreRejectsEveryOutOfScopePathBeforeIO.
    • "Stable cannot be written": the production stable rejection, reconcile-production being trixie-only, and scripts/validate-publish-target.sh (publish-to-r2: refuse the stable suite and drop the implicit stable default #66).

    Before listing any test name, check that it exists with grep -rn "func <Name>" internal.

  • Step 3: Correct any README text that says generate defaults to stable, or that it falls back silently.

  • Step 4: Run the verification commands from the header, plus node scripts/check-docs.mjs if that script exists.

PR summary must state

  • Item by item: implemented here (R2 generic codename, R3 Debian strict incremental) or already landed (with PR numbers).
  • The ADR-0013 note: Plan 0007 names generate.go/parser.go, but signed verification and initialize live in the production path.
  • Nothing here publishes; the gchlog canary needs Brian's separate authorization.

Plan approved by owner:odrade (standing grant approve-plans in lucilla).

Work item: w-request-r-20261002-ac50b8

… map Plan 0007 R1–R5

Finish core Plan 0007's R1–R5 in repogen. Most of it already landed in #62/#64/#66. This closes the remaining gaps: the generic `--codename stable` default, the Debian incremental restore fallbacks, and a README map from each R item to its code and tests.

Work-item: w-request-r-20261002-ac50b8
Reviewed-by: github-copilot/gpt-6-sol
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.36585% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/generator/deb/parser.go 86.51% 7 Missing and 5 partials ⚠️
internal/cli/generate.go 82.35% 4 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@bketelsen
bketelsen merged commit 749b142 into main Oct 2, 2026
3 checks passed
@bketelsen
bketelsen deleted the owners/w-request-r-20261002-ac50b8 branch October 2, 2026 14:46
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.

1 participant