Skip to content

Commit b5da4e4

Browse files
refactor: remove meta.size from population spec
Size is now exclusively set via 'sample -n' flag (required). Removes redundant size field from SpecMeta and all usages: - spec builder no longer extracts size from description - sampler requires count parameter (no fallback) - prompts/context strings no longer mention size - updated docs and tests
1 parent b026c8f commit b5da4e4

22 files changed

Lines changed: 44 additions & 126 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ extropy spec → extropy scenario → extropy persona → extropy sample → ext
5151
For `spec` command, use `--answers` to skip clarification prompts:
5252

5353
```bash
54-
extropy spec "500 German surgeons" -o surgeons --answers '{"location": "Bavaria"}'
54+
extropy spec "German surgeons" -o surgeons --answers '{"location": "Bavaria"}'
5555
```
5656

5757
Or use `--use-defaults` to accept default values:
5858

5959
```bash
60-
extropy spec "500 German surgeons" -o surgeons --use-defaults
60+
extropy spec "German surgeons" -o surgeons --use-defaults
6161
```
6262

6363
### Skip confirmations

docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Generate a population spec from a natural language description.
4848

4949
```bash
5050
# Create new study folder with population.v1.yaml
51-
extropy spec "500 German surgeons" -o surgeons
51+
extropy spec "German surgeons" -o surgeons
5252

5353
# Create with custom name (surgeons/hospital-staff.v1.yaml)
5454
extropy spec "German surgeons" -o surgeons/hospital-staff

extropy/cli/commands/scenario.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def do_selection():
127127
try:
128128
new_attributes = select_attributes(
129129
description=description,
130-
size=pop_spec.meta.size,
131130
geography=pop_spec.meta.geography,
132131
context=pop_spec.attributes,
133132
)

extropy/cli/commands/spec.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ def spec_command(
203203
out.needs_clarification(
204204
questions=questions,
205205
resume_command=resume_cmd,
206-
partial_data={"size": sufficiency_result.size},
207206
)
208207
raise typer.Exit(out.finish())
209208
else:
@@ -272,15 +271,14 @@ def spec_command(
272271
console.print(f" • {q}")
273272
raise typer.Exit(1)
274273

275-
size = sufficiency_result.size
276274
geography = sufficiency_result.geography
277275
agent_focus = sufficiency_result.agent_focus
278276
geo_str = f", {geography}" if geography else ""
279277
focus_str = f", focus: {agent_focus}" if agent_focus else ""
280278

281279
if not agent_mode:
282280
console.print(
283-
f"[green]✓[/green] Context sufficient ({size} agents{geo_str}{focus_str})"
281+
f"[green]✓[/green] Context sufficient{geo_str}{focus_str}"
284282
)
285283

286284
# Step 1: Attribute Selection
@@ -293,7 +291,7 @@ def spec_command(
293291
def do_selection():
294292
nonlocal attributes, selection_error
295293
try:
296-
attributes = select_attributes(description, size, geography)
294+
attributes = select_attributes(description, geography)
297295
except Exception as e:
298296
selection_error = e
299297
finally:
@@ -430,7 +428,6 @@ def do_hydration():
430428
with console.status("[cyan]Building spec...[/cyan]"):
431429
population_spec = build_spec(
432430
description=description,
433-
size=size,
434431
geography=geography,
435432
attributes=bound_attrs,
436433
sampling_order=sampling_order,
@@ -484,7 +481,6 @@ def do_hydration():
484481
out.success(
485482
"Spec saved",
486483
output=str(resolved_output),
487-
size=size,
488484
geography=geography,
489485
agent_focus=agent_focus,
490486
attribute_count=len(population_spec.attributes),

extropy/cli/display.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def display_spec_summary(spec: PopulationSpec) -> None:
5858
console.print("└" + "─" * 58 + "┘")
5959
console.print()
6060

61-
console.print(f"[bold]{spec.meta.description}[/bold] ({spec.meta.size} agents)")
61+
console.print(f"[bold]{spec.meta.description}[/bold]")
6262
console.print(
6363
f"Grounding: {grounding_indicator(spec.grounding.overall)} ({spec.grounding.sources_count} sources)"
6464
)

extropy/core/models/population.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,6 @@ class SpecMeta(BaseModel):
422422
"""Metadata about the population spec."""
423423

424424
description: str = Field(description="Original population description")
425-
size: int = Field(
426-
default=1000,
427-
description="Suggested number of agents (actual count determined by sample -n)",
428-
)
429425
geography: str | None = Field(default=None, description="Geographic scope")
430426
agent_focus: str | None = Field(
431427
default=None,
@@ -510,7 +506,6 @@ def summary(self) -> str:
510506
"""Get a text summary of the spec."""
511507
lines = [
512508
f"Population: {self.meta.description}",
513-
f"Size: {self.meta.size}",
514509
f"Grounding: {self.grounding.overall} ({self.grounding.sources_count} sources)",
515510
f"Attributes: {len(self.attributes)}",
516511
"",
@@ -596,7 +591,6 @@ def merge(self, extension: "PopulationSpec") -> "PopulationSpec":
596591

597592
merged_meta = SpecMeta(
598593
description=f"{self.meta.description} + {extension.meta.description}",
599-
size=self.meta.size,
600594
geography=self.meta.geography,
601595
agent_focus=self.meta.agent_focus,
602596
created_at=datetime.now(),
@@ -732,7 +726,6 @@ class SufficiencyResult(BaseModel):
732726
"""Result from context sufficiency check (Step 0)."""
733727

734728
sufficient: bool
735-
size: int = Field(default=1000, description="Extracted or default population size")
736729
geography: str | None = None
737730
agent_focus: str | None = Field(
738731
default=None,

extropy/population/network/config_generator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ def _build_prompt(
256256
257257
## Population
258258
- Description: {population_spec.meta.description}
259-
- Size: {population_spec.meta.size} people
260259
- Location/context: {population_spec.meta.geography or "unspecified"}
261260
262261
## Available Attributes

extropy/population/sampler/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _has_household_attributes(spec: PopulationSpec) -> bool:
7979

8080
def sample_population(
8181
spec: PopulationSpec,
82-
count: int | None = None,
82+
count: int,
8383
seed: int | None = None,
8484
on_progress: ItemProgressCallback | None = None,
8585
) -> SamplingResult:
@@ -92,7 +92,7 @@ def sample_population(
9292
9393
Args:
9494
spec: The population specification to sample from
95-
count: Number of agents to generate (defaults to spec.meta.size)
95+
count: Number of agents to generate (required)
9696
seed: Random seed for reproducibility (None = random)
9797
on_progress: Optional callback(current, total) for progress updates
9898
@@ -103,7 +103,7 @@ def sample_population(
103103
SamplingError: If sampling fails for any agent (e.g., formula error)
104104
"""
105105
# Resolve count
106-
n = count if count is not None else spec.meta.size
106+
n = count
107107

108108
# Initialize RNG
109109
if seed is None:

extropy/population/spec_builder/binder.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ def _compute_grounding_summary(
188188

189189
def build_spec(
190190
description: str,
191-
size: int,
192191
geography: str | None,
193192
attributes: list[AttributeSpec],
194193
sampling_order: list[str],
@@ -202,7 +201,6 @@ def build_spec(
202201
203202
Args:
204203
description: Original population description
205-
size: Number of agents
206204
geography: Geographic scope
207205
attributes: List of AttributeSpec
208206
sampling_order: Order for sampling
@@ -216,7 +214,6 @@ def build_spec(
216214
"""
217215
meta = SpecMeta(
218216
description=description,
219-
size=size,
220217
geography=geography,
221218
agent_focus=agent_focus,
222219
created_at=datetime.now(),

extropy/population/spec_builder/selector.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ def _is_multi_country_geography(geography: str | None, description: str) -> bool
152152

153153
def select_attributes(
154154
description: str,
155-
size: int,
156155
geography: str | None = None,
157156
context: list[AttributeSpec] | None = None,
158157
model: str | None = None,
@@ -173,7 +172,6 @@ def select_attributes(
173172
174173
Args:
175174
description: Natural language population description
176-
size: Number of agents (for context)
177175
geography: Geographic scope if known
178176
context: Existing attributes from base population (for extend mode)
179177
model: Model to use
@@ -240,7 +238,7 @@ def select_attributes(
240238
241239
## Population
242240
243-
"{description}" ({size} agents{geo_context})
241+
"{description}"{geo_context}
244242
245243
{constraint_note}
246244

0 commit comments

Comments
 (0)