1. Goal
Превратить immutable/frozen corpus из TASK-009 в deterministic build structure: ordered batches + один machine-readable DatasetManifest, который затем будет единственным входом для renderer.
2. Entry gate
| Проверка | Требование | Если нет |
|---|---|---|
| TASK-001 | Batch/DatasetManifest contracts VERIFIED | STOP |
| TASK-009 | Frozen ordered ArticleIdentity corpus VERIFIED | STOP |
| Corpus freeze | corpus_build_id immutable for this compile | STOP |
| IDs/navigation | article_id + sequence_number + prev/next valid | STOP |
| Schema target | STATIYA_ARTICLE_DATABASE 1.0 | STOP |
3. Core principles
- Maximum 30 logical articles per batch.
- Only final batch may be partial.
- Batching never changes article order.
- Batching never reassigns article IDs.
- DatasetManifest is generated from the frozen corpus, not from rendered HTML.
- article_count and batch_count are derived, never hand-entered.
- Every article belongs to exactly one batch per build.
- Batch boundaries are continuous and gap-free.
- Machine navigation must be complete before rendering.
- Same frozen corpus + same compiler version → same batch graph/manifest.
4. Scope
IN SCOPE
- batch partitioning;
- batch IDs/numbers;
- sequence start/end;
- full vs partial batch flag;
- article membership;
- prev/next batch refs;
- DatasetManifest;
- schema/build metadata;
- ordering summary;
- validation summary;
- AI traversal instructions;
- deterministic compile tests.
OUT OF SCOPE
- HTML templates;
- CSS;
- JSON embedding into pages;
- MASTER INDEX rendering;
- deploy;
- Work catalog registration;
- crawler/classifier logic;
- reordering ArticleIdentity corpus.
5. Input corpus
{
"corpus_build_id": "...",
"source_id": "SRC",
"source_name": "...",
"source_url": "...",
"ordering": {
"method": "ARCHIVE_ORDER",
"direction": "DESC",
"confidence": "HIGH",
"evidence_refs": []
},
"articles": [
{
"article_id": "SRC_000001",
"sequence_number": 1,
"canonical_url": "...",
"title": "...",
"prev_article_id": null,
"next_article_id": "SRC_000002"
}
]
}
Preconditions
- articles sorted by
sequence_number; - sequence numbers continuous from 1..N for initial build;
- article IDs unique;
- canonical URLs unique within frozen logical corpus;
- prev/next chain valid;
- corpus not mutable during compile.
6. Batching algorithm
Canonical initial algorithm:
MAX_BATCH_SIZE = 30
for start in range(0, article_count, MAX_BATCH_SIZE):
chunk = articles[start:start + MAX_BATCH_SIZE]
create Batch(
batch_number = start // 30 + 1,
article_ids = chunk.article_ids,
sequence_start = chunk.first.sequence_number,
sequence_end = chunk.last.sequence_number,
article_count = len(chunk),
is_partial = len(chunk) < 30
)
Examples
| Articles | Batches | Shape |
|---|---|---|
| 1 | 1 | 1 partial |
| 29 | 1 | 29 partial |
| 30 | 1 | 30 full |
| 31 | 2 | 30 full + 1 partial |
| 60 | 2 | 30 + 30 full |
| 61 | 3 | 30 + 30 + 1 partial |
7. Batch IDs
Batch ID должен быть deterministic within build/source.
Conceptual examples
SRC_BATCH_001 SRC_BATCH_002 SRC_BATCH_003
Rules
- batch_id unique within dataset build;
- batch_number starts at 1;
- batch ID does not replace build ID;
- filename may later derive from sequence range, but compiler does not hardcode renderer filename unless contract says so;
- same frozen initial corpus → same batch numbering.
8. Sequence boundaries
{
"batch_number": 2,
"sequence_start": 31,
"sequence_end": 60,
"article_count": 30,
"is_partial": false
}
Validation equations
sequence_end - sequence_start + 1 == article_count batch[0].sequence_start == 1 for every adjacent pair: next.sequence_start == current.sequence_end + 1
Global invariant
sum(batch.article_count) == dataset.article_count
10. DatasetManifest
{
"schema_name": "STATIYA_ARTICLE_DATABASE",
"schema_version": "1.0",
"dataset_id": "SRC_DATASET",
"source_id": "SRC",
"source_name": "Example Source",
"source_url": "https://example.invalid/",
"build_id": "BUILD_...",
"corpus_build_id": "CORPUS_...",
"dataset_status": "DRAFT",
"article_count": 61,
"batch_count": 3,
"ordering": {
"method": "ARCHIVE_ORDER",
"direction": "DESC",
"confidence": "HIGH",
"evidence_refs": []
},
"batches": [
{"batch_id":"SRC_BATCH_001","batch_number":1,"sequence_start":1,"sequence_end":30},
{"batch_id":"SRC_BATCH_002","batch_number":2,"sequence_start":31,"sequence_end":60},
{"batch_id":"SRC_BATCH_003","batch_number":3,"sequence_start":61,"sequence_end":61}
],
"validation_summary": {
"status": "PASS",
"checks_total": 0,
"checks_passed": 0,
"checks_failed": 0,
"warnings": 0,
"release_blockers": [],
"evidence_refs": []
},
"generator": {
"component": "batch_manifest_compiler",
"version": "REAL_VALUE"
},
"created_at": "..."
}
11. STATIYA_ARTICLE_DATABASE 1.0
TASK-010 фиксирует dataset-level representation, которую renderer будет встраивать в MASTER и batch HTML.
Dataset-level required metadata
- schema name/version;
- dataset/source identity;
- build identity;
- status;
- article_count;
- batch_count;
- ordering method/confidence/evidence;
- ordered batch directory;
- validation summary;
- generator/version;
- AI traversal metadata.
Batch-level required metadata
- batch_id;
- batch_number;
- sequence range;
- article_count;
- article IDs in order;
- prev/next batch;
- build/source IDs.
Article-level data remains from TASK-009
- article_id;
- sequence_number;
- title;
- canonical_url;
- aliases;
- prev/next article IDs;
- ordering metadata;
- verification status;
- versions.
12. AI traversal metadata
Manifest должен позволять другой AI-системе использовать dataset без визуального HTML parsing.
Canonical instructions
- Open MASTER dataset manifest.
- Read source/dataset/build metadata.
- Choose batch by sequence range or article ID.
- Open corresponding batch manifest/page.
- Find article by ID/title/sequence/canonical URL.
- Use prev/next article IDs for traversal.
- Use prev/next batch IDs for batch traversal.
- Open original source URL only when actual article content is required.
Machine field
{
"ai_traversal": {
"entrypoint": "MASTER",
"batch_lookup": ["article_id", "sequence_number", "canonical_url", "title"],
"article_navigation": ["prev_article_id", "next_article_id"],
"batch_navigation": ["prev_batch_id", "next_batch_id"],
"content_policy": "OPEN_ORIGINAL_SOURCE_WHEN_BODY_CONTENT_IS_NEEDED"
}
}
13. Validation rules
Article corpus
- article IDs unique;
- sequence numbers unique/continuous;
- canonical URLs unique within logical corpus;
- prev/next article chain valid.
Batches
- 1..30 articles each;
- only final batch may be partial;
- batch numbers continuous;
- sequence boundaries continuous;
- article appears in exactly one batch;
- batch article order equals corpus order;
- prev/next batch chain valid.
Manifest
article_count == len(corpus);batch_count == len(batches);sum(batch.article_count) == article_count;- all manifest batch refs resolve;
- schema name/version exact;
- ordering metadata present;
- build IDs consistent;
- no release blocker before status can progress beyond DRAFT.
14. Cross-layer consistency contract for TASK-011
Renderer later обязан отобразить ровно тот corpus, который уже скомпилировал TASK-010. Поэтому TASK-010 должен предоставить renderer-ready canonical inputs.
Renderer input package
{
"dataset_manifest": {...},
"batches": [
{
"batch": {...},
"articles": [...]
}
]
}
Rules
- renderer не делает повторный batching;
- renderer не сортирует articles заново;
- renderer не меняет article IDs;
- renderer не вычисляет counts вручную;
- visible records и embedded JSON читаются из одного canonical structure.
15. Build / version metadata
Различать:
- schema_version — структура dataset contract;
- compiler_version — версия TASK-010 implementation;
- corpus_build_id — замороженный logical corpus;
- dataset build_id — конкретная compiled dataset build;
- renderer_version — появится в TASK-011.
Determinism
При одинаковом corpus_build_id и одинаковой compiler version структурный результат должен быть эквивалентным. Runtime timestamps могут отличаться, но не membership/order/batch boundaries.
16. Partial corpus / edge cases
1–29 valid articles
- один partial batch;
- owner gate всё равно сохраняется на product flow;
- batch_count = 1;
- prev/next batch null.
0 articles
Нельзя компилировать «пустой успешный dataset» автоматически.
Это должно быть explicit PARTIAL/FAILED product outcome с reason/evidence,
а не article_count=0, status=VALIDATED.
Exactly 30
Один full batch, is_partial=false.
31+
Все batches full, кроме последнего при remainder.
17. Required frozen fixtures
| Corpus size | Expected batches | Key expectation |
|---|---|---|
| 1 | 1 | partial 1–1 |
| 29 | 1 | partial 1–29 |
| 30 | 1 | full 1–30 |
| 31 | 2 | 30 + 1 |
| 59 | 2 | 30 + 29 |
| 60 | 2 | 30 + 30 |
| 61 | 3 | 30 + 30 + 1 |
| 90 | 3 | 30 + 30 + 30 |
| 91 | 4 | 30 + 30 + 30 + 1 |
Negative fixtures
- duplicate article ID;
- duplicate sequence number;
- gap in sequence;
- article in two batches;
- batch with 31 articles;
- middle partial batch;
- broken prev/next batch link;
- manifest count mismatch;
- wrong schema name/version;
- zero-article validated dataset.
18. Acceptance tests
Batching
- all fixture corpus sizes produce exact expected boundaries;
- no batch exceeds 30;
- only final batch may be partial;
- article membership complete and exclusive;
- order preserved exactly.
Navigation
- first/last batch null edges correct;
- middle prev/next symmetric;
- no missing/cyclic invalid link;
- article navigation from TASK-009 unchanged.
Manifest
- exact schema name/version;
- article_count derived correctly;
- batch_count derived correctly;
- ordering metadata preserved;
- all build/source IDs consistent;
- AI traversal metadata present;
- validation summary generated from actual checks.
Determinism
- same frozen corpus compiled twice → same batch graph;
- same article IDs/order;
- same sequence boundaries;
- same manifest semantics excluding allowed volatile timestamps.
19. Luna / Medium dispatch packet
TASK_ID: TASK-010 TITLE: Batch + Dataset Manifest Compiler GOAL: Compile the frozen ordered ArticleIdentity corpus into deterministic batches of at most 30 articles and one validated STATIYA_ARTICLE_DATABASE 1.0 DatasetManifest. READ FIRST: - immutable START_PROJECT: FILL_FROM_PROJECT - /razraba/project_state.json - TASK-001 Batch/DatasetManifest contracts - TASK-009 frozen ArticleIdentity corpus + evidence - accepted schema/build conventions REUSE FIRST: Use existing serialization/schema validation helpers already present in the repository. Do not duplicate renderer/template responsibilities. ALLOWED WRITES: - exact batch compiler module - dataset manifest compiler/validator - TASK-010 fixtures/tests - TASK-010 evidence/checkpoint DO NOT: - render HTML - change article order - change article IDs - redo logical dedup - recalculate canonical URLs - infer publication order - deploy - hand-edit article_count/batch_count - create batches larger than 30 - refactor unrelated modules IMPLEMENT: 1. validate frozen corpus preconditions 2. partition into max-30 batches 3. assign batch_number / batch_id 4. calculate sequence_start/end 5. mark only final partial batch 6. build prev/next batch chain 7. build DatasetManifest 8. preserve ordering metadata 9. add AI traversal metadata 10. derive article_count/batch_count 11. run structural validation 12. expose renderer-ready canonical input package 13. frozen fixture tests for 1/29/30/31/59/60/61/90/91 14. negative invariant tests CRITICAL INVARIANTS: - max 30 per batch - only final batch may be partial - batching preserves corpus order - batching never changes article IDs - every article belongs to exactly one batch - boundaries are continuous - counts are derived - manifest schema is STATIYA_ARTICLE_DATABASE 1.0 - renderer must consume compiler output, not rebuild it ACCEPTANCE: - all size fixtures PASS - negative invariant fixtures reject - deterministic replay PASS - batch navigation PASS - manifest counts/build IDs PASS - AI traversal metadata present - no HTML rendering code added - no unrelated diff RETURN: 1. changed files 2. compiler/validator components added or reused 3. fixture matrix results 4. generated manifest example 5. tests executed 6. PASS/FAIL results 7. evidence paths 8. known gaps 9. next consumer: TASK-011
20. Verification protocol
1. Load frozen corpus fixture size 1 and validate batch output. 2. Repeat for 29, 30, 31, 59, 60, 61, 90, 91. 3. Run duplicate-ID negative fixture. 4. Run duplicate/gapped sequence negative fixtures. 5. Run 31-in-one-batch negative fixture. 6. Run middle-partial-batch negative fixture. 7. Run broken batch-navigation negative fixture. 8. Run manifest-count mismatch fixture. 9. Run zero-article validated-dataset negative fixture. 10. Compile identical corpus twice and compare structural output. 11. Validate renderer-input package shape. 12. Run existing relevant tests/lint/type-check. 13. Inspect git diff. 14. Record evidence. 15. Update /razraba only after PASS.
Required evidence record
{
"task_id": "TASK-010",
"result": "PASS | FAIL | BLOCKED",
"compiler_version": "REAL_VALUE",
"repo_revision_before": "REAL_VALUE",
"repo_revision_after": "REAL_VALUE",
"tests": {
"batch_sizes": "PASS | FAIL",
"boundaries": "PASS | FAIL",
"membership": "PASS | FAIL",
"batch_navigation": "PASS | FAIL",
"manifest_counts": "PASS | FAIL",
"schema_validation": "PASS | FAIL",
"ai_traversal": "PASS | FAIL",
"deterministic_replay": "PASS | FAIL",
"negative_invariants": "PASS | FAIL"
},
"example_manifest_ref": "...",
"known_gaps": [],
"next_consumer": "TASK-011"
}
21. Rollback / risks
| Риск | Действие |
|---|---|
| Batch >30 | RELEASE BLOCKER fix partitioning/validation |
| Middle partial batch appears | RELEASE BLOCKER |
| Compiler changes article order | Revert sorting; consume frozen order exactly |
| Compiler reassigns article IDs | RELEASE BLOCKER |
| Manifest counts manually stored and stale | Derive from canonical structures |
| Renderer logic leaks into compiler | Move presentation/template code to TASK-011 |
| Machine structure differs from renderer input | Expose one canonical renderer-input package |
| Replay changes batch boundaries | RELEASE BLOCKER |
| Unrelated diff | Revert unrelated changes |
22. Definition of Done
TASK-010 получает статус VERIFIED, только если:
- frozen corpus проходит pre-validation;
- batches создаются максимум по 30;
- только последний batch может быть partial;
- article order/IDs не меняются;
- membership complete/exclusive;
- sequence boundaries continuous;
- batch prev/next chain consistent;
- DatasetManifest соответствует
STATIYA_ARTICLE_DATABASE 1.0; - article_count/batch_count derived correctly;
- ordering/build metadata preserved;
- AI traversal metadata присутствует;
- renderer-ready package сформирован;
- same-input replay deterministic;
- positive/negative fixtures PASS;
- evidence записан;
- project_state/checkpoint обновлены после PASS.
23. Next exact action
После успешного TASK-010 следующий implementation packet:
EXEC-36 — TASK-011 MASTER + BATCH HTML RENDERER V1 IMPLEMENTATION PACKET
Он должен определить:
- renderer читает только TASK-010 canonical package;
- MASTER INDEX;
- batch HTML pages;
- minimal human-visible records;
- embedded
<script type="application/json">manifests; - optional JSON-LD ItemList;
rel=prev/next;- visible-vs-machine exact consistency;
- safe escaping;
- responsive editorial style без purple/lilac;
- stable filenames;
- render snapshot tests;
- rendered dataset validation.