@happyvertical/smrt-education 0.59.1 → 0.60.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -1
- package/README.md +7 -2
- package/agents/class-crunchlabs.md +32 -4
- package/agents/course-bundle-import.md +89 -10
- package/agents/lesson-materials.md +21 -4
- package/dist/chunks/course-authoring-contracts-C4Hqba-e.js.map +1 -1
- package/dist/chunks/{course-bundle-zip-5KUe3C5H.js → course-bundle-zip-CGR1Ci0Z.js} +3 -2
- package/dist/chunks/course-bundle-zip-CGR1Ci0Z.js.map +1 -0
- package/dist/chunks/{workbook-photo-service-CjcB0y8Y.js → workbook-photo-service-DHP5ja82.js} +103 -46
- package/dist/chunks/workbook-photo-service-DHP5ja82.js.map +1 -0
- package/dist/course-authoring-contracts.d.ts +1 -1
- package/dist/course-authoring-contracts.d.ts.map +1 -1
- package/dist/course-bundle-contracts.d.ts +2 -0
- package/dist/course-bundle-contracts.d.ts.map +1 -1
- package/dist/course-bundle-manifest-v2.d.ts +24 -1
- package/dist/course-bundle-manifest-v2.d.ts.map +1 -1
- package/dist/course-bundle-models.d.ts +88 -0
- package/dist/course-bundle-models.d.ts.map +1 -1
- package/dist/course-bundle-service.d.ts +153 -7
- package/dist/course-bundle-service.d.ts.map +1 -1
- package/dist/course-bundle.d.ts +17 -0
- package/dist/course-bundle.d.ts.map +1 -1
- package/dist/document-converter.d.ts +8 -0
- package/dist/document-converter.d.ts.map +1 -1
- package/dist/hearth-class-crunchlabs.d.ts +3 -2
- package/dist/hearth-class-crunchlabs.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +930 -142
- package/dist/index.js.map +1 -1
- package/dist/ingestion.js +1 -1
- package/dist/lesson-assets.d.ts +19 -0
- package/dist/lesson-assets.d.ts.map +1 -1
- package/dist/manifest.json +1803 -145
- package/dist/node.js +1 -1
- package/dist/smrt-knowledge.json +571 -15
- package/dist/sources/class-crunchlabs.d.ts +18 -0
- package/dist/sources/class-crunchlabs.d.ts.map +1 -1
- package/dist/submission-service.d.ts +24 -4
- package/dist/submission-service.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunks/course-bundle-zip-5KUe3C5H.js.map +0 -1
- package/dist/chunks/workbook-photo-service-CjcB0y8Y.js.map +0 -1
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-education",
|
|
6
|
-
"packageVersion": "0.
|
|
6
|
+
"packageVersion": "0.60.1",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
13
|
-
"moduleDoc:agents/lesson-materials.md": "
|
|
10
|
+
"manifest": "cf503e06deeb6fc6bbde8f30f6ea530b1a923c2a9622120f65ea2771bf50c29f",
|
|
11
|
+
"packageJson": "250593fd2c1215ec45fdf75dd514fc1f7f47fcac2500186dc25455704e936bce",
|
|
12
|
+
"agents": "72c5864c632190acc923ef81f5b11d8bcc76d61206bc4565948fd26d5c06d08b",
|
|
13
|
+
"moduleDoc:agents/lesson-materials.md": "4647e654fe3f5db0dc786e5ef7126ced5af9a7372805ddff8ebf8ded41bb5c1a",
|
|
14
14
|
"moduleDoc:agents/learner-service.md": "d7edf68000aec96b52920fb5e8dc4ff4e20b1d81b34413809e8212a885e1c3f9",
|
|
15
15
|
"moduleDoc:agents/submission-service.md": "0bb827a62848a3e0708fe2545eac7b64f829a6c9be96eee849c8f16c1fa631d0",
|
|
16
16
|
"moduleDoc:agents/lesson-work-service.md": "286dd0197b9bc8471636d58b67f9e11591a175eb5bafb1f7af03d5fee988b86d",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"moduleDoc:agents/course-generation-review.md": "7f6d5e67ed56ec9923bd00df05650b363fb0db30c1b1f004c8b203f9c62cd117",
|
|
21
21
|
"moduleDoc:agents/question-records.md": "c1648cccc27ed46b1b60cded93b20c7f3812cbcd2c37f183fd727ac030364703",
|
|
22
22
|
"moduleDoc:agents/question-extraction.md": "75972dda9b2f837471fb42f963ef143a098005c919a1a49db7ce395a5e5e50a7",
|
|
23
|
-
"moduleDoc:agents/course-bundle-import.md": "
|
|
24
|
-
"moduleDoc:agents/class-crunchlabs.md": "
|
|
23
|
+
"moduleDoc:agents/course-bundle-import.md": "2988680320bbb1d92214f75bfd2cd864d38e2027d064cbc7f575c34ca604fd07",
|
|
24
|
+
"moduleDoc:agents/class-crunchlabs.md": "1b227d83ebb1baeb4a2d78b529fba77f1afec5a12abb8e791090d723865abce5",
|
|
25
25
|
"moduleDoc:agents/source-import.md": "30ee823589d655442bcf1abcd86a2132172065b4bc5e3c4d89b1e8b7afcc66bc",
|
|
26
26
|
"moduleDoc:agents/family-intake.md": "540b6d37f438496acb0208b6ac7258264e2142bce3d2f986967b7741606fe4f7",
|
|
27
27
|
"moduleDoc:agents/catalog-previews.md": "5f4e0352274009b3ce00408017a16666036d24df695a7078c27317ba4e66f0a7",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"smrt"
|
|
74
74
|
],
|
|
75
75
|
"risks": [
|
|
76
|
-
"cross-package-refs:
|
|
76
|
+
"cross-package-refs:28",
|
|
77
77
|
"sensitive-fields-excluded",
|
|
78
78
|
"sti-inheritance"
|
|
79
79
|
],
|
|
@@ -5541,6 +5541,492 @@
|
|
|
5541
5541
|
"tags": [],
|
|
5542
5542
|
"risks": []
|
|
5543
5543
|
},
|
|
5544
|
+
{
|
|
5545
|
+
"name": "CourseBundleAttachment",
|
|
5546
|
+
"qualifiedName": "@happyvertical/smrt-education:CourseBundleAttachment",
|
|
5547
|
+
"collection": "coursebundleattachments",
|
|
5548
|
+
"description": "Append-only record that one imported bundle (a part of a unit) was attached to a family course (SMRT #4632).",
|
|
5549
|
+
"tableName": "course_bundle_attachments",
|
|
5550
|
+
"packageName": "@happyvertical/smrt-education",
|
|
5551
|
+
"extends": "SmrtObject",
|
|
5552
|
+
"fields": [
|
|
5553
|
+
{
|
|
5554
|
+
"name": "tenantId",
|
|
5555
|
+
"type": "text",
|
|
5556
|
+
"required": true,
|
|
5557
|
+
"columnType": "UUID"
|
|
5558
|
+
},
|
|
5559
|
+
{
|
|
5560
|
+
"name": "importId",
|
|
5561
|
+
"type": "foreignKey",
|
|
5562
|
+
"required": true,
|
|
5563
|
+
"related": "CourseBundleImport",
|
|
5564
|
+
"columnType": "UUID"
|
|
5565
|
+
},
|
|
5566
|
+
{
|
|
5567
|
+
"name": "courseId",
|
|
5568
|
+
"type": "foreignKey",
|
|
5569
|
+
"required": true,
|
|
5570
|
+
"related": "Course",
|
|
5571
|
+
"columnType": "UUID"
|
|
5572
|
+
},
|
|
5573
|
+
{
|
|
5574
|
+
"name": "unitKey",
|
|
5575
|
+
"type": "text",
|
|
5576
|
+
"required": false,
|
|
5577
|
+
"columnType": "TEXT"
|
|
5578
|
+
},
|
|
5579
|
+
{
|
|
5580
|
+
"name": "partIndex",
|
|
5581
|
+
"type": "integer",
|
|
5582
|
+
"required": true,
|
|
5583
|
+
"columnType": "INTEGER",
|
|
5584
|
+
"default": 1
|
|
5585
|
+
},
|
|
5586
|
+
{
|
|
5587
|
+
"name": "partCount",
|
|
5588
|
+
"type": "integer",
|
|
5589
|
+
"required": true,
|
|
5590
|
+
"columnType": "INTEGER",
|
|
5591
|
+
"default": 1
|
|
5592
|
+
},
|
|
5593
|
+
{
|
|
5594
|
+
"name": "attachedByUserId",
|
|
5595
|
+
"type": "text",
|
|
5596
|
+
"required": false,
|
|
5597
|
+
"columnType": "TEXT"
|
|
5598
|
+
},
|
|
5599
|
+
{
|
|
5600
|
+
"name": "recordedAt",
|
|
5601
|
+
"type": "text",
|
|
5602
|
+
"required": false,
|
|
5603
|
+
"columnType": "TEXT"
|
|
5604
|
+
}
|
|
5605
|
+
],
|
|
5606
|
+
"relationships": [
|
|
5607
|
+
{
|
|
5608
|
+
"name": "importId",
|
|
5609
|
+
"type": "foreignKey",
|
|
5610
|
+
"required": true,
|
|
5611
|
+
"related": "CourseBundleImport",
|
|
5612
|
+
"columnType": "UUID"
|
|
5613
|
+
},
|
|
5614
|
+
{
|
|
5615
|
+
"name": "courseId",
|
|
5616
|
+
"type": "foreignKey",
|
|
5617
|
+
"required": true,
|
|
5618
|
+
"related": "Course",
|
|
5619
|
+
"columnType": "UUID"
|
|
5620
|
+
}
|
|
5621
|
+
],
|
|
5622
|
+
"methods": [
|
|
5623
|
+
"delete",
|
|
5624
|
+
"save"
|
|
5625
|
+
],
|
|
5626
|
+
"methodSignatures": [
|
|
5627
|
+
{
|
|
5628
|
+
"name": "delete",
|
|
5629
|
+
"async": true,
|
|
5630
|
+
"returns": "Promise<void>"
|
|
5631
|
+
},
|
|
5632
|
+
{
|
|
5633
|
+
"name": "save",
|
|
5634
|
+
"async": true,
|
|
5635
|
+
"params": [
|
|
5636
|
+
"options?: SmrtSaveOptions"
|
|
5637
|
+
],
|
|
5638
|
+
"returns": "Promise<this>"
|
|
5639
|
+
}
|
|
5640
|
+
],
|
|
5641
|
+
"tenant": {
|
|
5642
|
+
"scoped": true,
|
|
5643
|
+
"mode": "required",
|
|
5644
|
+
"field": "tenantId"
|
|
5645
|
+
},
|
|
5646
|
+
"conflictColumns": [
|
|
5647
|
+
"tenant_id",
|
|
5648
|
+
"import_id"
|
|
5649
|
+
],
|
|
5650
|
+
"surfaces": [],
|
|
5651
|
+
"withheldSurfaces": [
|
|
5652
|
+
{
|
|
5653
|
+
"kind": "api",
|
|
5654
|
+
"operation": "delete",
|
|
5655
|
+
"code": "api-disabled",
|
|
5656
|
+
"reason": "api is disabled",
|
|
5657
|
+
"objectName": "@happyvertical/smrt-education:CourseBundleAttachment"
|
|
5658
|
+
},
|
|
5659
|
+
{
|
|
5660
|
+
"kind": "api",
|
|
5661
|
+
"operation": "save",
|
|
5662
|
+
"code": "api-disabled",
|
|
5663
|
+
"reason": "api is disabled",
|
|
5664
|
+
"objectName": "@happyvertical/smrt-education:CourseBundleAttachment"
|
|
5665
|
+
}
|
|
5666
|
+
],
|
|
5667
|
+
"relationshipFeatures": [
|
|
5668
|
+
"foreignKey",
|
|
5669
|
+
"uuidColumns"
|
|
5670
|
+
],
|
|
5671
|
+
"tags": [],
|
|
5672
|
+
"risks": []
|
|
5673
|
+
},
|
|
5674
|
+
{
|
|
5675
|
+
"name": "CourseBundleAttachmentCollection",
|
|
5676
|
+
"qualifiedName": "@happyvertical/smrt-education:CourseBundleAttachmentCollection",
|
|
5677
|
+
"collection": "coursebundleattachments",
|
|
5678
|
+
"tableName": "course_bundle_attachments",
|
|
5679
|
+
"packageName": "@happyvertical/smrt-education",
|
|
5680
|
+
"extends": "SmrtCollection",
|
|
5681
|
+
"fields": [],
|
|
5682
|
+
"relationships": [],
|
|
5683
|
+
"methods": [],
|
|
5684
|
+
"surfaces": [],
|
|
5685
|
+
"relationshipFeatures": [
|
|
5686
|
+
"uuidColumns"
|
|
5687
|
+
],
|
|
5688
|
+
"tags": [],
|
|
5689
|
+
"risks": []
|
|
5690
|
+
},
|
|
5691
|
+
{
|
|
5692
|
+
"name": "CourseBundleAudienceChoice",
|
|
5693
|
+
"qualifiedName": "@happyvertical/smrt-education:CourseBundleAudienceChoice",
|
|
5694
|
+
"collection": "coursebundleaudiencechoices",
|
|
5695
|
+
"description": "A guardian's audience choice for one material of an import, made in review before the bundle is attached (SMRT #4632). One row per (import, target); a later choice replaces the earlier one.",
|
|
5696
|
+
"tableName": "course_bundle_audience_choices",
|
|
5697
|
+
"packageName": "@happyvertical/smrt-education",
|
|
5698
|
+
"extends": "SmrtObject",
|
|
5699
|
+
"fields": [
|
|
5700
|
+
{
|
|
5701
|
+
"name": "tenantId",
|
|
5702
|
+
"type": "text",
|
|
5703
|
+
"required": true,
|
|
5704
|
+
"columnType": "UUID"
|
|
5705
|
+
},
|
|
5706
|
+
{
|
|
5707
|
+
"name": "importId",
|
|
5708
|
+
"type": "foreignKey",
|
|
5709
|
+
"required": true,
|
|
5710
|
+
"related": "CourseBundleImport",
|
|
5711
|
+
"columnType": "UUID"
|
|
5712
|
+
},
|
|
5713
|
+
{
|
|
5714
|
+
"name": "target",
|
|
5715
|
+
"type": "text",
|
|
5716
|
+
"required": false,
|
|
5717
|
+
"columnType": "TEXT"
|
|
5718
|
+
},
|
|
5719
|
+
{
|
|
5720
|
+
"name": "audience",
|
|
5721
|
+
"type": "text",
|
|
5722
|
+
"required": false,
|
|
5723
|
+
"columnType": "TEXT"
|
|
5724
|
+
},
|
|
5725
|
+
{
|
|
5726
|
+
"name": "chosenByUserId",
|
|
5727
|
+
"type": "text",
|
|
5728
|
+
"required": false,
|
|
5729
|
+
"columnType": "TEXT"
|
|
5730
|
+
},
|
|
5731
|
+
{
|
|
5732
|
+
"name": "chosenAt",
|
|
5733
|
+
"type": "text",
|
|
5734
|
+
"required": false,
|
|
5735
|
+
"columnType": "TEXT"
|
|
5736
|
+
}
|
|
5737
|
+
],
|
|
5738
|
+
"relationships": [
|
|
5739
|
+
{
|
|
5740
|
+
"name": "importId",
|
|
5741
|
+
"type": "foreignKey",
|
|
5742
|
+
"required": true,
|
|
5743
|
+
"related": "CourseBundleImport",
|
|
5744
|
+
"columnType": "UUID"
|
|
5745
|
+
}
|
|
5746
|
+
],
|
|
5747
|
+
"methods": [
|
|
5748
|
+
"save"
|
|
5749
|
+
],
|
|
5750
|
+
"methodSignatures": [
|
|
5751
|
+
{
|
|
5752
|
+
"name": "save",
|
|
5753
|
+
"async": true,
|
|
5754
|
+
"params": [
|
|
5755
|
+
"options?: SmrtSaveOptions"
|
|
5756
|
+
],
|
|
5757
|
+
"returns": "Promise<this>"
|
|
5758
|
+
}
|
|
5759
|
+
],
|
|
5760
|
+
"tenant": {
|
|
5761
|
+
"scoped": true,
|
|
5762
|
+
"mode": "required",
|
|
5763
|
+
"field": "tenantId"
|
|
5764
|
+
},
|
|
5765
|
+
"conflictColumns": [
|
|
5766
|
+
"tenant_id",
|
|
5767
|
+
"import_id",
|
|
5768
|
+
"target"
|
|
5769
|
+
],
|
|
5770
|
+
"surfaces": [],
|
|
5771
|
+
"withheldSurfaces": [
|
|
5772
|
+
{
|
|
5773
|
+
"kind": "api",
|
|
5774
|
+
"operation": "save",
|
|
5775
|
+
"code": "api-disabled",
|
|
5776
|
+
"reason": "api is disabled",
|
|
5777
|
+
"objectName": "@happyvertical/smrt-education:CourseBundleAudienceChoice"
|
|
5778
|
+
}
|
|
5779
|
+
],
|
|
5780
|
+
"relationshipFeatures": [
|
|
5781
|
+
"foreignKey",
|
|
5782
|
+
"uuidColumns"
|
|
5783
|
+
],
|
|
5784
|
+
"tags": [],
|
|
5785
|
+
"risks": []
|
|
5786
|
+
},
|
|
5787
|
+
{
|
|
5788
|
+
"name": "CourseBundleAudienceChoiceCollection",
|
|
5789
|
+
"qualifiedName": "@happyvertical/smrt-education:CourseBundleAudienceChoiceCollection",
|
|
5790
|
+
"collection": "coursebundleaudiencechoices",
|
|
5791
|
+
"tableName": "course_bundle_audience_choices",
|
|
5792
|
+
"packageName": "@happyvertical/smrt-education",
|
|
5793
|
+
"extends": "SmrtCollection",
|
|
5794
|
+
"fields": [],
|
|
5795
|
+
"relationships": [],
|
|
5796
|
+
"methods": [],
|
|
5797
|
+
"surfaces": [],
|
|
5798
|
+
"relationshipFeatures": [
|
|
5799
|
+
"uuidColumns"
|
|
5800
|
+
],
|
|
5801
|
+
"tags": [],
|
|
5802
|
+
"risks": []
|
|
5803
|
+
},
|
|
5804
|
+
{
|
|
5805
|
+
"name": "CourseBundlePlacement",
|
|
5806
|
+
"qualifiedName": "@happyvertical/smrt-education:CourseBundlePlacement",
|
|
5807
|
+
"displayLabelField": "title",
|
|
5808
|
+
"collection": "coursebundleplacements",
|
|
5809
|
+
"description": "Where a unit's section or lesson sits, and whether its position was declared (SMRT #4632).",
|
|
5810
|
+
"tableName": "course_bundle_placements",
|
|
5811
|
+
"packageName": "@happyvertical/smrt-education",
|
|
5812
|
+
"extends": "SmrtObject",
|
|
5813
|
+
"fields": [
|
|
5814
|
+
{
|
|
5815
|
+
"name": "tenantId",
|
|
5816
|
+
"type": "text",
|
|
5817
|
+
"required": true,
|
|
5818
|
+
"columnType": "UUID"
|
|
5819
|
+
},
|
|
5820
|
+
{
|
|
5821
|
+
"name": "courseId",
|
|
5822
|
+
"type": "foreignKey",
|
|
5823
|
+
"required": true,
|
|
5824
|
+
"related": "Course",
|
|
5825
|
+
"columnType": "UUID"
|
|
5826
|
+
},
|
|
5827
|
+
{
|
|
5828
|
+
"name": "kind",
|
|
5829
|
+
"type": "text",
|
|
5830
|
+
"required": false,
|
|
5831
|
+
"columnType": "TEXT"
|
|
5832
|
+
},
|
|
5833
|
+
{
|
|
5834
|
+
"name": "key",
|
|
5835
|
+
"type": "text",
|
|
5836
|
+
"required": false,
|
|
5837
|
+
"columnType": "TEXT"
|
|
5838
|
+
},
|
|
5839
|
+
{
|
|
5840
|
+
"name": "title",
|
|
5841
|
+
"type": "text",
|
|
5842
|
+
"required": false,
|
|
5843
|
+
"columnType": "TEXT"
|
|
5844
|
+
},
|
|
5845
|
+
{
|
|
5846
|
+
"name": "declaredOrder",
|
|
5847
|
+
"type": "integer",
|
|
5848
|
+
"required": false,
|
|
5849
|
+
"columnType": "INTEGER"
|
|
5850
|
+
},
|
|
5851
|
+
{
|
|
5852
|
+
"name": "implicitOrder",
|
|
5853
|
+
"type": "integer",
|
|
5854
|
+
"required": true,
|
|
5855
|
+
"columnType": "INTEGER",
|
|
5856
|
+
"default": 0
|
|
5857
|
+
},
|
|
5858
|
+
{
|
|
5859
|
+
"name": "partIndex",
|
|
5860
|
+
"type": "integer",
|
|
5861
|
+
"required": true,
|
|
5862
|
+
"columnType": "INTEGER",
|
|
5863
|
+
"default": 1
|
|
5864
|
+
}
|
|
5865
|
+
],
|
|
5866
|
+
"relationships": [
|
|
5867
|
+
{
|
|
5868
|
+
"name": "courseId",
|
|
5869
|
+
"type": "foreignKey",
|
|
5870
|
+
"required": true,
|
|
5871
|
+
"related": "Course",
|
|
5872
|
+
"columnType": "UUID"
|
|
5873
|
+
}
|
|
5874
|
+
],
|
|
5875
|
+
"methods": [
|
|
5876
|
+
"save"
|
|
5877
|
+
],
|
|
5878
|
+
"methodSignatures": [
|
|
5879
|
+
{
|
|
5880
|
+
"name": "save",
|
|
5881
|
+
"async": true,
|
|
5882
|
+
"params": [
|
|
5883
|
+
"options?: SmrtSaveOptions"
|
|
5884
|
+
],
|
|
5885
|
+
"returns": "Promise<this>"
|
|
5886
|
+
}
|
|
5887
|
+
],
|
|
5888
|
+
"tenant": {
|
|
5889
|
+
"scoped": true,
|
|
5890
|
+
"mode": "required",
|
|
5891
|
+
"field": "tenantId"
|
|
5892
|
+
},
|
|
5893
|
+
"conflictColumns": [
|
|
5894
|
+
"tenant_id",
|
|
5895
|
+
"course_id",
|
|
5896
|
+
"kind",
|
|
5897
|
+
"key"
|
|
5898
|
+
],
|
|
5899
|
+
"surfaces": [],
|
|
5900
|
+
"withheldSurfaces": [
|
|
5901
|
+
{
|
|
5902
|
+
"kind": "api",
|
|
5903
|
+
"operation": "save",
|
|
5904
|
+
"code": "api-disabled",
|
|
5905
|
+
"reason": "api is disabled",
|
|
5906
|
+
"objectName": "@happyvertical/smrt-education:CourseBundlePlacement"
|
|
5907
|
+
}
|
|
5908
|
+
],
|
|
5909
|
+
"relationshipFeatures": [
|
|
5910
|
+
"foreignKey",
|
|
5911
|
+
"uuidColumns"
|
|
5912
|
+
],
|
|
5913
|
+
"tags": [],
|
|
5914
|
+
"risks": []
|
|
5915
|
+
},
|
|
5916
|
+
{
|
|
5917
|
+
"name": "CourseBundlePlacementCollection",
|
|
5918
|
+
"qualifiedName": "@happyvertical/smrt-education:CourseBundlePlacementCollection",
|
|
5919
|
+
"collection": "coursebundleplacements",
|
|
5920
|
+
"tableName": "course_bundle_placements",
|
|
5921
|
+
"packageName": "@happyvertical/smrt-education",
|
|
5922
|
+
"extends": "SmrtCollection",
|
|
5923
|
+
"fields": [],
|
|
5924
|
+
"relationships": [],
|
|
5925
|
+
"methods": [],
|
|
5926
|
+
"surfaces": [],
|
|
5927
|
+
"relationshipFeatures": [
|
|
5928
|
+
"uuidColumns"
|
|
5929
|
+
],
|
|
5930
|
+
"tags": [],
|
|
5931
|
+
"risks": []
|
|
5932
|
+
},
|
|
5933
|
+
{
|
|
5934
|
+
"name": "CourseBundleUnit",
|
|
5935
|
+
"qualifiedName": "@happyvertical/smrt-education:CourseBundleUnit",
|
|
5936
|
+
"collection": "coursebundleunits",
|
|
5937
|
+
"description": "The one row every attach of a unit serializes on (SMRT #4632): one per (family, unit key), created if absent and then locked at the start of the attach transaction, before anything that decides the…",
|
|
5938
|
+
"tableName": "course_bundle_units",
|
|
5939
|
+
"packageName": "@happyvertical/smrt-education",
|
|
5940
|
+
"extends": "SmrtObject",
|
|
5941
|
+
"fields": [
|
|
5942
|
+
{
|
|
5943
|
+
"name": "tenantId",
|
|
5944
|
+
"type": "text",
|
|
5945
|
+
"required": true,
|
|
5946
|
+
"columnType": "UUID"
|
|
5947
|
+
},
|
|
5948
|
+
{
|
|
5949
|
+
"name": "unitKey",
|
|
5950
|
+
"type": "text",
|
|
5951
|
+
"required": false,
|
|
5952
|
+
"columnType": "TEXT"
|
|
5953
|
+
},
|
|
5954
|
+
{
|
|
5955
|
+
"name": "courseId",
|
|
5956
|
+
"type": "text",
|
|
5957
|
+
"required": false,
|
|
5958
|
+
"columnType": "TEXT"
|
|
5959
|
+
}
|
|
5960
|
+
],
|
|
5961
|
+
"relationships": [],
|
|
5962
|
+
"methods": [
|
|
5963
|
+
"delete",
|
|
5964
|
+
"save"
|
|
5965
|
+
],
|
|
5966
|
+
"methodSignatures": [
|
|
5967
|
+
{
|
|
5968
|
+
"name": "delete",
|
|
5969
|
+
"async": true,
|
|
5970
|
+
"returns": "Promise<void>"
|
|
5971
|
+
},
|
|
5972
|
+
{
|
|
5973
|
+
"name": "save",
|
|
5974
|
+
"async": true,
|
|
5975
|
+
"params": [
|
|
5976
|
+
"options?: SmrtSaveOptions"
|
|
5977
|
+
],
|
|
5978
|
+
"returns": "Promise<this>"
|
|
5979
|
+
}
|
|
5980
|
+
],
|
|
5981
|
+
"tenant": {
|
|
5982
|
+
"scoped": true,
|
|
5983
|
+
"mode": "required",
|
|
5984
|
+
"field": "tenantId"
|
|
5985
|
+
},
|
|
5986
|
+
"conflictColumns": [
|
|
5987
|
+
"tenant_id",
|
|
5988
|
+
"unit_key"
|
|
5989
|
+
],
|
|
5990
|
+
"surfaces": [],
|
|
5991
|
+
"withheldSurfaces": [
|
|
5992
|
+
{
|
|
5993
|
+
"kind": "api",
|
|
5994
|
+
"operation": "delete",
|
|
5995
|
+
"code": "api-disabled",
|
|
5996
|
+
"reason": "api is disabled",
|
|
5997
|
+
"objectName": "@happyvertical/smrt-education:CourseBundleUnit"
|
|
5998
|
+
},
|
|
5999
|
+
{
|
|
6000
|
+
"kind": "api",
|
|
6001
|
+
"operation": "save",
|
|
6002
|
+
"code": "api-disabled",
|
|
6003
|
+
"reason": "api is disabled",
|
|
6004
|
+
"objectName": "@happyvertical/smrt-education:CourseBundleUnit"
|
|
6005
|
+
}
|
|
6006
|
+
],
|
|
6007
|
+
"relationshipFeatures": [
|
|
6008
|
+
"uuidColumns"
|
|
6009
|
+
],
|
|
6010
|
+
"tags": [],
|
|
6011
|
+
"risks": []
|
|
6012
|
+
},
|
|
6013
|
+
{
|
|
6014
|
+
"name": "CourseBundleUnitCollection",
|
|
6015
|
+
"qualifiedName": "@happyvertical/smrt-education:CourseBundleUnitCollection",
|
|
6016
|
+
"collection": "coursebundleunits",
|
|
6017
|
+
"tableName": "course_bundle_units",
|
|
6018
|
+
"packageName": "@happyvertical/smrt-education",
|
|
6019
|
+
"extends": "SmrtCollection",
|
|
6020
|
+
"fields": [],
|
|
6021
|
+
"relationships": [],
|
|
6022
|
+
"methods": [],
|
|
6023
|
+
"surfaces": [],
|
|
6024
|
+
"relationshipFeatures": [
|
|
6025
|
+
"uuidColumns"
|
|
6026
|
+
],
|
|
6027
|
+
"tags": [],
|
|
6028
|
+
"risks": []
|
|
6029
|
+
},
|
|
5544
6030
|
{
|
|
5545
6031
|
"name": "CourseGenerationJob",
|
|
5546
6032
|
"qualifiedName": "@happyvertical/smrt-education:CourseGenerationJob",
|
|
@@ -10272,6 +10758,27 @@
|
|
|
10272
10758
|
"required": false,
|
|
10273
10759
|
"columnType": "TEXT",
|
|
10274
10760
|
"default": ""
|
|
10761
|
+
},
|
|
10762
|
+
{
|
|
10763
|
+
"name": "rendition",
|
|
10764
|
+
"type": "text",
|
|
10765
|
+
"required": false,
|
|
10766
|
+
"columnType": "TEXT",
|
|
10767
|
+
"default": ""
|
|
10768
|
+
},
|
|
10769
|
+
{
|
|
10770
|
+
"name": "renditionOfAssetId",
|
|
10771
|
+
"type": "crossPackageRef",
|
|
10772
|
+
"required": false,
|
|
10773
|
+
"related": "@happyvertical/smrt-assets:Asset",
|
|
10774
|
+
"columnType": "UUID"
|
|
10775
|
+
},
|
|
10776
|
+
{
|
|
10777
|
+
"name": "thumbnailAssetId",
|
|
10778
|
+
"type": "crossPackageRef",
|
|
10779
|
+
"required": false,
|
|
10780
|
+
"related": "@happyvertical/smrt-assets:Asset",
|
|
10781
|
+
"columnType": "UUID"
|
|
10275
10782
|
}
|
|
10276
10783
|
],
|
|
10277
10784
|
"relationships": [
|
|
@@ -10288,6 +10795,20 @@
|
|
|
10288
10795
|
"required": true,
|
|
10289
10796
|
"related": "@happyvertical/smrt-assets:Asset",
|
|
10290
10797
|
"columnType": "UUID"
|
|
10798
|
+
},
|
|
10799
|
+
{
|
|
10800
|
+
"name": "renditionOfAssetId",
|
|
10801
|
+
"type": "crossPackageRef",
|
|
10802
|
+
"required": false,
|
|
10803
|
+
"related": "@happyvertical/smrt-assets:Asset",
|
|
10804
|
+
"columnType": "UUID"
|
|
10805
|
+
},
|
|
10806
|
+
{
|
|
10807
|
+
"name": "thumbnailAssetId",
|
|
10808
|
+
"type": "crossPackageRef",
|
|
10809
|
+
"required": false,
|
|
10810
|
+
"related": "@happyvertical/smrt-assets:Asset",
|
|
10811
|
+
"columnType": "UUID"
|
|
10291
10812
|
}
|
|
10292
10813
|
],
|
|
10293
10814
|
"methods": [
|
|
@@ -10388,6 +10909,27 @@
|
|
|
10388
10909
|
"required": true,
|
|
10389
10910
|
"columnType": "INTEGER",
|
|
10390
10911
|
"default": 0
|
|
10912
|
+
},
|
|
10913
|
+
{
|
|
10914
|
+
"name": "rendition",
|
|
10915
|
+
"type": "text",
|
|
10916
|
+
"required": false,
|
|
10917
|
+
"columnType": "TEXT",
|
|
10918
|
+
"default": ""
|
|
10919
|
+
},
|
|
10920
|
+
{
|
|
10921
|
+
"name": "renditionOfAssetId",
|
|
10922
|
+
"type": "crossPackageRef",
|
|
10923
|
+
"required": false,
|
|
10924
|
+
"related": "@happyvertical/smrt-assets:Asset",
|
|
10925
|
+
"columnType": "UUID"
|
|
10926
|
+
},
|
|
10927
|
+
{
|
|
10928
|
+
"name": "thumbnailAssetId",
|
|
10929
|
+
"type": "crossPackageRef",
|
|
10930
|
+
"required": false,
|
|
10931
|
+
"related": "@happyvertical/smrt-assets:Asset",
|
|
10932
|
+
"columnType": "UUID"
|
|
10391
10933
|
}
|
|
10392
10934
|
],
|
|
10393
10935
|
"relationships": [
|
|
@@ -10404,6 +10946,20 @@
|
|
|
10404
10946
|
"required": true,
|
|
10405
10947
|
"related": "@happyvertical/smrt-assets:Asset",
|
|
10406
10948
|
"columnType": "UUID"
|
|
10949
|
+
},
|
|
10950
|
+
{
|
|
10951
|
+
"name": "renditionOfAssetId",
|
|
10952
|
+
"type": "crossPackageRef",
|
|
10953
|
+
"required": false,
|
|
10954
|
+
"related": "@happyvertical/smrt-assets:Asset",
|
|
10955
|
+
"columnType": "UUID"
|
|
10956
|
+
},
|
|
10957
|
+
{
|
|
10958
|
+
"name": "thumbnailAssetId",
|
|
10959
|
+
"type": "crossPackageRef",
|
|
10960
|
+
"required": false,
|
|
10961
|
+
"related": "@happyvertical/smrt-assets:Asset",
|
|
10962
|
+
"columnType": "UUID"
|
|
10407
10963
|
}
|
|
10408
10964
|
],
|
|
10409
10965
|
"methods": [
|
|
@@ -15631,19 +16187,19 @@
|
|
|
15631
16187
|
"surfaces": [],
|
|
15632
16188
|
"prompts": [],
|
|
15633
16189
|
"relationshipsV2": {
|
|
15634
|
-
"foreignKeyFields":
|
|
15635
|
-
"crossPackageRefFields":
|
|
16190
|
+
"foreignKeyFields": 193,
|
|
16191
|
+
"crossPackageRefFields": 28,
|
|
15636
16192
|
"junctionCollections": 2,
|
|
15637
16193
|
"hierarchicalObjects": 0,
|
|
15638
16194
|
"polymorphicAssociations": 0,
|
|
15639
|
-
"uuidColumns":
|
|
16195
|
+
"uuidColumns": 832
|
|
15640
16196
|
},
|
|
15641
|
-
"agentDoc": "# smrt-education\n\nCatalog objects are optional-tenant scoped and have no generated REST, CLI, MCP,\nor AI surface. Applications use `CatalogService`, supplying their actor-bound\nauthorization decision and the trusted `TenantCollection.withTenantCatalogReadScope`\nadapter from smrt-users. Catalog authorization receives the exact shared collection\nexecutor; live session/permission checks must use that executor. That read scope may widen only an allowlisted catalog\ncollection's `list` to self, ancestors, and globals; it never authorizes a get,\nwrite, raw query, sibling, or descendant read.\n\n`personal-use-copy` courses and all `answer-key`/`assessment-guidance` material\nare private family material. Do not publish them, promote them, or expose them\nthrough a learner-facing result. `LessonAsset` (lesson) and `CourseAsset` (course)\nare the sole owner joins for material files; do not add asset-id fields to lesson\nsubclasses. Material audience rules and external videos: [lesson materials](agents/lesson-materials.md);\na learner never sees guardian-audience material.\n\nLearner objects require exact tenant ownership and close generated surfaces.\n`LearnerService` owns actor/resource authorization and transactional planning and\nstart-progress; see [learner contract](agents/learner-service.md). Guardian\nrelationships require a host decision about their type and effective terms.\nNever expose direct collection writes as learner handlers, reset progress on a\nretry, or treat an unscored nullable decimal as zero.\n\nSubmission capture, guardian grading and private PDF packet splitting use\n`SubmissionService`; see [submission contract](agents/submission-service.md).\nKeep asset metadata on the same transaction and compensate only newly planned\nfiles after rollback; never expose source URIs or accept learner grade patches.\n\nValidation: `pnpm --filter @happyvertical/smrt-education test`,\n`test:postgres`, `typecheck`, and `build`.\n\nEvery lesson hand-in is lesson work (activity, attempt, revisions, release,\ncompletion decision); books are courses with `bookKey`, pages are `LessonPage`s,\nand loose work is placed by filing. Use [LessonWorkService](agents/lesson-work-service.md)\nand the [design record](agents/course-work-design.md); `migrateWorkbooksToCourses`\nis the one-time host migration. Keep provisional sharing separate from guardian\nGrade authority; never move filed work's IDs. Photo-first receipt/context\ncapture uses [WorkbookPhotoService](agents/photo-intake.md); covers/references\nnever create learning evidence, and blank exercises need explicit work intent.\n\nRevisioned authored courses, release, archive, enrollment pins and licence use\n[CourseAuthoringService](agents/course-authoring-service.md). Keep history\nappend-only, require request keys, and never weaken personal-use-copy rules.\n\nGeneration proposals into new draft revisions and revision-bound educational\nreview use [CourseGenerationReviewService](agents/course-generation-review.md).\nKeep supplied content unless a decision is recorded; reviews carry no score.\n\nImmutable questions, answer keys/rubrics, stable learning objectives, worksheet\nrender ids and exact-revision references use [QuestionAuthoringService](agents/question-records.md).\nKeep keys out of learner bundles; a missing key stays null. `attachGeneratedPrintable`\nstores the rendered PDFs; the guardian copy is always an `answer-key`, never `printable`.\n\nStructured questions from scans and imported course files use\n[QuestionExtractionService](agents/question-extraction.md) and the `extract-questions`\ningestion handler. Anchors come from provider region catalogs only; match by worksheet\nid and layout, never text; ambiguous matches stay unattached; source-keyed replays.\n\nCourse bundles (zip with a closed manifest v1 or v2, or a file set; Word/PowerPoint members render through an injected `DocumentConverter`, fail closed; v2 carries material roles, audience, lesson pages, course members and YouTube references) use\n[CourseBundleImportService](agents/course-bundle-import.md). Parse only with the\nbounded reader; refuse, never trim, hostile input; unsupported members stay\nvisible;
|
|
16197
|
+
"agentDoc": "# smrt-education\n\nCatalog objects are optional-tenant scoped and have no generated REST, CLI, MCP,\nor AI surface. Applications use `CatalogService`, supplying their actor-bound\nauthorization decision and the trusted `TenantCollection.withTenantCatalogReadScope`\nadapter from smrt-users. Catalog authorization receives the exact shared collection\nexecutor; live session/permission checks must use that executor. That read scope may widen only an allowlisted catalog\ncollection's `list` to self, ancestors, and globals; it never authorizes a get,\nwrite, raw query, sibling, or descendant read.\n\n`personal-use-copy` courses and all `answer-key`/`assessment-guidance` material\nare private family material. Do not publish them, promote them, or expose them\nthrough a learner-facing result. `LessonAsset` (lesson) and `CourseAsset` (course)\nare the sole owner joins for material files; do not add asset-id fields to lesson\nsubclasses. Material audience rules and external videos: [lesson materials](agents/lesson-materials.md);\na learner never sees guardian-audience material.\n\nLearner objects require exact tenant ownership and close generated surfaces.\n`LearnerService` owns actor/resource authorization and transactional planning and\nstart-progress; see [learner contract](agents/learner-service.md). Guardian\nrelationships require a host decision about their type and effective terms.\nNever expose direct collection writes as learner handlers, reset progress on a\nretry, or treat an unscored nullable decimal as zero.\n\nSubmission capture, guardian grading and private PDF packet splitting use\n`SubmissionService`; see [submission contract](agents/submission-service.md).\nKeep asset metadata on the same transaction and compensate only newly planned\nfiles after rollback; never expose source URIs or accept learner grade patches.\n\nValidation: `pnpm --filter @happyvertical/smrt-education test`,\n`test:postgres`, `typecheck`, and `build`.\n\nEvery lesson hand-in is lesson work (activity, attempt, revisions, release,\ncompletion decision); books are courses with `bookKey`, pages are `LessonPage`s,\nand loose work is placed by filing. Use [LessonWorkService](agents/lesson-work-service.md)\nand the [design record](agents/course-work-design.md); `migrateWorkbooksToCourses`\nis the one-time host migration. Keep provisional sharing separate from guardian\nGrade authority; never move filed work's IDs. Photo-first receipt/context\ncapture uses [WorkbookPhotoService](agents/photo-intake.md); covers/references\nnever create learning evidence, and blank exercises need explicit work intent.\n\nRevisioned authored courses, release, archive, enrollment pins and licence use\n[CourseAuthoringService](agents/course-authoring-service.md). Keep history\nappend-only, require request keys, and never weaken personal-use-copy rules.\n\nGeneration proposals into new draft revisions and revision-bound educational\nreview use [CourseGenerationReviewService](agents/course-generation-review.md).\nKeep supplied content unless a decision is recorded; reviews carry no score.\n\nImmutable questions, answer keys/rubrics, stable learning objectives, worksheet\nrender ids and exact-revision references use [QuestionAuthoringService](agents/question-records.md).\nKeep keys out of learner bundles; a missing key stays null. `attachGeneratedPrintable`\nstores the rendered PDFs; the guardian copy is always an `answer-key`, never `printable`.\n\nStructured questions from scans and imported course files use\n[QuestionExtractionService](agents/question-extraction.md) and the `extract-questions`\ningestion handler. Anchors come from provider region catalogs only; match by worksheet\nid and layout, never text; ambiguous matches stay unattached; source-keyed replays.\n\nCourse bundles (zip with a closed manifest v1 or v2, or a file set; Word/PowerPoint members render through an injected `DocumentConverter`, fail closed; v2 carries material roles, audience, lesson pages, course members and YouTube references) use\n[CourseBundleImportService](agents/course-bundle-import.md). Parse only with the\nbounded reader; refuse, never trim, hostile input; unsupported members stay\nvisible; nothing auto-published. `attachCourse` makes one family draft course per\nunit key (parts merge in any order, mismatches fail closed); review choices never\nopen keys, guidance or an editable original to a learner.\n\nClass CrunchLabs (a download read into a manifest v2 bundle; an operator-only\nglobal catalog provider until the operator's single public switch):\n[source contract](agents/class-crunchlabs.md). Never host its files; `operator`\nvisibility needs the host's `operatorTenantIds`.\n\nSource import: [host boundary and transaction contract](agents/source-import.md).\n`SourceImportService` requires host opt-in, matching active actor/tenant and\nexplicit licensing authorization; never add a system/global write bypass.\n\nFamily-owned unassigned originals and audited learner adoption use\n[FamilyIntakeService](agents/family-intake.md). Keep family source scope immutable;\nassignment alone never creates learning history or grants learner inbox access.\n\nPublisher catalog previews use [the preview contract](agents/catalog-previews.md).\nKeep independent image rights and source revisions; serve via `CatalogPreviewService`\nwith live actor/tenant authorization, never direct provider image URLs.\n\nEnrollment Plan projections and guardian-only parent notes use\n[the Plan contract](agents/learner-plan.md). Keep awaiting review separate from\nContinue; note authority/provenance never grants learner access or learning evidence.\n\nHomeschool group sharing uses [GroupSharingService](agents/group-sharing.md),\nits read-only reader and revision comment service. Group tenants never become\nfamily ancestors or guardians. Enumerate only the group-owned opaque roster index,\nthen revalidate each exact family edge and current policy. Media delivery must call\nthe reader on every request; signed storage URLs are not a sharing grant. Saved\nparent comment visibility applies on every child read. Progress with feedback\ndisabled contains counts only, never correctness, scores or concept labels.\n\nLearner-safe tutor context and append-only tutor transcripts use\n[TutorContextService and TutorSessionService](agents/tutor-context.md). Learner\naudience never carries keys, rubrics, notes or storage URIs; no AI call here.\n",
|
|
15642
16198
|
"moduleDocs": [
|
|
15643
16199
|
{
|
|
15644
16200
|
"path": "agents/lesson-materials.md",
|
|
15645
16201
|
"module": "lesson-materials",
|
|
15646
|
-
"content": "# Lesson materials and audience\n\nDesign record: [course work](course-work-design.md). Models are closed (no REST,\nCLI, MCP or AI surface); reads and writes go through `SubmissionService` (and its\n`LessonWorkService` subclass) with the usual actor, learner and enrollment checks.\n\n## Roles and audience\n\n`LessonAssetRelationship` (`LESSON_ASSET_RELATIONSHIPS`): `teacher-guide`, `slides`,\n`learner-pages`, `assessment`, `assessment-guidance`, `handout`, `printable`,\n`answer-key`, `video`, `attachment`. Each `LessonAsset`, `CourseAsset` and\n`LessonExternalVideo` row has `audience: 'learner' | 'guardian'`; `''` means the role\ndefault (`LESSON_ASSET_DEFAULT_AUDIENCE`): guardian for teacher-guide, slides,\nassessment-guidance and answer-key, learner otherwise. `materialAudience(role,\naudience?)` resolves and validates it. `answer-key` and `assessment-guidance`\n(`GUARDIAN_ONLY_RELATIONSHIPS`) can never be learner-audience and, like any join in\na personal-use-copy course, require a private asset under the host's exact\nactor/owner/asset capability.\n\n`CourseAsset` holds course-level material (supply list, posters) with the same\nroles, audience and private-asset rule, plus an optional title.\n\n## Learner never sees guardian material\n\n`listLessonMaterials({enrollmentId, lessonId})` and `listCourseMaterials({enrollmentId})`\nreturn `LessonMaterialView`s (`id`, `kind` file or external-video, `scope`, role,\naudience, title, order, `assetId` or provider/videoId/`embedUrl`). The learner\nthemself sees only learner-audience rows; an authorized guardian sees all. The\ncatalog projection without answer keys (every learner-facing catalog read) applies\nthe same rule. `signLessonMaterial`/`signCourseMaterial` sign only a file in the\nactor's own list (claim scope `lesson:<id>` / `course:<id>`); a guessed id of\nguardian material is denied. `signLessonPrintable` applies the same audience
|
|
16202
|
+
"content": "# Lesson materials and audience\n\nDesign record: [course work](course-work-design.md). Models are closed (no REST,\nCLI, MCP or AI surface); reads and writes go through `SubmissionService` (and its\n`LessonWorkService` subclass) with the usual actor, learner and enrollment checks.\n\n## Roles and audience\n\n`LessonAssetRelationship` (`LESSON_ASSET_RELATIONSHIPS`): `teacher-guide`, `slides`,\n`learner-pages`, `assessment`, `assessment-guidance`, `handout`, `printable`,\n`answer-key`, `video`, `attachment`. Each `LessonAsset`, `CourseAsset` and\n`LessonExternalVideo` row has `audience: 'learner' | 'guardian'`; `''` means the role\ndefault (`LESSON_ASSET_DEFAULT_AUDIENCE`): guardian for teacher-guide, slides,\nassessment-guidance and answer-key, learner otherwise. `materialAudience(role,\naudience?)` resolves and validates it. `answer-key` and `assessment-guidance`\n(`GUARDIAN_ONLY_RELATIONSHIPS`) can never be learner-audience and, like any join in\na personal-use-copy course, require a private asset under the host's exact\nactor/owner/asset capability.\n\n`CourseAsset` holds course-level material (supply list, posters) with the same\nroles, audience and private-asset rule, plus an optional title.\n\n## Rendition and thumbnail (SMRT #4632)\n\n`LessonAsset` and `CourseAsset` carry `rendition` (`''` a file as supplied,\n`original` an editable Word/PowerPoint file, `rendered` the PDF rendered from\none), `renditionOfAssetId` (a rendering's original) and `thumbnailAssetId` (an\noptional first-page image, null when no converter drew one). The model refuses\nan `original` with a learner audience: the learner gets the rendering, never the\neditable file. A new thumbnail must be an asset of the same family, and private\nunder the host's capability (same owner as the material) whenever the material\nmust be private.\n\n## Learner never sees guardian material\n\n`listLessonMaterials({enrollmentId, lessonId})` and `listCourseMaterials({enrollmentId})`\nreturn `LessonMaterialView`s (`id`, `kind` file or external-video, `scope`, role,\naudience, title, order, `assetId` or provider/videoId/`embedUrl`, and for files\n`mimeType` from the stored asset, `rendition`, `pairedMaterialId` (the other half\nof an original/rendered pair, only when this actor sees both) and\n`thumbnailAssetId`). Hosts read these instead of guessing by file extension. The learner\nthemself sees only learner-audience rows; an authorized guardian sees all. The\ncatalog projection without answer keys (every learner-facing catalog read) applies\nthe same rule. `signLessonMaterial`/`signCourseMaterial` sign only a file in the\nactor's own list (claim scope `lesson:<id>` / `course:<id>`); a guessed id of\nguardian material is denied; `thumbnail: true` signs the thumbnail of a visible\nmaterial instead. `signLessonPrintable` applies the same audience rule to the learner. Storage URIs never appear.\n\n`setMaterialAudience({enrollmentId, scope, kind, materialId, audience})` lets a\nguardian with plan authority change a family-owned row within the role's bounds\n(an `original` stays guardian). Bundle courses (`sourceKey` `course-bundle`) are\nfamily-owned, so this is the after-attach path; before attach use\n`CourseBundleImportService.chooseMaterialAudience`.\nAuthored courses change audience through course authoring (`CourseMaterialInput.audience`,\ncarried to the released join); shared or other families' rows are denied.\n\n## External videos\n\n`LessonExternalVideo` references a video at an allowlisted provider (YouTube only):\n`videoId` (11 characters), title, `stepOrder` and audience. It is never downloaded\nand has no Asset row. `parseYouTubeReference` accepts a bare id or an https\nyoutube.com / m. / music. / youtu.be / youtube-nocookie.com URL (watch, embed,\nshorts, live) and nothing else; `externalVideoEmbedUrl` returns the\nyoutube-nocookie embed URL. `addLessonVideo({enrollmentId, lessonId, reference,\ntitle, stepOrder, audience?})` adds one to a family-owned lesson (plan authority);\nthe same video with the same details replays, other details conflict, and a\nnon-allowlisted reference throws `ExternalVideoReferenceError`.\n\nTests: `src/__tests__/lesson-materials.test.ts`.\n"
|
|
15647
16203
|
},
|
|
15648
16204
|
{
|
|
15649
16205
|
"path": "agents/learner-service.md",
|
|
@@ -15693,12 +16249,12 @@
|
|
|
15693
16249
|
{
|
|
15694
16250
|
"path": "agents/course-bundle-import.md",
|
|
15695
16251
|
"module": "course-bundle-import",
|
|
15696
|
-
"content": "# Course bundle import\n\n`CourseBundleImportService` (SMRT #4578, extends `CourseAuthoringService`,\nconsumed by Hearth #94) imports a course bundle, a zip with an optional manifest\nor a plain file set, as bounded evidence, hands its supported members to the\nhost for ingestion extraction and proposes sections and lessons for review.\nRisk is high: untrusted archive parsing and new schema. It reuses the course\nauthorizer: `importBundle` needs `education.course.author`, `readImport`\n`education.course.read-draft`, `proposeStructure` `education.course.generate`\n(via `CourseGenerationReviewService`). Operations: `import-course-bundle`,\n`read-course-bundle`. Server only (Node `zlib`/`crypto`); no new dependency.\n\n## Flow\n\n1. `importBundle({ ...actor, bundle, limits?, onProgress?, receiveMember? })`\n authorizes **before parsing**, unpacks (stage `unpack`), classifies and lays\n out the structure (`classify`), writes the evidence in one transaction and\n then calls `receiveMember` for each accepted member (`extract`), outside any\n transaction. `bundle` is `{ archive: Uint8Array }` or `{ files: [{ path,\n bytes }] }`. Hostile or damaged input throws `CourseBundleRefusedError`\n (`reason`, optional `entry`) and writes nothing.\n2. `receiveMember(member, { replayed })` is the host's ingestion seam: call\n `IngestionService.receive` with `sourceKind: 'course_import'` and the member\n bytes, then queue extraction and `preserveQuestionExtractionAnalysis` as in\n [question extraction](question-extraction.md). Members carry `role`\n (manifest page role), `lessonKey`, `sectionKey`. It runs on a replay too\n (ingestion dedups by content hash), so an interrupted first run resumes. Its\n return values are in `result.receipts`.\n3. `proposeStructure({ ...actor, importId, bundle, courseId,\n expectedHeadRevisionId })` (stage `propose`) re-supplies the bundle (bytes\n are never retained), checks it is the imported one, and runs a deterministic\n `CourseMaterialGenerator` (`smrt-bundle-import`) through\n `requestGeneration`/`runGeneration`. The result is an ordinary proposal: a\n new draft revision of additions and fills; conflicts wait for\n `decideProposal`. Nothing is released, assigned or published. The request key\n is `bundle:<courseId>:<bundleIdentity>`, so a retry returns the same job; the\n same key with another head is `CourseRequestKeyConflictError`.\n4. `readImport({ ...actor, importId })` returns the recorded evidence.\n\nProgress is an observer callback (`onProgress({ stage, completed, total })`,\nstages `unpack`, `classify`, `render`, `extract`, `propose`; each starts at `completed: 0`;\n`render` is emitted only when the bundle has Word/PowerPoint members).\nIngestion has no public job-progress seam, so none is invented. A throwing\nlistener never affects the import.\n\n## Hard bounds (`COURSE_BUNDLE_LIMITS`; a host may only lower them)\n\n| limit | value |\n|---|---|\n| `maxArchiveBytes` (input) | 100 MiB |\n| `maxEntries` | 200 |\n| `maxEntryBytes` (inflated) | 50 MiB |\n| `maxTotalBytes` (inflated) | 200 MiB |\n| `maxCompressionRatio` (members over `ratioFloorBytes` = 64 KiB) | 100 |\n| `maxPathBytes` / `maxSegmentBytes` / `maxPathDepth` | 512 / 255 / 8 |\n| `maxManifestBytes` | 256 KiB |\n| `maxLessons` (the proposal schema's cap) | 50 |\n| `maxLessonBodyChars` | 100 000 |\n| `maxOfficeMembers` (Word/PowerPoint members rendered per bundle) | 50 |\n| `maxRenderedBytes` (PDF accepted back from the converter) | 50 MiB |\n| `conversionTimeoutMs` (one Office member) | 60 000 |\n| archive nesting | 1: a zip inside a zip is never expanded |\n\nA lesson whose combined text members exceed `maxLessonBodyChars` refuses the\nbundle (`lesson_too_large`, `entry` = lesson key) at import; text is never\ntrimmed or dropped. A plain file set enforces `maxTotalBytes` on its member\nbytes exactly as an archive does on inflated bytes.\n\nThe reader (`course-bundle-zip.ts`) parses the end record and central directory,\nvalidates every offset and size against the real buffer, inflates with\n`maxOutputLength` equal to the declared size (declared sizes are never trusted:\na mismatch either way is `size_mismatch`), checks CRC32 and re-checks the total\non actual output. Stored and deflate only. Refusals (`CourseBundleRefusalReason`)\ncover: not a zip, truncated, ambiguous end record (two end records that both fit\nthe file, for example one forged in a comment), zip64, multi-disk, central\ndirectory not ending at the end record, entries out of range or overlapping,\nlocal header name/method mismatch, encrypted entries (flags 0/6/13, AES method),\nsymlink and special files (unix mode; DOS reparse flag), unsupported method,\nbad CRC, ratio, entry count, totals, duplicate names (case/NFC-insensitive,\nbackslashes normalised first) and bad paths (`..`, `.`, empty segments, absolute,\ndrive letter or `:` anywhere, NUL/control/bidi characters, lone surrogates,\ntoo long or deep). An **honestly** oversize member (declared over\n`maxEntryBytes`) is not inflated and is recorded `refused / entry_too_large`.\n\n## Members and statuses\n\nBy content (never by extension alone): `docx`/`pptx`/`xlsx` (see below), `pdf` (`%PDF-` in the first 1 KiB),\n`image` (PNG, JPEG, WebP), `text` (`.txt`/`.md`, strict UTF-8, no control\ncharacters, body-sized), `manifest` (root `manifest.json`), else `unsupported`.\nStatus: `accepted` (handed to extraction), `duplicate` (same sha256 as an earlier\nmember in canonical order; recorded once as evidence, `duplicateOfPath`, never\nextracted again), `unsupported` (`unsupported_type`, `nested_archive`,\n`unreadable_text`), `refused` (`encrypted_pdf`, `entry_too_large`), `metadata`\n(the manifest). Nothing is dropped. An encrypted PDF is any PDF with an\n`/Encrypt` token anywhere in its bytes (trailer, xref stream): a false positive\non literal text inside an uncompressed stream is refused, never read.\n\n## Word and PowerPoint members (SMRT #4615)\n\nA `.docx`/`.pptx`/`.xlsx` member is an OOXML package only when the name and the\ncontent agree: a zip whose entries include `[Content_Types].xml` and\n`word/document.xml` (docx), `ppt/presentation.xml` (pptx) or `xl/workbook.xml`\n(xlsx). A workbook (a supply list) is rendered and kept like the others but has\nno text reader. Before the bytes go anywhere, the\npackage itself passes the same bounded zip reader (ratio, overlap, paths, CRC,\n100 MiB inflated); a failure is `refused / unsafe_office`, never a refusal of the\nwhole bundle. Other zips stay `unsupported / nested_archive`.\n\nTwo separate things happen to an accepted Office member, both after\nauthorization and before the evidence is written:\n\n- **Pages**: a `DocumentConverter` (`document-converter.ts`) renders the original\n to PDF. The importer enforces the byte and time limits itself (input\n `maxEntryBytes`, output `maxRenderedBytes`, `conversionTimeoutMs` with an abort\n signal and a hard race, so an adapter that ignores the signal still times out),\n and rejects output that is not a PDF or is encrypted. The converter is told a\n neutral file name (`document.docx`), never the bundle path. Identical documents\n are rendered once.\n- **Text**: an injectable `OfficeTextReader` (best effort; a failure or a `null`\n costs the member nothing) returns whole-document text and, for decks, text and\n speaker notes per slide. Office text is handed to the host on the accepted\n member (`officeText`) and is **never** inlined into a proposed lesson body:\n teacher guides and notes carry answers, and audience belongs to manifest v2.\n\n`receiveMember` gets the original `bytes` (store them as the private original\nasset: \"Open in PowerPoint\" for decks) and `rendered` (`{ bytes, sha256, mediaType:\n'application/pdf', converterId }`, store as a private asset beside the original:\nthe pages for \"Present\"/reading). The member row records `renderedSha256` and\n`renderedSizeBytes`; bytes are still not retained here.\n\n**Fail closed.** Any converter problem records that member `unsupported` with a\nreason and writes the rest of the bundle normally: `converter_unavailable` (none\nconfigured), `converter_failed` (unreachable or 5xx), `converter_timeout`,\n`converter_too_large`, `converter_rejected` (HTTP 4xx, not a PDF, encrypted),\n`office_limit` (beyond `maxOfficeMembers`, in natural path order). A member that\nfailed is not a lesson in the proposal, and identical copies of a failed document\nfail the same way rather than becoming duplicates of nothing. Outcomes are part\nof the append-only evidence, so a replay does not retry a recorded failure (to\nretry, change the bundle). A replay does re-render recorded-accepted members so the\nhost receives the bytes again; if it can no longer render one it throws\n`DocumentConversionError` rather than silently dropping an accepted member.\n\n### Host configuration\n\n```ts\nconst service = new CourseBundleImportService(db, authorizer, {\n converter: new GotenbergDocumentConverter({\n baseUrl: process.env.GOTENBERG_URL, // for example http://gotenberg:3000\n timeoutMs: 60_000,\n maxBytes: 50 * 1024 * 1024,\n }),\n officeTextReader, // optional, see below\n});\n```\n\n`GotenbergDocumentConverter` posts to `<baseUrl>/forms/libreoffice/convert`, talks\nto nothing else, refuses redirects and URLs with credentials, and caps the response\nas it streams. Run Gotenberg as an internal-only service with **no outbound\nnetwork**, its own size/time limits and no shared volume with the app; this\npackage assumes untrusted files never run next to the application. Tests use\n`FakeDocumentConverter` (records calls; `failWith`, `failWhen`, `delayMs`, `output`).\n\n`OfficeTextReader` reads Office text through the SDK without this package\ndepending on `@happyvertical/documents`: the host imports `extractOffice`\n(released in `@happyvertical/documents` 0.111.4, sdk#1486, Kreuzberg) and passes\nit to `createOfficeTextReader(extractOffice)`, which returns whole-document\ntext for Word and text plus speaker notes per slide for PowerPoint (images are\nnever requested). An absent engine reads as `null`; a corrupt file rejects and\nthe importer treats that as \"no text\". The repository's current `catalog:`\npin is 0.111.3, which predates the Office processors, so the host bumps the SDK\nset (and its minimum release age) before it can import `extractOffice`.\n\n## Manifest (`manifest.json`, version 1, closed)\n\n```json\n{ \"version\": 1, \"course\": { \"subject\": \"Math\" },\n \"sections\": [ { \"key\": \"unit-1\", \"title\": \"Unit One\",\n \"lessons\": [ { \"key\": \"sums\", \"title\": \"Sums\",\n \"members\": [ { \"path\": \"sheets/sums.pdf\", \"role\": \"exercise\" } ] } ] } ] }\n```\nEvery object is closed: an unknown key anywhere is `manifest_unknown_key` (with\nits path in `entry`); another version is `manifest_version`. Keys match\n`[A-Za-z0-9._:-]{1,120}` and are unique; roles are the extraction page roles\n(`exercise`, `example`, `instructions`, `cover`, `answer_key`, `mixed`,\n`unknown`); a listed path must exist and be listed once. The manifest is a source\nfact: roles are `source`, anything the extractor infers stays `inferred`, and a\nmanifest/extraction disagreement belongs in extraction review, not here. Without\na manifest each accepted member is one lesson, sections come from the top-level\ndirectory and order is natural path order (digit runs compare numerically, no\nlocale). Manifest order: the manifest, declared members, then the rest by path.\nLesson bodies are the readable text members of a lesson, joined; PDFs and images\nare never inlined. Members whose declared role is `answer_key` or `mixed` never\ncontribute text to a lesson body (they remain recorded evidence members); the\nproposal rationale only counts how many were withheld.\n\n## Manifest version 2 (SMRT #4615)\n\nA root `manifest.json` with `\"version\": 2` is laid out by the `manifest-v2`\nreader; version 1 keeps its own reader and page roles. The schema is closed in\nthe same way: an unknown key anywhere is `manifest_unknown_key` (with its path in\n`entry`), another version is `manifest_version`.\n\n```json\n{ \"version\": 2, \"course\": { \"subject\": \"Science\" },\n \"courseMembers\": [ { \"path\": \"unit/supplies.pdf\", \"role\": \"attachment\", \"title\": \"Supply list\" } ],\n \"sections\": [ { \"key\": \"unit\", \"title\": \"Unit\", \"lessons\": [ {\n \"key\": \"l1\", \"title\": \"Lesson 1\",\n \"members\": [ { \"path\": \"l1/log.docx\", \"role\": \"learner-pages\" },\n { \"path\": \"l1/deck.pptx\", \"role\": \"slides\" },\n { \"path\": \"l1/guidance.pdf\", \"role\": \"assessment-guidance\" } ],\n \"pages\": [ { \"member\": \"l1/log.docx\", \"from\": 1, \"to\": 4, \"label\": \"Mission log\" } ],\n \"videos\": [ { \"reference\": \"dQw4w9WgXcQ\", \"title\": \"Recap\", \"step\": 1 } ] } ] } ] }\n```\n\n- **Members** (lesson `members` and root `courseMembers`): `path` (must exist, listed\n once), `role` (required) one of `teacher-guide`, `slides`, `learner-pages`,\n `assessment`, `assessment-guidance`, `handout`, `printable`, `answer-key`,\n `attachment` (`manifest_role` otherwise; a video is a reference, never a file),\n optional `audience` and `title`. The audience is the role default\n (`LESSON_ASSET_DEFAULT_AUDIENCE`) unless stated; `answer-key` and\n `assessment-guidance` are always guardian (a learner audience is\n `manifest_audience`). Members not listed stay recorded evidence with no role.\n- **Pages**: `{ member, from, to, label? }` ranges over a member of the same lesson\n (PDF, Word or PowerPoint; the rendered PDF for Office). Each page becomes a\n `LessonPage` keyed `p<n>`, labelled `<label> <n>` (default `Page <n>`), ordered by\n declaration. Bad, overlapping or unpageable ranges are `manifest_pages`; at most\n 500 pages per lesson.\n- **Videos**: `{ reference, title, step, audience? }` where `reference` is a bare id\n or an allowlisted https YouTube URL (`parseYouTubeReference`; anything else is\n `manifest_video`), `step` an integer 0-9999. They become `LessonExternalVideo`\n rows; nothing is downloaded.\n- **Course members** become `CourseAsset` rows, not tied to any lesson.\n\nGuardian-audience text (teacher guides, guidance, keys) never enters a proposed\nlesson body; only learner-audience text members do. Under v2 `role` on the member\nevidence row is the material role and `audience` the effective audience (NULL on\nrows recorded before v2). The plan carries `materials` (also on\n`CourseBundleImportResult.materials`): the resolved materials, pages and videos,\nplus `skipped` for declared members that were unsupported, refused or failed\nrendering. A duplicate member resolves to the earlier identical member's bytes\n(`assetPath`) and one material per (place, role, content).\n\n`receiveMember` also gets `audience` and `courseLevel`. **Slides** keep the original\ndeck (hand `bytes` to the host as a private asset: \"Open in PowerPoint\") and its\nrendered pages (`rendered`: \"Present\").\n\n### Applying materials\n\n`applyMaterials({ ...actor, importId, bundle, courseId, lessons, assets })`\n(`education.course.author`, operation `apply-course-bundle-materials`) writes the\nrows in one transaction. The host has stored each accepted member as a private\nasset and created the course's lessons: `lessons` maps manifest lesson key to the\n`Lesson` id, `assets` maps member path to `{ original, rendered }` asset ids.\nSlides join both the original deck and the rendered PDF; the original join is always\nguardian-only whatever the deck's declared audience (the audience applies to the\nrendered PDF), and a join written earlier with a wider audience is repaired on\nre-apply (`repaired`); any other Word/PowerPoint\nmember joins only its rendered PDF, so a learner is never handed an editable\noriginal. `LessonAsset`/`CourseAsset` saves keep their private-asset rule (guardian-\nonly roles and personal-use-copy courses need private assets). It targets\nfamily-owned courses; an authored course is `authored-course` because authored\nmaterial changes through course authoring. Idempotent: an identical row is\n`unchanged`, a row with other details is `CourseBundleMaterialsError('conflict')`,\na missing asset or lesson is `asset-missing`/`lesson-missing`; any error writes\nnothing.\n\n### Retrying a failed rendering\n\n`retryRendering({ ...actor, importId, bundle, paths?, receiveMember? })`\n(`education.course.author`, operation `retry-course-bundle-rendering`, needs a\nconverter) renders the Word/PowerPoint members whose first import recorded a\n*transient* failure (`converter_unavailable`, `converter_failed`,\n`converter_timeout`; `COURSE_BUNDLE_RETRYABLE_REASONS`). The first import's member\nrows are never rewritten. A success appends one `course_bundle_renderings` row\nper (import, content hash); every reader (`readImport`, replayed imports,\nproposals) overlays it, so the member reads `accepted` (identical copies as\nduplicates) with its rendered hash. A failure records nothing, so asking again is\nalways allowed; a second retry of a repaired member is `unchanged` and renders\nnothing. Converter rejections, size limits and the Office member cap are not\nretryable: change the bundle. The bundle must be the imported one.\n\n## Readers\n\n`BundleReader { formatId, detect, prepare }` in a `BundleReaderRegistry`;\nbuilt-ins are `manifest-v2`, `manifest-v1` and `plain-files`. SCORM and Common Cartridge are\n**not implemented** (their manifests describe launch resources and activity\ntrees that do not map to sections/lessons without design); a host can register\na reader ahead of the built-ins (`register(reader, { first: true })`).\n\n## Identity and replay\n\n`bundleIdentity` (`cbi1-...`) digests the sorted (path, sha256) pairs, so\nre-zipping, reordering and timestamps replay. One `CourseBundleImport` per\n(tenant, identity); a concurrent first import replays once on the unique index.\n\n## Models (closed, required tenant, no REST/CLI/MCP/AI, append-only)\n\n`CourseBundleImport` (`course_bundle_imports`: identity, format, reader,\nmanifest version, counts, actor), `CourseBundleMember` (`course_bundle_members`:\nunique tenant/import/path; ordinal, sha256, size, media type, kind, status,\nreason, duplicate-of, role, audience, section and lesson key) and\n`CourseBundleRendering` (`course_bundle_renderings`: a deliberate retry's success). Hashes and placements only:\nbytes stay with the host's ingestion receipts. Rewrites and deletes throw.\nNormal manifest migrations create the tables and add `audience` (NULL on older rows).\n\n## Not in this release\n\n- Material rows for authored courses: a proposal still carries lesson text only;\n authored course material goes through `CourseMaterialInput` and release.\n- Ingestion's receipt contract is unchanged: there is no `application/zip` part\n type or `parentEvidenceId` in ingestion. The education side unpacks and the\n host receives members one by one, so archive-to-member lineage lives in\n `course_bundle_members` (and the host's receipts), not in ingestion evidence.\n Changing ingestion's published receipt is a separate design decision.\n- A manifest/extraction disagreement is not compared automatically.\n- SCORM / Common Cartridge readers; zip64; nested archives; encrypted zips.\n"
|
|
16252
|
+
"content": "# Course bundle import\n\n`CourseBundleImportService` (SMRT #4578, extends `CourseAuthoringService`,\nconsumed by Hearth #94) imports a course bundle, a zip with an optional manifest\nor a plain file set, as bounded evidence, hands its supported members to the\nhost for ingestion extraction and proposes sections and lessons for review.\nRisk is high: untrusted archive parsing and new schema. It reuses the course\nauthorizer: `importBundle` needs `education.course.author`, `readImport`\n`education.course.read-draft`, `proposeStructure` `education.course.generate`\n(via `CourseGenerationReviewService`). Operations: `import-course-bundle`,\n`read-course-bundle`. Server only (Node `zlib`/`crypto`); no new dependency.\n\n## Flow\n\n1. `importBundle({ ...actor, bundle, limits?, onProgress?, receiveMember? })`\n authorizes **before parsing**, unpacks (stage `unpack`), classifies and lays\n out the structure (`classify`), writes the evidence in one transaction and\n then calls `receiveMember` for each accepted member (`extract`), outside any\n transaction. `bundle` is `{ archive: Uint8Array }` or `{ files: [{ path,\n bytes }] }`. Hostile or damaged input throws `CourseBundleRefusedError`\n (`reason`, optional `entry`) and writes nothing.\n2. `receiveMember(member, { replayed })` is the host's ingestion seam: call\n `IngestionService.receive` with `sourceKind: 'course_import'` and the member\n bytes, then queue extraction and `preserveQuestionExtractionAnalysis` as in\n [question extraction](question-extraction.md). Members carry `role`\n (manifest page role), `lessonKey`, `sectionKey`. It runs on a replay too\n (ingestion dedups by content hash), so an interrupted first run resumes. Its\n return values are in `result.receipts`.\n3. `proposeStructure({ ...actor, importId, bundle, courseId,\n expectedHeadRevisionId })` (stage `propose`) re-supplies the bundle (bytes\n are never retained), checks it is the imported one, and runs a deterministic\n `CourseMaterialGenerator` (`smrt-bundle-import`) through\n `requestGeneration`/`runGeneration`. The result is an ordinary proposal: a\n new draft revision of additions and fills; conflicts wait for\n `decideProposal`. Nothing is released, assigned or published. The request key\n is `bundle:<courseId>:<bundleIdentity>`, so a retry returns the same job; the\n same key with another head is `CourseRequestKeyConflictError`.\n4. `readImport({ ...actor, importId })` returns the recorded evidence.\n\nProgress is an observer callback (`onProgress({ stage, completed, total })`,\nstages `unpack`, `classify`, `render`, `extract`, `propose`; each starts at `completed: 0`;\n`render` is emitted only when the bundle has Word/PowerPoint members).\nIngestion has no public job-progress seam, so none is invented. A throwing\nlistener never affects the import.\n\n## Hard bounds (`COURSE_BUNDLE_LIMITS`; a host may only lower them)\n\n| limit | value |\n|---|---|\n| `maxArchiveBytes` (input) | 100 MiB |\n| `maxEntries` | 200 |\n| `maxEntryBytes` (inflated) | 50 MiB |\n| `maxTotalBytes` (inflated) | 200 MiB |\n| `maxCompressionRatio` (members over `ratioFloorBytes` = 64 KiB) | 100 |\n| `maxPathBytes` / `maxSegmentBytes` / `maxPathDepth` | 512 / 255 / 8 |\n| `maxManifestBytes` | 256 KiB |\n| `maxLessons` (the proposal schema's cap) | 50 |\n| `maxLessonBodyChars` | 100 000 |\n| `maxOfficeMembers` (Word/PowerPoint members rendered per bundle) | 50 |\n| `maxRenderedBytes` (PDF accepted back from the converter) | 50 MiB |\n| `conversionTimeoutMs` (one Office member) | 60 000 |\n| `maxThumbnailBytes` (first-page image accepted back from the converter) | 5 MiB |\n| archive nesting | 1: a zip inside a zip is never expanded |\n\nA lesson whose combined text members exceed `maxLessonBodyChars` refuses the\nbundle (`lesson_too_large`, `entry` = lesson key) at import; text is never\ntrimmed or dropped. A plain file set enforces `maxTotalBytes` on its member\nbytes exactly as an archive does on inflated bytes.\n\nThe reader (`course-bundle-zip.ts`) parses the end record and central directory,\nvalidates every offset and size against the real buffer, inflates with\n`maxOutputLength` equal to the declared size (declared sizes are never trusted:\na mismatch either way is `size_mismatch`), checks CRC32 and re-checks the total\non actual output. Stored and deflate only. Refusals (`CourseBundleRefusalReason`)\ncover: not a zip, truncated, ambiguous end record (two end records that both fit\nthe file, for example one forged in a comment), zip64, multi-disk, central\ndirectory not ending at the end record, entries out of range or overlapping,\nlocal header name/method mismatch, encrypted entries (flags 0/6/13, AES method),\nsymlink and special files (unix mode; DOS reparse flag), unsupported method,\nbad CRC, ratio, entry count, totals, duplicate names (case/NFC-insensitive,\nbackslashes normalised first) and bad paths (`..`, `.`, empty segments, absolute,\ndrive letter or `:` anywhere, NUL/control/bidi characters, lone surrogates,\ntoo long or deep). An **honestly** oversize member (declared over\n`maxEntryBytes`) is not inflated and is recorded `refused / entry_too_large`.\n\n## Members and statuses\n\nBy content (never by extension alone): `docx`/`pptx`/`xlsx` (see below), `pdf` (`%PDF-` in the first 1 KiB),\n`image` (PNG, JPEG, WebP), `text` (`.txt`/`.md`, strict UTF-8, no control\ncharacters, body-sized), `manifest` (root `manifest.json`), else `unsupported`.\nStatus: `accepted` (handed to extraction), `duplicate` (same sha256 as an earlier\nmember in canonical order; recorded once as evidence, `duplicateOfPath`, never\nextracted again), `unsupported` (`unsupported_type`, `nested_archive`,\n`unreadable_text`), `refused` (`encrypted_pdf`, `entry_too_large`), `metadata`\n(the manifest). Nothing is dropped. An encrypted PDF is any PDF with an\n`/Encrypt` token anywhere in its bytes (trailer, xref stream): a false positive\non literal text inside an uncompressed stream is refused, never read.\n\n## Word and PowerPoint members (SMRT #4615)\n\nA `.docx`/`.pptx`/`.xlsx` member is an OOXML package only when the name and the\ncontent agree: a zip whose entries include `[Content_Types].xml` and\n`word/document.xml` (docx), `ppt/presentation.xml` (pptx) or `xl/workbook.xml`\n(xlsx). A workbook (a supply list) is rendered and kept like the others but has\nno text reader. Before the bytes go anywhere, the\npackage itself passes the same bounded zip reader (ratio, overlap, paths, CRC,\n100 MiB inflated); a failure is `refused / unsafe_office`, never a refusal of the\nwhole bundle. Other zips stay `unsupported / nested_archive`.\n\nTwo separate things happen to an accepted Office member, both after\nauthorization and before the evidence is written:\n\n- **Pages**: a `DocumentConverter` (`document-converter.ts`) renders the original\n to PDF. The importer enforces the byte and time limits itself (input\n `maxEntryBytes`, output `maxRenderedBytes`, `conversionTimeoutMs` with an abort\n signal and a hard race, so an adapter that ignores the signal still times out),\n and rejects output that is not a PDF or is encrypted. The converter is told a\n neutral file name (`document.docx`), never the bundle path. Identical documents\n are rendered once.\n- **Text**: an injectable `OfficeTextReader` (best effort; a failure or a `null`\n costs the member nothing) returns whole-document text and, for decks, text and\n speaker notes per slide. Office text is handed to the host on the accepted\n member (`officeText`) and is **never** inlined into a proposed lesson body:\n teacher guides and notes carry answers, and audience belongs to manifest v2.\n\n`receiveMember` gets the original `bytes` (store them as the private original\nasset: \"Open in PowerPoint\" for decks) and `rendered` (`{ bytes, sha256, mediaType:\n'application/pdf', converterId }`, store as a private asset beside the original:\nthe pages for \"Present\"/reading). The member row records `renderedSha256` and\n`renderedSizeBytes`; bytes are still not retained here. A converter may also\nreturn a first-page image (`DocumentConversionResult.thumbnail`); the importer\nkeeps it only when it is a PNG/JPEG/WebP within `maxThumbnailBytes` and hands it\nover as `rendered.thumbnail` (`{ bytes, sha256, mediaType }`), else null. An\nunusable thumbnail never fails the member. Gotenberg draws none, so it is null.\n\n**Fail closed.** Any converter problem records that member `unsupported` with a\nreason and writes the rest of the bundle normally: `converter_unavailable` (none\nconfigured), `converter_failed` (unreachable or 5xx), `converter_timeout`,\n`converter_too_large`, `converter_rejected` (HTTP 4xx, not a PDF, encrypted),\n`office_limit` (beyond `maxOfficeMembers`, in natural path order). A member that\nfailed is not a lesson in the proposal, and identical copies of a failed document\nfail the same way rather than becoming duplicates of nothing. Outcomes are part\nof the append-only evidence, so a replay does not retry a recorded failure (to\nretry, change the bundle). A replay does re-render recorded-accepted members so the\nhost receives the bytes again; if it can no longer render one it throws\n`DocumentConversionError` rather than silently dropping an accepted member.\n\n### Host configuration\n\n```ts\nconst service = new CourseBundleImportService(db, authorizer, {\n converter: new GotenbergDocumentConverter({\n baseUrl: process.env.GOTENBERG_URL, // for example http://gotenberg:3000\n timeoutMs: 60_000,\n maxBytes: 50 * 1024 * 1024,\n }),\n officeTextReader, // optional, see below\n});\n```\n\n`GotenbergDocumentConverter` posts to `<baseUrl>/forms/libreoffice/convert`, talks\nto nothing else, refuses redirects and URLs with credentials, and caps the response\nas it streams. Run Gotenberg as an internal-only service with **no outbound\nnetwork**, its own size/time limits and no shared volume with the app; this\npackage assumes untrusted files never run next to the application. Tests use\n`FakeDocumentConverter` (records calls; `failWith`, `failWhen`, `delayMs`, `output`).\n\n`OfficeTextReader` reads Office text through the SDK without this package\ndepending on `@happyvertical/documents`: the host imports `extractOffice`\n(released in `@happyvertical/documents` 0.111.4, sdk#1486, Kreuzberg) and passes\nit to `createOfficeTextReader(extractOffice)`, which returns whole-document\ntext for Word and text plus speaker notes per slide for PowerPoint (images are\nnever requested). An absent engine reads as `null`; a corrupt file rejects and\nthe importer treats that as \"no text\". The repository's current `catalog:`\npin is 0.111.3, which predates the Office processors, so the host bumps the SDK\nset (and its minimum release age) before it can import `extractOffice`.\n\n## Manifest (`manifest.json`, version 1, closed)\n\n```json\n{ \"version\": 1, \"course\": { \"subject\": \"Math\" },\n \"sections\": [ { \"key\": \"unit-1\", \"title\": \"Unit One\",\n \"lessons\": [ { \"key\": \"sums\", \"title\": \"Sums\",\n \"members\": [ { \"path\": \"sheets/sums.pdf\", \"role\": \"exercise\" } ] } ] } ] }\n```\nEvery object is closed: an unknown key anywhere is `manifest_unknown_key` (with\nits path in `entry`); another version is `manifest_version`. Keys match\n`[A-Za-z0-9._:-]{1,120}` and are unique; roles are the extraction page roles\n(`exercise`, `example`, `instructions`, `cover`, `answer_key`, `mixed`,\n`unknown`); a listed path must exist and be listed once. The manifest is a source\nfact: roles are `source`, anything the extractor infers stays `inferred`, and a\nmanifest/extraction disagreement belongs in extraction review, not here. Without\na manifest each accepted member is one lesson, sections come from the top-level\ndirectory and order is natural path order (digit runs compare numerically, no\nlocale). Manifest order: the manifest, declared members, then the rest by path.\nLesson bodies are the readable text members of a lesson, joined; PDFs and images\nare never inlined. Members whose declared role is `answer_key` or `mixed` never\ncontribute text to a lesson body (they remain recorded evidence members); the\nproposal rationale only counts how many were withheld.\n\n## Manifest version 2 (SMRT #4615)\n\nA root `manifest.json` with `\"version\": 2` is laid out by the `manifest-v2`\nreader; version 1 keeps its own reader and page roles. The schema is closed in\nthe same way: an unknown key anywhere is `manifest_unknown_key` (with its path in\n`entry`), another version is `manifest_version`.\n\n```json\n{ \"version\": 2, \"course\": { \"subject\": \"Science\" },\n \"courseMembers\": [ { \"path\": \"unit/supplies.pdf\", \"role\": \"attachment\", \"title\": \"Supply list\" } ],\n \"sections\": [ { \"key\": \"unit\", \"title\": \"Unit\", \"lessons\": [ {\n \"key\": \"l1\", \"title\": \"Lesson 1\",\n \"members\": [ { \"path\": \"l1/log.docx\", \"role\": \"learner-pages\" },\n { \"path\": \"l1/deck.pptx\", \"role\": \"slides\" },\n { \"path\": \"l1/guidance.pdf\", \"role\": \"assessment-guidance\" } ],\n \"pages\": [ { \"member\": \"l1/log.docx\", \"from\": 1, \"to\": 4, \"label\": \"Mission log\" } ],\n \"videos\": [ { \"reference\": \"dQw4w9WgXcQ\", \"title\": \"Recap\", \"step\": 1 } ] } ] } ] }\n```\n\n- **Members** (lesson `members` and root `courseMembers`): `path` (must exist, listed\n once), `role` (required) one of `teacher-guide`, `slides`, `learner-pages`,\n `assessment`, `assessment-guidance`, `handout`, `printable`, `answer-key`,\n `attachment` (`manifest_role` otherwise; a video is a reference, never a file),\n optional `audience` and `title`. The audience is the role default\n (`LESSON_ASSET_DEFAULT_AUDIENCE`) unless stated; `answer-key` and\n `assessment-guidance` are always guardian (a learner audience is\n `manifest_audience`). Members not listed stay recorded evidence with no role.\n- **Pages**: `{ member, from, to, label? }` ranges over a member of the same lesson\n (PDF, Word or PowerPoint; the rendered PDF for Office). Each page becomes a\n `LessonPage` keyed `p<n>`, labelled `<label> <n>` (default `Page <n>`), ordered by\n declaration. Bad, overlapping or unpageable ranges are `manifest_pages`; at most\n 500 pages per lesson.\n- **Videos**: `{ reference, title, step, audience? }` where `reference` is a bare id\n or an allowlisted https YouTube URL (`parseYouTubeReference`; anything else is\n `manifest_video`), `step` an integer 0-9999. They become `LessonExternalVideo`\n rows; nothing is downloaded.\n- **Course members** become `CourseAsset` rows, not tied to any lesson.\n- **Unit and parts** (SMRT #4632): `course.key` (a manifest key) names the unit\n and `course.title` its course title; `part: { index, count }` (1-50) marks one\n bundle of a unit split across several, and requires `course.key`\n (`manifest_invalid` otherwise). Sections and lessons may carry a unit-wide\n `order` (0-9999); without one the position in this manifest is used, and\n the order counts as implicit when parts are merged.\n\nGuardian-audience text (teacher guides, guidance, keys) never enters a proposed\nlesson body; only learner-audience text members do. Under v2 `role` on the member\nevidence row is the material role and `audience` the effective audience (NULL on\nrows recorded before v2). The plan carries `materials` (also on\n`CourseBundleImportResult.materials`): the resolved materials, pages and videos,\nplus `skipped` for declared members that were unsupported, refused or failed\nrendering. A duplicate member resolves to the earlier identical member's bytes\n(`assetPath`) and one material per (place, role, content).\n\n`receiveMember` also gets `audience` and `courseLevel`. **Slides** keep the original\ndeck (hand `bytes` to the host as a private asset: \"Open in PowerPoint\") and its\nrendered pages (`rendered`: \"Present\").\n\n### Attaching a family course (SMRT #4632)\n\n`attachCourse({ ...actor, importId, bundle, assets, courseId?, title?,\nlicenseKind? })` (`education.course.author`, operation `attach-course-bundle`) is\nthe published path from an import to a course: in one transaction it creates (or\nfinds) the family course, its sections and lessons, and writes the materials as\n`applyMaterials` does. `assets` maps member path to `{ original, rendered?,\nthumbnail? }` asset ids the host stored from `receiveMember`.\n\n- **Course**: a non-authored family draft (`sourceKey` `course-bundle`,\n `sourceRef` the unit key, `licenseKind` default `personal-use-copy`, title from\n the request, `course.title`, subject or first section). Ids derive from (family,\n unit key), sections and lessons from (course, key), so every part of a unit and\n every retry find the same rows. Lessons keep the manifest key in `externalRef`,\n `order` as `sortOrder` and, on creation, learner-audience text as `body` (after\n review choices). Nothing is released or published.\n- **Unit key**: `course.key`, else `bundle:<bundleIdentity>` (a one-part unit).\n- **Parts**: one `CourseBundleAttachment` per import (unique per import and per\n (course, part)). Attach parts in any order; the result says `part.attached` and\n `part.complete`. Fails closed and writes nothing: a `courseId` of another unit or\n another part count is `unit-mismatch`; a second import for an attached part is\n `part-conflict`. A replay is `replayed: true` and writes nothing new.\n- **Shared sections and lessons**: parts that share a key must agree, and the\n result never depends on arrival order. `CourseBundlePlacement`\n (`course_bundle_placements`) records each key's title and whether its order was\n declared. Another title, two different declared orders, or a declared order\n against an implicit one is `part-conflict` (nothing written). Between implicit\n positions the part with the lowest index decides; a lower part arriving later\n re-sorts the row. An existing row with no placement is `part-conflict`.\n- **Concurrency**: every attach transaction takes, in order, the import row lock\n (shared with `chooseMaterialAudience` and `applyMaterials`) and the unit lock: a\n `CourseBundleUnit` row (`course_bundle_units`, one per family and unit key)\n created if absent and then locked before anything that decides the outcome\n (attachments, the course, placements, choices) is read. On PostgreSQL a\n concurrent first create of the same unit waits and adopts the winner's row,\n so two first attaches can never both pass the checks.\n- **Zero renderings**: with no converter, Word/PowerPoint members are recorded\n `converter_unavailable` and listed in `skipped`; no rendered or original join,\n page or thumbnail is written for them, and nothing is faked. `retryRendering`\n later, then attach again: the replay adds the newly accepted materials.\n- `readImport` reports `attachment` (course, unit key, part) once attached.\n\n### Audience before and after attach\n\n`chooseMaterialAudience({ ...actor, importId, path | video: { lessonKey, videoId },\naudience })` (`education.course.author`, operation `choose-course-bundle-audience`)\nrecords a review choice (`course_bundle_audience_choices`, one per import and\ntarget; a later choice replaces it) within the role's bounds: keys and assessment\nguidance never become learner material (`invalid-audience`), and a path must be a\ndeclared v2 material of the import. `readImport` lists `audienceChoices`.\n`attachCourse` and `applyMaterials` apply them (a slides choice applies to the\nrendered pages; the original deck stays guardian). After attach a choice is\n`already-attached`: change the row with `SubmissionService.setMaterialAudience`.\nOn a re-attach an existing row keeps its audience (the family's choice), except an\noriginal, which is repaired to guardian.\n\n### Applying materials\n\n`applyMaterials({ ...actor, importId, bundle, courseId, lessons, assets })`\n(`education.course.author`, operation `apply-course-bundle-materials`) writes the\nrows in one transaction. The host has stored each accepted member as a private\nasset and created the course's lessons: `lessons` maps manifest lesson key to the\n`Lesson` id, `assets` maps member path to `{ original, rendered }` asset ids.\nSlides join both the original deck (`rendition: 'original'`) and the rendered PDF\n(`rendition: 'rendered'`, `renditionOfAssetId` the original); the original join is always\nguardian-only whatever the deck's declared audience (the audience applies to the\nrendered PDF; the model refuses a learner original), and a join written earlier with a\nwider audience is repaired on re-apply (`repaired`); any other Word/PowerPoint\nmember joins only its rendered PDF, so a learner is never handed an editable\noriginal. `assets[path].thumbnail` is recorded on the rendered join (or a plain\nfile's own join); rows written before this release get their rendition and\nthumbnail filled in on re-apply (`updated`). `LessonAsset`/`CourseAsset` saves keep their private-asset rule (guardian-\nonly roles and personal-use-copy courses need private assets). It targets\nfamily-owned courses; an authored course is `authored-course` because authored\nmaterial changes through course authoring. Idempotent: an identical row is\n`unchanged`, a row with other details (order, title, rendition, a video's title or\nstep) is `CourseBundleMaterialsError('conflict')`; audience is not compared (see\nabove). A missing asset or lesson is `asset-missing`/`lesson-missing`, a thumbnail\nunder another owner than its material `asset-owner`; any error writes nothing. A\nmember named twice (material and page range) is listed once in `skipped`.\n\n### Retrying a failed rendering\n\n`retryRendering({ ...actor, importId, bundle, paths?, receiveMember? })`\n(`education.course.author`, operation `retry-course-bundle-rendering`, needs a\nconverter) renders the Word/PowerPoint members whose first import recorded a\n*transient* failure (`converter_unavailable`, `converter_failed`,\n`converter_timeout`; `COURSE_BUNDLE_RETRYABLE_REASONS`). The first import's member\nrows are never rewritten. A success appends one `course_bundle_renderings` row\nper (import, content hash); every reader (`readImport`, replayed imports,\nproposals) overlays it, so the member reads `accepted` (identical copies as\nduplicates) with its rendered hash. A failure records nothing, so asking again is\nalways allowed; a second retry of a repaired member is `unchanged` and renders\nnothing. Converter rejections, size limits and the Office member cap are not\nretryable: change the bundle. The bundle must be the imported one.\n\n## Readers\n\n`BundleReader { formatId, detect, prepare }` in a `BundleReaderRegistry`;\nbuilt-ins are `manifest-v2`, `manifest-v1` and `plain-files`. SCORM and Common Cartridge are\n**not implemented** (their manifests describe launch resources and activity\ntrees that do not map to sections/lessons without design); a host can register\na reader ahead of the built-ins (`register(reader, { first: true })`).\n\n## Identity and replay\n\n`bundleIdentity` (`cbi1-...`) digests the sorted (path, sha256) pairs, so\nre-zipping, reordering and timestamps replay. One `CourseBundleImport` per\n(tenant, identity); a concurrent first import replays once on the unique index.\n\n## Models (closed, required tenant, no REST/CLI/MCP/AI, append-only)\n\n`CourseBundleImport` (`course_bundle_imports`: identity, format, reader,\nmanifest version, counts, actor), `CourseBundleMember` (`course_bundle_members`:\nunique tenant/import/path; ordinal, sha256, size, media type, kind, status,\nreason, duplicate-of, role, audience, section and lesson key) and\n`CourseBundleRendering` (`course_bundle_renderings`: a deliberate retry's success). Hashes and placements only:\nbytes stay with the host's ingestion receipts. Rewrites and deletes throw.\n`CourseBundleAttachment` (`course_bundle_attachments`) and the mutable\n`CourseBundleAudienceChoice` (`course_bundle_audience_choices`) and\n`CourseBundlePlacement` (`course_bundle_placements`) and `CourseBundleUnit`\n(`course_bundle_units`) belong to the attach path. Normal manifest migrations create the tables and add `audience` (NULL\non older rows) and, on `lesson_assets`/`course_assets`, `rendition`,\n`rendition_of_asset_id` and `thumbnail_asset_id` (additive; older joins read as a\nfile as supplied with no thumbnail).\n\n## Not in this release\n\n- Material rows for authored courses: a proposal still carries lesson text only;\n authored course material goes through `CourseMaterialInput` and release. The\n family path is `attachCourse`; `proposeStructure` stays the authored-draft path.\n- Ingestion's receipt contract is unchanged: there is no `application/zip` part\n type or `parentEvidenceId` in ingestion. The education side unpacks and the\n host receives members one by one, so archive-to-member lineage lives in\n `course_bundle_members` (and the host's receipts), not in ingestion evidence.\n Changing ingestion's published receipt is a separate design decision.\n- A manifest/extraction disagreement is not compared automatically.\n- SCORM / Common Cartridge readers; zip64; nested archives; encrypted zips.\n"
|
|
15697
16253
|
},
|
|
15698
16254
|
{
|
|
15699
16255
|
"path": "agents/class-crunchlabs.md",
|
|
15700
16256
|
"module": "class-crunchlabs",
|
|
15701
|
-
"content": "# Class CrunchLabs source (SMRT #4616)\n\nClass CrunchLabs is a global catalog provider (`class-crunchlabs`) whose units are\nlisted under Science, with the @ClassCrunchLabs YouTube course playlists as\npreviews. \"Add to a course\" reads the family's own download of the unit and runs\nthe [bundle import](course-bundle-import.md) with a manifest version 2 built from\nit. Files come from CrunchLabs' own downloads and YouTube; **nothing is hosted\nhere** and the listing has no acquirable formats.\n\n## Operator-only until permission, one public switch\n\n`CatalogVisibility` gains `operator`. A `CatalogPolicy` built with\n`operatorTenantIds` lets only those families (host configuration, never a\nrequest) see `operator` records; the default policy shows them to nobody, and\n`authorize` answers `operator-only`. Materialization refuses them.\n\n`createClassCrunchLabsCatalogAdapter({ playlists, publicListing? })` is a snapshot\n`CatalogSyncAdapter` (one terminal page, no cursor). By default\n(`CLASS_CRUNCHLABS_PUBLIC_LISTING_DEFAULT = false`) every record is `operator`\nvisibility with licence state `unknown`, no permitted operations and the text\n\"free curriculum, permission pending\". Only the literal `publicListing: true`,\nset by the operator in host configuration, makes records `catalog` visibility\nwith `verified` evidence permitting `link` only. The switch is part of each\nrecord's revision, so the next sync rewrites the rows when it is flipped.\n`classCrunchLabsPreviewEmbedUrl(record)` returns the youtube-nocookie playlist\nembed for a listed unit (null for anything else). The playlist data is an\ninjected `ClassCrunchLabsPlaylistSource`; the adapter never touches the network.\n\n`addClassCrunchLabsUnit({ service, actor, catalogActor, record, listing, policy,\nfiles, playlists, pageCounter?, receiveMember? })` re-checks\n`canAddClassCrunchLabsUnit(actor, policy, listing)`: visibility is derived from the\nhost's own `listing.publicListing` (operator unless the literal `true`), never from\nthe record or any caller-supplied visibility or licence; an operator-only listing\nis refused to every other family, and the course actor must be the catalog actor, builds the bundle and imports each part. Then
|
|
16257
|
+
"content": "# Class CrunchLabs source (SMRT #4616)\n\nClass CrunchLabs is a global catalog provider (`class-crunchlabs`) whose units are\nlisted under Science, with the @ClassCrunchLabs YouTube course playlists as\npreviews. \"Add to a course\" reads the family's own download of the unit and runs\nthe [bundle import](course-bundle-import.md) with a manifest version 2 built from\nit. Files come from CrunchLabs' own downloads and YouTube; **nothing is hosted\nhere** and the listing has no acquirable formats.\n\n## Operator-only until permission, one public switch\n\n`CatalogVisibility` gains `operator`. A `CatalogPolicy` built with\n`operatorTenantIds` lets only those families (host configuration, never a\nrequest) see `operator` records; the default policy shows them to nobody, and\n`authorize` answers `operator-only`. Materialization refuses them.\n\n`createClassCrunchLabsCatalogAdapter({ playlists, publicListing? })` is a snapshot\n`CatalogSyncAdapter` (one terminal page, no cursor). By default\n(`CLASS_CRUNCHLABS_PUBLIC_LISTING_DEFAULT = false`) every record is `operator`\nvisibility with licence state `unknown`, no permitted operations and the text\n\"free curriculum, permission pending\". Only the literal `publicListing: true`,\nset by the operator in host configuration, makes records `catalog` visibility\nwith `verified` evidence permitting `link` only. The switch is part of each\nrecord's revision, so the next sync rewrites the rows when it is flipped.\n`classCrunchLabsPreviewEmbedUrl(record)` returns the youtube-nocookie playlist\nembed for a listed unit (null for anything else). The playlist data is an\ninjected `ClassCrunchLabsPlaylistSource`; the adapter never touches the network.\n\n`addClassCrunchLabsUnit({ service, actor, catalogActor, record, listing, policy,\nfiles, playlists, pageCounter?, receiveMember? })` re-checks\n`canAddClassCrunchLabsUnit(actor, policy, listing)`: visibility is derived from the\nhost's own `listing.publicListing` (operator unless the literal `true`), never from\nthe record or any caller-supplied visibility or licence; an operator-only listing\nis refused to every other family, and the course actor must be the catalog actor, builds the bundle and imports each part. Then store each\npart's accepted members and `attachCourse` every part (any order): they merge\ninto one family course. Courses are `personal-use-copy` (`build.licenseKind`).\n\n## Reading a download\n\n`buildClassCrunchLabsBundle({ files, playlists?, unit?, pageCounter?,\nincludeUnitWideAggregates?, maxPartBytes? })` takes a `ClassCrunchLabsFileSource`:\n`folderClassCrunchLabsSource(dir)` (Node only, from `@happyvertical/smrt-education/node`, never the root: a folder, the Drive zip parts, or both;\nzips are read lazily from their central directory, zip64/encrypted/symlinks are\nskipped) or `memoryClassCrunchLabsSource(files)`. It never reads video files.\n\n- Layout: `<Unit>_All Unit Wide Materials` and `<Unit>_Lesson <n>`; letters A\n teacher manual, B slides, C student mission log, D status check assessment\n (plus guidance and the editable master), E handouts, F extras, G videos. A\n lettered directory wins over a file's own letter. Several units need `unit`.\n- Mapping to manifest v2: A `teacher-guide`, B `slides`, C `learner-pages`, D\n `assessment` / `assessment-guidance`, E `handout`, F `printable`, the unit-wide\n Supply List `attachment`. Audiences are the role defaults (teacher manual and\n guidance guardian, slides guardian, mission log learner); the editable\n assessment master is guardian. Unit-wide files become course members.\n- The unit-wide \"(all lessons)\" combined files repeat the per-lesson files and\n are large, so they are left out unless `includeUnitWideAggregates` (reported as\n `aggregate-of-lessons`); the supply list, posters and other extras are kept.\n- Titles (#4642): a material's title is its file name tidied: the letter prefix,\n lesson code (`L02`), unit name, version (`v1.0`, `v.1.1`), `copy` and stray dots\n and underscores are dropped (`A. L01_Teacher Mission Manual_<Unit>_v1.0.pdf` is\n `Teacher Mission Manual`; `... Assessment (Editable)` keeps its qualifier), and a\n trailing ` - detail` becomes `(detail)` (`SQIREL Poster - 8.5x11` is `SQIREL\n Poster (8.5×11)`). Two different files that tidy to one title in the same\n lesson or the course are told apart as `Title (2)`; byte-identical copies are\n already collapsed by de-duplication. A lesson is titled `Lesson N: Name`. The name is, in order: the cover headline of the lesson's\n teacher manual PDF, when the host passes `readFirstPageHeadline({ bytes, kind:\n 'pdf' })` (the most prominent, largest-type text on page 1, lines joined by a\n space; this package has no PDF text reader, so the host supplies one, for\n example from pdfjs; all capitals fold to title case, `WEIGHT & MOTION` is\n `Weight & Motion`; a throw or null is ignored); else the activity of the lesson's\n first (lowest step) `StudentHandsOnExploration` video name, in title case with\n small words lower (`L03.6_Video_StudentHandsOnExploration_PlayWithPlungers` is\n `Lesson 3: Play with Plungers`); else `Lesson N`. Video names are read whether or\n not a playlist matched them, both `L01.4_Video_` and `L01.4 Video_` forms, `-NNN`\n download suffixes dropped, and loose lesson videos at the download's root count\n for the unit their name ends with. Titles are manifest data, so a section or lesson title that differs from\n an already attached part of the same unit is `part-conflict` (see the bundle\n import's shared-placement rules, which are deliberately not relaxed): a unit\n imported before this change keeps its `Lesson N` titles, and getting the new\n titles means importing the unit again into a fresh course (a different course\n id, not `courseId` of the old one).\n- Lesson pages: the first mission log of a lesson gets a `Mission log` range\n from `pageCounter` (`createClassCrunchLabsPageCounter({ converter? })` counts\n PDFs with pdf-lib and Word files by rendering them through the converter).\n Without a count the lesson gets no pages and the report says so.\n- Videos: names `Lnn.step_Video_Kind_Title` are matched, by unit (playlist\n title), lesson and step (`L03.6` or `Lesson 3 ... Step 6` in the item title),\n to the unit playlist; two videos sharing a step are told apart by the item\n title naming their title or kind, else both stay unmatched (`ambiguous`).\n Matches become `videos` references with a title and a step order (materials\n prep videos are guardian audience); unit-level videos (a teaser) and unmatched\n ones are only reported.\n- De-duplication: repeated exports of one logical path collapse (CRC and size\n when known; the newer export wins, a changed file is `superseded`); the same\n bytes under another name or place keep one copy (the lesson-named file in its\n lesson, posters unit wide, never a `copy`).\n- A unit larger than one archive (bundle cap 100 MiB) is split by lesson into\n `build.parts` (default 90 MiB each; the first part carries the course members and\n any lesson that fits beside them, others go to the first part with room; if no\n lesson fits beside the course members the build refuses with `too_large`); `build.bundle`\n and `build.manifest` are the first part. Every part's manifest names the unit\n (`course.key` = `build.unitKey`, `classCrunchLabsUnitKey(unit)`, and `course.title`),\n its `part` (`index`/`count`) and each lesson's unit-wide `order` (the lesson\n number), so `attachCourse` merges the parts in lesson order whatever order they\n arrive in.\n\nThe `report` lists lessons, members, parts, pages, matched and unmatched videos,\nduplicates, ignored files and warnings. Fixtures in tests are synthetic files\nwith the same naming; no real download is ever copied into the repository.\n\nTests: `src/__tests__/class-crunchlabs.test.ts`.\n"
|
|
15702
16258
|
},
|
|
15703
16259
|
{
|
|
15704
16260
|
"path": "agents/source-import.md",
|