1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Build a per-entity [`ShardContext`] from a group manifest (Task 4.1).
//!
//! A shard runner calls [`build_shard_context`] once with the shard's own
//! `entity_code` to obtain the opaque context the orchestrator in
//! `datasynth-runtime` consumes. The context carries:
//!
//! - `entity_code` — the entity this shard is responsible for;
//! - `entity_seed` — the 32-byte per-entity seed decoded from the manifest
//! entry's hex-encoded `entity_seed` string;
//! - `extra_journal_entries` — the IC journal entries this entity must post
//! as either seller or buyer of each relationship it participates in.
//!
//! # v5.0 scope
//!
//! Only IC journal-entry injection is wired through the context. FX,
//! chart-of-accounts, and shared-master pool wiring lands in v5.0 Task 4.2
//! via `GeneratorConfig` — those concerns deliberately don't leak into the
//! opaque runtime [`ShardContext`] surface.
//!
//! # Determinism
//!
//! Two calls with the same manifest and entity code return contexts with
//! byte-identical `entity_code`, `entity_seed`, and
//! `extra_journal_entries.len()`. Full-struct equality does **not** hold
//! because `JournalEntryHeader::new` assigns a wall-clock-based
//! `document_id` via `Uuid::now_v7()` — the deterministic surface is the
//! set of IC-specific header fields, accounts, and amounts (see
//! `tests/shard_context.rs::test_deterministic_across_calls`).
use ShardContext;
use crate;
use crateGroupManifest;
use crate;
use cratederive_ic_pair_plans;
/// Build the [`ShardContext`] for `entity_code`, using the group
/// [`GroupManifest`] as the single source of truth.
///
/// # Errors
///
/// Returns [`GroupError::Config`] if `entity_code` does not match any
/// entity in `manifest.ownership_graph.entities`.
///
/// # Panics
///
/// Panics if the manifest entity's `entity_seed` field is not lowercase
/// 32-byte hex. This is an internal invariant violation — the manifest
/// builder (see `manifest/builder.rs`) always produces a 32-byte
/// blake3 digest hex-encoded via `hex::encode`, so hitting this panic
/// means the manifest was corrupted after construction.