package zddc

import "strings"

// Canonical project shape — the fixed set of top-level peers and the
// per-party record slots under archive/.
//
// The binary wires bespoke behavior to these names (tables at
// mdl/rsk/ssr, transmittal at staging/, WORM at archive/, the party
// registry at ssr/), so the SET of names is a deliberate hard rule
// rather than a cascade key. The point of this file is that the set
// lives in ONE place: handlers ask the predicates below instead of
// re-listing the names, so adding or adjusting a peer is a single edit.
//
// Note the layering: the names are hard-coded here, but per-peer
// BEHAVIOR (default_tool, worm, party_source, history, auto_own, …)
// stays cascade-driven in internal/zddc/defaults/ + on-disk .zddc. This file
// is identity/shape only.
var (
	// projectPeers: the flat set of physical directories permitted
	// directly under a project root. archive/ is the committed record;
	// the rest are party-partitioned workspaces/registers. Mkdir at the
	// project root is restricted to these plus system (_/.-prefixed)
	// names.
	projectPeers = []string{"archive", "incoming", "working", "staging", "reviewing", "mdl", "rsk", "ssr"}
	// rowSlots: the tables-rendered register peers. mdl/rsk aggregate
	// across their party subdirs; ssr is flat (one row file per party)
	// and is also the authoritative party registry.
	rowSlots = []string{"ssr", "mdl", "rsk"}
	// perPartySlots: the canonical lifecycle folders under
	// archive/<party>/ — the committed record, both WORM.
	perPartySlots = []string{"received", "issued"}
)

func slotIn(set []string, s string) bool {
	for _, v := range set {
		if v == s {
			return true
		}
	}
	return false
}

// IsProjectPeer reports whether name is one of the fixed top-level peers
// permitted directly under a project root.
func IsProjectPeer(name string) bool { return slotIn(projectPeers, strings.ToLower(name)) }

// IsRowSlot reports whether slot is a tables-rendered register peer
// (ssr/mdl/rsk).
func IsRowSlot(slot string) bool { return slotIn(rowSlots, slot) }

// IsPerPartySlot reports whether slot is a canonical lifecycle folder
// under archive/<party>/ (received/issued).
func IsPerPartySlot(slot string) bool { return slotIn(perPartySlots, slot) }
