Run artifact

workspace/targets/DupFind/blueprint/ARCHITECTURE.md

ARCHITECTURE: DupFind

FieldValue
Version20261025 V1
DescriptionModule layout, package boundaries, and pipeline of the dupfind command-line duplicate file finder.
Depends OnNone
Providesgo.mod, internal/, cmd/dupfind, bin/

Overview

dupfind is a single-binary Go command-line tool. It finds regular files under a directory whose contents are byte-for-byte identical, reports them as a CSV listing or a one-row CSV summary, and never deletes, moves, or modifies any file.

Pipeline: parse arguments, validate the directory, walk, group by size, hash same-size groups with SHA-256, order and number groups, emit CSV.

Technology Stack

Derived from TECHNOLOGY_STACK.md; that file is the decision of record.

TechnologyWhere it applies
Go 1.22 or newer, standard library onlyAll application code; go.mod declares no third-party requirement
go test and go vetTest runner behind bin/test.sh
POSIX shbin/test.sh

Module Layout

PathPackageResponsibility
go.modmodule rootModule path and Go toolchain version; no require lines
cmd/dupfindmainCalls cli.Run(os.Args[1:], os.Stdout, os.Stderr) and passes the result to os.Exit; the only caller of os.Exit
internal/clicliRun(args []string, stdout, stderr io.Writer) int: argument parsing, directory validation, pipeline orchestration, exit codes
internal/walkwalkRecursive directory walk yielding eligible regular files
internal/dupesdupesSize grouping, SHA-256 digest grouping, reclaimable bytes, ordering and numbering
internal/reportreportCSV listing and summary writers using encoding/csv
bin/test.shPOSIX shRuns go vet ./... then go test ./... from the application root

Boundaries

Module Ownership

BoundaryOwning moduleAllowed low-level APIs
Directory traversal and file metadatainternal/walkos.Lstat, os.ReadDir, io/fs
File content reading and hashinginternal/dupesos.Open, crypto/sha256, io.Copy
CSV outputinternal/reportencoding/csv
Process arguments and exit codesinternal/cli and cmd/dupfindflag, os.Args, os.Exit (main only)
Persistence, configuration files, external servicesNone; the tool has no persistent stateNone

Foundation Scope

The foundation story creates go.mod, the package tree above, a cmd/dupfind/main.go that delegates to cli.Run, and a minimal compiling placeholder in each internal package, so that go build ./cmd/dupfind, go vet ./..., and go test ./... succeed before feature stories land. The placeholder Run returns 0. bin/ exists; bin/test.sh itself is delivered by the test-gate story.

Programmatic Acceptance

=== AC arch-module-no-third-party ===
Intent: The application root is a Go module that declares no third-party requirement.

import pathlib

text = pathlib.Path("go.mod").read_text() lines = [ln.strip() for ln in text.splitlines()] module_lines = [ln for ln in lines if ln.startswith("module ")] go_lines = [ln for ln in lines if ln.startswith("go ")] assert len(module_lines) == 1, text assert len(go_lines) == 1, text assert "require" not in text, text === END AC arch-module-no-third-party ===

=== AC arch-package-tree ===
Intent: The package directories named by the architecture exist in the build tree.

import pathlib

for rel in ["cmd/dupfind", "internal/cli", "internal/walk", "internal/dupes", "internal/report", "bin"]: assert pathlib.Path(rel).is_dir(), rel assert pathlib.Path("cmd/dupfind/main.go").is_file() === END AC arch-package-tree ===

=== AC arch-vet-and-build ===
Intent: The foundation compiles and passes go vet across every package.

import subprocess import sys

for cmd in (["go", "vet", "./..."], ["go", "build", "./..."]): result = subprocess.run(cmd, capture_output=True, text=True) print(result.stdout) print(result.stderr, file=sys.stderr) assert result.returncode == 0, cmd === END AC arch-vet-and-build ===

User Acceptance

Guardrails