bochencs commited on
Commit
e89a6fe
·
verified ·
1 Parent(s): 4450ce6

Add multidomain OpenEnv tasks and source

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. LICENSES/Apache-2.0-PDBThink.txt +201 -0
  3. LICENSES/CC-BY-4.0.txt +395 -0
  4. LICENSES/MIT-adapters.txt +21 -0
  5. LICENSES/ODC-BY-1.0.txt +428 -0
  6. LICENSES/README.txt +10 -0
  7. LICENSES/TMax-NOTICE.txt +6 -0
  8. MANIFEST.json +0 -0
  9. README.md +48 -2
  10. REGISTRATION.json +33 -0
  11. SHA256SUMS +357 -0
  12. SOURCE_LOCK.json +0 -0
  13. components/awm/ADAPTATIONS.txt +3 -0
  14. components/awm/Dockerfile +18 -0
  15. components/awm/LICENSE_SCOPE.json +22 -0
  16. components/awm/NOTICE +6 -0
  17. components/awm/SOURCE_CREDITS.json +9 -0
  18. components/awm/TASKS.json +72 -0
  19. components/awm/awm-requirements.lock +44 -0
  20. components/awm/config.json +26 -0
  21. components/awm/private/tasks/awm-accounting-1-invoice/SOURCE.json +11 -0
  22. components/awm/private/tasks/awm-accounting-1-invoice/initial.db +3 -0
  23. components/awm/private/tasks/awm-accounting-1-invoice/original_api.py +1767 -0
  24. components/awm/private/tasks/awm-accounting-1-invoice/original_verifier.py +145 -0
  25. components/awm/private/tasks/awm-manufacturing-1-schedule/SOURCE.json +11 -0
  26. components/awm/private/tasks/awm-manufacturing-1-schedule/initial.db +3 -0
  27. components/awm/private/tasks/awm-manufacturing-1-schedule/original_api.py +1524 -0
  28. components/awm/private/tasks/awm-manufacturing-1-schedule/original_verifier.py +104 -0
  29. components/awm/requirements.lock +112 -0
  30. components/awm/runtime/awm/__init__.py +1 -0
  31. components/awm/runtime/awm/adapter.py +89 -0
  32. components/awm/runtime/awm/launch_service.py +52 -0
  33. components/awm/runtime/awm/openenv_app.py +95 -0
  34. components/awm/runtime/awm/server.py +31 -0
  35. components/awm/runtime/awm/wire_client.py +123 -0
  36. components/awm/runtime/awm/worker.py +144 -0
  37. components/awm/runtime/common/__init__.py +1 -0
  38. components/awm/runtime/common/contracts.py +7 -0
  39. components/awm/runtime/common/http_routes.py +64 -0
  40. components/awm/runtime/common/models.py +54 -0
  41. components/awm/upstream/README.md +89 -0
  42. components/awm/upstream/accounting_1-gen_db.jsonl +1 -0
  43. components/awm/upstream/accounting_1-gen_envs.jsonl +1 -0
  44. components/awm/upstream/accounting_1-gen_sample.jsonl +1 -0
  45. components/awm/upstream/manufacturing_execution_system_1-gen_db.jsonl +1 -0
  46. components/awm/upstream/manufacturing_execution_system_1-gen_envs.jsonl +0 -0
  47. components/awm/upstream/manufacturing_execution_system_1-gen_sample.jsonl +1 -0
  48. components/math/ADAPTATIONS.txt +2 -0
  49. components/math/FILE_ALLOWLIST.json +596 -0
  50. components/math/MANIFEST.json +57 -0
.gitattributes CHANGED
@@ -58,3 +58,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ components/awm/private/tasks/awm-accounting-1-invoice/initial.db filter=lfs diff=lfs merge=lfs -text
62
+ components/awm/private/tasks/awm-manufacturing-1-schedule/initial.db filter=lfs diff=lfs merge=lfs -text
LICENSES/Apache-2.0-PDBThink.txt ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
LICENSES/CC-BY-4.0.txt ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution 4.0 International Public License
58
+
59
+ By exercising the Licensed Rights (defined below), You accept and agree
60
+ to be bound by the terms and conditions of this Creative Commons
61
+ Attribution 4.0 International Public License ("Public License"). To the
62
+ extent this Public License may be interpreted as a contract, You are
63
+ granted the Licensed Rights in consideration of Your acceptance of
64
+ these terms and conditions, and the Licensor grants You such rights in
65
+ consideration of benefits the Licensor receives from making the
66
+ Licensed Material available under these terms and conditions.
67
+
68
+
69
+ Section 1 -- Definitions.
70
+
71
+ a. Adapted Material means material subject to Copyright and Similar
72
+ Rights that is derived from or based upon the Licensed Material
73
+ and in which the Licensed Material is translated, altered,
74
+ arranged, transformed, or otherwise modified in a manner requiring
75
+ permission under the Copyright and Similar Rights held by the
76
+ Licensor. For purposes of this Public License, where the Licensed
77
+ Material is a musical work, performance, or sound recording,
78
+ Adapted Material is always produced where the Licensed Material is
79
+ synched in timed relation with a moving image.
80
+
81
+ b. Adapter's License means the license You apply to Your Copyright
82
+ and Similar Rights in Your contributions to Adapted Material in
83
+ accordance with the terms and conditions of this Public License.
84
+
85
+ c. Copyright and Similar Rights means copyright and/or similar rights
86
+ closely related to copyright including, without limitation,
87
+ performance, broadcast, sound recording, and Sui Generis Database
88
+ Rights, without regard to how the rights are labeled or
89
+ categorized. For purposes of this Public License, the rights
90
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
91
+ Rights.
92
+
93
+ d. Effective Technological Measures means those measures that, in the
94
+ absence of proper authority, may not be circumvented under laws
95
+ fulfilling obligations under Article 11 of the WIPO Copyright
96
+ Treaty adopted on December 20, 1996, and/or similar international
97
+ agreements.
98
+
99
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
100
+ any other exception or limitation to Copyright and Similar Rights
101
+ that applies to Your use of the Licensed Material.
102
+
103
+ f. Licensed Material means the artistic or literary work, database,
104
+ or other material to which the Licensor applied this Public
105
+ License.
106
+
107
+ g. Licensed Rights means the rights granted to You subject to the
108
+ terms and conditions of this Public License, which are limited to
109
+ all Copyright and Similar Rights that apply to Your use of the
110
+ Licensed Material and that the Licensor has authority to license.
111
+
112
+ h. Licensor means the individual(s) or entity(ies) granting rights
113
+ under this Public License.
114
+
115
+ i. Share means to provide material to the public by any means or
116
+ process that requires permission under the Licensed Rights, such
117
+ as reproduction, public display, public performance, distribution,
118
+ dissemination, communication, or importation, and to make material
119
+ available to the public including in ways that members of the
120
+ public may access the material from a place and at a time
121
+ individually chosen by them.
122
+
123
+ j. Sui Generis Database Rights means rights other than copyright
124
+ resulting from Directive 96/9/EC of the European Parliament and of
125
+ the Council of 11 March 1996 on the legal protection of databases,
126
+ as amended and/or succeeded, as well as other essentially
127
+ equivalent rights anywhere in the world.
128
+
129
+ k. You means the individual or entity exercising the Licensed Rights
130
+ under this Public License. Your has a corresponding meaning.
131
+
132
+
133
+ Section 2 -- Scope.
134
+
135
+ a. License grant.
136
+
137
+ 1. Subject to the terms and conditions of this Public License,
138
+ the Licensor hereby grants You a worldwide, royalty-free,
139
+ non-sublicensable, non-exclusive, irrevocable license to
140
+ exercise the Licensed Rights in the Licensed Material to:
141
+
142
+ a. reproduce and Share the Licensed Material, in whole or
143
+ in part; and
144
+
145
+ b. produce, reproduce, and Share Adapted Material.
146
+
147
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
148
+ Exceptions and Limitations apply to Your use, this Public
149
+ License does not apply, and You do not need to comply with
150
+ its terms and conditions.
151
+
152
+ 3. Term. The term of this Public License is specified in Section
153
+ 6(a).
154
+
155
+ 4. Media and formats; technical modifications allowed. The
156
+ Licensor authorizes You to exercise the Licensed Rights in
157
+ all media and formats whether now known or hereafter created,
158
+ and to make technical modifications necessary to do so. The
159
+ Licensor waives and/or agrees not to assert any right or
160
+ authority to forbid You from making technical modifications
161
+ necessary to exercise the Licensed Rights, including
162
+ technical modifications necessary to circumvent Effective
163
+ Technological Measures. For purposes of this Public License,
164
+ simply making modifications authorized by this Section 2(a)
165
+ (4) never produces Adapted Material.
166
+
167
+ 5. Downstream recipients.
168
+
169
+ a. Offer from the Licensor -- Licensed Material. Every
170
+ recipient of the Licensed Material automatically
171
+ receives an offer from the Licensor to exercise the
172
+ Licensed Rights under the terms and conditions of this
173
+ Public License.
174
+
175
+ b. No downstream restrictions. You may not offer or impose
176
+ any additional or different terms or conditions on, or
177
+ apply any Effective Technological Measures to, the
178
+ Licensed Material if doing so restricts exercise of the
179
+ Licensed Rights by any recipient of the Licensed
180
+ Material.
181
+
182
+ 6. No endorsement. Nothing in this Public License constitutes or
183
+ may be construed as permission to assert or imply that You
184
+ are, or that Your use of the Licensed Material is, connected
185
+ with, or sponsored, endorsed, or granted official status by,
186
+ the Licensor or others designated to receive attribution as
187
+ provided in Section 3(a)(1)(A)(i).
188
+
189
+ b. Other rights.
190
+
191
+ 1. Moral rights, such as the right of integrity, are not
192
+ licensed under this Public License, nor are publicity,
193
+ privacy, and/or other similar personality rights; however, to
194
+ the extent possible, the Licensor waives and/or agrees not to
195
+ assert any such rights held by the Licensor to the limited
196
+ extent necessary to allow You to exercise the Licensed
197
+ Rights, but not otherwise.
198
+
199
+ 2. Patent and trademark rights are not licensed under this
200
+ Public License.
201
+
202
+ 3. To the extent possible, the Licensor waives any right to
203
+ collect royalties from You for the exercise of the Licensed
204
+ Rights, whether directly or through a collecting society
205
+ under any voluntary or waivable statutory or compulsory
206
+ licensing scheme. In all other cases the Licensor expressly
207
+ reserves any right to collect such royalties.
208
+
209
+
210
+ Section 3 -- License Conditions.
211
+
212
+ Your exercise of the Licensed Rights is expressly made subject to the
213
+ following conditions.
214
+
215
+ a. Attribution.
216
+
217
+ 1. If You Share the Licensed Material (including in modified
218
+ form), You must:
219
+
220
+ a. retain the following if it is supplied by the Licensor
221
+ with the Licensed Material:
222
+
223
+ i. identification of the creator(s) of the Licensed
224
+ Material and any others designated to receive
225
+ attribution, in any reasonable manner requested by
226
+ the Licensor (including by pseudonym if
227
+ designated);
228
+
229
+ ii. a copyright notice;
230
+
231
+ iii. a notice that refers to this Public License;
232
+
233
+ iv. a notice that refers to the disclaimer of
234
+ warranties;
235
+
236
+ v. a URI or hyperlink to the Licensed Material to the
237
+ extent reasonably practicable;
238
+
239
+ b. indicate if You modified the Licensed Material and
240
+ retain an indication of any previous modifications; and
241
+
242
+ c. indicate the Licensed Material is licensed under this
243
+ Public License, and include the text of, or the URI or
244
+ hyperlink to, this Public License.
245
+
246
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
247
+ reasonable manner based on the medium, means, and context in
248
+ which You Share the Licensed Material. For example, it may be
249
+ reasonable to satisfy the conditions by providing a URI or
250
+ hyperlink to a resource that includes the required
251
+ information.
252
+
253
+ 3. If requested by the Licensor, You must remove any of the
254
+ information required by Section 3(a)(1)(A) to the extent
255
+ reasonably practicable.
256
+
257
+ 4. If You Share Adapted Material You produce, the Adapter's
258
+ License You apply must not prevent recipients of the Adapted
259
+ Material from complying with this Public License.
260
+
261
+
262
+ Section 4 -- Sui Generis Database Rights.
263
+
264
+ Where the Licensed Rights include Sui Generis Database Rights that
265
+ apply to Your use of the Licensed Material:
266
+
267
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
268
+ to extract, reuse, reproduce, and Share all or a substantial
269
+ portion of the contents of the database;
270
+
271
+ b. if You include all or a substantial portion of the database
272
+ contents in a database in which You have Sui Generis Database
273
+ Rights, then the database in which You have Sui Generis Database
274
+ Rights (but not its individual contents) is Adapted Material; and
275
+
276
+ c. You must comply with the conditions in Section 3(a) if You Share
277
+ all or a substantial portion of the contents of the database.
278
+
279
+ For the avoidance of doubt, this Section 4 supplements and does not
280
+ replace Your obligations under this Public License where the Licensed
281
+ Rights include other Copyright and Similar Rights.
282
+
283
+
284
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
285
+
286
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
287
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
288
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
289
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
290
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
291
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
292
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
293
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
294
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
295
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
296
+
297
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
298
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
299
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
300
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
301
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
302
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
303
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
304
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
305
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
306
+
307
+ c. The disclaimer of warranties and limitation of liability provided
308
+ above shall be interpreted in a manner that, to the extent
309
+ possible, most closely approximates an absolute disclaimer and
310
+ waiver of all liability.
311
+
312
+
313
+ Section 6 -- Term and Termination.
314
+
315
+ a. This Public License applies for the term of the Copyright and
316
+ Similar Rights licensed here. However, if You fail to comply with
317
+ this Public License, then Your rights under this Public License
318
+ terminate automatically.
319
+
320
+ b. Where Your right to use the Licensed Material has terminated under
321
+ Section 6(a), it reinstates:
322
+
323
+ 1. automatically as of the date the violation is cured, provided
324
+ it is cured within 30 days of Your discovery of the
325
+ violation; or
326
+
327
+ 2. upon express reinstatement by the Licensor.
328
+
329
+ For the avoidance of doubt, this Section 6(b) does not affect any
330
+ right the Licensor may have to seek remedies for Your violations
331
+ of this Public License.
332
+
333
+ c. For the avoidance of doubt, the Licensor may also offer the
334
+ Licensed Material under separate terms or conditions or stop
335
+ distributing the Licensed Material at any time; however, doing so
336
+ will not terminate this Public License.
337
+
338
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
339
+ License.
340
+
341
+
342
+ Section 7 -- Other Terms and Conditions.
343
+
344
+ a. The Licensor shall not be bound by any additional or different
345
+ terms or conditions communicated by You unless expressly agreed.
346
+
347
+ b. Any arrangements, understandings, or agreements regarding the
348
+ Licensed Material not stated herein are separate from and
349
+ independent of the terms and conditions of this Public License.
350
+
351
+
352
+ Section 8 -- Interpretation.
353
+
354
+ a. For the avoidance of doubt, this Public License does not, and
355
+ shall not be interpreted to, reduce, limit, restrict, or impose
356
+ conditions on any use of the Licensed Material that could lawfully
357
+ be made without permission under this Public License.
358
+
359
+ b. To the extent possible, if any provision of this Public License is
360
+ deemed unenforceable, it shall be automatically reformed to the
361
+ minimum extent necessary to make it enforceable. If the provision
362
+ cannot be reformed, it shall be severed from this Public License
363
+ without affecting the enforceability of the remaining terms and
364
+ conditions.
365
+
366
+ c. No term or condition of this Public License will be waived and no
367
+ failure to comply consented to unless expressly agreed to by the
368
+ Licensor.
369
+
370
+ d. Nothing in this Public License constitutes or may be interpreted
371
+ as a limitation upon, or waiver of, any privileges and immunities
372
+ that apply to the Licensor or You, including from the legal
373
+ processes of any jurisdiction or authority.
374
+
375
+
376
+ =======================================================================
377
+
378
+ Creative Commons is not a party to its public
379
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
380
+ its public licenses to material it publishes and in those instances
381
+ will be considered the “Licensor.” The text of the Creative Commons
382
+ public licenses is dedicated to the public domain under the CC0 Public
383
+ Domain Dedication. Except for the limited purpose of indicating that
384
+ material is shared under a Creative Commons public license or as
385
+ otherwise permitted by the Creative Commons policies published at
386
+ creativecommons.org/policies, Creative Commons does not authorize the
387
+ use of the trademark "Creative Commons" or any other trademark or logo
388
+ of Creative Commons without its prior written consent including,
389
+ without limitation, in connection with any unauthorized modifications
390
+ to any of its public licenses or any other arrangements,
391
+ understandings, or agreements concerning use of licensed material. For
392
+ the avoidance of doubt, this paragraph does not form part of the
393
+ public licenses.
394
+
395
+ Creative Commons may be contacted at creativecommons.org.
LICENSES/MIT-adapters.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Complete Work contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
LICENSES/ODC-BY-1.0.txt ADDED
@@ -0,0 +1,428 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ODC Attribution License (ODC-By)
2
+
3
+ ### Preamble
4
+
5
+ The Open Data Commons Attribution License is a license agreement
6
+ intended to allow users to freely share, modify, and use this Database
7
+ subject only to the attribution requirements set out in Section 4.
8
+
9
+ Databases can contain a wide variety of types of content (images,
10
+ audiovisual material, and sounds all in the same database, for example),
11
+ and so this license only governs the rights over the Database, and not
12
+ the contents of the Database individually. Licensors may therefore wish
13
+ to use this license together with another license for the contents.
14
+
15
+ Sometimes the contents of a database, or the database itself, can be
16
+ covered by other rights not addressed here (such as private contracts,
17
+ trademark over the name, or privacy rights / data protection rights
18
+ over information in the contents), and so you are advised that you may
19
+ have to consult other documents or clear other rights before doing
20
+ activities not covered by this License.
21
+
22
+ ------
23
+
24
+ The Licensor (as defined below)
25
+
26
+ and
27
+
28
+ You (as defined below)
29
+
30
+ agree as follows:
31
+
32
+ ### 1.0 Definitions of Capitalised Words
33
+
34
+ "Collective Database" - Means this Database in unmodified form as part
35
+ of a collection of independent databases in themselves that together are
36
+ assembled into a collective whole. A work that constitutes a Collective
37
+ Database will not be considered a Derivative Database.
38
+
39
+ "Convey" - As a verb, means Using the Database, a Derivative Database,
40
+ or the Database as part of a Collective Database in any way that enables
41
+ a Person to make or receive copies of the Database or a Derivative
42
+ Database. Conveying does not include interaction with a user through a
43
+ computer network, or creating and Using a Produced Work, where no
44
+ transfer of a copy of the Database or a Derivative Database occurs.
45
+
46
+ "Contents" - The contents of this Database, which includes the
47
+ information, independent works, or other material collected into the
48
+ Database. For example, the contents of the Database could be factual
49
+ data or works such as images, audiovisual material, text, or sounds.
50
+
51
+ "Database" - A collection of material (the Contents) arranged in a
52
+ systematic or methodical way and individually accessible by electronic
53
+ or other means offered under the terms of this License.
54
+
55
+ "Database Directive" - Means Directive 96/9/EC of the European
56
+ Parliament and of the Council of 11 March 1996 on the legal protection
57
+ of databases, as amended or succeeded.
58
+
59
+ "Database Right" - Means rights resulting from the Chapter III ("sui
60
+ generis") rights in the Database Directive (as amended and as transposed
61
+ by member states), which includes the Extraction and Re-utilisation of
62
+ the whole or a Substantial part of the Contents, as well as any similar
63
+ rights available in the relevant jurisdiction under Section 10.4.
64
+
65
+ "Derivative Database" - Means a database based upon the Database, and
66
+ includes any translation, adaptation, arrangement, modification, or any
67
+ other alteration of the Database or of a Substantial part of the
68
+ Contents. This includes, but is not limited to, Extracting or
69
+ Re-utilising the whole or a Substantial part of the Contents in a new
70
+ Database.
71
+
72
+ "Extraction" - Means the permanent or temporary transfer of all or a
73
+ Substantial part of the Contents to another medium by any means or in
74
+ any form.
75
+
76
+ "License" - Means this license agreement and is both a license of rights
77
+ such as copyright and Database Rights and an agreement in contract.
78
+
79
+ "Licensor" - Means the Person that offers the Database under the terms
80
+ of this License.
81
+
82
+ "Person" - Means a natural or legal person or a body of persons
83
+ corporate or incorporate.
84
+
85
+ "Produced Work" - a work (such as an image, audiovisual material, text,
86
+ or sounds) resulting from using the whole or a Substantial part of the
87
+ Contents (via a search or other query) from this Database, a Derivative
88
+ Database, or this Database as part of a Collective Database.
89
+
90
+ "Publicly" - means to Persons other than You or under Your control by
91
+ either more than 50% ownership or by the power to direct their
92
+ activities (such as contracting with an independent consultant).
93
+
94
+ "Re-utilisation" - means any form of making available to the public all
95
+ or a Substantial part of the Contents by the distribution of copies, by
96
+ renting, by online or other forms of transmission.
97
+
98
+ "Substantial" - Means substantial in terms of quantity or quality or a
99
+ combination of both. The repeated and systematic Extraction or
100
+ Re-utilisation of insubstantial parts of the Contents may amount to the
101
+ Extraction or Re-utilisation of a Substantial part of the Contents.
102
+
103
+ "Use" - As a verb, means doing any act that is restricted by copyright
104
+ or Database Rights whether in the original medium or any other; and
105
+ includes without limitation distributing, copying, publicly performing,
106
+ publicly displaying, and preparing derivative works of the Database, as
107
+ well as modifying the Database as may be technically necessary to use it
108
+ in a different mode or format.
109
+
110
+ "You" - Means a Person exercising rights under this License who has not
111
+ previously violated the terms of this License with respect to the
112
+ Database, or who has received express permission from the Licensor to
113
+ exercise rights under this License despite a previous violation.
114
+
115
+ Words in the singular include the plural and vice versa.
116
+
117
+ ### 2.0 What this License covers
118
+
119
+ 2.1. Legal effect of this document. This License is:
120
+
121
+ a. A license of applicable copyright and neighbouring rights;
122
+
123
+ b. A license of the Database Right; and
124
+
125
+ c. An agreement in contract between You and the Licensor.
126
+
127
+ 2.2 Legal rights covered. This License covers the legal rights in the
128
+ Database, including:
129
+
130
+ a. Copyright. Any copyright or neighbouring rights in the Database.
131
+ The copyright licensed includes any individual elements of the
132
+ Database, but does not cover the copyright over the Contents
133
+ independent of this Database. See Section 2.4 for details. Copyright
134
+ law varies between jurisdictions, but is likely to cover: the Database
135
+ model or schema, which is the structure, arrangement, and organisation
136
+ of the Database, and can also include the Database tables and table
137
+ indexes; the data entry and output sheets; and the Field names of
138
+ Contents stored in the Database;
139
+
140
+ b. Database Rights. Database Rights only extend to the Extraction and
141
+ Re-utilisation of the whole or a Substantial part of the Contents.
142
+ Database Rights can apply even when there is no copyright over the
143
+ Database. Database Rights can also apply when the Contents are removed
144
+ from the Database and are selected and arranged in a way that would
145
+ not infringe any applicable copyright; and
146
+
147
+ c. Contract. This is an agreement between You and the Licensor for
148
+ access to the Database. In return you agree to certain conditions of
149
+ use on this access as outlined in this License.
150
+
151
+ 2.3 Rights not covered.
152
+
153
+ a. This License does not apply to computer programs used in the making
154
+ or operation of the Database;
155
+
156
+ b. This License does not cover any patents over the Contents or the
157
+ Database; and
158
+
159
+ c. This License does not cover any trademarks associated with the
160
+ Database.
161
+
162
+ 2.4 Relationship to Contents in the Database. The individual items of
163
+ the Contents contained in this Database may be covered by other rights,
164
+ including copyright, patent, data protection, privacy, or personality
165
+ rights, and this License does not cover any rights (other than Database
166
+ Rights or in contract) in individual Contents contained in the Database.
167
+ For example, if used on a Database of images (the Contents), this
168
+ License would not apply to copyright over individual images, which could
169
+ have their own separate licenses, or one single license covering all of
170
+ the rights over the images.
171
+
172
+ ### 3.0 Rights granted
173
+
174
+ 3.1 Subject to the terms and conditions of this License, the Licensor
175
+ grants to You a worldwide, royalty-free, non-exclusive, terminable (but
176
+ only under Section 9) license to Use the Database for the duration of
177
+ any applicable copyright and Database Rights. These rights explicitly
178
+ include commercial use, and do not exclude any field of endeavour. To
179
+ the extent possible in the relevant jurisdiction, these rights may be
180
+ exercised in all media and formats whether now known or created in the
181
+ future.
182
+
183
+ The rights granted cover, for example:
184
+
185
+ a. Extraction and Re-utilisation of the whole or a Substantial part of
186
+ the Contents;
187
+
188
+ b. Creation of Derivative Databases;
189
+
190
+ c. Creation of Collective Databases;
191
+
192
+ d. Creation of temporary or permanent reproductions by any means and
193
+ in any form, in whole or in part, including of any Derivative
194
+ Databases or as a part of Collective Databases; and
195
+
196
+ e. Distribution, communication, display, lending, making available, or
197
+ performance to the public by any means and in any form, in whole or in
198
+ part, including of any Derivative Database or as a part of Collective
199
+ Databases.
200
+
201
+ 3.2 Compulsory license schemes. For the avoidance of doubt:
202
+
203
+ a. Non-waivable compulsory license schemes. In those jurisdictions in
204
+ which the right to collect royalties through any statutory or
205
+ compulsory licensing scheme cannot be waived, the Licensor reserves
206
+ the exclusive right to collect such royalties for any exercise by You
207
+ of the rights granted under this License;
208
+
209
+ b. Waivable compulsory license schemes. In those jurisdictions in
210
+ which the right to collect royalties through any statutory or
211
+ compulsory licensing scheme can be waived, the Licensor waives the
212
+ exclusive right to collect such royalties for any exercise by You of
213
+ the rights granted under this License; and,
214
+
215
+ c. Voluntary license schemes. The Licensor waives the right to collect
216
+ royalties, whether individually or, in the event that the Licensor is
217
+ a member of a collecting society that administers voluntary licensing
218
+ schemes, via that society, from any exercise by You of the rights
219
+ granted under this License.
220
+
221
+ 3.3 The right to release the Database under different terms, or to stop
222
+ distributing or making available the Database, is reserved. Note that
223
+ this Database may be multiple-licensed, and so You may have the choice
224
+ of using alternative licenses for this Database. Subject to Section
225
+ 10.4, all other rights not expressly granted by Licensor are reserved.
226
+
227
+ ### 4.0 Conditions of Use
228
+
229
+ 4.1 The rights granted in Section 3 above are expressly made subject to
230
+ Your complying with the following conditions of use. These are important
231
+ conditions of this License, and if You fail to follow them, You will be
232
+ in material breach of its terms.
233
+
234
+ 4.2 Notices. If You Publicly Convey this Database, any Derivative
235
+ Database, or the Database as part of a Collective Database, then You
236
+ must:
237
+
238
+ a. Do so only under the terms of this License;
239
+
240
+ b. Include a copy of this License or its Uniform Resource Identifier (URI)
241
+ with the Database or Derivative Database, including both in the
242
+ Database or Derivative Database and in any relevant documentation;
243
+
244
+ c. Keep intact any copyright or Database Right notices and notices
245
+ that refer to this License; and
246
+
247
+ d. If it is not possible to put the required notices in a particular
248
+ file due to its structure, then You must include the notices in a
249
+ location (such as a relevant directory) where users would be likely to
250
+ look for it.
251
+
252
+ 4.3 Notice for using output (Contents). Creating and Using a Produced
253
+ Work does not require the notice in Section 4.2. However, if you
254
+ Publicly Use a Produced Work, You must include a notice associated with
255
+ the Produced Work reasonably calculated to make any Person that uses,
256
+ views, accesses, interacts with, or is otherwise exposed to the Produced
257
+ Work aware that Content was obtained from the Database, Derivative
258
+ Database, or the Database as part of a Collective Database, and that it
259
+ is available under this License.
260
+
261
+ a. Example notice. The following text will satisfy notice under
262
+ Section 4.3:
263
+
264
+ Contains information from DATABASE NAME which is made available
265
+ under the ODC Attribution License.
266
+
267
+ DATABASE NAME should be replaced with the name of the Database and a
268
+ hyperlink to the location of the Database. "ODC Attribution License"
269
+ should contain a hyperlink to the URI of the text of this License. If
270
+ hyperlinks are not possible, You should include the plain text of the
271
+ required URI's with the above notice.
272
+
273
+ 4.4 Licensing of others. You may not sublicense the Database. Each time
274
+ You communicate the Database, the whole or Substantial part of the
275
+ Contents, or any Derivative Database to anyone else in any way, the
276
+ Licensor offers to the recipient a license to the Database on the same
277
+ terms and conditions as this License. You are not responsible for
278
+ enforcing compliance by third parties with this License, but You may
279
+ enforce any rights that You have over a Derivative Database. You are
280
+ solely responsible for any modifications of a Derivative Database made
281
+ by You or another Person at Your direction. You may not impose any
282
+ further restrictions on the exercise of the rights granted or affirmed
283
+ under this License.
284
+
285
+ ### 5.0 Moral rights
286
+
287
+ 5.1 Moral rights. This section covers moral rights, including any rights
288
+ to be identified as the author of the Database or to object to treatment
289
+ that would otherwise prejudice the author's honour and reputation, or
290
+ any other derogatory treatment:
291
+
292
+ a. For jurisdictions allowing waiver of moral rights, Licensor waives
293
+ all moral rights that Licensor may have in the Database to the fullest
294
+ extent possible by the law of the relevant jurisdiction under Section
295
+ 10.4;
296
+
297
+ b. If waiver of moral rights under Section 5.1 a in the relevant
298
+ jurisdiction is not possible, Licensor agrees not to assert any moral
299
+ rights over the Database and waives all claims in moral rights to the
300
+ fullest extent possible by the law of the relevant jurisdiction under
301
+ Section 10.4; and
302
+
303
+ c. For jurisdictions not allowing waiver or an agreement not to assert
304
+ moral rights under Section 5.1 a and b, the author may retain their
305
+ moral rights over certain aspects of the Database.
306
+
307
+ Please note that some jurisdictions do not allow for the waiver of moral
308
+ rights, and so moral rights may still subsist over the Database in some
309
+ jurisdictions.
310
+
311
+ ### 6.0 Fair dealing, Database exceptions, and other rights not affected
312
+
313
+ 6.1 This License does not affect any rights that You or anyone else may
314
+ independently have under any applicable law to make any use of this
315
+ Database, including without limitation:
316
+
317
+ a. Exceptions to the Database Right including: Extraction of Contents
318
+ from non-electronic Databases for private purposes, Extraction for
319
+ purposes of illustration for teaching or scientific research, and
320
+ Extraction or Re-utilisation for public security or an administrative
321
+ or judicial procedure.
322
+
323
+ b. Fair dealing, fair use, or any other legally recognised limitation
324
+ or exception to infringement of copyright or other applicable laws.
325
+
326
+ 6.2 This License does not affect any rights of lawful users to Extract
327
+ and Re-utilise insubstantial parts of the Contents, evaluated
328
+ quantitatively or qualitatively, for any purposes whatsoever, including
329
+ creating a Derivative Database (subject to other rights over the
330
+ Contents, see Section 2.4). The repeated and systematic Extraction or
331
+ Re-utilisation of insubstantial parts of the Contents may however amount
332
+ to the Extraction or Re-utilisation of a Substantial part of the
333
+ Contents.
334
+
335
+ ### 7.0 Warranties and Disclaimer
336
+
337
+ 7.1 The Database is licensed by the Licensor "as is" and without any
338
+ warranty of any kind, either express, implied, or arising by statute,
339
+ custom, course of dealing, or trade usage. Licensor specifically
340
+ disclaims any and all implied warranties or conditions of title,
341
+ non-infringement, accuracy or completeness, the presence or absence of
342
+ errors, fitness for a particular purpose, merchantability, or otherwise.
343
+ Some jurisdictions do not allow the exclusion of implied warranties, so
344
+ this exclusion may not apply to You.
345
+
346
+ ### 8.0 Limitation of liability
347
+
348
+ 8.1 Subject to any liability that may not be excluded or limited by law,
349
+ the Licensor is not liable for, and expressly excludes, all liability
350
+ for loss or damage however and whenever caused to anyone by any use
351
+ under this License, whether by You or by anyone else, and whether caused
352
+ by any fault on the part of the Licensor or not. This exclusion of
353
+ liability includes, but is not limited to, any special, incidental,
354
+ consequential, punitive, or exemplary damages such as loss of revenue,
355
+ data, anticipated profits, and lost business. This exclusion applies
356
+ even if the Licensor has been advised of the possibility of such
357
+ damages.
358
+
359
+ 8.2 If liability may not be excluded by law, it is limited to actual and
360
+ direct financial loss to the extent it is caused by proved negligence on
361
+ the part of the Licensor.
362
+
363
+ ### 9.0 Termination of Your rights under this License
364
+
365
+ 9.1 Any breach by You of the terms and conditions of this License
366
+ automatically terminates this License with immediate effect and without
367
+ notice to You. For the avoidance of doubt, Persons who have received the
368
+ Database, the whole or a Substantial part of the Contents, Derivative
369
+ Databases, or the Database as part of a Collective Database from You
370
+ under this License will not have their licenses terminated provided
371
+ their use is in full compliance with this License or a license granted
372
+ under Section 4.8 of this License. Sections 1, 2, 7, 8, 9 and 10 will
373
+ survive any termination of this License.
374
+
375
+ 9.2 If You are not in breach of the terms of this License, the Licensor
376
+ will not terminate Your rights under it.
377
+
378
+ 9.3 Unless terminated under Section 9.1, this License is granted to You
379
+ for the duration of applicable rights in the Database.
380
+
381
+ 9.4 Reinstatement of rights. If you cease any breach of the terms and
382
+ conditions of this License, then your full rights under this License
383
+ will be reinstated:
384
+
385
+ a. Provisionally and subject to permanent termination until the 60th
386
+ day after cessation of breach;
387
+
388
+ b. Permanently on the 60th day after cessation of breach unless
389
+ otherwise reasonably notified by the Licensor; or
390
+
391
+ c. Permanently if reasonably notified by the Licensor of the
392
+ violation, this is the first time You have received notice of
393
+ violation of this License from the Licensor, and You cure the
394
+ violation prior to 30 days after your receipt of the notice.
395
+
396
+ 9.5 Notwithstanding the above, Licensor reserves the right to release
397
+ the Database under different license terms or to stop distributing or
398
+ making available the Database. Releasing the Database under different
399
+ license terms or stopping the distribution of the Database will not
400
+ withdraw this License (or any other license that has been, or is
401
+ required to be, granted under the terms of this License), and this
402
+ License will continue in full force and effect unless terminated as
403
+ stated above.
404
+
405
+ ### 10.0 General
406
+
407
+ 10.1 If any provision of this License is held to be invalid or
408
+ unenforceable, that must not affect the validity or enforceability of
409
+ the remainder of the terms and conditions of this License and each
410
+ remaining provision of this License shall be valid and enforced to the
411
+ fullest extent permitted by law.
412
+
413
+ 10.2 This License is the entire agreement between the parties with
414
+ respect to the rights granted here over the Database. It replaces any
415
+ earlier understandings, agreements or representations with respect to
416
+ the Database.
417
+
418
+ 10.3 If You are in breach of the terms of this License, You will not be
419
+ entitled to rely on the terms of this License or to complain of any
420
+ breach by the Licensor.
421
+
422
+ 10.4 Choice of law. This License takes effect in and will be governed by
423
+ the laws of the relevant jurisdiction in which the License terms are
424
+ sought to be enforced. If the standard suite of rights granted under
425
+ applicable copyright law and Database Rights in the relevant
426
+ jurisdiction includes additional rights not granted under this License,
427
+ these additional rights are granted in this License in order to meet the
428
+ terms of this License.
LICENSES/README.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ Each upstream component retains its own license and attribution.
2
+
3
+ PDBThink original tasks and checkers: Open Athena, Apache-2.0. The upstream source identifies the coordinates as wwPDB CC0 material. See Apache-2.0-PDBThink.txt and components/pdbthink/licenses/.
4
+ TMax original task data: Ai2, ODC-BY 1.0. TMax-NOTICE.txt and the original author citations are retained. The upstream card also specifies research and educational use, the Ai2 Responsible Use Guidelines, and upstream terms for generated content. Those source requirements continue to apply. See ODC-BY-1.0.txt.
5
+ MiMo original training tasks, task assets, and embedded Requests and Plaso code: the original Apache-2.0 licenses and associated notices retain their file-specific scope, as recorded in components/mimo-code/licenses/ and SOURCE.json.
6
+ MathConstraint Costas, Ramsey, and Social Golfers: Viresh Pati and contributors, CC BY 4.0, obtained through amphora's pinned Harbor revision. The image also contains an unregistered RLVE round-robin alternative with its original MIT notice. See components/math/licenses/, NOTICE.txt, and SOURCE.json.
7
+ AgentWorldModel: Zhaoyang Wang, Canwen Xu, Boyi Liu, Yite Wang, Siwei Han, Zhewei Yao, Huaxiu Yao, and Yuxiong He, CC BY 4.0. See CC-BY-4.0.txt, components/awm/NOTICE, and LICENSE_SCOPE.json.
8
+ The project's existing MIT license applies to the new adapters and packaging documentation only. It does not replace or alter any upstream license.
9
+
10
+ OpenEnv SDK commit: 86a180ede21e044f7929b9a7783ad83aa67d83a3. The operating systems, Python, and third-party libraries retain their respective licenses. Original distribution notices remain in the images. Dependency records support reproduction and do not relicense those dependencies.
LICENSES/TMax-NOTICE.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ Contains information from allenai/TMax-15K (https://huggingface.co/datasets/allenai/TMax-15K), declared under the Open Data Commons Attribution License: https://opendatacommons.org/licenses/by/1-0/ .
2
+ Harbor task conversion: TMaxxx/TMax-15K-Harbor, revision 48a77eb0b017606c643ed905f96db41672914798.
3
+ The six selected tasks retain their original instructions, scoring assertions and fixed input assets. The OpenEnv adapter changes execution and transport and protects original inputs and private checkers.
4
+ The original dataset card also states research/education use, Ai2 Responsible Use Guidelines and applicable upstream terms for generated content; retain those statements with the component source notices.
5
+ See components/tmax/SOURCE.json and licenses/ for the original Ai2 revision and full source attribution.
6
+ OpenEnv SDK revision: 86a180ede21e044f7929b9a7783ad83aa67d83a3. Ubuntu, CPython and installed packages retain their upstream notices and licenses in the runtime image.
MANIFEST.json ADDED
The diff for this file is too large to render. See raw diff
 
README.md CHANGED
@@ -1,5 +1,51 @@
1
  ---
 
 
2
  license: other
3
- license_name: custom
4
- license_link: LICENSE
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
  license: other
5
+ license_name: mixed-upstream-licenses
6
+ license_link: https://huggingface.co/datasets/bochencs/openenv-multidomain/blob/main/LICENSES/README.txt
7
+ task_categories:
8
+ - reinforcement-learning
9
+ size_categories:
10
+ - n<1K
11
+ tags:
12
+ - openenv
13
+ - harbor
14
+ - multi-domain
15
+ configs:
16
+ - config_name: default
17
+ data_files:
18
+ - split: train
19
+ path: tasks.jsonl
20
  ---
21
+
22
+ This dataset contains 15 fixed training tasks served by five OpenEnv images.
23
+
24
+ | Task type | Count | Source |
25
+ |---|---:|---|
26
+ | Software repair | 2 | MiMo |
27
+ | Database and financial data processing | 3 | TMax |
28
+ | Business API workflows | 1 | AgentWorldModel |
29
+ | Manufacturing log processing | 1 | TMax |
30
+ | Video analysis | 1 | TMax |
31
+ | Physical parameter identification | 1 | TMax |
32
+ | Mathematical constraint construction | 3 | MathConstruct |
33
+ | Protein geometry | 3 | PDBThink |
34
+
35
+ `tasks.jsonl` lists task IDs, original instruction paths, and pinned source revisions. Each ID represents one original task. Reset restores its original inputs or database. The preserved original checkers compute binary rewards of 0 or 1.
36
+
37
+ `components/` contains runtime adapters, original tasks, inputs, checkers, and dependency records. `upstream/` preserves original Harbor materials. All images serve `schema.json`. Software, data, and mathematical tasks use `exec` and `finish`; business tasks use `call` and `finish`; protein tasks accept one `submit_answer` call.
38
+
39
+ `REGISTRATION.json` lists the 15 registered training IDs and two unregistered alternatives available in the images. `SOURCE_LOCK.json`, `MANIFEST.json`, and `SHA256SUMS` record source provenance and file hashes. Licenses and attribution appear in `LICENSES/README.txt` and the component notices.
40
+
41
+ Validate the local dataset:
42
+
43
+ ```sh
44
+ python3 -B validate_dataset.py
45
+ ```
46
+
47
+ Restore required source directories after downloading from Hugging Face:
48
+
49
+ ```sh
50
+ python3 -B prepare_source_tree.py
51
+ ```
REGISTRATION.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "selected_task_ids": [
3
+ "candidate-1005-software-systems",
4
+ "task_008667_2151f271",
5
+ "construct-mc-ramsey-l4-s0",
6
+ "awm-accounting-1-invoice",
7
+ "task_000260_7b7cc286",
8
+ "pdbthink-s09-70c0778d985e571dde37",
9
+ "task_000663_dff2c340",
10
+ "candidate-1001-security-forensics",
11
+ "task_000056_f726766b",
12
+ "construct-mc-social-golfers-l4-s0",
13
+ "pdbthink-s09-7ba4aa076b6bb5633953",
14
+ "task_005684_3c8594a3",
15
+ "construct-mc-costas-array-l3-s0",
16
+ "task_008998_ae4cbe72",
17
+ "pdbthink-s09-772d9c283d4255fc0a11"
18
+ ],
19
+ "selected_count": 15,
20
+ "skill_family_count": 8,
21
+ "unregistered_available_tasks": {
22
+ "math": [
23
+ "construct-rlve-round-robin-scores-l3-s0"
24
+ ],
25
+ "awm": [
26
+ "awm-manufacturing-1-schedule"
27
+ ]
28
+ },
29
+ "not_in_primary_package": [
30
+ "PortSim w04"
31
+ ],
32
+ "rule": "Only IDs in tasks.jsonl and the submission payload receive training steps. Additional image-supported original tasks are unregistered backups, not extra selected questions."
33
+ }
SHA256SUMS ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 LICENSES/Apache-2.0-PDBThink.txt
2
+ 9e5f1b3c610b9c2da5c313bf81d577a7d1acec686bdb0384edefa6df0f90cd94 LICENSES/CC-BY-4.0.txt
3
+ c9d5f2c24789a4ee7502fd1426c6a2090ba766b24f20d0ef663d3b149b7466d3 LICENSES/MIT-adapters.txt
4
+ 11a6d83734845ad09d809667aa219857a5b985b28c258a2eebf5677668a6bd3b LICENSES/ODC-BY-1.0.txt
5
+ 584119e89dde3125ead1266f2b0df8e5703aa39db498802d8c939324ffd0d8ce LICENSES/README.txt
6
+ 85da239bb4104a67e515dca538d1a4b345eed77c5d460fe76625bae905b431ed LICENSES/TMax-NOTICE.txt
7
+ 5ea28ca93163591f2b3767b7089f65488f09210f91bcd6555f3132f7c39348c6 MANIFEST.json
8
+ abafb0904285aa1bf767882e7dc62100c6ba6dad62785b5ca17432a5503c766a README.md
9
+ 458a593d295c61d4e72f48123e12a530396eba64bb1e98336c5df64cd1d1fbb6 REGISTRATION.json
10
+ 91ef4f71d10ae3874a47b80d0264e6f14e6317fc241d54700fd509ae1ff1d550 SOURCE_LOCK.json
11
+ dbaa91cef8aa2714c2761091e7a4f3b026a98add56e4b867b1f3e0c72c7445fd components/awm/ADAPTATIONS.txt
12
+ 1c26892b11e285d319e7ebc65f6cb275d38e5a4e5b581f9d022b026d72a3a3db components/awm/Dockerfile
13
+ 1ea6a4d0c80da30d5f658364aaef2664cf09f32da0bce23c448e1fc1e4c4a7a6 components/awm/LICENSE_SCOPE.json
14
+ 4d91952ef79d73182302464db3d190b0427ac04754eb6b7f5b1e8ad739c0bb1c components/awm/NOTICE
15
+ ae057f0e66d0e924e81f553e729148cd98161bf070283928ef4fb658e9cf3546 components/awm/SOURCE_CREDITS.json
16
+ 4d97456d2794c1f347c47f3c32733294d83778165d99b923bae4ebeec15261b2 components/awm/TASKS.json
17
+ 65d41089191536d5940648213b09924ba93e55d92df0080634e16d13615fd1ac components/awm/awm-requirements.lock
18
+ 1639f6ced0ae83cb1f87bb2737578602c1d410b2974ca2a889302e6a186b29fa components/awm/config.json
19
+ 3a1cc59eece46232d3ebb39df3cbfedd0625ab85bcf5e1d6cb090ea6ecec0e58 components/awm/private/tasks/awm-accounting-1-invoice/SOURCE.json
20
+ 8ad2959536e44caba47bcbeca9018e47e7157783194d19b429aa8f22a60f4771 components/awm/private/tasks/awm-accounting-1-invoice/initial.db
21
+ 57362b907a2d454bbd29b95dfebb7d84207ce9d7e22533eaf54853ee4fb84990 components/awm/private/tasks/awm-accounting-1-invoice/original_api.py
22
+ 3cd0d63022caa900e32bda0b0d3ae5c9948ce3c195b77ba1906c7ddebea9c58b components/awm/private/tasks/awm-accounting-1-invoice/original_verifier.py
23
+ 93eda02b7f5e0bd7aca37a2becc3fd20925472a8f33143171e4cc250564ff7b3 components/awm/private/tasks/awm-manufacturing-1-schedule/SOURCE.json
24
+ 9a523ebee8c25ca61aa43075c6263e5d3b310d39157ebddabea4cb754e610a1c components/awm/private/tasks/awm-manufacturing-1-schedule/initial.db
25
+ ff94326bc0d2a826a2a211512a617f0b9f5d91866b9c77ea17f6502f77b75aa6 components/awm/private/tasks/awm-manufacturing-1-schedule/original_api.py
26
+ f0cd8fa0f1a17e76f8e87cfbe59a81645a750999f747be36b8d25d9244e5b8f1 components/awm/private/tasks/awm-manufacturing-1-schedule/original_verifier.py
27
+ 0078892ae5870080b3417677926bc64f4f87ba9e8110ff400f18954e361455fc components/awm/requirements.lock
28
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/awm/runtime/awm/__init__.py
29
+ 98218136805b95d2cc5e98e190ef79e6d0a9c2950d8f61844b4672d4e2dac651 components/awm/runtime/awm/adapter.py
30
+ 0638af1cd1c6a311ee85109143ec6a59646a5f3d41c4b30312526dec561da33d components/awm/runtime/awm/launch_service.py
31
+ f47b0cc104a7a962fc932c4d3f3bb8bfcf1524dec049b9c2c33161924038b94e components/awm/runtime/awm/openenv_app.py
32
+ 484c7caeaa301b91f468a9e55a251a6b529c6f9d0f2e4951c9602071c40ebcea components/awm/runtime/awm/server.py
33
+ b5267c0f1cc015a68154affade8d89f6b6a01e9e4cc47a2dbdb74020e108ab5f components/awm/runtime/awm/wire_client.py
34
+ 06d2f12af151c8de707360ad950f6298a59668b203be8c64430d9cc602c7df54 components/awm/runtime/awm/worker.py
35
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/awm/runtime/common/__init__.py
36
+ b1e1429208e84aefc2422ee1d2400ad793c43cd5c0e8db213a3b669fe0947ce1 components/awm/runtime/common/contracts.py
37
+ 7263c04e9175faf66501ed9b2ac2f9a637557a8b1966d839fb9944eb01abac0e components/awm/runtime/common/http_routes.py
38
+ 26e7a67537ce7ae34909b724243c37242b9c8055cbfe0c717179dac74347786a components/awm/runtime/common/models.py
39
+ 12a0f7eb70edfb5e6fb02f9904c3e06daea24eab392ff4d6cef229ce18237810 components/awm/upstream/README.md
40
+ 1cd23311c95c9919621b226c99dcab54faf815300c72cd542a394a5e69463a6e components/awm/upstream/accounting_1-gen_db.jsonl
41
+ 99f1883338fa6f4827cb9c6c4c9cf9222c28a2a9842202cbe524921921de3ae3 components/awm/upstream/accounting_1-gen_envs.jsonl
42
+ 28cf8d5611b0d63b9e17d0e991e328c2970cfef5595c08d084f2b1bad7a441fd components/awm/upstream/accounting_1-gen_sample.jsonl
43
+ a50a67f6680c40b779f831067fe84d5633a10af60c6b488a4d6510fa818f45f3 components/awm/upstream/manufacturing_execution_system_1-gen_db.jsonl
44
+ 882e62163cdd51b0dba39ceb6ad110f263001681e68961648a5acad2d9e20c28 components/awm/upstream/manufacturing_execution_system_1-gen_envs.jsonl
45
+ fe9ae64f008a723f8ec10bc02a754a810243f0e97e82221b0ed730faf5cce63a components/awm/upstream/manufacturing_execution_system_1-gen_sample.jsonl
46
+ 15c3c4f106c052941f16970b3981ae9c9a7bbe4c913430bcac10edbc14e73151 components/math/ADAPTATIONS.txt
47
+ 3391c140ba8b7dd1378d16065c7488379b3114ce3f6009461bf31c416138e2f5 components/math/FILE_ALLOWLIST.json
48
+ bc17cd61f2a4ce4d05194787d9e25f1d38f8fdd8856d904f1e04f44c6d768211 components/math/MANIFEST.json
49
+ 73b544ecebc5d10e34e72f187bfdccf8ad66c9df4c37b03eeca7323a12401248 components/math/NOTICE.txt
50
+ a037cf3ce617aa3e0216bf5e0677d229679bfffdd30dba9057b58bb413c39732 components/math/SDK_DEPENDENCIES.json
51
+ a91ceb6c6b39e532fbef753034f1979d2364672d9bb6a45395c946dd8208befd components/math/SOURCE.json
52
+ fe67677e50ff773b044feb9122e26a4dbb1dc647a5c88ba9db0adf952167104a components/math/TASKS.json
53
+ 190f2c6c257c0cbc4cb6bfa2efe8e5fdca221b1c18b39aa70331781f2be79afa components/math/config.json
54
+ 9e5f1b3c610b9c2da5c313bf81d577a7d1acec686bdb0384edefa6df0f90cd94 components/math/licenses/MathConstraint-LICENSE
55
+ 10afac3400d1abccc7ec2322e07563a3e495c13ac39d3865564aa2e2423b398e components/math/licenses/RLVE-LICENSE
56
+ 200b2ce93f2a5b9671165f9aea3cc4d89db995352c1e1e3db6d418262b058516 components/math/licenses/UPSTREAM_COLLECTION_LICENSES.md
57
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/math/runtime/common/__init__.py
58
+ b1e1429208e84aefc2422ee1d2400ad793c43cd5c0e8db213a3b669fe0947ce1 components/math/runtime/common/contracts.py
59
+ 7263c04e9175faf66501ed9b2ac2f9a637557a8b1966d839fb9944eb01abac0e components/math/runtime/common/http_routes.py
60
+ 26e7a67537ce7ae34909b724243c37242b9c8055cbfe0c717179dac74347786a components/math/runtime/common/models.py
61
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/math/runtime/native_shell/__init__.py
62
+ 80eb3b90287840668e72040dc55ba115bfc3f4251a25cb2b94af0ed3759dd6b3 components/math/runtime/native_shell/actor_launcher.py
63
+ 6cc693d7a384d6d76b8c99bfb6af2e5188c03aac81671cfec3414733fb98089a components/math/runtime/native_shell/backend.py
64
+ cfe9ed6c11b9da324f5e752ffbf1d8ca5c074120f6067dd01d99590e568adf53 components/math/runtime/native_shell/environment.py
65
+ 4217040e7b055f57c6faef5aaa2a481757eda9856afb5a8816098b65fe788ef1 components/math/runtime/native_shell/guard.py
66
+ db4dc3e27abe2dc45cc29b534882975aa9ea8e5b8ebedb67c943fad83810805b components/math/runtime/native_shell/launch_service.py
67
+ 3a0de8fbd07613f323cbd1e42e4345f0268f7a21bc4326622c8e22f4d318f30e components/math/runtime/native_shell/server.py
68
+ 6934b8fa5117549cb5ba30a1e6ebbd00df2bf4191ba10765473d05a3fd346465 components/math/runtime/native_shell/verifier_launcher.py
69
+ b5267c0f1cc015a68154affade8d89f6b6a01e9e4cc47a2dbdb74020e108ab5f components/math/runtime/native_shell/wire_client.py
70
+ 56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c components/math/upstream/construct-mc-costas-array-l3-s0/environment/Dockerfile
71
+ 15a02495c009c52f7cbc0f2c1daa95e0a4d0981026e123b83aaa892565fd68b5 components/math/upstream/construct-mc-costas-array-l3-s0/environment/instance.json
72
+ 88e4a26e71d8483fbc89627210e4ed07f6dfef0fb16ce3e6d31e84a04bd050f9 components/math/upstream/construct-mc-costas-array-l3-s0/instruction.md
73
+ b62ba527da418f1b84d165707ea56ea805953289b0993cc3176e988ef59c3d32 components/math/upstream/construct-mc-costas-array-l3-s0/task.toml
74
+ 3c0290e35201f077926099989cd0e82c10bf091cb33c572cacc02bca075debdb components/math/upstream/construct-mc-costas-array-l3-s0/tests/check.py
75
+ 15a02495c009c52f7cbc0f2c1daa95e0a4d0981026e123b83aaa892565fd68b5 components/math/upstream/construct-mc-costas-array-l3-s0/tests/instance.json
76
+ d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73 components/math/upstream/construct-mc-costas-array-l3-s0/tests/run.py
77
+ a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e components/math/upstream/construct-mc-costas-array-l3-s0/tests/test.sh
78
+ 56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c components/math/upstream/construct-mc-ramsey-l4-s0/environment/Dockerfile
79
+ 9c2fb12f3e08390c54d4ec516860f404fee82ff0c9d1fdc952364965b6307b92 components/math/upstream/construct-mc-ramsey-l4-s0/environment/instance.json
80
+ dacf1d28faa912ac766cb9a8859b9a2d08940d2c52a9f8460c85ce0595a16c81 components/math/upstream/construct-mc-ramsey-l4-s0/instruction.md
81
+ d2ea623dfdf1ab4864399d4231f17b7c6800cc73e1ad9d1c583816d149dca377 components/math/upstream/construct-mc-ramsey-l4-s0/task.toml
82
+ 923f9e1258610a3cc3d5c2984b1855ed7341af13bc7592ff42aed0e0f91fc74d components/math/upstream/construct-mc-ramsey-l4-s0/tests/check.py
83
+ 9c2fb12f3e08390c54d4ec516860f404fee82ff0c9d1fdc952364965b6307b92 components/math/upstream/construct-mc-ramsey-l4-s0/tests/instance.json
84
+ d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73 components/math/upstream/construct-mc-ramsey-l4-s0/tests/run.py
85
+ a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e components/math/upstream/construct-mc-ramsey-l4-s0/tests/test.sh
86
+ 56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c components/math/upstream/construct-mc-social-golfers-l4-s0/environment/Dockerfile
87
+ cb27969d6fe8e38fac137b603f5e86da8b5f66023bc8288c6476e1b8881bfe73 components/math/upstream/construct-mc-social-golfers-l4-s0/environment/instance.json
88
+ a638ef887b79167571086549b8d9438447d07b800772aac868b3e9a2e6899cd2 components/math/upstream/construct-mc-social-golfers-l4-s0/instruction.md
89
+ fb08db6bba18360321c1ac959d0af5f655435579d5cb88864d924897254c7546 components/math/upstream/construct-mc-social-golfers-l4-s0/task.toml
90
+ 9514518058e308fc2ae0ec0b8ce8a50993d5dfa09708ac9c3609e1edbbae126a components/math/upstream/construct-mc-social-golfers-l4-s0/tests/check.py
91
+ cb27969d6fe8e38fac137b603f5e86da8b5f66023bc8288c6476e1b8881bfe73 components/math/upstream/construct-mc-social-golfers-l4-s0/tests/instance.json
92
+ d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73 components/math/upstream/construct-mc-social-golfers-l4-s0/tests/run.py
93
+ a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e components/math/upstream/construct-mc-social-golfers-l4-s0/tests/test.sh
94
+ 56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c components/math/upstream/construct-rlve-round-robin-scores-l3-s0/environment/Dockerfile
95
+ b8c26f77936e8e23c97ff9488800c364a5c1b8663a93d508500dcde958a4721a components/math/upstream/construct-rlve-round-robin-scores-l3-s0/environment/instance.json
96
+ db8d002ee820a699d6b7b819cb88ed583990529649255af446c22c98889ad370 components/math/upstream/construct-rlve-round-robin-scores-l3-s0/instruction.md
97
+ d42f4225ae8850e6abe3e1b612b0da6f2e896322a3e9e00e6addb988a8f8332a components/math/upstream/construct-rlve-round-robin-scores-l3-s0/task.toml
98
+ 930cd10836482427303a497cfa896934ccdc24116879eaa4c5d32a572d01353c components/math/upstream/construct-rlve-round-robin-scores-l3-s0/tests/check.py
99
+ b8c26f77936e8e23c97ff9488800c364a5c1b8663a93d508500dcde958a4721a components/math/upstream/construct-rlve-round-robin-scores-l3-s0/tests/instance.json
100
+ d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73 components/math/upstream/construct-rlve-round-robin-scores-l3-s0/tests/run.py
101
+ a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e components/math/upstream/construct-rlve-round-robin-scores-l3-s0/tests/test.sh
102
+ 9825666034cc109ee29e794870e502c4d9ff67b22bee26a7e808eda5676d1b14 components/mimo-code/README.txt
103
+ a037cf3ce617aa3e0216bf5e0677d229679bfffdd30dba9057b58bb413c39732 components/mimo-code/SDK_DEPENDENCIES.json
104
+ 1d8034fd8f402d3cfbcb68e6a666ffb8b10f2374d1f2dfaa623a91a320fd7ada components/mimo-code/SDK_RUNTIME.json
105
+ 150edf38d6ba4b6ba26ec991f256f7e2630935b3951a16e8688d8d86ad1eac85 components/mimo-code/SOURCE.json
106
+ cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 components/mimo-code/licenses/plaso-Apache-2.0.txt
107
+ 09e8a9bcec8067104652c168685ab0931e7868f9c8284b66f5ae6edae5f1130b components/mimo-code/licenses/requests-Apache-2.0.txt
108
+ 54af5390562f313695c706cc01071a28928f25025f50306c02f3f519faaf5b49 components/mimo-code/source_bundle/Dockerfile
109
+ a95e52958c35cf9a4b925558ca38029006ed04f9abc89e008f96e8ffd08fd629 components/mimo-code/source_bundle/config.json
110
+ 836618cb7e01e236878d367272157e4be6a31d538bf8b9f8cc9ed630aac04482 components/mimo-code/source_bundle/openenv-requirements.lock
111
+ fdc4026cc5e1301ffb6bdfd12f61c9d1591909ddf05501b43ef6ade47d01641f components/mimo-code/source_bundle/pristine-other/Dockerfile
112
+ 34adb79a4013c52a9e46791281763841a36fe1f500beb8a2be547e5975af0526 components/mimo-code/source_bundle/pristine-other/requirements-shared.txt
113
+ cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 components/mimo-code/source_bundle/pristine-other/vendor/plaso/LICENSE
114
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 components/mimo-code/source_bundle/pristine-other/vendor/plaso/dfwinreg/__init__.py
115
+ 082bb8b1c061c3ce920949abc37528ec77e292758ce68423657cd5d2d87897a0 components/mimo-code/source_bundle/pristine-other/vendor/plaso/dfwinreg/errors.py
116
+ b92752fa2da3ff17c53e164eccf8a91905ed6fb71551c531d7927ff0a9dab271 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/containers/events.py
117
+ 22061b1f10090bbecda41391007c7e2295baaf4f1f4797b5babff82bd43a5387 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/containers/interface.py
118
+ 0d84bc47cd82f1d57e884c918b5dd75d81bbc1a80380890b3a54edd420e0f22c components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/containers/manager.py
119
+ 69aa7937cb245410683d37f42ceebaff039d2b5796065f4c0c4618290ffb4a5e components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/containers/time_events.py
120
+ 1be04adf9ae090fa68333eb26f087e4d09edecb843340404e9b51bedf32a94aa components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/containers/windows_events.py
121
+ a11900d7bc98b80e318e0967f0218aca2e304d328954da20139fc342bb2fb697 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/lib/definitions.py
122
+ e18590112b9db1dfcc0c4df44750678cc886134452e1619248a2ef07544d7143 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/interface.py
123
+ ff2e0bed3543e230ff9d98b044356199e9419b99cef7faa997d21811d598ab4a components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/mediator.py
124
+ 88a70819243e00cf6557c40c1ebe21eb87ee06272e69c18d7c93ea6c5baac0b4 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/plugins.py
125
+ f5f747e98a017ebd019ddba45c36ea73c5de1f3b48d3238cec8cb44b39919793 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/winreg_parser.py
126
+ e026e975023b44b9c99dfb22b1d4d4b99d396019aed592d08bf2adc636ccc069 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/winreg_plugins/default.py
127
+ 2ef4e78f16ef5a1c9850aa08615737d01e2953d837dbf4692d9be18f205439e2 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/winreg_plugins/interface.py
128
+ 4711ac18d81ff23cf782b870861ef5f841a14cbfccc23fcaa7d995d6df04ee7e components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/winreg_plugins/network_drives.py
129
+ b33bf0efb841b2d19941aa2dc1b517fac09b60dc50f2c01841231cd04195ad27 components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/winreg_plugins/services.py
130
+ 956ba2a62fdb6860f71a345b4bdeffdda1b90de618f2fc51a29a7ebea829641a components/mimo-code/source_bundle/pristine-other/vendor/plaso/plaso/parsers/winreg_plugins/timezone.py
131
+ 84d16f933ae230cb9c53ec4d0addc397380705017079ee8c5430465b1035a6fb components/mimo-code/source_bundle/pristine-other/vendor/plaso/pytz/__init__.py
132
+ ad2fab71ce6887529d53aaedaf50b793a769e8ac34c596342e00491434a6ebd3 components/mimo-code/source_bundle/pristine-other/vendor/plaso/requirements.txt
133
+ 9c3a29f59a514add92378b7885a35b73a9695631fcc27849ed198fe481f33fc6 components/mimo-code/source_bundle/pristine-other/vendor/plaso/setup.py
134
+ 67aa9abe820736c53b272f93e86569d3aa7ef113fcff02696ebcd34185d991c5 components/mimo-code/source_bundle/pristine-other/vendor/plaso/test_data/regf/100_sub_keys.hiv
135
+ 370cdc7037cd01aeeae15dd0e86a44239138425372efd2cf35f066c1fbb36f50 components/mimo-code/source_bundle/pristine-other/vendor/plaso/test_data/regf/corrupt_sub_key_list.hiv
136
+ 4e7e2bb2ff10353a6b8ec54b11ed0420b8ab6c45483c7e77e761accb310acd75 components/mimo-code/source_bundle/pristine-other/vendor/plaso/tests/parsers/winreg_plugins/interface.py
137
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 components/mimo-code/source_bundle/pristine-other/vendor/plaso/tools/__init__.py
138
+ 5906eb2e26a100d1b993cc982ebdc7cbb18d74788a70f3446e8e7a50c04b111d components/mimo-code/source_bundle/pristine-other/vendor/plaso/tools/run_case.py
139
+ fdc4026cc5e1301ffb6bdfd12f61c9d1591909ddf05501b43ef6ade47d01641f components/mimo-code/source_bundle/pristine/Dockerfile
140
+ 34adb79a4013c52a9e46791281763841a36fe1f500beb8a2be547e5975af0526 components/mimo-code/source_bundle/pristine/requirements-shared.txt
141
+ 8d76dedce7d7a38ea383d8db3784f3ab808648a3bb19d613efa6e01088daea49 components/mimo-code/source_bundle/pristine/tools/run_regression.py
142
+ 09e8a9bcec8067104652c168685ab0931e7868f9c8284b66f5ae6edae5f1130b components/mimo-code/source_bundle/pristine/vendor/requests/LICENSE
143
+ 345f26b9f691435e39d0eb6f7f4150a390f43175b22f8d61ac95e7f2827f0a77 components/mimo-code/source_bundle/pristine/vendor/requests/pyproject.toml
144
+ 80534322a1a3167d8775829ee220a6acf4fe455f3f778c4b8e94bcf7fadfa0b5 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/__init__.py
145
+ abba90670b0370a3dc40d97c2dea46a35d4bec941ff10d7c3cf3098ef04a17f9 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/__version__.py
146
+ 4c7d8d132c9898fc7d715e473f3ac74785ddc4ab96d2c9240f87835dc6d981ff components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/_internal_utils.py
147
+ d06df79f54a279c0cc3faec596c446246d5ad14edfd529eb328defbd62a44a89 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/_types.py
148
+ cc9b1b02694fee0353481fbad84fe3ddbedec4441dba54df7914c63f2aa85937 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/adapters.py
149
+ 4d15480ac046f089209798e8650476ef4a28ebe6f81b400758f8ef42ec6b5509 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/api.py
150
+ fdc8bb34a8a5a088b169ca13277d107b0bc94ee63ed5e89dd4f5569d9b2bb04c components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/auth.py
151
+ fd9c6b83359cef90ff6c4eeeab8dcc2388da382ebca7d00a499b3c0b434a87e4 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/certs.py
152
+ 4a51c5ab07b015c298d6ea69d71502979cd3ed6b935d88e4433ce5341dacf584 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/compat.py
153
+ 05d12b965c76f229803e17aef1c9969d712e4f4d0f6a06c05e0a47212fd5b417 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/cookies.py
154
+ c5e18f3352454968e337bb3056f0867df2f37c0a0d2c1a77dc05e7e0b3c0411b components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/exceptions.py
155
+ e5845e93980b2e25be418fb7fe0b8e6e999fef8f84afc5a43f4546efdc24691f components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/help.py
156
+ ebd8a02475d31a0e473a8f553e9501ff43645b9563885ad52844e7a63f0d76ab components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/hooks.py
157
+ 557962f283e48bb20604129509979803687c9bf8b43e5d0f38e8d5037a5c2131 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/models.py
158
+ fe0d2067af355320252874631fa91a9db6a8c71d9e01beaacdc5e2383c932287 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/packages.py
159
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/py.typed
160
+ 3d2089736ced93b2b405624a943f866d22652b17df06a85eb010f86272fc3e7d components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/sessions.py
161
+ 1950f47c89cf18019787e07d8ce48f66d6b38e622f7d94d70a90247fee6c040e components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/status_codes.py
162
+ ba9460c39078f25e6f1d2a24ac941ac6f8d2ee97197fa8c8d0c262d8a1e67a02 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/structures.py
163
+ b879cb3f671cf1c28e8ff9b2b02151bcdb8974b4820a514cfdd1f5a038443cd2 components/mimo-code/source_bundle/pristine/vendor/requests/src/requests/utils.py
164
+ ac7f253daae0905f9b3dec647cae736bb3c090185aa373b30b3e851599e5342c components/mimo-code/source_bundle/pristine/vendor/requests/tests/__init__.py
165
+ 6d65ffb582519f80a66c5d1ef571e3c33395a199f9e67fcb500c6ad2d7800e0a components/mimo-code/source_bundle/pristine/vendor/requests/tests/conftest.py
166
+ 91ee3b9532c67d6fd533f9f8a7e910a63eb5a0558e569cc2ac20d2c047a5369d components/mimo-code/source_bundle/pristine/vendor/requests/tests/test_requests.py
167
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/mimo-code/source_bundle/runtime/code_runtime/__init__.py
168
+ 80eb3b90287840668e72040dc55ba115bfc3f4251a25cb2b94af0ed3759dd6b3 components/mimo-code/source_bundle/runtime/code_runtime/actor_launcher.py
169
+ 691b1b428f7134e98b27e402b735b3f6be36439ab64865bf3e4fc343a676ebe3 components/mimo-code/source_bundle/runtime/code_runtime/backend.py
170
+ 4ebf25639af6ccbe8faad346be45e2b5dd778e659b2a34faec51b6ad62e68102 components/mimo-code/source_bundle/runtime/code_runtime/code_child_launcher.py
171
+ ef8546819e3ece598ae9032254beb550f030f703f486bbfa9fe754a321f85430 components/mimo-code/source_bundle/runtime/code_runtime/environment.py
172
+ 4217040e7b055f57c6faef5aaa2a481757eda9856afb5a8816098b65fe788ef1 components/mimo-code/source_bundle/runtime/code_runtime/guard.py
173
+ e5df97cf4e32894de79f90ea5f70074fd83cdcfe191a1c013af737fbbad02025 components/mimo-code/source_bundle/runtime/code_runtime/launch_service.py
174
+ 37679a90257e5907fec750293fb74610c95400e46db0a4905973bb6e9a3d96b1 components/mimo-code/source_bundle/runtime/code_runtime/server.py
175
+ 62ff949eeda90727ac3cae771454b12ea35d4c6fa1b51ae9333f5bdb82fbe94d components/mimo-code/source_bundle/runtime/code_runtime/trusted_checker.py
176
+ 6934b8fa5117549cb5ba30a1e6ebbd00df2bf4191ba10765473d05a3fd346465 components/mimo-code/source_bundle/runtime/code_runtime/verifier_launcher.py
177
+ b5267c0f1cc015a68154affade8d89f6b6a01e9e4cc47a2dbdb74020e108ab5f components/mimo-code/source_bundle/runtime/code_runtime/wire_client.py
178
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/mimo-code/source_bundle/runtime/common/__init__.py
179
+ b1e1429208e84aefc2422ee1d2400ad793c43cd5c0e8db213a3b669fe0947ce1 components/mimo-code/source_bundle/runtime/common/contracts.py
180
+ 7263c04e9175faf66501ed9b2ac2f9a637557a8b1966d839fb9944eb01abac0e components/mimo-code/source_bundle/runtime/common/http_routes.py
181
+ 26e7a67537ce7ae34909b724243c37242b9c8055cbfe0c717179dac74347786a components/mimo-code/source_bundle/runtime/common/models.py
182
+ 6d55a1b1cb882a951518a74f06dbd70bdb845a3669b4ad0210e4aff0c56d82a3 components/mimo-code/source_bundle/source-other/instruction.md
183
+ 88538e9f67364bbdea3a753ba3a6cb3cc66ca998e2e6ffe2e92190e36125f1bd components/mimo-code/source_bundle/source-other/task.toml
184
+ 336149b10b45d03b7774ba589d984e9663135cfc660f3a133fc482a8716d0e3a components/mimo-code/source_bundle/source-other/tests/anti_hack_guard.py
185
+ 5ceff9d56caaa93b84f9d8bdc55009efca27f7e3e0fe9f6e7fc18e2f6aca9b1b components/mimo-code/source_bundle/source-other/tests/fixtures/expected.json
186
+ dcd500a72c68f04bd5d7b9faadde661274cb2648fb1d064b79b868908463b756 components/mimo-code/source_bundle/source-other/tests/fixtures/pristine_env_manifest.json
187
+ 8152f7541a6105f16a8da923f375093607fddf1adba35c816eab455080af061e components/mimo-code/source_bundle/source-other/tests/task_test.sh
188
+ 5034fb5c341b758a915ae4e59abbc5c27fb39894ff37b0e8b02233b3156a1c35 components/mimo-code/source_bundle/source-other/tests/test.sh
189
+ 266d7ff9688685eef6ee0fbe7a35935dfe1fed615604843d175a9369adb6a279 components/mimo-code/source_bundle/source-other/tests/test_outputs.py
190
+ 44d9729328960cc04484e8ff23d492ac54edfc83f5910c24301742c895b96920 components/mimo-code/source_bundle/source/instruction.md
191
+ 5cc7f78314cff7486514a872696334ea7add1614ab4d0e0c575f281a89f7425d components/mimo-code/source_bundle/source/task.toml
192
+ 336149b10b45d03b7774ba589d984e9663135cfc660f3a133fc482a8716d0e3a components/mimo-code/source_bundle/source/tests/anti_hack_guard.py
193
+ 544b5385c6ded480cc93e3c39938fce50b1ec7185d6e6052c5d53b9514968921 components/mimo-code/source_bundle/source/tests/fixtures/pristine_env_manifest.json
194
+ 24593e6c78d47ddcb3e95e62464ca66169005ef390b5bef717a1bc3952f1fb38 components/mimo-code/source_bundle/source/tests/fixtures/regression_cases.json
195
+ 786d65d844825a6cc7827d64dd9b34f388ef1f2be78c609e3a84ede8ed363bf1 components/mimo-code/source_bundle/source/tests/task_test.sh
196
+ 5034fb5c341b758a915ae4e59abbc5c27fb39894ff37b0e8b02233b3156a1c35 components/mimo-code/source_bundle/source/tests/test.sh
197
+ ae66085efc08ce1ac14b78e4aa9635452528c4ace0c2eddb79aeb3c023487a0c components/mimo-code/source_bundle/source/tests/test_outputs.py
198
+ b0cbd2dbfe130357ab86c48b3f0ee1acca985828022542d97f1f9d77e147f261 components/pdbthink/DEPENDENCIES.json
199
+ 0c2bd4c86b8d834a907605e71d8dc3763513da29cf07c324eb718c8818b1ec45 components/pdbthink/Dockerfile
200
+ 4ac5bc8faf3c53e689d3e1857e81c904da28c239dacc10e69c6f6bee67ba687a components/pdbthink/config.json
201
+ 7c98afbca1961f056579b344a5552c574582c6c19926578a748519fdd99496d7 components/pdbthink/licenses/DEPENDENCIES.json
202
+ c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 components/pdbthink/licenses/LICENSE-PDBTHINK
203
+ ce75bb41edfeadb6dbe07aa8a8feacc4ed326c27695327ab56a45d80f38045cc components/pdbthink/licenses/SOURCE.json
204
+ 56e4865b7517b35a7d316a8881561b622f10af0b29bd8394c59a4316ae285e1c components/pdbthink/private/tasks/pdbthink-s09-70c0778d985e571dde37/public_task.json
205
+ 8f8067d6fbd793412dd078f35617d367999a644cf040ef4996dfd96c2b2e936f components/pdbthink/private/tasks/pdbthink-s09-70c0778d985e571dde37/tests/coordinate_scoring/__init__.py
206
+ 72035a296ec599f0e4743141a76f8dc908be5ac6a7fd500d36fcbb29b8b3687c components/pdbthink/private/tasks/pdbthink-s09-70c0778d985e571dde37/tests/coordinate_scoring/parse.py
207
+ 8046af2d8ca0e74d40ca60624ea3c678b81fa3b76b634818fd96757282f12c34 components/pdbthink/private/tasks/pdbthink-s09-70c0778d985e571dde37/tests/coordinate_scoring/scorers.py
208
+ 1519e6cc81fa143b8fa97d394b831df6f896e0e8e3deab637f799bd23000e4b4 components/pdbthink/private/tasks/pdbthink-s09-70c0778d985e571dde37/tests/gold.json
209
+ bf3f533beddf0e9db369e092e297d2905013f2aedad52919cb1db76ed7a566f7 components/pdbthink/private/tasks/pdbthink-s09-70c0778d985e571dde37/tests/test.sh
210
+ 628bca2d87aa70d0176cb3a79879c64bbfb07fc53dd094fd3060173b24a76ef4 components/pdbthink/private/tasks/pdbthink-s09-70c0778d985e571dde37/tests/verifier.toml
211
+ 91441587561c00649cec98159d22f64d11b01fff459601cce79579737f0fa37c components/pdbthink/private/tasks/pdbthink-s09-70c0778d985e571dde37/tests/verify.py
212
+ 5d2dfa7c57a5c628a9c12cd097e7b644a155e380f1f6af48233560dbab0b4376 components/pdbthink/private/tasks/pdbthink-s09-772d9c283d4255fc0a11/public_task.json
213
+ 8f8067d6fbd793412dd078f35617d367999a644cf040ef4996dfd96c2b2e936f components/pdbthink/private/tasks/pdbthink-s09-772d9c283d4255fc0a11/tests/coordinate_scoring/__init__.py
214
+ 72035a296ec599f0e4743141a76f8dc908be5ac6a7fd500d36fcbb29b8b3687c components/pdbthink/private/tasks/pdbthink-s09-772d9c283d4255fc0a11/tests/coordinate_scoring/parse.py
215
+ 8046af2d8ca0e74d40ca60624ea3c678b81fa3b76b634818fd96757282f12c34 components/pdbthink/private/tasks/pdbthink-s09-772d9c283d4255fc0a11/tests/coordinate_scoring/scorers.py
216
+ 995383611b5cf7f9f9d766df703fa00d02e445329f992f4c1a31f8e1e508a390 components/pdbthink/private/tasks/pdbthink-s09-772d9c283d4255fc0a11/tests/gold.json
217
+ bf3f533beddf0e9db369e092e297d2905013f2aedad52919cb1db76ed7a566f7 components/pdbthink/private/tasks/pdbthink-s09-772d9c283d4255fc0a11/tests/test.sh
218
+ 628bca2d87aa70d0176cb3a79879c64bbfb07fc53dd094fd3060173b24a76ef4 components/pdbthink/private/tasks/pdbthink-s09-772d9c283d4255fc0a11/tests/verifier.toml
219
+ 91441587561c00649cec98159d22f64d11b01fff459601cce79579737f0fa37c components/pdbthink/private/tasks/pdbthink-s09-772d9c283d4255fc0a11/tests/verify.py
220
+ 7d267c32438351a4d92533f6e9960da36a1e39c768ad56988904029cb90da0c5 components/pdbthink/private/tasks/pdbthink-s09-7ba4aa076b6bb5633953/public_task.json
221
+ 8f8067d6fbd793412dd078f35617d367999a644cf040ef4996dfd96c2b2e936f components/pdbthink/private/tasks/pdbthink-s09-7ba4aa076b6bb5633953/tests/coordinate_scoring/__init__.py
222
+ 72035a296ec599f0e4743141a76f8dc908be5ac6a7fd500d36fcbb29b8b3687c components/pdbthink/private/tasks/pdbthink-s09-7ba4aa076b6bb5633953/tests/coordinate_scoring/parse.py
223
+ 8046af2d8ca0e74d40ca60624ea3c678b81fa3b76b634818fd96757282f12c34 components/pdbthink/private/tasks/pdbthink-s09-7ba4aa076b6bb5633953/tests/coordinate_scoring/scorers.py
224
+ 4ed8e4260bc71b5a863888cd3fa2c7bca6210fc5138f96fd2207462c348318b7 components/pdbthink/private/tasks/pdbthink-s09-7ba4aa076b6bb5633953/tests/gold.json
225
+ bf3f533beddf0e9db369e092e297d2905013f2aedad52919cb1db76ed7a566f7 components/pdbthink/private/tasks/pdbthink-s09-7ba4aa076b6bb5633953/tests/test.sh
226
+ 628bca2d87aa70d0176cb3a79879c64bbfb07fc53dd094fd3060173b24a76ef4 components/pdbthink/private/tasks/pdbthink-s09-7ba4aa076b6bb5633953/tests/verifier.toml
227
+ 91441587561c00649cec98159d22f64d11b01fff459601cce79579737f0fa37c components/pdbthink/private/tasks/pdbthink-s09-7ba4aa076b6bb5633953/tests/verify.py
228
+ 0078892ae5870080b3417677926bc64f4f87ba9e8110ff400f18954e361455fc components/pdbthink/requirements.lock
229
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/pdbthink/runtime/common/__init__.py
230
+ b1e1429208e84aefc2422ee1d2400ad793c43cd5c0e8db213a3b669fe0947ce1 components/pdbthink/runtime/common/contracts.py
231
+ 7263c04e9175faf66501ed9b2ac2f9a637557a8b1966d839fb9944eb01abac0e components/pdbthink/runtime/common/http_routes.py
232
+ 26e7a67537ce7ae34909b724243c37242b9c8055cbfe0c717179dac74347786a components/pdbthink/runtime/common/models.py
233
+ 9f56e761d79bfdb34304a012586cb04d16b435ef6130091a97702e559260a2f2 components/pdbthink/runtime/pdbthink/__init__.py
234
+ 1683d5e2fab016801207ecdde6cbd4d3730ed8c4ca22aafd0f3bf651dce0faf1 components/pdbthink/runtime/pdbthink/adapter.py
235
+ cc89f1e687da1a71af567ac450fd761da0e5d4fe56901695de304aabd81c59bd components/pdbthink/runtime/pdbthink/launch_service.py
236
+ 7ab1b3b05068cd5b0f20497062a8da5fd905c45e8eee295cb8f2fc5c7aca6577 components/pdbthink/runtime/pdbthink/openenv_app.py
237
+ 76012b37d916b4044c6fe1da4e7accdf9faa2216f50c73d5b87cd12b7f1d70cf components/pdbthink/runtime/pdbthink/server.py
238
+ b1f6f82ff9e113aedd742a8f4b0c18c545020677503765ee913c31e20964b96f components/pdbthink/runtime/pdbthink/transport.py
239
+ b5267c0f1cc015a68154affade8d89f6b6a01e9e4cc47a2dbdb74020e108ab5f components/pdbthink/runtime/pdbthink/wire_client.py
240
+ 58d031f7955f7f774733189b8297a1db7f515bb206c26ac50fad68f580848974 components/tmax/DEPENDENCIES.json
241
+ a29f4e2ba9e60f543f7f0ff90c16bc7515fd2175ea7abaacff73f0bd7f7e91e4 components/tmax/FILE_ALLOWLIST.json
242
+ 9ae187d852f4cd6974fc9c65fba942df4e5586d73ddb3c48916a09376a3d36ac components/tmax/LICENSE_SCOPE.json
243
+ f30eb64313c2645348ca3d965c40c9a466eb3754f3302206e44133d19bc87d6a components/tmax/NOTICE.txt
244
+ 8228f41f6ed3488d787e85f78ec8d9358ff8d5d515c6ec537ab0eb06537048d1 components/tmax/SOURCE.json
245
+ 9296f353c436adf1f5019adb05854fec1bb4601f8201a3f5763bf3b4116399e5 components/tmax/TASKS.json
246
+ 9ffea3f8661105381b8db21a63e9d641b4a2f2c6a3cae9c4de963a51d8d5d8d8 components/tmax/config.json
247
+ 11a6d83734845ad09d809667aa219857a5b985b28c258a2eebf5677668a6bd3b components/tmax/licenses/ODC-BY-1.0.txt
248
+ 0e66e8816b8f2b4a17d37ec7abc5b8ca5708bae9d71d2c5323d8666d7e7ffa1d components/tmax/licenses/TMAX_DATASET_README.md
249
+ 836618cb7e01e236878d367272157e4be6a31d538bf8b9f8cc9ed630aac04482 components/tmax/requirements.lock
250
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/tmax/runtime/common/__init__.py
251
+ b1e1429208e84aefc2422ee1d2400ad793c43cd5c0e8db213a3b669fe0947ce1 components/tmax/runtime/common/contracts.py
252
+ 7263c04e9175faf66501ed9b2ac2f9a637557a8b1966d839fb9944eb01abac0e components/tmax/runtime/common/http_routes.py
253
+ 26e7a67537ce7ae34909b724243c37242b9c8055cbfe0c717179dac74347786a components/tmax/runtime/common/models.py
254
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b components/tmax/runtime/native_shell/__init__.py
255
+ 80eb3b90287840668e72040dc55ba115bfc3f4251a25cb2b94af0ed3759dd6b3 components/tmax/runtime/native_shell/actor_launcher.py
256
+ 1a60616f3539f34ab141b3e58292369936844a5c3c4ceba3f58814e04f30b7fe components/tmax/runtime/native_shell/backend.py
257
+ cfe9ed6c11b9da324f5e752ffbf1d8ca5c074120f6067dd01d99590e568adf53 components/tmax/runtime/native_shell/environment.py
258
+ 4217040e7b055f57c6faef5aaa2a481757eda9856afb5a8816098b65fe788ef1 components/tmax/runtime/native_shell/guard.py
259
+ db4dc3e27abe2dc45cc29b534882975aa9ea8e5b8ebedb67c943fad83810805b components/tmax/runtime/native_shell/launch_service.py
260
+ 3a0de8fbd07613f323cbd1e42e4345f0268f7a21bc4326622c8e22f4d318f30e components/tmax/runtime/native_shell/server.py
261
+ 6934b8fa5117549cb5ba30a1e6ebbd00df2bf4191ba10765473d05a3fd346465 components/tmax/runtime/native_shell/verifier_launcher.py
262
+ b5267c0f1cc015a68154affade8d89f6b6a01e9e4cc47a2dbdb74020e108ab5f components/tmax/runtime/native_shell/wire_client.py
263
+ eab8396a1b533f70468039f8ac1b5fe9927faf4ded578172ec932ef7bf2af22a components/tmax/tasks/task_000056_f726766b/source/external/app/vibration_data.wav
264
+ 714f780883970365cfffe408e2c76e75f499005f87551fc84b55d79368e77197 components/tmax/tasks/task_000056_f726766b/source/instruction.md
265
+ e36405ea22dc2679124b64c5e8d7f3c52fb3cfa9f529d4694e26532db5b341d0 components/tmax/tasks/task_000056_f726766b/source/task.toml
266
+ 3ae0ce20b61928cc7f524ea6fb43ed55d3df32a9a87834825518d2397e31672e components/tmax/tasks/task_000056_f726766b/source/tests/test.sh
267
+ 327c5346a779a44e27ef0cbd9f107e863d599fc6e47f95f248eaec03c15117c4 components/tmax/tasks/task_000056_f726766b/source/tests/test_final_state.py
268
+ a6c4cf2043d8642babb9b546096b3f559a375b59d54a43efebd57e9728466184 components/tmax/tasks/task_000260_7b7cc286/pristine/pipeline/find_threshold.sh
269
+ 4631f1f805e6b826a796502ed5d94e676b3061cf448f2f9225116395aa3bb13b components/tmax/tasks/task_000260_7b7cc286/pristine/pipeline/process.sh
270
+ f3ae2df41978712dbffe58665a9582e3d0951f211c5cca5ece9f536225d28ba8 components/tmax/tasks/task_000260_7b7cc286/pristine/pipeline/serialize.sh
271
+ 3c04251fe92c30d29ac4d887608f4385176e3bda932594437f82b08a5b348938 components/tmax/tasks/task_000260_7b7cc286/source/external/app/video.mp4
272
+ 79c9fd4e4d41524db109d90b0415a4f0a2b9d24bf690fa8d7340ce3cb5ce0975 components/tmax/tasks/task_000260_7b7cc286/source/instruction.md
273
+ d36c49060b4ddbca3b13a5aa98cf5b195c07bff725b91107f58a087ec4325423 components/tmax/tasks/task_000260_7b7cc286/source/task.toml
274
+ 3ae0ce20b61928cc7f524ea6fb43ed55d3df32a9a87834825518d2397e31672e components/tmax/tasks/task_000260_7b7cc286/source/tests/test.sh
275
+ aae204101d5c024a0b5cbda42fa686e7d2928fd9be3ad55fd14314b2502182a5 components/tmax/tasks/task_000260_7b7cc286/source/tests/test_final_state.py
276
+ 170911a153d00eb0f037ca56a2cbd10d4aa2b7a418e25a0f1df58b1c77589788 components/tmax/tasks/task_000663_dff2c340/pristine/backup_catalog.db
277
+ feae25374139b4b1d8ec9759d553c591841d9330a071217f46a2e464bd32bbd7 components/tmax/tasks/task_000663_dff2c340/source/instruction.md
278
+ 85d17b0b5f2f018805d139044cedadeda55cc93406e9d7b548b28fc6aa8ae30a components/tmax/tasks/task_000663_dff2c340/source/task.toml
279
+ 3ae0ce20b61928cc7f524ea6fb43ed55d3df32a9a87834825518d2397e31672e components/tmax/tasks/task_000663_dff2c340/source/tests/test.sh
280
+ 7a273b9bf8bc61eeec1b8dda674b5f6ba5356abbfd923b413b09d2584c1ef72f components/tmax/tasks/task_000663_dff2c340/source/tests/test_final_state.py
281
+ 9fe1c89ee823f133d35dea66840ecb7f87d599487524b7aa1d6371e8f664058e components/tmax/tasks/task_005684_3c8594a3/pristine/compliance_audit.db
282
+ f4eee4e0643fcfb7399df10e1947ec9dbda28c74bacf307167f443506268f583 components/tmax/tasks/task_005684_3c8594a3/source/instruction.md
283
+ 5fc0da5f24b16f866fbc354cfc7cb148a17d353dff3b263c1c6caf94bf30b6a2 components/tmax/tasks/task_005684_3c8594a3/source/task.toml
284
+ 3ae0ce20b61928cc7f524ea6fb43ed55d3df32a9a87834825518d2397e31672e components/tmax/tasks/task_005684_3c8594a3/source/tests/test.sh
285
+ 495630c7ede4e75ef5644c1ee5b69f04969a4059ef094787c19a3014734d3cf2 components/tmax/tasks/task_005684_3c8594a3/source/tests/test_final_state.py
286
+ d6b5039ee32f3a43069245984c8fe5a9689028a9aac06e26a64017c54bd11976 components/tmax/tasks/task_008667_2151f271/pristine/data/financial.db
287
+ 629b28471809f802c58831d100315b83012c0066df3b265a2d379a19e61a2262 components/tmax/tasks/task_008667_2151f271/pristine/data/transactions.jsonl
288
+ 50d1d10121dfa3b565842fd10f2589ceb91b4459126787af7793cec9cc0d06b1 components/tmax/tasks/task_008667_2151f271/source/instruction.md
289
+ d45954c25df30184144533cbf3ad4160377f627db5b926c3bbc9186327067897 components/tmax/tasks/task_008667_2151f271/source/task.toml
290
+ 3ae0ce20b61928cc7f524ea6fb43ed55d3df32a9a87834825518d2397e31672e components/tmax/tasks/task_008667_2151f271/source/tests/test.sh
291
+ cb73fd0ab1765768ebfecc50054ba13c143cc51be201127515eb495904ddf9e6 components/tmax/tasks/task_008667_2151f271/source/tests/test_final_state.py
292
+ 909d2e964c0831d8af91b722b4424ed829c261d6b7db1a95180d8a809527ddaf components/tmax/tasks/task_008998_ae4cbe72/pristine/robot_dump.log.gz
293
+ f81f86b07681931baabdba313cc4e988c01bff7a1f1d83349dfa939cdaa20669 components/tmax/tasks/task_008998_ae4cbe72/source/instruction.md
294
+ c8ff58ad07c30c2da028625be23e41319f95e22524944c9d37de2ec255428cd9 components/tmax/tasks/task_008998_ae4cbe72/source/task.toml
295
+ 3ae0ce20b61928cc7f524ea6fb43ed55d3df32a9a87834825518d2397e31672e components/tmax/tasks/task_008998_ae4cbe72/source/tests/test.sh
296
+ e03b84ca0519367e5f86b7b3a3231afa5209b1971431497699200099035f5014 components/tmax/tasks/task_008998_ae4cbe72/source/tests/test_final_state.py
297
+ c44d259c4421b16dc5f0bc3912cdd800f6c25746ea31bede5060c9605b225025 components/tmax/upstream/task_000056_f726766b/environment/Dockerfile
298
+ fc9e91cc78e1817d80b4ba8c2dc9a638d0c57959825ee34f5e3d7688ad80dfb9 components/tmax/upstream/task_000056_f726766b/environment/_fixtures/app/fixtures/audio.label.txt
299
+ f55a8eec263c9be975b2adccdda6a07c680109b851a89f55779f14076aaa30d5 components/tmax/upstream/task_000056_f726766b/environment/_fixtures/app/fixtures/audio.wav
300
+ 0e71b3e06fcf8cc6f9d95ba2e9664dfbba7786949a0e21b810ada563ae27a637 components/tmax/upstream/task_000056_f726766b/environment/base_install.sh
301
+ 70d52288d5c9a7d23bbd63fb086a7f886961a1335632cc6efb892572d197563b components/tmax/upstream/task_000056_f726766b/environment/post_install.sh
302
+ e36405ea22dc2679124b64c5e8d7f3c52fb3cfa9f529d4694e26532db5b341d0 components/tmax/upstream/task_000056_f726766b/task.toml
303
+ 98f66d958e8ee701c0579095c2e65254a63194845b894a45db2a6180a46a3193 components/tmax/upstream/task_000260_7b7cc286/environment/Dockerfile
304
+ 4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5 components/tmax/upstream/task_000260_7b7cc286/environment/_fixtures/app/fixtures/video.label.txt
305
+ bf759113108b136ec3b5fa507d035c1e66ac243b52da09fa07ab58566ee27f58 components/tmax/upstream/task_000260_7b7cc286/environment/_fixtures/app/fixtures/video.mp4
306
+ 0e71b3e06fcf8cc6f9d95ba2e9664dfbba7786949a0e21b810ada563ae27a637 components/tmax/upstream/task_000260_7b7cc286/environment/base_install.sh
307
+ ba40e8bc5a20718d686892069c073ee96760685a32fe3291f2f6fbb630a7ae03 components/tmax/upstream/task_000260_7b7cc286/environment/post_install.sh
308
+ 483c9171d3e67bec029d9b88cee24d554fa9310a61ec47940312be5f2951bc30 components/tmax/upstream/task_000260_7b7cc286/task.toml
309
+ ac07540077f0810363eb57110b6cefeae93df6271c1cc6121d2d62cdc13a9535 components/tmax/upstream/task_000663_dff2c340/environment/Dockerfile
310
+ a449c18295cee8a3e7ed0c958fe219cbed2d2a8e7fdad924f2679444b3377b94 components/tmax/upstream/task_000663_dff2c340/environment/post_install.sh
311
+ 85d17b0b5f2f018805d139044cedadeda55cc93406e9d7b548b28fc6aa8ae30a components/tmax/upstream/task_000663_dff2c340/task.toml
312
+ ac07540077f0810363eb57110b6cefeae93df6271c1cc6121d2d62cdc13a9535 components/tmax/upstream/task_005684_3c8594a3/environment/Dockerfile
313
+ b431517fec535c62b42b517f9212cbb1e9cf80bdf883a55c02bfba08f0d4c404 components/tmax/upstream/task_005684_3c8594a3/environment/post_install.sh
314
+ 5fc0da5f24b16f866fbc354cfc7cb148a17d353dff3b263c1c6caf94bf30b6a2 components/tmax/upstream/task_005684_3c8594a3/task.toml
315
+ ac07540077f0810363eb57110b6cefeae93df6271c1cc6121d2d62cdc13a9535 components/tmax/upstream/task_008667_2151f271/environment/Dockerfile
316
+ 3a777366c4b998e6368627f4775a73cea29fdbdc9991daedfb13244153c17841 components/tmax/upstream/task_008667_2151f271/environment/post_install.sh
317
+ d45954c25df30184144533cbf3ad4160377f627db5b926c3bbc9186327067897 components/tmax/upstream/task_008667_2151f271/task.toml
318
+ ac07540077f0810363eb57110b6cefeae93df6271c1cc6121d2d62cdc13a9535 components/tmax/upstream/task_008998_ae4cbe72/environment/Dockerfile
319
+ 26dfa63d063430c2370144b8e30c1f905dde4e2722403c1e8131a5a84e2d5e69 components/tmax/upstream/task_008998_ae4cbe72/environment/post_install.sh
320
+ c8ff58ad07c30c2da028625be23e41319f95e22524944c9d37de2ec255428cd9 components/tmax/upstream/task_008998_ae4cbe72/task.toml
321
+ abea24b268b08f72897859e527fe90c89c08d2afab7305cf52d4255f2feeb897 prepare_source_tree.py
322
+ 10993deaaa8553929fa0b3b6bf3c1ad100baaaf9ff10ae8ed139a8ec4279a3c4 schema.json
323
+ 5eba017b2fb18e65bb63d7116df8aa502c90e157c5be4d67021b60a57b7ae848 tasks.jsonl
324
+ 66b564f58a409177999eda6eea1e5c8009d88c6d72faffa1bac7c497b800a460 upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/environment/Dockerfile
325
+ 33d86986d7b9d0a12678be7326d02048cf812cb536fc45fdb2837c9772c64ddf upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/instruction.md
326
+ f61bc6944b49d7a8095eef3903cd4b10982417f02c04f4d2b47620dd2128f30d upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/prompt.json
327
+ eaf162755c72fae0936eab27b370732356f5b184aa1077e543b46f8ce327db7d upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/task.toml
328
+ 8f8067d6fbd793412dd078f35617d367999a644cf040ef4996dfd96c2b2e936f upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/tests/coordinate_scoring/__init__.py
329
+ 72035a296ec599f0e4743141a76f8dc908be5ac6a7fd500d36fcbb29b8b3687c upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/tests/coordinate_scoring/parse.py
330
+ 8046af2d8ca0e74d40ca60624ea3c678b81fa3b76b634818fd96757282f12c34 upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/tests/coordinate_scoring/scorers.py
331
+ 1519e6cc81fa143b8fa97d394b831df6f896e0e8e3deab637f799bd23000e4b4 upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/tests/gold.json
332
+ bf3f533beddf0e9db369e092e297d2905013f2aedad52919cb1db76ed7a566f7 upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/tests/test.sh
333
+ 628bca2d87aa70d0176cb3a79879c64bbfb07fc53dd094fd3060173b24a76ef4 upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/tests/verifier.toml
334
+ 91441587561c00649cec98159d22f64d11b01fff459601cce79579737f0fa37c upstream/pdbthink/pdbthink-s09-70c0778d985e571dde37/tests/verify.py
335
+ 66b564f58a409177999eda6eea1e5c8009d88c6d72faffa1bac7c497b800a460 upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/environment/Dockerfile
336
+ 1eba6ac44775863993c8215f0d146cdccc7e8874a05b694e79db776e375dd7b1 upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/instruction.md
337
+ 77c1f05eb4f17a1d1b3291d916c999104262acfd9180ef775fa51232228ec2bc upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/prompt.json
338
+ 3c85ab2cfb5782ee7b40bd4fb0ef1b323d1874e6f2ffb23554b7b630ea46454c upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/task.toml
339
+ 8f8067d6fbd793412dd078f35617d367999a644cf040ef4996dfd96c2b2e936f upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/tests/coordinate_scoring/__init__.py
340
+ 72035a296ec599f0e4743141a76f8dc908be5ac6a7fd500d36fcbb29b8b3687c upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/tests/coordinate_scoring/parse.py
341
+ 8046af2d8ca0e74d40ca60624ea3c678b81fa3b76b634818fd96757282f12c34 upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/tests/coordinate_scoring/scorers.py
342
+ 995383611b5cf7f9f9d766df703fa00d02e445329f992f4c1a31f8e1e508a390 upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/tests/gold.json
343
+ bf3f533beddf0e9db369e092e297d2905013f2aedad52919cb1db76ed7a566f7 upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/tests/test.sh
344
+ 628bca2d87aa70d0176cb3a79879c64bbfb07fc53dd094fd3060173b24a76ef4 upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/tests/verifier.toml
345
+ 91441587561c00649cec98159d22f64d11b01fff459601cce79579737f0fa37c upstream/pdbthink/pdbthink-s09-772d9c283d4255fc0a11/tests/verify.py
346
+ 66b564f58a409177999eda6eea1e5c8009d88c6d72faffa1bac7c497b800a460 upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/environment/Dockerfile
347
+ 21dc586748f23a8630118831399e1c40d62443444d454bf6f5e7f60ba334b06f upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/instruction.md
348
+ 97d07b9814fff65f7cd78bf968d4854aa2aa75e8535ceb574b35a93dbf087db0 upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/prompt.json
349
+ 45af241c0dc3ed0b71fff4db4b2f334760bc387aaff0a74a6dc9543cce2effe1 upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/task.toml
350
+ 8f8067d6fbd793412dd078f35617d367999a644cf040ef4996dfd96c2b2e936f upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/tests/coordinate_scoring/__init__.py
351
+ 72035a296ec599f0e4743141a76f8dc908be5ac6a7fd500d36fcbb29b8b3687c upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/tests/coordinate_scoring/parse.py
352
+ 8046af2d8ca0e74d40ca60624ea3c678b81fa3b76b634818fd96757282f12c34 upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/tests/coordinate_scoring/scorers.py
353
+ 4ed8e4260bc71b5a863888cd3fa2c7bca6210fc5138f96fd2207462c348318b7 upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/tests/gold.json
354
+ bf3f533beddf0e9db369e092e297d2905013f2aedad52919cb1db76ed7a566f7 upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/tests/test.sh
355
+ 628bca2d87aa70d0176cb3a79879c64bbfb07fc53dd094fd3060173b24a76ef4 upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/tests/verifier.toml
356
+ 91441587561c00649cec98159d22f64d11b01fff459601cce79579737f0fa37c upstream/pdbthink/pdbthink-s09-7ba4aa076b6bb5633953/tests/verify.py
357
+ 26ee528d240a5208cf89d540b8e0a3ceb26435a15dc1fbb57f7034c8e6eec980 validate_dataset.py
SOURCE_LOCK.json ADDED
The diff for this file is too large to render. See raw diff
 
components/awm/ADAPTATIONS.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ Interface: call and finish using the original FastApiMCP business tools.
2
+ Reset copies the original seed database; finish runs the original state checker.
3
+ Each episode has a 600-second limit. FastApiMCP 0.4.0 and the OpenEnv SDK use separate Python environments. Dependency versions are recorded in the two requirements.lock files.
components/awm/Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim-bookworm@sha256:392307d22300de8b5986851a12d9176dfc0fc073e65bf6523ebd7dcbeb23564e
2
+ USER root
3
+ COPY wheels /tmp/sdk-wheels
4
+ COPY requirements.lock /opt/awm/requirements.lock
5
+ RUN python -m pip install --no-cache-dir --no-index --find-links=/tmp/sdk-wheels --require-hashes -r /opt/awm/requirements.lock && python -m pip check && rm -rf /tmp/sdk-wheels
6
+ COPY awm_wheels /tmp/awm-wheels
7
+ COPY awm-requirements.lock /opt/awm/awm-requirements.lock
8
+ RUN python -m venv /opt/awm-venv && /opt/awm-venv/bin/python -m pip install --no-cache-dir --no-index --find-links=/tmp/awm-wheels --require-hashes -r /opt/awm/awm-requirements.lock && /opt/awm-venv/bin/python -m pip check && rm -rf /tmp/awm-wheels
9
+ COPY runtime /opt/awm/runtime
10
+ COPY private /opt/awm/private
11
+ COPY config.json /opt/awm/config.json
12
+ COPY NOTICE SOURCE_CREDITS.json /opt/awm/
13
+ RUN chmod -R go-rwx /opt/awm && mkdir -p /var/lib/awm && chmod 700 /var/lib/awm
14
+ ENV PYTHONPATH=/opt/awm/runtime PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 ENABLE_WEB_INTERFACE=false OPENENV_MODE=simulation GRADIO_ANALYTICS_ENABLED=false HF_HUB_OFFLINE=1
15
+ WORKDIR /opt/awm
16
+ EXPOSE 8000
17
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=3).read()"]
18
+ CMD ["python", "-m", "awm.server"]
components/awm/LICENSE_SCOPE.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "component": "awm",
3
+ "upstream": {
4
+ "scope": "Original AWM request text, generated API source, schema/sample rows and pure-code verifiers",
5
+ "license": "CC-BY-4.0",
6
+ "notice": "NOTICE",
7
+ "source_credit": "SOURCE_CREDITS.json",
8
+ "materialized_seed": "Frozen database generated from the original schema/sample SQL; not an upstream binary file."
9
+ },
10
+ "adapter": {
11
+ "scope": "Local transport/packaging adaptations in awm/runtime and configuration metadata",
12
+ "note": "Local adaptation; not attributed as upstream AWM source."
13
+ },
14
+ "dependencies": {
15
+ "scope": "Installed third-party libraries and official OpenEnv SDK",
16
+ "note": "Keep respective installed package licenses; these are not relicensed under dataset licenses. Dependency names, versions and wheel hashes are in lock files.",
17
+ "lock_files": [
18
+ "requirements.lock",
19
+ "awm-requirements.lock"
20
+ ]
21
+ }
22
+ }
components/awm/NOTICE ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ This image adapts two unchanged original train tasks from AgentWorldModel-1K.
2
+ Authors: Zhaoyang Wang, Canwen Xu, Boyi Liu, Yite Wang, Siwei Han, Zhewei Yao, Huaxiu Yao, Yuxiong He.
3
+ Dataset: https://huggingface.co/datasets/Snowflake/AgentWorldModel-1K/tree/dde80a0283fe781bdc51656bce57063dc5650213
4
+ License: Creative Commons Attribution 4.0 International (CC BY 4.0).
5
+ License terms: https://creativecommons.org/licenses/by/4.0/
6
+ Changes: shared OpenEnv transport, fixed task selection, isolated per-episode database, original FastApiMCP 0.4.0 worker environment. Original task requests, API source, seed data and pure-code graders are unchanged.
components/awm/SOURCE_CREDITS.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "repo": "Snowflake/AgentWorldModel-1K",
3
+ "revision": "dde80a0283fe781bdc51656bce57063dc5650213",
4
+ "url": "https://huggingface.co/datasets/Snowflake/AgentWorldModel-1K/tree/dde80a0283fe781bdc51656bce57063dc5650213",
5
+ "license": "CC-BY-4.0",
6
+ "authors": "Zhaoyang Wang, Canwen Xu, Boyi Liu, Yite Wang, Siwei Han, Zhewei Yao, Huaxiu Yao, Yuxiong He",
7
+ "paper": "https://arxiv.org/abs/2602.10090",
8
+ "code": "https://github.com/Snowflake-Labs/agent-world-model"
9
+ }
components/awm/TASKS.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "task_id": "awm-accounting-1-invoice",
4
+ "source_repo": "Snowflake/AgentWorldModel-1K",
5
+ "source_revision": "dde80a0283fe781bdc51656bce57063dc5650213",
6
+ "source_record": "gen_tasks.jsonl#scenario=accounting_1;tasks[1]",
7
+ "source_instruction_sha256": "a08b48d978d8a70cfea5c6e871d079622fc99ac8438fb38d6d6816bdfa399c99",
8
+ "original_limits": null,
9
+ "original_limits_note": "No numeric episode/CPU/memory limits were found in the selected AWM dataset rows; do not infer defaults.",
10
+ "adapter_limits": {
11
+ "episode_seconds": 600,
12
+ "cpus": 1,
13
+ "memory_mb": 2048,
14
+ "max_context_length": 32768,
15
+ "max_completion_tokens": 32768
16
+ },
17
+ "interface": {
18
+ "schema_sha256": "10993deaaa8553929fa0b3b6bf3c1ad100baaaf9ff10ae8ed139a8ec4279a3c4",
19
+ "ops": [
20
+ "call",
21
+ "finish"
22
+ ],
23
+ "business_tools": "Unchanged original FastApiMCP 0.4.0 operation names and argument schemas",
24
+ "shell": false,
25
+ "reset": "Fixed task_id, fresh original seed copy, no random task substitution",
26
+ "reward": "0 or 1 from original pure-code state verifier at finish; terminal immutable"
27
+ },
28
+ "tool_count": 27,
29
+ "original_files_sha256": {
30
+ "original_api.py": "57362b907a2d454bbd29b95dfebb7d84207ce9d7e22533eaf54853ee4fb84990",
31
+ "original_verifier.py": "3cd0d63022caa900e32bda0b0d3ae5c9948ce3c195b77ba1906c7ddebea9c58b",
32
+ "initial.db": "8ad2959536e44caba47bcbeca9018e47e7157783194d19b429aa8f22a60f4771",
33
+ "SOURCE.json": "3a1cc59eece46232d3ebb39df3cbfedd0625ab85bcf5e1d6cb090ea6ecec0e58"
34
+ },
35
+ "license": "CC-BY-4.0"
36
+ },
37
+ {
38
+ "task_id": "awm-manufacturing-1-schedule",
39
+ "source_repo": "Snowflake/AgentWorldModel-1K",
40
+ "source_revision": "dde80a0283fe781bdc51656bce57063dc5650213",
41
+ "source_record": "gen_tasks.jsonl#scenario=manufacturing_execution_system_1;tasks[5]",
42
+ "source_instruction_sha256": "95404884accb6e78e1a8421cf62b7a6379955bf931dd35ccd71900d01f5180e4",
43
+ "original_limits": null,
44
+ "original_limits_note": "No numeric episode/CPU/memory limits were found in the selected AWM dataset rows; do not infer defaults.",
45
+ "adapter_limits": {
46
+ "episode_seconds": 600,
47
+ "cpus": 1,
48
+ "memory_mb": 2048,
49
+ "max_context_length": 32768,
50
+ "max_completion_tokens": 32768
51
+ },
52
+ "interface": {
53
+ "schema_sha256": "10993deaaa8553929fa0b3b6bf3c1ad100baaaf9ff10ae8ed139a8ec4279a3c4",
54
+ "ops": [
55
+ "call",
56
+ "finish"
57
+ ],
58
+ "business_tools": "Unchanged original FastApiMCP 0.4.0 operation names and argument schemas",
59
+ "shell": false,
60
+ "reset": "Fixed task_id, fresh original seed copy, no random task substitution",
61
+ "reward": "0 or 1 from original pure-code state verifier at finish; terminal immutable"
62
+ },
63
+ "tool_count": 50,
64
+ "original_files_sha256": {
65
+ "original_api.py": "ff94326bc0d2a826a2a211512a617f0b9f5d91866b9c77ea17f6502f77b75aa6",
66
+ "original_verifier.py": "f0cd8fa0f1a17e76f8e87cfbe59a81645a750999f747be36b8d25d9244e5b8f1",
67
+ "initial.db": "9a523ebee8c25ca61aa43075c6263e5d3b310d39157ebddabea4cb754e610a1c",
68
+ "SOURCE.json": "93eda02b7f5e0bd7aca37a2becc3fd20925472a8f33143171e4cc250564ff7b3"
69
+ },
70
+ "license": "CC-BY-4.0"
71
+ }
72
+ ]
components/awm/awm-requirements.lock ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ annotated-doc==0.0.5 --hash=sha256:117bac03a25ede5df5440e855b32d556049ca169ead221505badf432fed4b101
2
+ annotated-types==0.8.0 --hash=sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0
3
+ anyio==4.15.1 --hash=sha256:6152fdbbf9a77fdec97731721bebf7c4c44f7c29b424b0065826173efc7ed101
4
+ attrs==26.1.0 --hash=sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309
5
+ certifi==2026.7.22 --hash=sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775
6
+ cffi==2.1.1 --hash=sha256:c1453022f490d2459a11819d83ad1d586e9ff65a12ac3e705ffebd46d3685dcf
7
+ charset-normalizer==3.5.2 --hash=sha256:3d31298449090ab8d47b7b1b2a555ff73cac7ed438a08b7ac160980c7ebed649
8
+ click==8.5.0 --hash=sha256:255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360
9
+ cryptography==50.0.2 --hash=sha256:630ebfea3bf689d075f82316324ff7433dc447fe6bc1bfc76524b74b4a9567d2
10
+ fastapi==0.115.12 --hash=sha256:e94613d6c05e27be7ffebdd6ea5f388112e5e430c8f7d6494a9d1d88d43e814d
11
+ fastapi-mcp==0.4.0 --hash=sha256:d4a3fe7966af24d44e4b412720561c95eb12bed999a4443a88221834b3b15aec
12
+ greenlet==3.2.5 --hash=sha256:45fcea7b697b91290b36eafc12fff479aca6ba6500d98ef6f34d5634c7119cbe
13
+ h11==0.16.0 --hash=sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86
14
+ httpcore==1.0.9 --hash=sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55
15
+ httpx==0.28.1 --hash=sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad
16
+ httpx-sse==0.4.3 --hash=sha256:0ac1c9fe3c0afad2e0ebb25a934a59f4c7823b60792691f779fad2c5568830fc
17
+ idna==3.20 --hash=sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c
18
+ jsonschema==4.26.0 --hash=sha256:d489f15263b8d200f8387e64b4c3a75f06629559fb73deb8fdfb525f2dab50ce
19
+ jsonschema-specifications==2025.9.1 --hash=sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe
20
+ markdown-it-py==4.2.0 --hash=sha256:9f7ebbcd14fe59494226453aed97c1070d83f8d24b6fc3a3bcf9a38092641c4a
21
+ mcp==1.26.0 --hash=sha256:904a21c33c25aa98ddbeb47273033c435e595bbacfdb177f4bd87f6dceebe1ca
22
+ mdurl==0.1.2 --hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8
23
+ pycparser==3.11 --hash=sha256:51d5a8ba2be0bbe440b99d2112604c95bbbc3c2748a64260186c541e1729cd80
24
+ pydantic==2.12.5 --hash=sha256:e561593fccf61e8a20fc46dfc2dfe075b8be7d0188df33f221ad1f0139180f9d
25
+ pydantic_core==2.41.5 --hash=sha256:eceb81a8d74f9267ef4081e246ffd6d129da5d87e37a77c9bde550cb04870c1c
26
+ pydantic-settings==2.15.0 --hash=sha256:0ba092c291c94baceb5eff768aa0d56400a457585bc0175925a5a5510303da42
27
+ Pygments==2.21.0 --hash=sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9
28
+ PyJWT==2.15.1 --hash=sha256:42d59d631f7768a1028a64c7ff581a9bf7519804daf91fc5b6c56e30eec5e193
29
+ python-dotenv==1.2.4 --hash=sha256:42269a8a5b3fd54ffa6f3d84b18abed50064717576b4ecf03dc4a55d8aa04fdc
30
+ python-multipart==0.0.32 --hash=sha256:ff6d3f776f16878c894e52e107296ffc890e913c611b1a4ec6c44e2821fe2e23
31
+ referencing==0.37.0 --hash=sha256:381329a9f99628c9069361716891d34ad94af76e461dcb0335825aecc7692231
32
+ requests==2.34.2 --hash=sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0
33
+ rich==15.0.0 --hash=sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb
34
+ rpds-py==2026.9.1 --hash=sha256:addeda51556dac7c1a2f14cda62db8b621cd12afba3091d03a96c72932387eab
35
+ shellingham==1.5.4 --hash=sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686
36
+ SQLAlchemy==2.0.41 --hash=sha256:6145afea51ff0af7f2564a05fa95eb46f542919e6523729663a5d285ecb3cf5e
37
+ sse-starlette==3.0.3 --hash=sha256:af5bf5a6f3933df1d9c7f8539633dc8444ca6a97ab2e2a7cd3b6e431ac03a431
38
+ starlette==0.46.2 --hash=sha256:595633ce89f8ffa71a015caed34a5b2dc1c0cdb3f0f1fbd1e69339cf2abeec35
39
+ tomli==2.5.0 --hash=sha256:6cf74416bdc94ae458b14e37286c1073081850ac8459a00d0c5efef5d44294c6
40
+ typer==0.27.3 --hash=sha256:e50022f28b82a86313e54501317a1db64bf8f8d036ff8cfe5ca7e47675454aff
41
+ typing_extensions==4.16.0 --hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8
42
+ typing-inspection==0.4.4 --hash=sha256:65b8397ba37ccbce054456aaccddfc91e6e3083c92824df348d96ca832f3f147
43
+ urllib3==2.8.0 --hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3
44
+ uvicorn==0.54.0 --hash=sha256:505bdb0f318731d45f1f712071fc781a8981f6847a31c902c9f5e652d4f67faf
components/awm/config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tasks": [
3
+ {
4
+ "task_id": "awm-accounting-1-invoice",
5
+ "split": "train",
6
+ "original_sha256": {
7
+ "original_api.py": "57362b907a2d454bbd29b95dfebb7d84207ce9d7e22533eaf54853ee4fb84990",
8
+ "original_verifier.py": "3cd0d63022caa900e32bda0b0d3ae5c9948ce3c195b77ba1906c7ddebea9c58b",
9
+ "initial.db": "8ad2959536e44caba47bcbeca9018e47e7157783194d19b429aa8f22a60f4771",
10
+ "SOURCE.json": "3a1cc59eece46232d3ebb39df3cbfedd0625ab85bcf5e1d6cb090ea6ecec0e58"
11
+ },
12
+ "timeout_seconds": 600
13
+ },
14
+ {
15
+ "task_id": "awm-manufacturing-1-schedule",
16
+ "split": "train",
17
+ "original_sha256": {
18
+ "original_api.py": "ff94326bc0d2a826a2a211512a617f0b9f5d91866b9c77ea17f6502f77b75aa6",
19
+ "original_verifier.py": "f0cd8fa0f1a17e76f8e87cfbe59a81645a750999f747be36b8d25d9244e5b8f1",
20
+ "initial.db": "9a523ebee8c25ca61aa43075c6263e5d3b310d39157ebddabea4cb754e610a1c",
21
+ "SOURCE.json": "93eda02b7f5e0bd7aca37a2becc3fd20925472a8f33143171e4cc250564ff7b3"
22
+ },
23
+ "timeout_seconds": 600
24
+ }
25
+ ]
26
+ }
components/awm/private/tasks/awm-accounting-1-invoice/SOURCE.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "repo": "Snowflake/AgentWorldModel-1K",
3
+ "revision": "dde80a0283fe781bdc51656bce57063dc5650213",
4
+ "scenario": "accounting_1",
5
+ "task_idx": 1,
6
+ "task": "Create an invoice for customer 'Acme Design Studio' dated 2025-01-05 with due_date 2025-02-04 containing two line_items ('Logo redesign' quantity 1 unit_price 1200 with no discount and 'Brand guideline document' quantity 1 unit_price 800 with a 10% discount), assign it to department 'Design', and mark its tax_category as 'Standard Sales Tax 8.5%'.",
7
+ "task_id": "awm-accounting-1-invoice",
8
+ "license": "CC-BY-4.0",
9
+ "split": "train",
10
+ "original_format": "FastAPI through FastApiMCP 0.4.0"
11
+ }
components/awm/private/tasks/awm-accounting-1-invoice/initial.db ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ad2959536e44caba47bcbeca9018e47e7157783194d19b429aa8f22a60f4771
3
+ size 331776
components/awm/private/tasks/awm-accounting-1-invoice/original_api.py ADDED
@@ -0,0 +1,1767 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Query, Path, Body
2
+ from pydantic import BaseModel, Field, ConfigDict
3
+ from typing import Optional, List, Dict
4
+ from datetime import datetime, date
5
+ import os
6
+ from sqlalchemy import (
7
+ create_engine,
8
+ Column,
9
+ Integer,
10
+ String,
11
+ DateTime,
12
+ Date,
13
+ Float,
14
+ Text,
15
+ ForeignKey,
16
+ CheckConstraint,
17
+ Index,
18
+ )
19
+ from sqlalchemy.orm import declarative_base, relationship, sessionmaker
20
+
21
+ database_url = os.getenv("DATABASE_PATH", "sqlite:///outputs/databases/zenledger_small_business_accounting_suite.db")
22
+ engine = create_engine(database_url, future=True)
23
+ SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False, future=True)
24
+ Base = declarative_base()
25
+
26
+ class User(Base):
27
+ __tablename__ = "users"
28
+ id = Column(Integer, primary_key=True)
29
+ username = Column(Text, unique=True, nullable=False)
30
+ email = Column(Text, unique=True, nullable=False)
31
+ full_name = Column(Text)
32
+ created_at = Column(DateTime, default=datetime.utcnow)
33
+ updated_at = Column(DateTime)
34
+
35
+ class Department(Base):
36
+ __tablename__ = "departments"
37
+ id = Column(Integer, primary_key=True)
38
+ name = Column(Text, unique=True, nullable=False)
39
+ description = Column(Text)
40
+ created_at = Column(DateTime, default=datetime.utcnow)
41
+ updated_at = Column(DateTime)
42
+
43
+ class TaxCategory(Base):
44
+ __tablename__ = "tax_categories"
45
+ id = Column(Integer, primary_key=True)
46
+ name = Column(Text, unique=True, nullable=False)
47
+ description = Column(Text)
48
+ rate = Column(Float, nullable=False)
49
+ is_compound = Column(Integer, nullable=False, default=0)
50
+ created_at = Column(DateTime, default=datetime.utcnow)
51
+ updated_at = Column(DateTime)
52
+
53
+ class PaymentTerm(Base):
54
+ __tablename__ = "payment_terms"
55
+ id = Column(Integer, primary_key=True)
56
+ name = Column(Text, unique=True, nullable=False)
57
+ days = Column(Integer, nullable=False)
58
+ description = Column(Text)
59
+ created_at = Column(DateTime, default=datetime.utcnow)
60
+ updated_at = Column(DateTime)
61
+
62
+ class Customer(Base):
63
+ __tablename__ = "customers"
64
+ id = Column(Integer, primary_key=True)
65
+ name = Column(Text, unique=True, nullable=False)
66
+ billing_email = Column(Text)
67
+ payment_terms_id = Column(Integer, ForeignKey("payment_terms.id"))
68
+ default_tax_category_id = Column(Integer, ForeignKey("tax_categories.id"))
69
+ created_at = Column(DateTime, default=datetime.utcnow)
70
+ updated_at = Column(DateTime)
71
+
72
+ class Account(Base):
73
+ __tablename__ = "accounts"
74
+ id = Column(Integer, primary_key=True)
75
+ name = Column(Text, unique=True, nullable=False)
76
+ code = Column(Text)
77
+ type = Column(Text, nullable=False)
78
+ sub_type = Column(Text)
79
+ is_active = Column(Integer, nullable=False, default=1)
80
+ created_at = Column(DateTime, default=datetime.utcnow)
81
+ updated_at = Column(DateTime)
82
+
83
+ class Vendor(Base):
84
+ __tablename__ = "vendors"
85
+ id = Column(Integer, primary_key=True)
86
+ name = Column(Text, unique=True, nullable=False)
87
+ contact_email = Column(Text)
88
+ payment_terms_id = Column(Integer, ForeignKey("payment_terms.id"))
89
+ default_expense_category_id = Column(Integer, ForeignKey("accounts.id"))
90
+ created_at = Column(DateTime, default=datetime.utcnow)
91
+ updated_at = Column(DateTime)
92
+
93
+ class BankAccount(Base):
94
+ __tablename__ = "bank_accounts"
95
+ id = Column(Integer, primary_key=True)
96
+ name = Column(Text, unique=True, nullable=False)
97
+ institution_name = Column(Text)
98
+ account_number_masked = Column(Text)
99
+ account_id = Column(Integer, ForeignKey("accounts.id"), nullable=False)
100
+ created_at = Column(DateTime, default=datetime.utcnow)
101
+ updated_at = Column(DateTime)
102
+
103
+ class Invoice(Base):
104
+ __tablename__ = "invoices"
105
+ id = Column(Integer, primary_key=True)
106
+ invoice_number = Column(Text, unique=True, nullable=False)
107
+ customer_id = Column(Integer, ForeignKey("customers.id"), nullable=False)
108
+ department_id = Column(Integer, ForeignKey("departments.id"))
109
+ tax_category_id = Column(Integer, ForeignKey("tax_categories.id"))
110
+ invoice_date = Column(Date, nullable=False)
111
+ due_date = Column(Date, nullable=False)
112
+ currency = Column(Text, nullable=False, default="USD")
113
+ status = Column(Text, nullable=False)
114
+ subtotal = Column(Float, nullable=False, default=0.0)
115
+ tax_amount = Column(Float, nullable=False, default=0.0)
116
+ total = Column(Float, nullable=False, default=0.0)
117
+ balance_due = Column(Float, nullable=False, default=0.0)
118
+ payment_terms_id = Column(Integer, ForeignKey("payment_terms.id"))
119
+ created_at = Column(DateTime, default=datetime.utcnow)
120
+ updated_at = Column(DateTime)
121
+
122
+ class InvoiceLineItem(Base):
123
+ __tablename__ = "invoice_line_items"
124
+ id = Column(Integer, primary_key=True)
125
+ invoice_id = Column(Integer, ForeignKey("invoices.id", ondelete="CASCADE"), nullable=False)
126
+ description = Column(Text, nullable=False)
127
+ quantity = Column(Float, nullable=False)
128
+ unit_price = Column(Float, nullable=False)
129
+ discount_percent = Column(Float, nullable=False, default=0.0)
130
+ line_subtotal = Column(Float, nullable=False, default=0.0)
131
+ tax_amount = Column(Float, nullable=False, default=0.0)
132
+ total = Column(Float, nullable=False, default=0.0)
133
+ revenue_account_id = Column(Integer, ForeignKey("accounts.id"))
134
+ department_id = Column(Integer, ForeignKey("departments.id"))
135
+ created_at = Column(DateTime, default=datetime.utcnow)
136
+ updated_at = Column(DateTime)
137
+
138
+ class Payment(Base):
139
+ __tablename__ = "payments"
140
+ id = Column(Integer, primary_key=True)
141
+ customer_id = Column(Integer, ForeignKey("customers.id"), nullable=False)
142
+ payment_date = Column(Date, nullable=False)
143
+ settlement_date = Column(Date)
144
+ amount = Column(Float, nullable=False)
145
+ currency = Column(Text, nullable=False, default="USD")
146
+ method = Column(Text, nullable=False)
147
+ reference = Column(Text)
148
+ created_at = Column(DateTime, default=datetime.utcnow)
149
+ updated_at = Column(DateTime)
150
+
151
+ class PaymentApplication(Base):
152
+ __tablename__ = "payment_applications"
153
+ id = Column(Integer, primary_key=True)
154
+ payment_id = Column(Integer, ForeignKey("payments.id", ondelete="CASCADE"), nullable=False)
155
+ invoice_id = Column(Integer, ForeignKey("invoices.id", ondelete="CASCADE"), nullable=False)
156
+ amount = Column(Float, nullable=False)
157
+ created_at = Column(DateTime, default=datetime.utcnow)
158
+ updated_at = Column(DateTime)
159
+
160
+ class Bill(Base):
161
+ __tablename__ = "bills"
162
+ id = Column(Integer, primary_key=True)
163
+ bill_number = Column(Text)
164
+ vendor_id = Column(Integer, ForeignKey("vendors.id"), nullable=False)
165
+ bill_date = Column(Date, nullable=False)
166
+ due_date = Column(Date)
167
+ currency = Column(Text, nullable=False, default="USD")
168
+ amount = Column(Float, nullable=False)
169
+ description = Column(Text)
170
+ department_id = Column(Integer, ForeignKey("departments.id"))
171
+ reimbursement_status = Column(Text, nullable=False)
172
+ payment_terms_id = Column(Integer, ForeignKey("payment_terms.id"))
173
+ status = Column(Text, nullable=False, default="open")
174
+ created_at = Column(DateTime, default=datetime.utcnow)
175
+ updated_at = Column(DateTime)
176
+
177
+ class RecurringExpense(Base):
178
+ __tablename__ = "recurring_expenses"
179
+ id = Column(Integer, primary_key=True)
180
+ name = Column(Text, nullable=False)
181
+ vendor_id = Column(Integer, ForeignKey("vendors.id"))
182
+ amount = Column(Float, nullable=False)
183
+ expense_account_id = Column(Integer, ForeignKey("accounts.id"), nullable=False)
184
+ department_id = Column(Integer, ForeignKey("departments.id"))
185
+ frequency = Column(Text, nullable=False)
186
+ next_run_date = Column(Date, nullable=False)
187
+ end_date = Column(Date)
188
+ is_active = Column(Integer, nullable=False, default=1)
189
+ created_at = Column(DateTime, default=datetime.utcnow)
190
+ updated_at = Column(DateTime)
191
+
192
+ class BankTransaction(Base):
193
+ __tablename__ = "bank_transactions"
194
+ id = Column(Integer, primary_key=True)
195
+ bank_account_id = Column(Integer, ForeignKey("bank_accounts.id"), nullable=False)
196
+ transaction_date = Column(Date, nullable=False)
197
+ posted_date = Column(Date)
198
+ description = Column(Text, nullable=False)
199
+ amount = Column(Float, nullable=False)
200
+ external_id = Column(Text)
201
+ created_at = Column(DateTime, default=datetime.utcnow)
202
+ updated_at = Column(DateTime)
203
+
204
+ class JournalEntry(Base):
205
+ __tablename__ = "journal_entries"
206
+ id = Column(Integer, primary_key=True)
207
+ entry_date = Column(Date, nullable=False)
208
+ description = Column(Text)
209
+ department_id = Column(Integer, ForeignKey("departments.id"))
210
+ source = Column(Text)
211
+ source_id = Column(Integer)
212
+ created_by_user_id = Column(Integer, ForeignKey("users.id"))
213
+ created_at = Column(DateTime, default=datetime.utcnow)
214
+ updated_at = Column(DateTime)
215
+
216
+ class JournalEntryLine(Base):
217
+ __tablename__ = "journal_entry_lines"
218
+ id = Column(Integer, primary_key=True)
219
+ journal_entry_id = Column(Integer, ForeignKey("journal_entries.id", ondelete="CASCADE"), nullable=False)
220
+ account_id = Column(Integer, ForeignKey("accounts.id"), nullable=False)
221
+ department_id = Column(Integer, ForeignKey("departments.id"))
222
+ description = Column(Text)
223
+ debit = Column(Float, nullable=False, default=0.0)
224
+ credit = Column(Float, nullable=False, default=0.0)
225
+ created_at = Column(DateTime, default=datetime.utcnow)
226
+ updated_at = Column(DateTime)
227
+
228
+ class BankTransactionJournalLink(Base):
229
+ __tablename__ = "bank_transaction_journal_links"
230
+ id = Column(Integer, primary_key=True)
231
+ bank_transaction_id = Column(Integer, ForeignKey("bank_transactions.id", ondelete="CASCADE"), nullable=False)
232
+ journal_entry_id = Column(Integer, ForeignKey("journal_entries.id", ondelete="CASCADE"), nullable=False)
233
+ created_at = Column(DateTime, default=datetime.utcnow)
234
+
235
+ class RecurringInvoice(Base):
236
+ __tablename__ = "recurring_invoices"
237
+ id = Column(Integer, primary_key=True)
238
+ customer_id = Column(Integer, ForeignKey("customers.id"), nullable=False)
239
+ name = Column(Text, nullable=False)
240
+ description = Column(Text)
241
+ quantity = Column(Float, nullable=False)
242
+ unit_price = Column(Float, nullable=False)
243
+ discount_percent = Column(Float, nullable=False, default=0.0)
244
+ frequency = Column(Text, nullable=False)
245
+ next_run_date = Column(Date, nullable=False)
246
+ end_date = Column(Date)
247
+ payment_terms_id = Column(Integer, ForeignKey("payment_terms.id"))
248
+ tax_category_id = Column(Integer, ForeignKey("tax_categories.id"))
249
+ department_id = Column(Integer, ForeignKey("departments.id"))
250
+ currency = Column(Text, nullable=False, default="USD")
251
+ is_active = Column(Integer, nullable=False, default=1)
252
+ created_at = Column(DateTime, default=datetime.utcnow)
253
+ updated_at = Column(DateTime)
254
+
255
+ class AccountingPeriod(Base):
256
+ __tablename__ = "accounting_periods"
257
+ id = Column(Integer, primary_key=True)
258
+ start_date = Column(Date, nullable=False)
259
+ end_date = Column(Date, nullable=False)
260
+ close_date = Column(Date)
261
+ is_locked = Column(Integer, nullable=False, default=0)
262
+ created_at = Column(DateTime, default=datetime.utcnow)
263
+ updated_at = Column(DateTime)
264
+
265
+ Index("idx_users_email", User.email)
266
+ Index("idx_departments_name", Department.name, unique=True)
267
+ Index("idx_tax_categories_name", TaxCategory.name, unique=True)
268
+ Index("idx_payment_terms_name", PaymentTerm.name, unique=True)
269
+ Index("idx_customers_name", Customer.name, unique=True)
270
+ Index("idx_customers_payment_terms_id", Customer.payment_terms_id)
271
+ Index("idx_customers_tax_category_id", Customer.default_tax_category_id)
272
+ Index("idx_vendors_name", Vendor.name, unique=True)
273
+ Index("idx_vendors_payment_terms_id", Vendor.payment_terms_id)
274
+ Index("idx_vendors_expense_category_id", Vendor.default_expense_category_id)
275
+ Index("idx_accounts_name", Account.name, unique=True)
276
+ Index("idx_accounts_type", Account.type)
277
+ Index("idx_bank_accounts_name", BankAccount.name, unique=True)
278
+ Index("idx_bank_accounts_account_id", BankAccount.account_id)
279
+ Index("idx_invoices_invoice_number", Invoice.invoice_number, unique=True)
280
+ Index("idx_invoices_customer_id", Invoice.customer_id)
281
+ Index("idx_invoices_department_id", Invoice.department_id)
282
+ Index("idx_invoices_tax_category_id", Invoice.tax_category_id)
283
+ Index("idx_invoices_invoice_date", Invoice.invoice_date)
284
+ Index("idx_invoice_line_items_invoice_id", InvoiceLineItem.invoice_id)
285
+ Index("idx_invoice_line_items_department_id", InvoiceLineItem.department_id)
286
+ Index("idx_payments_customer_id", Payment.customer_id)
287
+ Index("idx_payments_payment_date", Payment.payment_date)
288
+ Index("idx_payment_applications_payment_id", PaymentApplication.payment_id)
289
+ Index("idx_payment_applications_invoice_id", PaymentApplication.invoice_id)
290
+ Index("idx_bills_vendor_id", Bill.vendor_id)
291
+ Index("idx_bills_department_id", Bill.department_id)
292
+ Index("idx_bills_bill_date", Bill.bill_date)
293
+ Index("idx_recurring_expenses_vendor_id", RecurringExpense.vendor_id)
294
+ Index("idx_recurring_expenses_next_run_date", RecurringExpense.next_run_date)
295
+ Index("idx_recurring_expenses_department_id", RecurringExpense.department_id)
296
+ Index("idx_bank_transactions_account_id", BankTransaction.bank_account_id)
297
+ Index("idx_bank_transactions_date", BankTransaction.transaction_date)
298
+ Index("idx_journal_entries_entry_date", JournalEntry.entry_date)
299
+ Index("idx_journal_entries_department_id", JournalEntry.department_id)
300
+ Index("idx_journal_entry_lines_entry_id", JournalEntryLine.journal_entry_id)
301
+ Index("idx_journal_entry_lines_account_id", JournalEntryLine.account_id)
302
+ Index("idx_journal_entry_lines_department_id", JournalEntryLine.department_id)
303
+ Index("idx_bt_journal_links_bt_id", BankTransactionJournalLink.bank_transaction_id)
304
+ Index("idx_bt_journal_links_je_id", BankTransactionJournalLink.journal_entry_id)
305
+ Index("idx_recurring_invoices_customer_id", RecurringInvoice.customer_id)
306
+ Index("idx_recurring_invoices_next_run_date", RecurringInvoice.next_run_date)
307
+ Index("idx_recurring_invoices_department_id", RecurringInvoice.department_id)
308
+ Index("idx_accounting_periods_start_end", AccountingPeriod.start_date, AccountingPeriod.end_date)
309
+ Index("idx_accounting_periods_is_locked", AccountingPeriod.is_locked)
310
+
311
+ Base.metadata.create_all(engine)
312
+
313
+ app = FastAPI(title="ZenLedger Small Business Accounting Suite API", version="1.0.0")
314
+
315
+ class CustomerCreateRequest(BaseModel):
316
+ name: str = Field(..., description="Customer legal or display name (must be unique)", example="Acme Design Studio")
317
+ billing_email: Optional[str] = Field(None, description="Primary billing email address for invoices", example="billing@acmedesign.com")
318
+ payment_terms_id: Optional[int] = Field(None, description="ID of payment_terms row to use as default terms", example=2)
319
+ default_tax_category_id: Optional[int] = Field(None, description="ID of tax_categories row used as default customer tax", example=1)
320
+
321
+ class CustomerResponse(BaseModel):
322
+ model_config = ConfigDict(from_attributes=True)
323
+ id: int = Field(..., description="Unique customer identifier", example=10)
324
+ name: str = Field(..., description="Customer name", example="Acme Design Studio")
325
+ billing_email: Optional[str] = Field(None, description="Customer billing email", example="billing@acmedesign.com")
326
+ payment_terms_id: Optional[int] = Field(None, description="Linked payment_terms.id or null", example=3)
327
+ default_tax_category_id: Optional[int] = Field(None, description="Linked tax_categories.id or null", example=1)
328
+ created_at: Optional[datetime] = Field(None, description="Timestamp when customer was created (ISO 8601)", example="2025-01-04T10:15:23Z")
329
+ updated_at: Optional[datetime] = Field(None, description="Timestamp for last update or null", example=None)
330
+
331
+ class CustomersListResponse(BaseModel):
332
+ customers: List[CustomerResponse] = Field(..., description="List of customers", example=[])
333
+
334
+ class PaymentTermResponse(BaseModel):
335
+ model_config = ConfigDict(from_attributes=True)
336
+ id: int = Field(..., description="Payment terms ID", example=3)
337
+ name: str = Field(..., description="Name of payment terms", example="Net 30")
338
+ days: int = Field(..., description="Number of days from invoice date to due date", example=30)
339
+ description: Optional[str] = Field(None, description="Optional description", example="Payment due 30 days from invoice date")
340
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2024-01-01T00:00:00Z")
341
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example=None)
342
+
343
+ class PaymentTermsListResponse(BaseModel):
344
+ payment_terms: List[PaymentTermResponse] = Field(..., description="List of payment terms", example=[])
345
+
346
+ class TaxCategoryResponse(BaseModel):
347
+ model_config = ConfigDict(from_attributes=True)
348
+ id: int = Field(..., description="Tax category ID", example=1)
349
+ name: str = Field(..., description="Tax category name", example="Standard Sales Tax 8.5%")
350
+ description: Optional[str] = Field(None, description="Optional description of when this tax applies", example="Standard local sales tax")
351
+ rate: float = Field(..., description="Tax rate as decimal (e.g., 0.085 for 8.5%)", example=0.085)
352
+ is_compound: bool = Field(..., description="True if tax is compounded with other taxes", example=False)
353
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2024-01-01T00:00:00Z")
354
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example=None)
355
+
356
+ class TaxCategoriesListResponse(BaseModel):
357
+ tax_categories: List[TaxCategoryResponse] = Field(..., description="List of tax categories", example=[])
358
+
359
+ class DepartmentResponse(BaseModel):
360
+ model_config = ConfigDict(from_attributes=True)
361
+ id: int = Field(..., description="Department ID", example=2)
362
+ name: str = Field(..., description="Department name", example="Design")
363
+ description: Optional[str] = Field(None, description="Optional department description", example="Design and creative services")
364
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2024-01-01T00:00:00Z")
365
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example=None)
366
+
367
+ class DepartmentsListResponse(BaseModel):
368
+ departments: List[DepartmentResponse] = Field(..., description="List of departments", example=[])
369
+
370
+ class AccountResponse(BaseModel):
371
+ model_config = ConfigDict(from_attributes=True)
372
+ id: int = Field(..., description="Account ID", example=50)
373
+ name: str = Field(..., description="Account name", example="Software Subscriptions")
374
+ code: Optional[str] = Field(None, description="Optional account code", example="6100")
375
+ type: str = Field(..., description="High-level account type", example="expense")
376
+ sub_type: Optional[str] = Field(None, description="Optional subtype classification", example="Operating Expense")
377
+ is_active: bool = Field(..., description="Whether account can be posted to", example=True)
378
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2024-01-01T00:00:00Z")
379
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example=None)
380
+
381
+ class AccountsListResponse(BaseModel):
382
+ accounts: List[AccountResponse] = Field(..., description="List of accounts", example=[])
383
+
384
+ class BankAccountResponse(BaseModel):
385
+ model_config = ConfigDict(from_attributes=True)
386
+ id: int = Field(..., description="Bank account ID", example=1)
387
+ name: str = Field(..., description="Display name for the bank account", example="Chase Business Checking ****1023")
388
+ institution_name: Optional[str] = Field(None, description="Financial institution name", example="Chase")
389
+ account_number_masked: Optional[str] = Field(None, description="Masked bank account number", example="****1023")
390
+ account_id: int = Field(..., description="Linked GL account ID", example=101)
391
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2024-01-01T00:00:00Z")
392
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example=None)
393
+
394
+ class BankAccountsListResponse(BaseModel):
395
+ bank_accounts: List[BankAccountResponse] = Field(..., description="List of bank accounts", example=[])
396
+
397
+ class InvoiceCreateRequest(BaseModel):
398
+ invoice_number: str = Field(..., description="Unique invoice number", example="INV-2025-001")
399
+ customer_id: int = Field(..., description="Customer ID that this invoice belongs to", example=10)
400
+ invoice_date: str = Field(..., description="Invoice date in ISO format YYYY-MM-DD", example="2025-01-05")
401
+ due_date: str = Field(..., description="Due date in ISO format YYYY-MM-DD", example="2025-02-04")
402
+ department_id: Optional[int] = Field(None, description="Department responsible for this invoice", example=2)
403
+ tax_category_id: Optional[int] = Field(None, description="Tax category applied at invoice level", example=1)
404
+ payment_terms_id: Optional[int] = Field(None, description="Payment terms to apply; defaults to customer terms if omitted", example=3)
405
+ currency: Optional[str] = Field("USD", description="Currency code, defaults to USD", example="USD")
406
+ status: Optional[str] = Field("draft", description="Initial status (draft or open)", example="open")
407
+
408
+ class InvoiceResponse(BaseModel):
409
+ model_config = ConfigDict(from_attributes=True)
410
+ id: int = Field(..., description="Invoice ID", example=1001)
411
+ invoice_number: str = Field(..., description="Unique invoice number", example="INV-2025-001")
412
+ customer_id: int = Field(..., description="Linked customer ID", example=10)
413
+ department_id: Optional[int] = Field(None, description="Linked department ID", example=2)
414
+ tax_category_id: Optional[int] = Field(None, description="Linked tax category ID", example=1)
415
+ invoice_date: date = Field(..., description="Invoice date", example="2025-01-05")
416
+ due_date: date = Field(..., description="Due date", example="2025-02-04")
417
+ currency: str = Field(..., description="Currency code", example="USD")
418
+ status: str = Field(..., description="Invoice status", example="open")
419
+ subtotal: float = Field(..., description="Sum of line_subtotals before tax", example=2000.0)
420
+ tax_amount: float = Field(..., description="Total tax applied to invoice", example=170.0)
421
+ total: float = Field(..., description="Invoice total including tax", example=2170.0)
422
+ balance_due: float = Field(..., description="Remaining balance due on invoice", example=2170.0)
423
+ payment_terms_id: Optional[int] = Field(None, description="Linked payment_terms ID", example=3)
424
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-05T09:00:00Z")
425
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
426
+
427
+ class InvoiceLineItemCreateRequest(BaseModel):
428
+ invoice_id: int = Field(..., description="ID of the invoice this line belongs to", example=1001)
429
+ description: str = Field(..., description="Description of the product or service", example="Logo redesign")
430
+ quantity: float = Field(..., description="Quantity of units sold", example=1.0)
431
+ unit_price: float = Field(..., description="Price per unit", example=1200.0)
432
+ discount_percent: Optional[float] = Field(0.0, description="Discount percentage applied to this line", example=10.0)
433
+ revenue_account_id: Optional[int] = Field(None, description="Revenue account to credit for this line", example=400)
434
+ department_id: Optional[int] = Field(None, description="Department for this line; overrides invoice department", example=2)
435
+
436
+ class InvoiceLineItemResponse(BaseModel):
437
+ model_config = ConfigDict(from_attributes=True)
438
+ id: int = Field(..., description="Invoice line item ID", example=5001)
439
+ invoice_id: int = Field(..., description="Parent invoice ID", example=1001)
440
+ description: str = Field(..., description="Line item description", example="Logo redesign")
441
+ quantity: float = Field(..., description="Quantity", example=1.0)
442
+ unit_price: float = Field(..., description="Unit price", example=1200.0)
443
+ discount_percent: float = Field(..., description="Discount percent", example=0.0)
444
+ line_subtotal: float = Field(..., description="Subtotal before tax for this line", example=1200.0)
445
+ tax_amount: float = Field(..., description="Tax for this line", example=102.0)
446
+ total: float = Field(..., description="Total including tax for this line", example=1302.0)
447
+ revenue_account_id: Optional[int] = Field(None, description="Linked revenue account ID", example=400)
448
+ department_id: Optional[int] = Field(None, description="Linked department ID", example=2)
449
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-05T09:10:00Z")
450
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
451
+
452
+ class InvoiceRecalculateTotalsResponse(BaseModel):
453
+ invoice_id: int = Field(..., description="Invoice ID", example=1001)
454
+ subtotal: float = Field(..., description="Updated subtotal", example=2000.0)
455
+ tax_amount: float = Field(..., description="Updated tax amount", example=170.0)
456
+ total: float = Field(..., description="Updated total", example=2170.0)
457
+ balance_due: float = Field(..., description="Updated balance due after payments", example=1270.0)
458
+
459
+ class InvoicesListItemResponse(BaseModel):
460
+ model_config = ConfigDict(from_attributes=True)
461
+ id: int = Field(..., description="Invoice ID", example=1001)
462
+ invoice_number: str = Field(..., description="Invoice number", example="INV-2025-001")
463
+ customer_id: int = Field(..., description="Customer ID", example=10)
464
+ invoice_date: date = Field(..., description="Invoice date", example="2025-01-05")
465
+ due_date: date = Field(..., description="Due date", example="2025-02-04")
466
+ status: str = Field(..., description="Invoice status", example="open")
467
+ subtotal: float = Field(..., description="Subtotal amount", example=2000.0)
468
+ tax_amount: float = Field(..., description="Tax amount", example=170.0)
469
+ total: float = Field(..., description="Total invoice amount", example=2170.0)
470
+ balance_due: float = Field(..., description="Outstanding balance", example=1270.0)
471
+ department_id: Optional[int] = Field(None, description="Linked department ID", example=2)
472
+ tax_category_id: Optional[int] = Field(None, description="Linked tax category ID", example=1)
473
+ payment_terms_id: Optional[int] = Field(None, description="Linked payment terms ID", example=3)
474
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-05T09:00:00Z")
475
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-10T10:00:00Z")
476
+
477
+ class InvoicesListResponse(BaseModel):
478
+ invoices: List[InvoicesListItemResponse] = Field(..., description="List of invoices", example=[])
479
+
480
+ class PaymentCreateRequest(BaseModel):
481
+ customer_id: int = Field(..., description="Customer who made the payment", example=10)
482
+ payment_date: str = Field(..., description="Date payment was received (YYYY-MM-DD)", example="2025-01-10")
483
+ settlement_date: Optional[str] = Field(None, description="Date payment settled in bank (YYYY-MM-DD)", example="2025-01-10")
484
+ amount: float = Field(..., description="Gross payment amount", example=900.0)
485
+ currency: Optional[str] = Field("USD", description="Currency code (defaults to USD)", example="USD")
486
+ method: str = Field(..., description="Payment method description", example="Credit Card")
487
+ reference: Optional[str] = Field(None, description="External reference or transaction ID", example="STRIPE-12345")
488
+
489
+ class PaymentResponse(BaseModel):
490
+ model_config = ConfigDict(from_attributes=True)
491
+ id: int = Field(..., description="Payment ID", example=2001)
492
+ customer_id: int = Field(..., description="Customer ID", example=10)
493
+ payment_date: date = Field(..., description="Payment date", example="2025-01-10")
494
+ settlement_date: Optional[date] = Field(None, description="Settlement date", example="2025-01-10")
495
+ amount: float = Field(..., description="Payment amount", example=900.0)
496
+ currency: str = Field(..., description="Payment currency", example="USD")
497
+ method: str = Field(..., description="Payment method", example="Credit Card")
498
+ reference: Optional[str] = Field(None, description="External reference ID", example="STRIPE-12345")
499
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-10T12:00:00Z")
500
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
501
+
502
+ class PaymentApplicationCreateRequest(BaseModel):
503
+ payment_id: int = Field(..., description="Payment to allocate", example=2001)
504
+ invoice_id: int = Field(..., description="Invoice receiving this payment portion", example=1001)
505
+ amount: float = Field(..., description="Amount applied from payment to invoice", example=900.0)
506
+
507
+ class PaymentApplicationResponse(BaseModel):
508
+ model_config = ConfigDict(from_attributes=True)
509
+ id: int = Field(..., description="Payment application ID", example=3001)
510
+ payment_id: int = Field(..., description="Linked payment ID", example=2001)
511
+ invoice_id: int = Field(..., description="Linked invoice ID", example=1001)
512
+ amount: float = Field(..., description="Amount applied", example=900.0)
513
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-10T12:05:00Z")
514
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
515
+
516
+ class VendorCreateRequest(BaseModel):
517
+ name: str = Field(..., description="Vendor legal or display name", example="PixelPrint Supplies")
518
+ contact_email: Optional[str] = Field(None, description="Vendor accounts payable contact email", example="accounts@pixelprint.com")
519
+ payment_terms_id: Optional[int] = Field(None, description="Default payment terms for this vendor", example=2)
520
+ default_expense_category_id: Optional[int] = Field(None, description="Default expense account for purchases from this vendor", example=60)
521
+
522
+ class VendorResponse(BaseModel):
523
+ model_config = ConfigDict(from_attributes=True)
524
+ id: int = Field(..., description="Vendor ID", example=20)
525
+ name: str = Field(..., description="Vendor name", example="PixelPrint Supplies")
526
+ contact_email: Optional[str] = Field(None, description="Vendor email", example="accounts@pixelprint.com")
527
+ payment_terms_id: Optional[int] = Field(None, description="Linked payment_terms ID", example=2)
528
+ default_expense_category_id: Optional[int] = Field(None, description="Linked default expense account ID", example=60)
529
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-03T08:00:00Z")
530
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
531
+
532
+ class VendorsListResponse(BaseModel):
533
+ vendors: List[VendorResponse] = Field(..., description="List of vendors", example=[])
534
+
535
+ class BillCreateRequest(BaseModel):
536
+ bill_number: Optional[str] = Field(None, description="Vendor-provided bill or invoice number", example="BILL-2025-001")
537
+ vendor_id: int = Field(..., description="Vendor this bill is from", example=20)
538
+ bill_date: str = Field(..., description="Date on the vendor bill (YYYY-MM-DD)", example="2025-01-03")
539
+ due_date: Optional[str] = Field(None, description="Due date if known (YYYY-MM-DD)", example="2025-01-18")
540
+ currency: Optional[str] = Field("USD", description="Bill currency code", example="USD")
541
+ amount: float = Field(..., description="Total bill amount", example=325.5)
542
+ description: Optional[str] = Field(None, description="Description of the bill or purpose", example="Printer ink and paper")
543
+ department_id: Optional[int] = Field(None, description="Department to expense this bill to", example=3)
544
+ reimbursement_status: str = Field(..., description="Reimbursement status (Not Reimbursable, Reimbursable, Reimbursed)", example="Not Reimbursable")
545
+ payment_terms_id: Optional[int] = Field(None, description="Payment terms used for due_date calculation", example=1)
546
+ status: Optional[str] = Field("open", description="Bill status (open, paid, void)", example="open")
547
+
548
+ class BillResponse(BaseModel):
549
+ model_config = ConfigDict(from_attributes=True)
550
+ id: int = Field(..., description="Bill ID", example=7001)
551
+ bill_number: Optional[str] = Field(None, description="Vendor bill number", example="BILL-2025-001")
552
+ vendor_id: int = Field(..., description="Vendor ID", example=20)
553
+ bill_date: date = Field(..., description="Bill date", example="2025-01-03")
554
+ due_date: Optional[date] = Field(None, description="Due date", example="2025-01-18")
555
+ currency: str = Field(..., description="Currency code", example="USD")
556
+ amount: float = Field(..., description="Bill amount", example=325.5)
557
+ description: Optional[str] = Field(None, description="Bill description", example="Printer ink and paper")
558
+ department_id: Optional[int] = Field(None, description="Department ID", example=3)
559
+ reimbursement_status: str = Field(..., description="Reimbursement status", example="Not Reimbursable")
560
+ payment_terms_id: Optional[int] = Field(None, description="Payment terms ID", example=1)
561
+ status: str = Field(..., description="Bill status", example="open")
562
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-03T09:30:00Z")
563
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
564
+
565
+ class RecurringExpenseCreateRequest(BaseModel):
566
+ name: str = Field(..., description="Name of the recurring expense", example="Monthly Co-working Space Rent")
567
+ vendor_id: Optional[int] = Field(None, description="Vendor providing the recurring service", example=30)
568
+ amount: float = Field(..., description="Recurring amount for each run", example=650.0)
569
+ expense_account_id: int = Field(..., description="Expense account ID to debit", example=80)
570
+ department_id: Optional[int] = Field(None, description="Department that bears this recurring expense", example=4)
571
+ frequency: str = Field(..., description="Run frequency (daily, weekly, monthly, quarterly, yearly)", example="monthly")
572
+ next_run_date: str = Field(..., description="Next date the template should generate an expense (YYYY-MM-DD)", example="2025-02-01")
573
+ end_date: Optional[str] = Field(None, description="Date after which no more runs occur", example="2025-12-01")
574
+ is_active: Optional[bool] = Field(True, description="Whether this template is active", example=True)
575
+
576
+ class RecurringExpenseResponse(BaseModel):
577
+ model_config = ConfigDict(from_attributes=True)
578
+ id: int = Field(..., description="Recurring expense template ID", example=9001)
579
+ name: str = Field(..., description="Template name", example="Monthly Co-working Space Rent")
580
+ vendor_id: Optional[int] = Field(None, description="Vendor ID", example=30)
581
+ amount: float = Field(..., description="Recurring amount", example=650.0)
582
+ expense_account_id: int = Field(..., description="Expense account ID", example=80)
583
+ department_id: Optional[int] = Field(None, description="Department ID", example=4)
584
+ frequency: str = Field(..., description="Frequency", example="monthly")
585
+ next_run_date: date = Field(..., description="Next run date", example="2025-02-01")
586
+ end_date: Optional[date] = Field(None, description="End date", example="2025-12-01")
587
+ is_active: bool = Field(..., description="Whether template is active", example=True)
588
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-15T09:00:00Z")
589
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
590
+
591
+ class BankTransactionItemRequest(BaseModel):
592
+ transaction_date: str = Field(..., description="Transaction date (YYYY-MM-DD)", example="2025-01-01")
593
+ posted_date: Optional[str] = Field(None, description="Posted date (YYYY-MM-DD)", example="2025-01-02")
594
+ description: str = Field(..., description="Bank description", example="Client payment ACME")
595
+ amount: float = Field(..., description="Transaction amount (positive or negative)", example=1500.0)
596
+ external_id: Optional[str] = Field(None, description="External bank transaction identifier", example="txn_001")
597
+
598
+ class BankTransactionsBatchImportRequest(BaseModel):
599
+ bank_account_id: int = Field(..., description="Bank account ID these transactions belong to", example=1)
600
+ transactions: List[BankTransactionItemRequest] = Field(..., description="Array of bank transactions to import", example=[])
601
+
602
+ class BankTransactionResponse(BaseModel):
603
+ model_config = ConfigDict(from_attributes=True)
604
+ id: int = Field(..., description="Bank transaction ID", example=6001)
605
+ bank_account_id: int = Field(..., description="Bank account ID", example=1)
606
+ transaction_date: date = Field(..., description="Transaction date", example="2025-01-01")
607
+ posted_date: Optional[date] = Field(None, description="Posted date", example="2025-01-02")
608
+ description: str = Field(..., description="Transaction description", example="Client payment ACME")
609
+ amount: float = Field(..., description="Transaction amount", example=1500.0)
610
+ external_id: Optional[str] = Field(None, description="External transaction ID", example="txn_001")
611
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-07T10:00:00Z")
612
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
613
+
614
+ class BankTransactionsBatchImportResponse(BaseModel):
615
+ bank_transactions: List[BankTransactionResponse] = Field(..., description="Imported bank transactions", example=[])
616
+
617
+ class BankTransactionsListResponse(BaseModel):
618
+ bank_transactions: List[BankTransactionResponse] = Field(..., description="List of bank transactions", example=[])
619
+
620
+ class JournalEntryCreateRequest(BaseModel):
621
+ entry_date: str = Field(..., description="Date of the journal entry (YYYY-MM-DD)", example="2024-12-31")
622
+ description: Optional[str] = Field(None, description="Narrative description of the entry", example="Year-end accrual for expenses")
623
+ department_id: Optional[int] = Field(None, description="Department that this entry belongs to", example=4)
624
+ source: Optional[str] = Field(None, description="System source of this entry", example="manual")
625
+ source_id: Optional[int] = Field(None, description="External source ID if applicable", example=None)
626
+
627
+ class JournalEntryResponse(BaseModel):
628
+ model_config = ConfigDict(from_attributes=True)
629
+ id: int = Field(..., description="Journal entry ID", example=8001)
630
+ entry_date: date = Field(..., description="Entry date", example="2024-12-31")
631
+ description: Optional[str] = Field(None, description="Entry description", example="Year-end accrual for expenses")
632
+ department_id: Optional[int] = Field(None, description="Department ID", example=4)
633
+ source: Optional[str] = Field(None, description="Source system", example="manual")
634
+ source_id: Optional[int] = Field(None, description="Source record ID", example=None)
635
+ created_by_user_id: Optional[int] = Field(None, description="User who created the entry (always 1)", example=1)
636
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2024-12-31T23:50:00Z")
637
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
638
+
639
+ class JournalEntryLineCreateRequest(BaseModel):
640
+ journal_entry_id: int = Field(..., description="Parent journal entry ID", example=8001)
641
+ account_id: int = Field(..., description="Account to debit or credit", example=50)
642
+ department_id: Optional[int] = Field(None, description="Department for this line if different from header", example=4)
643
+ description: Optional[str] = Field(None, description="Line-specific description", example="Accrual for December software expenses")
644
+ debit: Optional[float] = Field(0.0, description="Debit amount (0 if this is a credit line)", example=300.0)
645
+ credit: Optional[float] = Field(0.0, description="Credit amount (0 if this is a debit line)", example=0.0)
646
+
647
+ class JournalEntryLineResponse(BaseModel):
648
+ model_config = ConfigDict(from_attributes=True)
649
+ id: int = Field(..., description="Journal entry line ID", example=8101)
650
+ journal_entry_id: int = Field(..., description="Parent journal entry ID", example=8001)
651
+ account_id: int = Field(..., description="Account ID", example=50)
652
+ department_id: Optional[int] = Field(None, description="Department ID", example=4)
653
+ description: Optional[str] = Field(None, description="Line description", example="Accrual for December software expenses")
654
+ debit: float = Field(..., description="Debit amount", example=300.0)
655
+ credit: float = Field(..., description="Credit amount", example=0.0)
656
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2024-12-31T23:51:00Z")
657
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
658
+
659
+ class BankTransactionJournalLinkCreateRequest(BaseModel):
660
+ bank_transaction_id: int = Field(..., description="Bank transaction ID being reconciled", example=6001)
661
+ journal_entry_id: int = Field(..., description="Journal entry ID representing the accounting for this transaction", example=8005)
662
+
663
+ class BankTransactionJournalLinkResponse(BaseModel):
664
+ model_config = ConfigDict(from_attributes=True)
665
+ id: int = Field(..., description="Link ID", example=90001)
666
+ bank_transaction_id: int = Field(..., description="Bank transaction ID", example=6001)
667
+ journal_entry_id: int = Field(..., description="Journal entry ID", example=8005)
668
+ created_at: Optional[datetime] = Field(None, description="Link creation timestamp", example="2025-01-07T11:00:00Z")
669
+
670
+ class RecurringInvoiceCreateRequest(BaseModel):
671
+ customer_id: int = Field(..., description="Customer who will receive recurring invoices", example=15)
672
+ name: str = Field(..., description="Name of the recurring invoice template", example="Monthly SEO Retainer")
673
+ description: Optional[str] = Field(None, description="Description of the service or product", example="Monthly SEO services retainer")
674
+ quantity: float = Field(..., description="Quantity per recurring invoice", example=1.0)
675
+ unit_price: float = Field(..., description="Unit price per run", example=1500.0)
676
+ discount_percent: Optional[float] = Field(0.0, description="Discount percent per run", example=0.0)
677
+ frequency: str = Field(..., description="Frequency (daily, weekly, monthly, quarterly, yearly)", example="monthly")
678
+ next_run_date: str = Field(..., description="Date of next invoice generation (YYYY-MM-DD)", example="2025-02-01")
679
+ end_date: Optional[str] = Field(None, description="Final date for invoice generation", example="2025-07-01")
680
+ payment_terms_id: Optional[int] = Field(None, description="Payment terms applied to generated invoices", example=4)
681
+ tax_category_id: Optional[int] = Field(None, description="Tax category for generated invoices", example=5)
682
+ department_id: Optional[int] = Field(None, description="Department for generated invoices", example=2)
683
+ currency: Optional[str] = Field("USD", description="Currency for generated invoices", example="USD")
684
+ is_active: Optional[bool] = Field(True, description="Whether this recurring schedule is active", example=True)
685
+
686
+ class RecurringInvoiceResponse(BaseModel):
687
+ model_config = ConfigDict(from_attributes=True)
688
+ id: int = Field(..., description="Recurring invoice template ID", example=9501)
689
+ customer_id: int = Field(..., description="Customer ID", example=15)
690
+ name: str = Field(..., description="Template name", example="Monthly SEO Retainer")
691
+ description: Optional[str] = Field(None, description="Template description", example="Monthly SEO services retainer")
692
+ quantity: float = Field(..., description="Quantity per invoice", example=1.0)
693
+ unit_price: float = Field(..., description="Unit price", example=1500.0)
694
+ discount_percent: float = Field(..., description="Discount percent", example=0.0)
695
+ frequency: str = Field(..., description="Frequency", example="monthly")
696
+ next_run_date: date = Field(..., description="Next run date", example="2025-02-01")
697
+ end_date: Optional[date] = Field(None, description="End date", example="2025-07-01")
698
+ payment_terms_id: Optional[int] = Field(None, description="Payment terms ID", example=4)
699
+ tax_category_id: Optional[int] = Field(None, description="Tax category ID", example=5)
700
+ department_id: Optional[int] = Field(None, description="Department ID", example=2)
701
+ currency: str = Field(..., description="Currency", example="USD")
702
+ is_active: bool = Field(..., description="Whether template is active", example=True)
703
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-20T09:00:00Z")
704
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
705
+
706
+ class AccountingPeriodCreateRequest(BaseModel):
707
+ start_date: str = Field(..., description="Start date of the period (YYYY-MM-DD)", example="2024-01-01")
708
+ end_date: str = Field(..., description="End date of the period (YYYY-MM-DD)", example="2024-12-31")
709
+ close_date: Optional[str] = Field(None, description="Date when the period was closed", example="2024-12-31")
710
+ is_locked: Optional[bool] = Field(False, description="Whether the period is locked against changes", example=True)
711
+
712
+ class AccountingPeriodUpdateRequest(BaseModel):
713
+ close_date: Optional[str] = Field(None, description="New close date or null to clear", example="2024-12-31")
714
+ is_locked: Optional[bool] = Field(None, description="Set true to lock or false to unlock", example=True)
715
+
716
+ class AccountingPeriodResponse(BaseModel):
717
+ model_config = ConfigDict(from_attributes=True)
718
+ id: int = Field(..., description="Accounting period ID", example=10001)
719
+ start_date: date = Field(..., description="Start date", example="2024-01-01")
720
+ end_date: date = Field(..., description="End date", example="2024-12-31")
721
+ close_date: Optional[date] = Field(None, description="Close date or null", example="2024-12-31")
722
+ is_locked: bool = Field(..., description="Locked flag", example=True)
723
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2024-12-31T23:55:00Z")
724
+ updated_at: Optional[datetime] = Field(None, description="Update timestamp", example=None)
725
+
726
+ class ProfitAndLossReportResponse(BaseModel):
727
+ start_date: str = Field(..., description="Report start date", example="2025-01-01")
728
+ end_date: str = Field(..., description="Report end date", example="2025-01-31")
729
+ department_id: Optional[int] = Field(None, description="Department filter or null if not filtered", example=2)
730
+ total_revenue: float = Field(..., description="Sum of income account balances for the period", example=5000.0)
731
+ total_expenses: float = Field(..., description="Sum of expense account balances for the period", example=3000.0)
732
+ net_profit: float = Field(..., description="total_revenue - total_expenses", example=2000.0)
733
+ detail: Dict[str, List[Dict[str, Optional[float]]]] = Field(..., description="Optional breakdown of accounts", example={"income_accounts": [], "expense_accounts": []})
734
+
735
+ @app.post(
736
+ "/api/customers",
737
+ response_model=CustomerResponse,
738
+ summary="Create a new customer",
739
+ description="Create a customer with optional payment terms and tax category.",
740
+ tags=["customers"],
741
+ operation_id="create_customer",
742
+ )
743
+ async def create_customer_endpoint(body: CustomerCreateRequest = Body(...)) -> CustomerResponse:
744
+ session = SessionLocal()
745
+ customer = Customer(
746
+ name=body.name,
747
+ billing_email=body.billing_email,
748
+ payment_terms_id=body.payment_terms_id,
749
+ default_tax_category_id=body.default_tax_category_id,
750
+ created_at=datetime.utcnow(),
751
+ updated_at=None,
752
+ )
753
+ session.add(customer)
754
+ session.commit()
755
+ session.refresh(customer)
756
+ session.close()
757
+ return CustomerResponse(
758
+ id=customer.id,
759
+ name=customer.name,
760
+ billing_email=customer.billing_email,
761
+ payment_terms_id=customer.payment_terms_id,
762
+ default_tax_category_id=customer.default_tax_category_id,
763
+ created_at=customer.created_at,
764
+ updated_at=customer.updated_at,
765
+ )
766
+
767
+ @app.get(
768
+ "/api/customers",
769
+ response_model=CustomersListResponse,
770
+ summary="List customers with optional filters",
771
+ description="Retrieve customers filtered by name or billing email.",
772
+ tags=["customers"],
773
+ operation_id="list_customers",
774
+ )
775
+ async def list_customers_endpoint(
776
+ name: Optional[str] = Query(None, description="Filter by exact or partial customer name", example="Acme"),
777
+ billing_email: Optional[str] = Query(None, description="Filter customers by billing_email exact match", example="billing@acmedesign.com"),
778
+ limit: Optional[int] = Query(50, description="Maximum number of records to return", example=50),
779
+ offset: Optional[int] = Query(0, description="Number of records to skip for pagination", example=0),
780
+ ) -> CustomersListResponse:
781
+ session = SessionLocal()
782
+ query = session.query(Customer)
783
+ if name is not None:
784
+ query = query.filter(Customer.name.contains(name))
785
+ if billing_email is not None:
786
+ query = query.filter(Customer.billing_email == billing_email)
787
+ customers = query.offset(offset).limit(limit).all()
788
+ session.close()
789
+ return CustomersListResponse(customers=customers)
790
+
791
+ @app.get(
792
+ "/api/customers/{customer_id}",
793
+ response_model=CustomerResponse,
794
+ summary="Get a single customer by ID",
795
+ description="Fetch one customer by ID to inspect billing settings.",
796
+ tags=["customers"],
797
+ operation_id="get_customer",
798
+ )
799
+ async def get_customer_endpoint(
800
+ customer_id: int = Path(..., description="Customer ID to retrieve", example=10)
801
+ ) -> CustomerResponse:
802
+ session = SessionLocal()
803
+ customer = session.query(Customer).filter(Customer.id == customer_id).first()
804
+ session.close()
805
+ if customer is None:
806
+ return CustomerResponse(
807
+ id=0,
808
+ name="",
809
+ billing_email=None,
810
+ payment_terms_id=None,
811
+ default_tax_category_id=None,
812
+ created_at=None,
813
+ updated_at=None,
814
+ )
815
+ return CustomerResponse(
816
+ id=customer.id,
817
+ name=customer.name,
818
+ billing_email=customer.billing_email,
819
+ payment_terms_id=customer.payment_terms_id,
820
+ default_tax_category_id=customer.default_tax_category_id,
821
+ created_at=customer.created_at,
822
+ updated_at=customer.updated_at,
823
+ )
824
+
825
+ @app.get(
826
+ "/api/payment_terms",
827
+ response_model=PaymentTermsListResponse,
828
+ summary="List payment terms",
829
+ description="Retrieve payment_terms records optionally filtered by name.",
830
+ tags=["payment_terms"],
831
+ operation_id="list_payment_terms",
832
+ )
833
+ async def list_payment_terms_endpoint(
834
+ name: Optional[str] = Query(None, description="Filter terms by name", example="Net 30")
835
+ ) -> PaymentTermsListResponse:
836
+ session = SessionLocal()
837
+ query = session.query(PaymentTerm)
838
+ if name is not None:
839
+ query = query.filter(PaymentTerm.name.contains(name))
840
+ payment_terms = query.all()
841
+ session.close()
842
+ return PaymentTermsListResponse(payment_terms=payment_terms)
843
+
844
+ @app.get(
845
+ "/api/tax_categories",
846
+ response_model=TaxCategoriesListResponse,
847
+ summary="List tax categories",
848
+ description="Retrieve available tax_categories optionally filtered by name.",
849
+ tags=["tax_categories"],
850
+ operation_id="list_tax_categories",
851
+ )
852
+ async def list_tax_categories_endpoint(
853
+ name: Optional[str] = Query(None, description="Filter tax categories by exact or partial name", example="Standard Sales Tax 8.5%")
854
+ ) -> TaxCategoriesListResponse:
855
+ session = SessionLocal()
856
+ query = session.query(TaxCategory)
857
+ if name is not None:
858
+ query = query.filter(TaxCategory.name.contains(name))
859
+ rows = query.all()
860
+ tax_categories: List[TaxCategoryResponse] = []
861
+ for r in rows:
862
+ tax_categories.append(
863
+ TaxCategoryResponse(
864
+ id=r.id,
865
+ name=r.name,
866
+ description=r.description,
867
+ rate=r.rate,
868
+ is_compound=bool(r.is_compound),
869
+ created_at=r.created_at,
870
+ updated_at=r.updated_at,
871
+ )
872
+ )
873
+ session.close()
874
+ return TaxCategoriesListResponse(tax_categories=tax_categories)
875
+
876
+ @app.get(
877
+ "/api/departments",
878
+ response_model=DepartmentsListResponse,
879
+ summary="List departments",
880
+ description="Retrieve departments to map human-readable names to IDs.",
881
+ tags=["departments"],
882
+ operation_id="list_departments",
883
+ )
884
+ async def list_departments_endpoint(
885
+ name: Optional[str] = Query(None, description="Filter departments by name", example="Design")
886
+ ) -> DepartmentsListResponse:
887
+ session = SessionLocal()
888
+ query = session.query(Department)
889
+ if name is not None:
890
+ query = query.filter(Department.name.contains(name))
891
+ departments = query.all()
892
+ session.close()
893
+ return DepartmentsListResponse(departments=departments)
894
+
895
+ @app.get(
896
+ "/api/accounts",
897
+ response_model=AccountsListResponse,
898
+ summary="List chart of accounts",
899
+ description="Retrieve accounts filtered by type or name.",
900
+ tags=["accounts"],
901
+ operation_id="list_accounts",
902
+ )
903
+ async def list_accounts_endpoint(
904
+ type: Optional[str] = Query(None, description="Filter accounts by type (asset, liability, equity, income, expense, contra)", example="expense"),
905
+ name: Optional[str] = Query(None, description="Filter accounts by name", example="Software Subscriptions"),
906
+ ) -> AccountsListResponse:
907
+ session = SessionLocal()
908
+ query = session.query(Account)
909
+ if type is not None:
910
+ query = query.filter(Account.type == type)
911
+ if name is not None:
912
+ query = query.filter(Account.name.contains(name))
913
+ rows = query.all()
914
+ accounts_list: List[AccountResponse] = []
915
+ for a in rows:
916
+ accounts_list.append(
917
+ AccountResponse(
918
+ id=a.id,
919
+ name=a.name,
920
+ code=a.code,
921
+ type=a.type,
922
+ sub_type=a.sub_type,
923
+ is_active=bool(a.is_active),
924
+ created_at=a.created_at,
925
+ updated_at=a.updated_at,
926
+ )
927
+ )
928
+ session.close()
929
+ return AccountsListResponse(accounts=accounts_list)
930
+
931
+ @app.get(
932
+ "/api/bank_accounts",
933
+ response_model=BankAccountsListResponse,
934
+ summary="List bank accounts",
935
+ description="Retrieve bank_accounts to find IDs for bank transactions.",
936
+ tags=["bank_accounts"],
937
+ operation_id="list_bank_accounts",
938
+ )
939
+ async def list_bank_accounts_endpoint(
940
+ name: Optional[str] = Query(None, description="Filter bank accounts by name", example="Chase Business Checking ****1023")
941
+ ) -> BankAccountsListResponse:
942
+ session = SessionLocal()
943
+ query = session.query(BankAccount)
944
+ if name is not None:
945
+ query = query.filter(BankAccount.name.contains(name))
946
+ bank_accounts = query.all()
947
+ session.close()
948
+ return BankAccountsListResponse(bank_accounts=bank_accounts)
949
+
950
+ @app.post(
951
+ "/api/invoices",
952
+ response_model=InvoiceResponse,
953
+ summary="Create a new invoice header",
954
+ description="Create an invoice record without line items.",
955
+ tags=["invoices"],
956
+ operation_id="create_invoice",
957
+ )
958
+ async def create_invoice_endpoint(body: InvoiceCreateRequest = Body(...)) -> InvoiceResponse:
959
+ session = SessionLocal()
960
+ invoice = Invoice(
961
+ invoice_number=body.invoice_number,
962
+ customer_id=body.customer_id,
963
+ department_id=body.department_id,
964
+ tax_category_id=body.tax_category_id,
965
+ invoice_date=date.fromisoformat(body.invoice_date),
966
+ due_date=date.fromisoformat(body.due_date),
967
+ currency=body.currency if body.currency is not None else "USD",
968
+ status=body.status if body.status is not None else "draft",
969
+ subtotal=0.0,
970
+ tax_amount=0.0,
971
+ total=0.0,
972
+ balance_due=0.0,
973
+ payment_terms_id=body.payment_terms_id,
974
+ created_at=datetime.utcnow(),
975
+ updated_at=None,
976
+ )
977
+ session.add(invoice)
978
+ session.commit()
979
+ session.refresh(invoice)
980
+ session.close()
981
+ return InvoiceResponse(
982
+ id=invoice.id,
983
+ invoice_number=invoice.invoice_number,
984
+ customer_id=invoice.customer_id,
985
+ department_id=invoice.department_id,
986
+ tax_category_id=invoice.tax_category_id,
987
+ invoice_date=invoice.invoice_date,
988
+ due_date=invoice.due_date,
989
+ currency=invoice.currency,
990
+ status=invoice.status,
991
+ subtotal=invoice.subtotal,
992
+ tax_amount=invoice.tax_amount,
993
+ total=invoice.total,
994
+ balance_due=invoice.balance_due,
995
+ payment_terms_id=invoice.payment_terms_id,
996
+ created_at=invoice.created_at,
997
+ updated_at=invoice.updated_at,
998
+ )
999
+
1000
+ @app.post(
1001
+ "/api/invoice_line_items",
1002
+ response_model=InvoiceLineItemResponse,
1003
+ summary="Add a line item to an invoice",
1004
+ description="Create an invoice line and update invoice totals.",
1005
+ tags=["invoices", "invoice_line_items"],
1006
+ operation_id="create_invoice_line_item",
1007
+ )
1008
+ async def create_invoice_line_item_endpoint(
1009
+ body: InvoiceLineItemCreateRequest = Body(...)
1010
+ ) -> InvoiceLineItemResponse:
1011
+ session = SessionLocal()
1012
+ invoice = session.query(Invoice).filter(Invoice.id == body.invoice_id).first()
1013
+ tax_rate = 0.0
1014
+ if invoice is not None and invoice.tax_category_id is not None:
1015
+ tax_cat = session.query(TaxCategory).filter(TaxCategory.id == invoice.tax_category_id).first()
1016
+ if tax_cat is not None:
1017
+ tax_rate = tax_cat.rate
1018
+ discount_percent = body.discount_percent if body.discount_percent is not None else 0.0
1019
+ gross = body.quantity * body.unit_price
1020
+ discount_amount = gross * (discount_percent / 100.0)
1021
+ line_subtotal = gross - discount_amount
1022
+ tax_amount = line_subtotal * tax_rate
1023
+ total = line_subtotal + tax_amount
1024
+ item = InvoiceLineItem(
1025
+ invoice_id=body.invoice_id,
1026
+ description=body.description,
1027
+ quantity=body.quantity,
1028
+ unit_price=body.unit_price,
1029
+ discount_percent=discount_percent,
1030
+ line_subtotal=line_subtotal,
1031
+ tax_amount=tax_amount,
1032
+ total=total,
1033
+ revenue_account_id=body.revenue_account_id,
1034
+ department_id=body.department_id if body.department_id is not None else (invoice.department_id if invoice is not None else None),
1035
+ created_at=datetime.utcnow(),
1036
+ updated_at=None,
1037
+ )
1038
+ session.add(item)
1039
+ if invoice is not None:
1040
+ subtotal_sum = session.query(InvoiceLineItem).filter(InvoiceLineItem.invoice_id == invoice.id).all()
1041
+ subtotal_value = 0.0
1042
+ tax_value = 0.0
1043
+ total_value = 0.0
1044
+ for li in subtotal_sum:
1045
+ subtotal_value += li.line_subtotal
1046
+ tax_value += li.tax_amount
1047
+ total_value += li.total
1048
+ subtotal_value += line_subtotal
1049
+ tax_value += tax_amount
1050
+ total_value += total
1051
+ invoice.subtotal = subtotal_value
1052
+ invoice.tax_amount = tax_value
1053
+ invoice.total = total_value
1054
+ payments = session.query(PaymentApplication).filter(PaymentApplication.invoice_id == invoice.id).all()
1055
+ paid_amount = 0.0
1056
+ for p in payments:
1057
+ paid_amount += p.amount
1058
+ invoice.balance_due = invoice.total - paid_amount
1059
+ invoice.updated_at = datetime.utcnow()
1060
+ session.commit()
1061
+ session.refresh(item)
1062
+ session.close()
1063
+ return InvoiceLineItemResponse(
1064
+ id=item.id,
1065
+ invoice_id=item.invoice_id,
1066
+ description=item.description,
1067
+ quantity=item.quantity,
1068
+ unit_price=item.unit_price,
1069
+ discount_percent=item.discount_percent,
1070
+ line_subtotal=item.line_subtotal,
1071
+ tax_amount=item.tax_amount,
1072
+ total=item.total,
1073
+ revenue_account_id=item.revenue_account_id,
1074
+ department_id=item.department_id,
1075
+ created_at=item.created_at,
1076
+ updated_at=item.updated_at,
1077
+ )
1078
+
1079
+ @app.post(
1080
+ "/api/invoices/{invoice_id}/recalculate_totals",
1081
+ response_model=InvoiceRecalculateTotalsResponse,
1082
+ summary="Recalculate invoice totals",
1083
+ description="Recompute totals from line items and applied payments.",
1084
+ tags=["invoices"],
1085
+ operation_id="recalculate_invoice_totals",
1086
+ )
1087
+ async def recalculate_invoice_totals_endpoint(
1088
+ invoice_id: int = Path(..., description="Invoice ID whose totals should be recalculated", example=1001)
1089
+ ) -> InvoiceRecalculateTotalsResponse:
1090
+ session = SessionLocal()
1091
+ invoice = session.query(Invoice).filter(Invoice.id == invoice_id).first()
1092
+ if invoice is None:
1093
+ session.close()
1094
+ return InvoiceRecalculateTotalsResponse(invoice_id=0, subtotal=0.0, tax_amount=0.0, total=0.0, balance_due=0.0)
1095
+ lines = session.query(InvoiceLineItem).filter(InvoiceLineItem.invoice_id == invoice_id).all()
1096
+ subtotal = 0.0
1097
+ tax_amount = 0.0
1098
+ total = 0.0
1099
+ for li in lines:
1100
+ subtotal += li.line_subtotal
1101
+ tax_amount += li.tax_amount
1102
+ total += li.total
1103
+ payments = session.query(PaymentApplication).filter(PaymentApplication.invoice_id == invoice_id).all()
1104
+ paid_amount = 0.0
1105
+ for pa in payments:
1106
+ paid_amount += pa.amount
1107
+ invoice.subtotal = subtotal
1108
+ invoice.tax_amount = tax_amount
1109
+ invoice.total = total
1110
+ invoice.balance_due = total - paid_amount
1111
+ invoice.updated_at = datetime.utcnow()
1112
+ session.commit()
1113
+ session.close()
1114
+ return InvoiceRecalculateTotalsResponse(
1115
+ invoice_id=invoice_id,
1116
+ subtotal=subtotal,
1117
+ tax_amount=tax_amount,
1118
+ total=total,
1119
+ balance_due=invoice.balance_due,
1120
+ )
1121
+
1122
+ @app.get(
1123
+ "/api/invoices",
1124
+ response_model=InvoicesListResponse,
1125
+ summary="List invoices with filters",
1126
+ description="Retrieve invoices filtered by number, customer, status, or dates.",
1127
+ tags=["invoices"],
1128
+ operation_id="list_invoices",
1129
+ )
1130
+ async def list_invoices_endpoint(
1131
+ invoice_number: Optional[str] = Query(None, description="Filter by invoice_number", example="INV-2025-001"),
1132
+ customer_id: Optional[int] = Query(None, description="Filter invoices for a given customer ID", example=10),
1133
+ status: Optional[str] = Query(None, description="Filter by invoice status (draft, open, paid, void)", example="open"),
1134
+ from_date: Optional[str] = Query(None, description="Filter by minimum invoice_date (YYYY-MM-DD)", example="2025-01-01"),
1135
+ to_date: Optional[str] = Query(None, description="Filter by maximum invoice_date (YYYY-MM-DD)", example="2025-01-31"),
1136
+ limit: Optional[int] = Query(50, description="Max number of invoices to return", example=50),
1137
+ offset: Optional[int] = Query(0, description="Number of invoices to skip", example=0),
1138
+ ) -> InvoicesListResponse:
1139
+ session = SessionLocal()
1140
+ query = session.query(Invoice)
1141
+ if invoice_number is not None:
1142
+ query = query.filter(Invoice.invoice_number == invoice_number)
1143
+ if customer_id is not None:
1144
+ query = query.filter(Invoice.customer_id == customer_id)
1145
+ if status is not None:
1146
+ query = query.filter(Invoice.status == status)
1147
+ if from_date is not None:
1148
+ query = query.filter(Invoice.invoice_date >= date.fromisoformat(from_date))
1149
+ if to_date is not None:
1150
+ query = query.filter(Invoice.invoice_date <= date.fromisoformat(to_date))
1151
+ invoices = query.offset(offset).limit(limit).all()
1152
+ session.close()
1153
+ return InvoicesListResponse(invoices=invoices)
1154
+
1155
+ @app.post(
1156
+ "/api/payments",
1157
+ response_model=PaymentResponse,
1158
+ summary="Record a customer payment",
1159
+ description="Create a payment row for a customer without allocations.",
1160
+ tags=["payments"],
1161
+ operation_id="create_payment",
1162
+ )
1163
+ async def create_payment_endpoint(body: PaymentCreateRequest = Body(...)) -> PaymentResponse:
1164
+ session = SessionLocal()
1165
+ payment = Payment(
1166
+ customer_id=body.customer_id,
1167
+ payment_date=date.fromisoformat(body.payment_date),
1168
+ settlement_date=date.fromisoformat(body.settlement_date) if body.settlement_date is not None else None,
1169
+ amount=body.amount,
1170
+ currency=body.currency if body.currency is not None else "USD",
1171
+ method=body.method,
1172
+ reference=body.reference,
1173
+ created_at=datetime.utcnow(),
1174
+ updated_at=None,
1175
+ )
1176
+ session.add(payment)
1177
+ session.commit()
1178
+ session.refresh(payment)
1179
+ session.close()
1180
+ return PaymentResponse(
1181
+ id=payment.id,
1182
+ customer_id=payment.customer_id,
1183
+ payment_date=payment.payment_date,
1184
+ settlement_date=payment.settlement_date,
1185
+ amount=payment.amount,
1186
+ currency=payment.currency,
1187
+ method=payment.method,
1188
+ reference=payment.reference,
1189
+ created_at=payment.created_at,
1190
+ updated_at=payment.updated_at,
1191
+ )
1192
+
1193
+ @app.post(
1194
+ "/api/payment_applications",
1195
+ response_model=PaymentApplicationResponse,
1196
+ summary="Apply a payment to an invoice",
1197
+ description="Allocate part or all of a payment amount to a specific invoice.",
1198
+ tags=["payments", "payment_applications"],
1199
+ operation_id="create_payment_application",
1200
+ )
1201
+ async def create_payment_application_endpoint(
1202
+ body: PaymentApplicationCreateRequest = Body(...)
1203
+ ) -> PaymentApplicationResponse:
1204
+ session = SessionLocal()
1205
+ payment_app = PaymentApplication(
1206
+ payment_id=body.payment_id,
1207
+ invoice_id=body.invoice_id,
1208
+ amount=body.amount,
1209
+ created_at=datetime.utcnow(),
1210
+ updated_at=None,
1211
+ )
1212
+ session.add(payment_app)
1213
+ invoice = session.query(Invoice).filter(Invoice.id == body.invoice_id).first()
1214
+ if invoice is not None:
1215
+ payments = session.query(PaymentApplication).filter(PaymentApplication.invoice_id == body.invoice_id).all()
1216
+ total_applied = 0.0
1217
+ for p in payments:
1218
+ total_applied += p.amount
1219
+ total_applied += body.amount
1220
+ invoice.balance_due = invoice.total - total_applied
1221
+ if invoice.balance_due <= 0:
1222
+ invoice.status = "paid"
1223
+ invoice.updated_at = datetime.utcnow()
1224
+ session.commit()
1225
+ session.refresh(payment_app)
1226
+ session.close()
1227
+ return PaymentApplicationResponse(
1228
+ id=payment_app.id,
1229
+ payment_id=payment_app.payment_id,
1230
+ invoice_id=payment_app.invoice_id,
1231
+ amount=payment_app.amount,
1232
+ created_at=payment_app.created_at,
1233
+ updated_at=payment_app.updated_at,
1234
+ )
1235
+
1236
+ @app.post(
1237
+ "/api/vendors",
1238
+ response_model=VendorResponse,
1239
+ summary="Create a new vendor",
1240
+ description="Create a vendor with default payment terms and expense category.",
1241
+ tags=["vendors"],
1242
+ operation_id="create_vendor",
1243
+ )
1244
+ async def create_vendor_endpoint(body: VendorCreateRequest = Body(...)) -> VendorResponse:
1245
+ session = SessionLocal()
1246
+ vendor = Vendor(
1247
+ name=body.name,
1248
+ contact_email=body.contact_email,
1249
+ payment_terms_id=body.payment_terms_id,
1250
+ default_expense_category_id=body.default_expense_category_id,
1251
+ created_at=datetime.utcnow(),
1252
+ updated_at=None,
1253
+ )
1254
+ session.add(vendor)
1255
+ session.commit()
1256
+ session.refresh(vendor)
1257
+ session.close()
1258
+ return VendorResponse(
1259
+ id=vendor.id,
1260
+ name=vendor.name,
1261
+ contact_email=vendor.contact_email,
1262
+ payment_terms_id=vendor.payment_terms_id,
1263
+ default_expense_category_id=vendor.default_expense_category_id,
1264
+ created_at=vendor.created_at,
1265
+ updated_at=vendor.updated_at,
1266
+ )
1267
+
1268
+ @app.get(
1269
+ "/api/vendors",
1270
+ response_model=VendorsListResponse,
1271
+ summary="List vendors",
1272
+ description="Retrieve vendors to find IDs when creating bills.",
1273
+ tags=["vendors"],
1274
+ operation_id="list_vendors",
1275
+ )
1276
+ async def list_vendors_endpoint(
1277
+ name: Optional[str] = Query(None, description="Filter vendors by name", example="PixelPrint")
1278
+ ) -> VendorsListResponse:
1279
+ session = SessionLocal()
1280
+ query = session.query(Vendor)
1281
+ if name is not None:
1282
+ query = query.filter(Vendor.name.contains(name))
1283
+ vendors = query.all()
1284
+ session.close()
1285
+ return VendorsListResponse(vendors=vendors)
1286
+
1287
+ @app.post(
1288
+ "/api/bills",
1289
+ response_model=BillResponse,
1290
+ summary="Create a bill",
1291
+ description="Create a bills row for vendor expenses.",
1292
+ tags=["bills"],
1293
+ operation_id="create_bill",
1294
+ )
1295
+ async def create_bill_endpoint(body: BillCreateRequest = Body(...)) -> BillResponse:
1296
+ session = SessionLocal()
1297
+ bill = Bill(
1298
+ bill_number=body.bill_number,
1299
+ vendor_id=body.vendor_id,
1300
+ bill_date=date.fromisoformat(body.bill_date),
1301
+ due_date=date.fromisoformat(body.due_date) if body.due_date is not None else None,
1302
+ currency=body.currency if body.currency is not None else "USD",
1303
+ amount=body.amount,
1304
+ description=body.description,
1305
+ department_id=body.department_id,
1306
+ reimbursement_status=body.reimbursement_status,
1307
+ payment_terms_id=body.payment_terms_id,
1308
+ status=body.status if body.status is not None else "open",
1309
+ created_at=datetime.utcnow(),
1310
+ updated_at=None,
1311
+ )
1312
+ session.add(bill)
1313
+ session.commit()
1314
+ session.refresh(bill)
1315
+ session.close()
1316
+ return BillResponse(
1317
+ id=bill.id,
1318
+ bill_number=bill.bill_number,
1319
+ vendor_id=bill.vendor_id,
1320
+ bill_date=bill.bill_date,
1321
+ due_date=bill.due_date,
1322
+ currency=bill.currency,
1323
+ amount=bill.amount,
1324
+ description=bill.description,
1325
+ department_id=bill.department_id,
1326
+ reimbursement_status=bill.reimbursement_status,
1327
+ payment_terms_id=bill.payment_terms_id,
1328
+ status=bill.status,
1329
+ created_at=bill.created_at,
1330
+ updated_at=bill.updated_at,
1331
+ )
1332
+
1333
+ @app.post(
1334
+ "/api/recurring_expenses",
1335
+ response_model=RecurringExpenseResponse,
1336
+ summary="Create a recurring expense template",
1337
+ description="Create recurring_expenses templates such as monthly rent.",
1338
+ tags=["recurring_expenses"],
1339
+ operation_id="create_recurring_expense",
1340
+ )
1341
+ async def create_recurring_expense_endpoint(
1342
+ body: RecurringExpenseCreateRequest = Body(...)
1343
+ ) -> RecurringExpenseResponse:
1344
+ session = SessionLocal()
1345
+ recurring = RecurringExpense(
1346
+ name=body.name,
1347
+ vendor_id=body.vendor_id,
1348
+ amount=body.amount,
1349
+ expense_account_id=body.expense_account_id,
1350
+ department_id=body.department_id,
1351
+ frequency=body.frequency,
1352
+ next_run_date=date.fromisoformat(body.next_run_date),
1353
+ end_date=date.fromisoformat(body.end_date) if body.end_date is not None else None,
1354
+ is_active=1 if (body.is_active if body.is_active is not None else True) else 0,
1355
+ created_at=datetime.utcnow(),
1356
+ updated_at=None,
1357
+ )
1358
+ session.add(recurring)
1359
+ session.commit()
1360
+ session.refresh(recurring)
1361
+ session.close()
1362
+ return RecurringExpenseResponse(
1363
+ id=recurring.id,
1364
+ name=recurring.name,
1365
+ vendor_id=recurring.vendor_id,
1366
+ amount=recurring.amount,
1367
+ expense_account_id=recurring.expense_account_id,
1368
+ department_id=recurring.department_id,
1369
+ frequency=recurring.frequency,
1370
+ next_run_date=recurring.next_run_date,
1371
+ end_date=recurring.end_date,
1372
+ is_active=bool(recurring.is_active),
1373
+ created_at=recurring.created_at,
1374
+ updated_at=recurring.updated_at,
1375
+ )
1376
+
1377
+ @app.post(
1378
+ "/api/bank_transactions/batch_import",
1379
+ response_model=BankTransactionsBatchImportResponse,
1380
+ summary="Import a batch of bank transactions",
1381
+ description="Insert multiple bank_transactions for a bank account in one call.",
1382
+ tags=["bank_transactions"],
1383
+ operation_id="batch_import_bank_transactions",
1384
+ )
1385
+ async def batch_import_bank_transactions_endpoint(
1386
+ body: BankTransactionsBatchImportRequest = Body(...)
1387
+ ) -> BankTransactionsBatchImportResponse:
1388
+ session = SessionLocal()
1389
+ created_items: List[BankTransactionResponse] = []
1390
+ for t in body.transactions:
1391
+ bt = BankTransaction(
1392
+ bank_account_id=body.bank_account_id,
1393
+ transaction_date=date.fromisoformat(t.transaction_date),
1394
+ posted_date=date.fromisoformat(t.posted_date) if t.posted_date is not None else None,
1395
+ description=t.description,
1396
+ amount=t.amount,
1397
+ external_id=t.external_id,
1398
+ created_at=datetime.utcnow(),
1399
+ updated_at=None,
1400
+ )
1401
+ session.add(bt)
1402
+ session.commit()
1403
+ session.refresh(bt)
1404
+ created_items.append(
1405
+ BankTransactionResponse(
1406
+ id=bt.id,
1407
+ bank_account_id=bt.bank_account_id,
1408
+ transaction_date=bt.transaction_date,
1409
+ posted_date=bt.posted_date,
1410
+ description=bt.description,
1411
+ amount=bt.amount,
1412
+ external_id=bt.external_id,
1413
+ created_at=bt.created_at,
1414
+ updated_at=bt.updated_at,
1415
+ )
1416
+ )
1417
+ session.close()
1418
+ return BankTransactionsBatchImportResponse(bank_transactions=created_items)
1419
+
1420
+ @app.get(
1421
+ "/api/bank_transactions",
1422
+ response_model=BankTransactionsListResponse,
1423
+ summary="List bank transactions",
1424
+ description="Retrieve bank_transactions for a bank account filtered by date.",
1425
+ tags=["bank_transactions"],
1426
+ operation_id="list_bank_transactions",
1427
+ )
1428
+ async def list_bank_transactions_endpoint(
1429
+ bank_account_id: int = Query(..., description="Bank account ID to filter transactions", example=1),
1430
+ from_date: Optional[str] = Query(None, description="Minimum transaction_date (YYYY-MM-DD)", example="2025-01-01"),
1431
+ to_date: Optional[str] = Query(None, description="Maximum transaction_date (YYYY-MM-DD)", example="2025-01-07"),
1432
+ limit: Optional[int] = Query(100, description="Maximum number of records", example=100),
1433
+ offset: Optional[int] = Query(0, description="Records to skip", example=0),
1434
+ ) -> BankTransactionsListResponse:
1435
+ session = SessionLocal()
1436
+ query = session.query(BankTransaction).filter(BankTransaction.bank_account_id == bank_account_id)
1437
+ if from_date is not None:
1438
+ query = query.filter(BankTransaction.transaction_date >= date.fromisoformat(from_date))
1439
+ if to_date is not None:
1440
+ query = query.filter(BankTransaction.transaction_date <= date.fromisoformat(to_date))
1441
+ transactions = query.offset(offset).limit(limit).all()
1442
+ session.close()
1443
+ return BankTransactionsListResponse(bank_transactions=transactions)
1444
+
1445
+ @app.post(
1446
+ "/api/journal_entries",
1447
+ response_model=JournalEntryResponse,
1448
+ summary="Create a journal entry header",
1449
+ description="Create a journal_entries header with entry_date and description.",
1450
+ tags=["journal_entries"],
1451
+ operation_id="create_journal_entry",
1452
+ )
1453
+ async def create_journal_entry_endpoint(
1454
+ body: JournalEntryCreateRequest = Body(...)
1455
+ ) -> JournalEntryResponse:
1456
+ session = SessionLocal()
1457
+ entry = JournalEntry(
1458
+ entry_date=date.fromisoformat(body.entry_date),
1459
+ description=body.description,
1460
+ department_id=body.department_id,
1461
+ source=body.source,
1462
+ source_id=body.source_id,
1463
+ created_by_user_id=1,
1464
+ created_at=datetime.utcnow(),
1465
+ updated_at=None,
1466
+ )
1467
+ session.add(entry)
1468
+ session.commit()
1469
+ session.refresh(entry)
1470
+ session.close()
1471
+ return JournalEntryResponse(
1472
+ id=entry.id,
1473
+ entry_date=entry.entry_date,
1474
+ description=entry.description,
1475
+ department_id=entry.department_id,
1476
+ source=entry.source,
1477
+ source_id=entry.source_id,
1478
+ created_by_user_id=entry.created_by_user_id,
1479
+ created_at=entry.created_at,
1480
+ updated_at=entry.updated_at,
1481
+ )
1482
+
1483
+ @app.post(
1484
+ "/api/journal_entry_lines",
1485
+ response_model=JournalEntryLineResponse,
1486
+ summary="Add a line to a journal entry",
1487
+ description="Create a journal_entry_lines row for an account with debit or credit.",
1488
+ tags=["journal_entries", "journal_entry_lines"],
1489
+ operation_id="create_journal_entry_line",
1490
+ )
1491
+ async def create_journal_entry_line_endpoint(
1492
+ body: JournalEntryLineCreateRequest = Body(...)
1493
+ ) -> JournalEntryLineResponse:
1494
+ session = SessionLocal()
1495
+ debit_value = body.debit if body.debit is not None else 0.0
1496
+ credit_value = body.credit if body.credit is not None else 0.0
1497
+ line = JournalEntryLine(
1498
+ journal_entry_id=body.journal_entry_id,
1499
+ account_id=body.account_id,
1500
+ department_id=body.department_id,
1501
+ description=body.description,
1502
+ debit=debit_value,
1503
+ credit=credit_value,
1504
+ created_at=datetime.utcnow(),
1505
+ updated_at=None,
1506
+ )
1507
+ session.add(line)
1508
+ session.commit()
1509
+ session.refresh(line)
1510
+ session.close()
1511
+ return JournalEntryLineResponse(
1512
+ id=line.id,
1513
+ journal_entry_id=line.journal_entry_id,
1514
+ account_id=line.account_id,
1515
+ department_id=line.department_id,
1516
+ description=line.description,
1517
+ debit=line.debit,
1518
+ credit=line.credit,
1519
+ created_at=line.created_at,
1520
+ updated_at=line.updated_at,
1521
+ )
1522
+
1523
+ @app.post(
1524
+ "/api/bank_transaction_journal_links",
1525
+ response_model=BankTransactionJournalLinkResponse,
1526
+ summary="Link a bank transaction to a journal entry",
1527
+ description="Create a bank_transaction_journal_links row to connect bank_transactions with journal_entries.",
1528
+ tags=["bank_transactions", "journal_entries"],
1529
+ operation_id="create_bank_transaction_journal_link",
1530
+ )
1531
+ async def create_bank_transaction_journal_link_endpoint(
1532
+ body: BankTransactionJournalLinkCreateRequest = Body(...)
1533
+ ) -> BankTransactionJournalLinkResponse:
1534
+ session = SessionLocal()
1535
+ link = BankTransactionJournalLink(
1536
+ bank_transaction_id=body.bank_transaction_id,
1537
+ journal_entry_id=body.journal_entry_id,
1538
+ created_at=datetime.utcnow(),
1539
+ )
1540
+ session.add(link)
1541
+ session.commit()
1542
+ session.refresh(link)
1543
+ session.close()
1544
+ return BankTransactionJournalLinkResponse(
1545
+ id=link.id,
1546
+ bank_transaction_id=link.bank_transaction_id,
1547
+ journal_entry_id=link.journal_entry_id,
1548
+ created_at=link.created_at,
1549
+ )
1550
+
1551
+ @app.post(
1552
+ "/api/recurring_invoices",
1553
+ response_model=RecurringInvoiceResponse,
1554
+ summary="Create a recurring invoice schedule",
1555
+ description="Create a recurring_invoices template specifying settings.",
1556
+ tags=["recurring_invoices"],
1557
+ operation_id="create_recurring_invoice",
1558
+ )
1559
+ async def create_recurring_invoice_endpoint(
1560
+ body: RecurringInvoiceCreateRequest = Body(...)
1561
+ ) -> RecurringInvoiceResponse:
1562
+ session = SessionLocal()
1563
+ recurring = RecurringInvoice(
1564
+ customer_id=body.customer_id,
1565
+ name=body.name,
1566
+ description=body.description,
1567
+ quantity=body.quantity,
1568
+ unit_price=body.unit_price,
1569
+ discount_percent=body.discount_percent if body.discount_percent is not None else 0.0,
1570
+ frequency=body.frequency,
1571
+ next_run_date=date.fromisoformat(body.next_run_date),
1572
+ end_date=date.fromisoformat(body.end_date) if body.end_date is not None else None,
1573
+ payment_terms_id=body.payment_terms_id,
1574
+ tax_category_id=body.tax_category_id,
1575
+ department_id=body.department_id,
1576
+ currency=body.currency if body.currency is not None else "USD",
1577
+ is_active=1 if (body.is_active if body.is_active is not None else True) else 0,
1578
+ created_at=datetime.utcnow(),
1579
+ updated_at=None,
1580
+ )
1581
+ session.add(recurring)
1582
+ session.commit()
1583
+ session.refresh(recurring)
1584
+ session.close()
1585
+ return RecurringInvoiceResponse(
1586
+ id=recurring.id,
1587
+ customer_id=recurring.customer_id,
1588
+ name=recurring.name,
1589
+ description=recurring.description,
1590
+ quantity=recurring.quantity,
1591
+ unit_price=recurring.unit_price,
1592
+ discount_percent=recurring.discount_percent,
1593
+ frequency=recurring.frequency,
1594
+ next_run_date=recurring.next_run_date,
1595
+ end_date=recurring.end_date,
1596
+ payment_terms_id=recurring.payment_terms_id,
1597
+ tax_category_id=recurring.tax_category_id,
1598
+ department_id=recurring.department_id,
1599
+ currency=recurring.currency,
1600
+ is_active=bool(recurring.is_active),
1601
+ created_at=recurring.created_at,
1602
+ updated_at=recurring.updated_at,
1603
+ )
1604
+
1605
+ @app.post(
1606
+ "/api/accounting_periods",
1607
+ response_model=AccountingPeriodResponse,
1608
+ summary="Create an accounting period",
1609
+ description="Create an accounting_periods row representing a fiscal period.",
1610
+ tags=["accounting_periods"],
1611
+ operation_id="create_accounting_period",
1612
+ )
1613
+ async def create_accounting_period_endpoint(
1614
+ body: AccountingPeriodCreateRequest = Body(...)
1615
+ ) -> AccountingPeriodResponse:
1616
+ session = SessionLocal()
1617
+ period = AccountingPeriod(
1618
+ start_date=date.fromisoformat(body.start_date),
1619
+ end_date=date.fromisoformat(body.end_date),
1620
+ close_date=date.fromisoformat(body.close_date) if body.close_date is not None else None,
1621
+ is_locked=1 if (body.is_locked if body.is_locked is not None else False) else 0,
1622
+ created_at=datetime.utcnow(),
1623
+ updated_at=None,
1624
+ )
1625
+ session.add(period)
1626
+ session.commit()
1627
+ session.refresh(period)
1628
+ session.close()
1629
+ return AccountingPeriodResponse(
1630
+ id=period.id,
1631
+ start_date=period.start_date,
1632
+ end_date=period.end_date,
1633
+ close_date=period.close_date,
1634
+ is_locked=bool(period.is_locked),
1635
+ created_at=period.created_at,
1636
+ updated_at=period.updated_at,
1637
+ )
1638
+
1639
+ @app.patch(
1640
+ "/api/accounting_periods/{period_id}",
1641
+ response_model=AccountingPeriodResponse,
1642
+ summary="Update an accounting period lock status",
1643
+ description="Update close_date and is_locked for an accounting period.",
1644
+ tags=["accounting_periods"],
1645
+ operation_id="update_accounting_period_lock",
1646
+ )
1647
+ async def update_accounting_period_lock_endpoint(
1648
+ period_id: int = Path(..., description="Accounting period ID to update", example=10001),
1649
+ body: AccountingPeriodUpdateRequest = Body(...),
1650
+ ) -> AccountingPeriodResponse:
1651
+ session = SessionLocal()
1652
+ period = session.query(AccountingPeriod).filter(AccountingPeriod.id == period_id).first()
1653
+ if period is None:
1654
+ session.close()
1655
+ return AccountingPeriodResponse(
1656
+ id=0,
1657
+ start_date=date.fromisoformat("1970-01-01"),
1658
+ end_date=date.fromisoformat("1970-01-01"),
1659
+ close_date=None,
1660
+ is_locked=False,
1661
+ created_at=None,
1662
+ updated_at=None,
1663
+ )
1664
+ if body.close_date is not None:
1665
+ period.close_date = date.fromisoformat(body.close_date)
1666
+ if body.close_date is None and body.close_date is not ...:
1667
+ if body.close_date is None:
1668
+ period.close_date = None
1669
+ if body.is_locked is not None:
1670
+ period.is_locked = 1 if body.is_locked else 0
1671
+ period.updated_at = datetime.utcnow()
1672
+ session.commit()
1673
+ session.refresh(period)
1674
+ session.close()
1675
+ return AccountingPeriodResponse(
1676
+ id=period.id,
1677
+ start_date=period.start_date,
1678
+ end_date=period.end_date,
1679
+ close_date=period.close_date,
1680
+ is_locked=bool(period.is_locked),
1681
+ created_at=period.created_at,
1682
+ updated_at=period.updated_at,
1683
+ )
1684
+
1685
+ @app.get(
1686
+ "/api/reports/profit_and_loss",
1687
+ response_model=ProfitAndLossReportResponse,
1688
+ summary="Generate a profit and loss report",
1689
+ description="Compute revenue, expenses, and net profit for a date range.",
1690
+ tags=["reports"],
1691
+ operation_id="generate_profit_and_loss",
1692
+ )
1693
+ async def generate_profit_and_loss_endpoint(
1694
+ start_date: str = Query(..., description="Start date for the report (YYYY-MM-DD)", example="2025-01-01"),
1695
+ end_date: str = Query(..., description="End date for the report (YYYY-MM-DD)", example="2025-01-31"),
1696
+ department_id: Optional[int] = Query(None, description="Optional department filter to restrict results", example=2),
1697
+ ) -> ProfitAndLossReportResponse:
1698
+ session = SessionLocal()
1699
+ start = date.fromisoformat(start_date)
1700
+ end = date.fromisoformat(end_date)
1701
+ entries_query = session.query(JournalEntry).filter(
1702
+ JournalEntry.entry_date >= start, JournalEntry.entry_date <= end
1703
+ )
1704
+ if department_id is not None:
1705
+ entries_query = entries_query.filter(JournalEntry.department_id == department_id)
1706
+ entries = entries_query.all()
1707
+ entry_ids = [e.id for e in entries]
1708
+ lines_query = session.query(JournalEntryLine).filter(JournalEntryLine.journal_entry_id.in_(entry_ids)) if entry_ids else session.query(JournalEntryLine).filter(JournalEntryLine.id == -1)
1709
+ if department_id is not None:
1710
+ lines_query = lines_query.filter(
1711
+ (JournalEntryLine.department_id == department_id) | (JournalEntryLine.department_id.is_(None))
1712
+ )
1713
+ lines = lines_query.all()
1714
+ account_ids = list({l.account_id for l in lines})
1715
+ accounts = {}
1716
+ if account_ids:
1717
+ account_rows = session.query(Account).filter(Account.id.in_(account_ids)).all()
1718
+ for a in account_rows:
1719
+ accounts[a.id] = a
1720
+ total_revenue = 0.0
1721
+ total_expenses = 0.0
1722
+ income_details: List[Dict[str, Optional[float]]] = []
1723
+ expense_details: List[Dict[str, Optional[float]]] = []
1724
+ income_map: Dict[int, float] = {}
1725
+ expense_map: Dict[int, float] = {}
1726
+ for l in lines:
1727
+ a = accounts.get(l.account_id)
1728
+ if a is None:
1729
+ continue
1730
+ net_amount = l.debit - l.credit
1731
+ if a.type == "income":
1732
+ amount = -net_amount
1733
+ total_revenue += amount
1734
+ income_map[a.id] = income_map.get(a.id, 0.0) + amount
1735
+ if a.type == "expense":
1736
+ amount = net_amount
1737
+ total_expenses += amount
1738
+ expense_map[a.id] = expense_map.get(a.id, 0.0) + amount
1739
+ for aid, amt in income_map.items():
1740
+ a = accounts.get(aid)
1741
+ if a is not None:
1742
+ income_details.append({"account_id": float(a.id), "account_name": a.name, "amount": amt})
1743
+ for aid, amt in expense_map.items():
1744
+ a = accounts.get(aid)
1745
+ if a is not None:
1746
+ expense_details.append({"account_id": float(a.id), "account_name": a.name, "amount": amt})
1747
+ net_profit = total_revenue - total_expenses
1748
+ session.close()
1749
+ detail = {
1750
+ "income_accounts": income_details,
1751
+ "expense_accounts": expense_details,
1752
+ }
1753
+ return ProfitAndLossReportResponse(
1754
+ start_date=start_date,
1755
+ end_date=end_date,
1756
+ department_id=department_id,
1757
+ total_revenue=total_revenue,
1758
+ total_expenses=total_expenses,
1759
+ net_profit=net_profit,
1760
+ detail=detail,
1761
+ )
1762
+
1763
+ if __name__ == "__main__":
1764
+ import uvicorn, os
1765
+ host = os.getenv("HOST", "127.0.0.1")
1766
+ port = int(os.getenv("PORT", "8000"))
1767
+ uvicorn.run(app, host=host, port=port)
components/awm/private/tasks/awm-accounting-1-invoice/original_verifier.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def verify_task_completion(initial_db_path: str, final_db_path: str, final_answer: str | None = None) -> dict:
2
+ import sqlite3
3
+
4
+ def safe_query(db_path: str, query: str, params: tuple = ()) -> list:
5
+ try:
6
+ conn = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True)
7
+ cursor = conn.cursor()
8
+ cursor.execute(query, params)
9
+ results = cursor.fetchall()
10
+ conn.close()
11
+ return results
12
+ except Exception:
13
+ return []
14
+
15
+ # Get customer_id for 'Acme Design Studio'
16
+ customer_query = "SELECT id FROM customers WHERE name = 'Acme Design Studio'"
17
+ customer_result = safe_query(final_db_path, customer_query)
18
+ if not customer_result:
19
+ return {"result": "others"}
20
+ customer_id = customer_result[0][0]
21
+
22
+ # Get department_id for 'Design'
23
+ dept_query = "SELECT id FROM departments WHERE name = 'Design'"
24
+ dept_result = safe_query(final_db_path, dept_query)
25
+ if not dept_result:
26
+ return {"result": "others"}
27
+ dept_id = dept_result[0][0]
28
+
29
+ # Get tax_category_id for 'Standard Sales Tax 8.5%'
30
+ tax_query = "SELECT id, rate FROM tax_categories WHERE name = 'Standard Sales Tax 8.5%'"
31
+ tax_result = safe_query(final_db_path, tax_query)
32
+ if not tax_result:
33
+ return {"result": "others"}
34
+ tax_category_id = tax_result[0][0]
35
+ tax_rate = tax_result[0][1]
36
+
37
+ # Find invoices in initial state for this customer with these dates
38
+ initial_invoice_query = """SELECT id FROM invoices
39
+ WHERE customer_id = ? AND invoice_date = '2025-01-05' AND due_date = '2025-02-04'
40
+ AND department_id = ? AND tax_category_id = ?"""
41
+ initial_invoices = safe_query(initial_db_path, initial_invoice_query,
42
+ (customer_id, dept_id, tax_category_id))
43
+
44
+ # Find invoices in final state for this customer with these dates
45
+ final_invoice_query = """SELECT id, subtotal, tax_amount, total FROM invoices
46
+ WHERE customer_id = ? AND invoice_date = '2025-01-05' AND due_date = '2025-02-04'
47
+ AND department_id = ? AND tax_category_id = ?"""
48
+ final_invoices = safe_query(final_db_path, final_invoice_query,
49
+ (customer_id, dept_id, tax_category_id))
50
+
51
+ # Check if a new invoice was created
52
+ if len(final_invoices) <= len(initial_invoices):
53
+ return {"result": "others"}
54
+
55
+ # Find the newly created invoice(s)
56
+ initial_invoice_ids = set(inv[0] for inv in initial_invoices)
57
+ new_invoices = [inv for inv in final_invoices if inv[0] not in initial_invoice_ids]
58
+
59
+ if not new_invoices:
60
+ return {"result": "others"}
61
+
62
+ # Check each new invoice to find one that matches our requirements
63
+ for invoice in new_invoices:
64
+ invoice_id = invoice[0]
65
+ invoice_subtotal = invoice[1]
66
+ invoice_tax = invoice[2]
67
+ invoice_total = invoice[3]
68
+
69
+ # Get line items for this invoice
70
+ line_items_query = """SELECT description, quantity, unit_price, discount_percent,
71
+ line_subtotal, tax_amount, total, department_id
72
+ FROM invoice_line_items WHERE invoice_id = ? ORDER BY id"""
73
+ line_items = safe_query(final_db_path, line_items_query, (invoice_id,))
74
+
75
+ # Must have exactly 2 line items
76
+ if len(line_items) != 2:
77
+ continue
78
+
79
+ # Check first line item: 'Logo redesign'
80
+ item1 = line_items[0]
81
+ if item1[0] != 'Logo redesign':
82
+ continue
83
+ if abs(item1[1] - 1.0) > 0.001: # quantity
84
+ continue
85
+ if abs(item1[2] - 1200.0) > 0.001: # unit_price
86
+ continue
87
+ if abs(item1[3] - 0.0) > 0.001: # discount_percent
88
+ continue
89
+ if item1[7] != dept_id: # department_id
90
+ continue
91
+
92
+ # Calculate expected values for item1
93
+ expected_subtotal1 = 1200.0 * 1.0 * (1 - 0.0 / 100.0)
94
+ expected_tax1 = expected_subtotal1 * tax_rate
95
+ expected_total1 = expected_subtotal1 + expected_tax1
96
+
97
+ if abs(item1[4] - expected_subtotal1) > 0.01: # line_subtotal
98
+ continue
99
+ if abs(item1[5] - expected_tax1) > 0.01: # tax_amount
100
+ continue
101
+ if abs(item1[6] - expected_total1) > 0.01: # total
102
+ continue
103
+
104
+ # Check second line item: 'Brand guideline document'
105
+ item2 = line_items[1]
106
+ if item2[0] != 'Brand guideline document':
107
+ continue
108
+ if abs(item2[1] - 1.0) > 0.001: # quantity
109
+ continue
110
+ if abs(item2[2] - 800.0) > 0.001: # unit_price
111
+ continue
112
+ if abs(item2[3] - 10.0) > 0.001: # discount_percent
113
+ continue
114
+ if item2[7] != dept_id: # department_id
115
+ continue
116
+
117
+ # Calculate expected values for item2
118
+ expected_subtotal2 = 800.0 * 1.0 * (1 - 10.0 / 100.0)
119
+ expected_tax2 = expected_subtotal2 * tax_rate
120
+ expected_total2 = expected_subtotal2 + expected_tax2
121
+
122
+ if abs(item2[4] - expected_subtotal2) > 0.01: # line_subtotal
123
+ continue
124
+ if abs(item2[5] - expected_tax2) > 0.01: # tax_amount
125
+ continue
126
+ if abs(item2[6] - expected_total2) > 0.01: # total
127
+ continue
128
+
129
+ # Verify invoice totals match sum of line items
130
+ total_subtotal = expected_subtotal1 + expected_subtotal2
131
+ total_tax = expected_tax1 + expected_tax2
132
+ total_amount = expected_total1 + expected_total2
133
+
134
+ if abs(invoice_subtotal - total_subtotal) > 0.01:
135
+ continue
136
+ if abs(invoice_tax - total_tax) > 0.01:
137
+ continue
138
+ if abs(invoice_total - total_amount) > 0.01:
139
+ continue
140
+
141
+ # All checks passed for this invoice
142
+ return {"result": "complete"}
143
+
144
+ # No invoice matched all requirements
145
+ return {"result": "others"}
components/awm/private/tasks/awm-manufacturing-1-schedule/SOURCE.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "repo": "Snowflake/AgentWorldModel-1K",
3
+ "revision": "dde80a0283fe781bdc51656bce57063dc5650213",
4
+ "scenario": "manufacturing_execution_system_1",
5
+ "task_idx": 5,
6
+ "task": "For job 'J-2025-0332', create three job_tasks: (1) cutting at work_center 'Laser Cutter LC-01' requiring_skill_level = 'intermediate' with planned_start '2026-01-05T08:00:00' and planned_finish '2026-01-05T10:00:00'; (2) welding at 'Weld Cell WC-02' requiring_skill_level = 'advanced' from '2026-01-05T11:00:00' to '2026-01-05T14:00:00'; and (3) painting at 'Paint Booth PB-01' requiring_skill_level = 'intermediate' from '2026-01-06T09:00:00' to '2026-01-06T11:00:00'.",
7
+ "task_id": "awm-manufacturing-1-schedule",
8
+ "license": "CC-BY-4.0",
9
+ "split": "train",
10
+ "original_format": "FastAPI through FastApiMCP 0.4.0"
11
+ }
components/awm/private/tasks/awm-manufacturing-1-schedule/initial.db ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a523ebee8c25ca61aa43075c6263e5d3b310d39157ebddabea4cb754e610a1c
3
+ size 307200
components/awm/private/tasks/awm-manufacturing-1-schedule/original_api.py ADDED
@@ -0,0 +1,1524 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Query, Path, Body
2
+ from pydantic import BaseModel, Field, ConfigDict
3
+ from typing import Optional, List
4
+ from sqlalchemy import create_engine, Column, Integer, String, Float, DateTime, Date, ForeignKey, UniqueConstraint, Index, REAL
5
+ from sqlalchemy.orm import declarative_base, relationship, sessionmaker
6
+ from datetime import datetime
7
+ import os
8
+
9
+ database_url = os.getenv("DATABASE_PATH", "sqlite:///outputs/databases/craftbench_custom_manufacturing_job_tracker.db")
10
+ engine = create_engine(database_url, connect_args={"check_same_thread": False} if database_url.startswith("sqlite") else {})
11
+ SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
12
+ Base = declarative_base()
13
+
14
+ class User(Base):
15
+ __tablename__ = "users"
16
+ id = Column(Integer, primary_key=True)
17
+ username = Column(String, unique=True, nullable=False, index=True)
18
+ email = Column(String, unique=True, nullable=False, index=True)
19
+ full_name = Column(String)
20
+ created_at = Column(DateTime, default=datetime.utcnow)
21
+ updated_at = Column(DateTime, default=datetime.utcnow)
22
+
23
+ class Customer(Base):
24
+ __tablename__ = "customers"
25
+ id = Column(Integer, primary_key=True)
26
+ name = Column(String, unique=True, nullable=False, index=True)
27
+ billing_address = Column(String, nullable=False)
28
+ contact_person = Column(String)
29
+ email = Column(String)
30
+ phone = Column(String)
31
+ created_at = Column(DateTime, default=datetime.utcnow)
32
+ updated_at = Column(DateTime, default=datetime.utcnow)
33
+
34
+ class ProductTemplate(Base):
35
+ __tablename__ = "product_templates"
36
+ id = Column(Integer, primary_key=True)
37
+ name = Column(String, unique=True, nullable=False, index=True)
38
+ description = Column(String)
39
+ created_at = Column(DateTime, default=datetime.utcnow)
40
+ updated_at = Column(DateTime, default=datetime.utcnow)
41
+
42
+ class ProductTemplateOption(Base):
43
+ __tablename__ = "product_template_options"
44
+ id = Column(Integer, primary_key=True)
45
+ product_template_id = Column(Integer, ForeignKey("product_templates.id", ondelete="CASCADE"), nullable=False)
46
+ option_name = Column(String, nullable=False)
47
+ option_value = Column(String, nullable=False)
48
+ created_at = Column(DateTime, default=datetime.utcnow)
49
+ updated_at = Column(DateTime, default=datetime.utcnow)
50
+ __table_args__ = (UniqueConstraint("product_template_id", "option_name", "option_value"),)
51
+ product_template = relationship("ProductTemplate", foreign_keys=[product_template_id])
52
+
53
+ class StandardTaskSequence(Base):
54
+ __tablename__ = "standard_task_sequences"
55
+ id = Column(Integer, primary_key=True)
56
+ product_template_id = Column(Integer, ForeignKey("product_templates.id", ondelete="CASCADE"), nullable=False)
57
+ sequence_order = Column(Integer, nullable=False)
58
+ task_name = Column(String, nullable=False)
59
+ default_planned_duration_hours = Column(REAL, nullable=False)
60
+ created_at = Column(DateTime, default=datetime.utcnow)
61
+ updated_at = Column(DateTime, default=datetime.utcnow)
62
+ __table_args__ = (UniqueConstraint("product_template_id", "sequence_order"),)
63
+ product_template = relationship("ProductTemplate", foreign_keys=[product_template_id])
64
+
65
+ class CustomSpec(Base):
66
+ __tablename__ = "custom_specs"
67
+ id = Column(Integer, primary_key=True)
68
+ customer_id = Column(Integer, ForeignKey("customers.id", ondelete="RESTRICT"), nullable=False)
69
+ product_template_id = Column(Integer, ForeignKey("product_templates.id", ondelete="RESTRICT"), nullable=False)
70
+ notes = Column(String)
71
+ created_at = Column(DateTime, default=datetime.utcnow)
72
+ updated_at = Column(DateTime, default=datetime.utcnow)
73
+ customer = relationship("Customer", foreign_keys=[customer_id])
74
+ product_template = relationship("ProductTemplate", foreign_keys=[product_template_id])
75
+
76
+ class CustomSpecOption(Base):
77
+ __tablename__ = "custom_spec_options"
78
+ id = Column(Integer, primary_key=True)
79
+ custom_spec_id = Column(Integer, ForeignKey("custom_specs.id", ondelete="CASCADE"), nullable=False)
80
+ option_name = Column(String, nullable=False)
81
+ option_value = Column(String, nullable=False)
82
+ created_at = Column(DateTime, default=datetime.utcnow)
83
+ updated_at = Column(DateTime, default=datetime.utcnow)
84
+ __table_args__ = (UniqueConstraint("custom_spec_id", "option_name"),)
85
+ custom_spec = relationship("CustomSpec", foreign_keys=[custom_spec_id])
86
+
87
+ class CustomSpecNumericParam(Base):
88
+ __tablename__ = "custom_spec_numeric_params"
89
+ id = Column(Integer, primary_key=True)
90
+ custom_spec_id = Column(Integer, ForeignKey("custom_specs.id", ondelete="CASCADE"), nullable=False)
91
+ param_name = Column(String, nullable=False)
92
+ param_value = Column(REAL, nullable=False)
93
+ unit = Column(String)
94
+ created_at = Column(DateTime, default=datetime.utcnow)
95
+ updated_at = Column(DateTime, default=datetime.utcnow)
96
+ __table_args__ = (UniqueConstraint("custom_spec_id", "param_name"),)
97
+ custom_spec = relationship("CustomSpec", foreign_keys=[custom_spec_id])
98
+
99
+ class Quote(Base):
100
+ __tablename__ = "quotes"
101
+ id = Column(Integer, primary_key=True)
102
+ quote_number = Column(String, unique=True, nullable=False)
103
+ customer_id = Column(Integer, ForeignKey("customers.id", ondelete="RESTRICT"), nullable=False)
104
+ custom_spec_id = Column(Integer, ForeignKey("custom_specs.id", ondelete="SET NULL"))
105
+ estimated_hours = Column(REAL, nullable=False)
106
+ material_cost = Column(REAL, nullable=False)
107
+ labor_rate = Column(REAL, nullable=False)
108
+ status = Column(String, nullable=False)
109
+ internal_note = Column(String)
110
+ created_at = Column(DateTime, default=datetime.utcnow)
111
+ updated_at = Column(DateTime, default=datetime.utcnow)
112
+ customer = relationship("Customer", foreign_keys=[customer_id])
113
+ custom_spec = relationship("CustomSpec", foreign_keys=[custom_spec_id])
114
+
115
+ class Job(Base):
116
+ __tablename__ = "jobs"
117
+ id = Column(Integer, primary_key=True)
118
+ job_number = Column(String, unique=True, nullable=False, index=True)
119
+ customer_id = Column(Integer, ForeignKey("customers.id", ondelete="RESTRICT"), nullable=False)
120
+ quote_id = Column(Integer, ForeignKey("quotes.id", ondelete="SET NULL"))
121
+ custom_spec_id = Column(Integer, ForeignKey("custom_specs.id", ondelete="SET NULL"))
122
+ priority = Column(String, nullable=False)
123
+ due_date = Column(Date)
124
+ status = Column(String, nullable=False)
125
+ created_at = Column(DateTime, default=datetime.utcnow)
126
+ updated_at = Column(DateTime, default=datetime.utcnow)
127
+ customer = relationship("Customer", foreign_keys=[customer_id])
128
+ quote = relationship("Quote", foreign_keys=[quote_id])
129
+ custom_spec = relationship("CustomSpec", foreign_keys=[custom_spec_id])
130
+
131
+ class WorkCenter(Base):
132
+ __tablename__ = "work_centers"
133
+ id = Column(Integer, primary_key=True)
134
+ name = Column(String, unique=True, nullable=False, index=True)
135
+ description = Column(String)
136
+ created_at = Column(DateTime, default=datetime.utcnow)
137
+ updated_at = Column(DateTime, default=datetime.utcnow)
138
+
139
+ class JobTask(Base):
140
+ __tablename__ = "job_tasks"
141
+ id = Column(Integer, primary_key=True)
142
+ task_code = Column(String, unique=True, nullable=False)
143
+ job_id = Column(Integer, ForeignKey("jobs.id", ondelete="CASCADE"), nullable=False)
144
+ sequence_order = Column(Integer, nullable=False)
145
+ task_name = Column(String, nullable=False)
146
+ work_center_id = Column(Integer, ForeignKey("work_centers.id", ondelete="RESTRICT"), nullable=False)
147
+ requiring_skill_level = Column(String)
148
+ planned_start = Column(DateTime)
149
+ planned_finish = Column(DateTime)
150
+ planned_duration_hours = Column(REAL)
151
+ actual_start = Column(DateTime)
152
+ actual_finish = Column(DateTime)
153
+ created_at = Column(DateTime, default=datetime.utcnow)
154
+ updated_at = Column(DateTime, default=datetime.utcnow)
155
+ __table_args__ = (UniqueConstraint("job_id", "sequence_order"),)
156
+ job = relationship("Job", foreign_keys=[job_id])
157
+ work_center = relationship("WorkCenter", foreign_keys=[work_center_id])
158
+
159
+ class TimeLog(Base):
160
+ __tablename__ = "time_logs"
161
+ id = Column(Integer, primary_key=True)
162
+ job_task_id = Column(Integer, ForeignKey("job_tasks.id", ondelete="CASCADE"), nullable=False)
163
+ operator_username = Column(String, nullable=False)
164
+ work_center_id = Column(Integer, ForeignKey("work_centers.id", ondelete="RESTRICT"), nullable=False)
165
+ log_start = Column(DateTime, default=datetime.utcnow)
166
+ actual_duration_hours = Column(REAL, nullable=False)
167
+ scrap_quantity = Column(Integer, default=0)
168
+ note = Column(String)
169
+ created_at = Column(DateTime, default=datetime.utcnow)
170
+ updated_at = Column(DateTime, default=datetime.utcnow)
171
+ job_task = relationship("JobTask", foreign_keys=[job_task_id])
172
+ work_center = relationship("WorkCenter", foreign_keys=[work_center_id])
173
+
174
+ class Material(Base):
175
+ __tablename__ = "materials"
176
+ id = Column(Integer, primary_key=True)
177
+ name = Column(String, unique=True, nullable=False, index=True)
178
+ unit_of_measure = Column(String, nullable=False)
179
+ created_at = Column(DateTime, default=datetime.utcnow)
180
+ updated_at = Column(DateTime, default=datetime.utcnow)
181
+
182
+ class InventoryLot(Base):
183
+ __tablename__ = "inventory_lots"
184
+ id = Column(Integer, primary_key=True)
185
+ lot_number = Column(String, unique=True, nullable=False, index=True)
186
+ material_id = Column(Integer, ForeignKey("materials.id", ondelete="RESTRICT"), nullable=False)
187
+ on_hand_quantity = Column(REAL, nullable=False)
188
+ reserved_quantity = Column(REAL, nullable=False, default=0)
189
+ created_at = Column(DateTime, default=datetime.utcnow)
190
+ updated_at = Column(DateTime, default=datetime.utcnow)
191
+ material = relationship("Material", foreign_keys=[material_id])
192
+
193
+ class MaterialReservation(Base):
194
+ __tablename__ = "material_reservations"
195
+ id = Column(Integer, primary_key=True)
196
+ job_id = Column(Integer, ForeignKey("jobs.id", ondelete="CASCADE"), nullable=False)
197
+ inventory_lot_id = Column(Integer, ForeignKey("inventory_lots.id", ondelete="RESTRICT"), nullable=False)
198
+ quantity = Column(REAL, nullable=False)
199
+ created_at = Column(DateTime, default=datetime.utcnow)
200
+ updated_at = Column(DateTime, default=datetime.utcnow)
201
+ job = relationship("Job", foreign_keys=[job_id])
202
+ inventory_lot = relationship("InventoryLot", foreign_keys=[inventory_lot_id])
203
+
204
+ class Shipment(Base):
205
+ __tablename__ = "shipments"
206
+ id = Column(Integer, primary_key=True)
207
+ shipment_number = Column(String, unique=True, nullable=False)
208
+ job_id = Column(Integer, ForeignKey("jobs.id", ondelete="RESTRICT"), nullable=False)
209
+ customer_id = Column(Integer, ForeignKey("customers.id", ondelete="RESTRICT"), nullable=False)
210
+ delivery_status = Column(String, nullable=False)
211
+ shipped_at = Column(DateTime)
212
+ delivered_at = Column(DateTime)
213
+ created_at = Column(DateTime, default=datetime.utcnow)
214
+ updated_at = Column(DateTime, default=datetime.utcnow)
215
+ job = relationship("Job", foreign_keys=[job_id])
216
+ customer = relationship("Customer", foreign_keys=[customer_id])
217
+
218
+ class ShipmentPackage(Base):
219
+ __tablename__ = "shipment_packages"
220
+ id = Column(Integer, primary_key=True)
221
+ shipment_id = Column(Integer, ForeignKey("shipments.id", ondelete="CASCADE"), nullable=False)
222
+ package_number = Column(Integer, nullable=False)
223
+ weight_kg = Column(REAL, nullable=False)
224
+ tracking_number = Column(String, nullable=False)
225
+ created_at = Column(DateTime, default=datetime.utcnow)
226
+ updated_at = Column(DateTime, default=datetime.utcnow)
227
+ __table_args__ = (UniqueConstraint("shipment_id", "package_number"), UniqueConstraint("tracking_number"),)
228
+ shipment = relationship("Shipment", foreign_keys=[shipment_id])
229
+
230
+ Index("idx_users_username", User.username)
231
+ Index("idx_users_email", User.email)
232
+ Index("idx_customers_name", Customer.name)
233
+ Index("idx_product_templates_name", ProductTemplate.name)
234
+ Index("idx_pto_template", ProductTemplateOption.product_template_id)
235
+ Index("idx_pto_name_value", ProductTemplateOption.option_name, ProductTemplateOption.option_value)
236
+ Index("idx_sts_template", StandardTaskSequence.product_template_id)
237
+ Index("idx_custom_specs_customer", CustomSpec.customer_id)
238
+ Index("idx_custom_specs_template", CustomSpec.product_template_id)
239
+ Index("idx_quotes_customer", Quote.customer_id)
240
+ Index("idx_quotes_status", Quote.status)
241
+ Index("idx_jobs_job_number", Job.job_number)
242
+ Index("idx_jobs_customer", Job.customer_id)
243
+ Index("idx_jobs_status", Job.status)
244
+ Index("idx_jobs_due_date", Job.due_date)
245
+ Index("idx_work_centers_name", WorkCenter.name)
246
+ Index("idx_job_tasks_job", JobTask.job_id)
247
+ Index("idx_job_tasks_work_center", JobTask.work_center_id)
248
+ Index("idx_job_tasks_planned_range", JobTask.planned_start, JobTask.planned_finish)
249
+ Index("idx_time_logs_job_task", TimeLog.job_task_id)
250
+ Index("idx_time_logs_work_center", TimeLog.work_center_id)
251
+ Index("idx_time_logs_log_start", TimeLog.log_start)
252
+ Index("idx_materials_name", Material.name)
253
+ Index("idx_inventory_lots_material", InventoryLot.material_id)
254
+ Index("idx_inventory_lots_lot_number", InventoryLot.lot_number)
255
+ Index("idx_material_reservations_job", MaterialReservation.job_id)
256
+ Index("idx_material_reservations_lot", MaterialReservation.inventory_lot_id)
257
+ Index("idx_shipments_job", Shipment.job_id)
258
+ Index("idx_shipments_customer", Shipment.customer_id)
259
+ Index("idx_shipments_status", Shipment.delivery_status)
260
+ Index("idx_shipment_packages_shipment", ShipmentPackage.shipment_id)
261
+ Index("idx_shipment_packages_tracking", ShipmentPackage.tracking_number)
262
+
263
+ Base.metadata.create_all(bind=engine)
264
+
265
+ app = FastAPI(title="CraftBench Custom Manufacturing Job Tracker", version="1.0.0")
266
+
267
+ class CustomerCreateRequest(BaseModel):
268
+ name: str = Field(..., description="Unique customer name", example="Acme Robotics LLC")
269
+ billing_address: str = Field(..., description="Full billing address", example="1200 Industrial Way, Dayton, OH 45402")
270
+ contact_person: Optional[str] = Field(None, description="Primary contact person name", example="Maria Santos")
271
+ email: Optional[str] = Field(None, description="Primary contact email", example="m.santos@acmerobotics.com")
272
+ phone: Optional[str] = Field(None, description="Primary contact phone", example="+1-937-555-0142")
273
+
274
+ class CustomerResponse(BaseModel):
275
+ model_config = ConfigDict(from_attributes=True)
276
+ id: int = Field(..., description="Customer primary key", example=1)
277
+ name: str = Field(..., description="Customer name", example="Acme Robotics LLC")
278
+ billing_address: str = Field(..., description="Billing address", example="1200 Industrial Way, Dayton, OH 45402")
279
+ contact_person: Optional[str] = Field(None, description="Contact person", example="Maria Santos")
280
+ email: Optional[str] = Field(None, description="Contact email", example="m.santos@acmerobotics.com")
281
+ phone: Optional[str] = Field(None, description="Contact phone", example="+1-937-555-0142")
282
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T10:15:00Z")
283
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T10:15:00Z")
284
+
285
+ class CustomersListResponse(BaseModel):
286
+ items: List[CustomerResponse] = Field(..., description="List of customers", example=[])
287
+ total: int = Field(..., description="Total customers matching filter", example=1)
288
+
289
+ class ProductTemplateCreateRequest(BaseModel):
290
+ name: str = Field(..., description="Unique product template name", example="Steel Workbench Pro")
291
+ description: Optional[str] = Field(None, description="Template description", example="Heavy-duty steel workbench for industrial use")
292
+
293
+ class ProductTemplateResponse(BaseModel):
294
+ model_config = ConfigDict(from_attributes=True)
295
+ id: int = Field(..., description="Product template primary key", example=1)
296
+ name: str = Field(..., description="Template name", example="Steel Workbench Pro")
297
+ description: Optional[str] = Field(None, description="Template description", example="Heavy-duty steel workbench for industrial use")
298
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T10:20:00Z")
299
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T10:20:00Z")
300
+
301
+ class ProductTemplatesListResponse(BaseModel):
302
+ items: List[ProductTemplateResponse] = Field(..., description="List of product templates", example=[])
303
+ total: int = Field(..., description="Total templates matching filter", example=1)
304
+
305
+ class ProductTemplateOptionCreateRequest(BaseModel):
306
+ option_name: str = Field(..., description="Name of the option", example="color")
307
+ option_value: str = Field(..., description="Allowed value for the option", example="blue")
308
+
309
+ class ProductTemplateOptionResponse(BaseModel):
310
+ model_config = ConfigDict(from_attributes=True)
311
+ id: int = Field(..., description="Option primary key", example=1)
312
+ product_template_id: int = Field(..., description="Associated product template ID", example=1)
313
+ option_name: str = Field(..., description="Option name", example="color")
314
+ option_value: str = Field(..., description="Option value", example="blue")
315
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T10:25:00Z")
316
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T10:25:00Z")
317
+
318
+ class ProductTemplateOptionsListResponse(BaseModel):
319
+ items: List[ProductTemplateOptionResponse] = Field(..., description="List of template options", example=[])
320
+
321
+ class StandardTaskSequenceCreateRequest(BaseModel):
322
+ sequence_order: int = Field(..., description="Order of this task in the sequence", example=1)
323
+ task_name: str = Field(..., description="Name of the task operation", example="cutting")
324
+ default_planned_duration_hours: float = Field(..., description="Default planned duration in hours", example=1.5)
325
+
326
+ class StandardTaskSequenceResponse(BaseModel):
327
+ model_config = ConfigDict(from_attributes=True)
328
+ id: int = Field(..., description="Standard task primary key", example=1)
329
+ product_template_id: int = Field(..., description="Template ID", example=1)
330
+ sequence_order: int = Field(..., description="Sequence order index", example=1)
331
+ task_name: str = Field(..., description="Task name", example="cutting")
332
+ default_planned_duration_hours: float = Field(..., description="Planned duration in hours", example=1.5)
333
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T10:30:00Z")
334
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T10:30:00Z")
335
+
336
+ class StandardTaskSequencesListResponse(BaseModel):
337
+ items: List[StandardTaskSequenceResponse] = Field(..., description="Standard task sequence steps", example=[])
338
+
339
+ class CustomSpecCreateRequest(BaseModel):
340
+ customer_id: int = Field(..., description="Customer ID owning the spec", example=1)
341
+ product_template_id: int = Field(..., description="Product template ID", example=1)
342
+ notes: Optional[str] = Field(None, description="Freeform notes about the custom spec", example="Blue 6ft workbench with powder coat")
343
+
344
+ class CustomSpecResponse(BaseModel):
345
+ model_config = ConfigDict(from_attributes=True)
346
+ id: int = Field(..., description="Custom spec primary key", example=1)
347
+ customer_id: int = Field(..., description="Customer ID", example=1)
348
+ product_template_id: int = Field(..., description="Product template ID", example=1)
349
+ notes: Optional[str] = Field(None, description="Notes", example="Blue 6ft workbench with powder coat")
350
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T10:35:00Z")
351
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T10:35:00Z")
352
+
353
+ class CustomSpecsListResponse(BaseModel):
354
+ items: List[CustomSpecResponse] = Field(..., description="Custom specs", example=[])
355
+ total: int = Field(..., description="Total matching custom specs", example=1)
356
+
357
+ class CustomSpecOptionUpsertRequest(BaseModel):
358
+ option_name: str = Field(..., description="Option name", example="color")
359
+ option_value: str = Field(..., description="Option value to store", example="blue")
360
+
361
+ class CustomSpecOptionResponse(BaseModel):
362
+ model_config = ConfigDict(from_attributes=True)
363
+ id: int = Field(..., description="Custom spec option ID", example=1)
364
+ custom_spec_id: int = Field(..., description="Parent custom spec ID", example=1)
365
+ option_name: str = Field(..., description="Option name", example="color")
366
+ option_value: str = Field(..., description="Option value", example="blue")
367
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T10:40:00Z")
368
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T10:45:00Z")
369
+
370
+ class CustomSpecOptionsListResponse(BaseModel):
371
+ items: List[CustomSpecOptionResponse] = Field(..., description="Custom spec options", example=[])
372
+
373
+ class CustomSpecNumericParamUpsertRequest(BaseModel):
374
+ param_name: str = Field(..., description="Parameter name", example="length")
375
+ param_value: float = Field(..., description="Numeric value", example=1830.0)
376
+ unit: Optional[str] = Field(None, description="Measurement unit", example="mm")
377
+
378
+ class CustomSpecNumericParamResponse(BaseModel):
379
+ model_config = ConfigDict(from_attributes=True)
380
+ id: int = Field(..., description="Numeric param ID", example=1)
381
+ custom_spec_id: int = Field(..., description="Custom spec ID", example=1)
382
+ param_name: str = Field(..., description="Parameter name", example="length")
383
+ param_value: float = Field(..., description="Parameter value", example=1830.0)
384
+ unit: Optional[str] = Field(None, description="Parameter unit", example="mm")
385
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T10:45:00Z")
386
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T10:50:00Z")
387
+
388
+ class CustomSpecNumericParamsListResponse(BaseModel):
389
+ items: List[CustomSpecNumericParamResponse] = Field(..., description="Numeric parameters", example=[])
390
+
391
+ class QuoteCreateRequest(BaseModel):
392
+ quote_number: str = Field(..., description="Unique quote number", example="Q-2025-0147")
393
+ customer_id: int = Field(..., description="Customer ID for this quote", example=1)
394
+ custom_spec_id: Optional[int] = Field(None, description="Linked custom spec ID", example=1)
395
+ estimated_hours: float = Field(..., description="Estimated labor hours", example=12.0)
396
+ material_cost: float = Field(..., description="Estimated material cost", example=420.0)
397
+ labor_rate: float = Field(..., description="Labor rate per hour", example=65.0)
398
+ status: str = Field(..., description="Quote status", example="sent")
399
+ internal_note: Optional[str] = Field(None, description="Internal reference note", example="Rush order requested")
400
+
401
+ class QuoteResponse(BaseModel):
402
+ model_config = ConfigDict(from_attributes=True)
403
+ id: int = Field(..., description="Quote ID", example=1)
404
+ quote_number: str = Field(..., description="Quote number", example="Q-2025-0147")
405
+ customer_id: int = Field(..., description="Customer ID", example=1)
406
+ custom_spec_id: Optional[int] = Field(None, description="Custom spec ID or null", example=1)
407
+ estimated_hours: float = Field(..., description="Estimated hours", example=12.0)
408
+ material_cost: float = Field(..., description="Material cost", example=420.0)
409
+ labor_rate: float = Field(..., description="Labor rate", example=65.0)
410
+ status: str = Field(..., description="Quote status", example="sent")
411
+ internal_note: Optional[str] = Field(None, description="Internal note", example="Rush order requested")
412
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T10:55:00Z")
413
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T10:55:00Z")
414
+
415
+ class QuotesListItemResponse(BaseModel):
416
+ model_config = ConfigDict(from_attributes=True)
417
+ id: int = Field(..., description="Quote ID", example=1)
418
+ quote_number: str = Field(..., description="Quote number", example="Q-2025-0147")
419
+ customer_id: int = Field(..., description="Customer ID", example=1)
420
+ status: str = Field(..., description="Quote status", example="accepted")
421
+ estimated_hours: float = Field(..., description="Estimated hours", example=12.0)
422
+ material_cost: float = Field(..., description="Material cost", example=420.0)
423
+ labor_rate: float = Field(..., description="Labor rate", example=65.0)
424
+
425
+ class QuotesListResponse(BaseModel):
426
+ items: List[QuotesListItemResponse] = Field(..., description="Quotes", example=[])
427
+ total: int = Field(..., description="Total matching quotes", example=1)
428
+
429
+ class QuoteUpdateRequest(BaseModel):
430
+ status: Optional[str] = Field(None, description="New status for the quote", example="sent")
431
+ internal_note: Optional[str] = Field(None, description="Updated internal note", example="Customer confirmed")
432
+
433
+ class QuoteUpdateResponse(BaseModel):
434
+ model_config = ConfigDict(from_attributes=True)
435
+ id: int = Field(..., description="Quote ID", example=1)
436
+ quote_number: str = Field(..., description="Quote number", example="Q-2025-0147")
437
+ status: str = Field(..., description="Updated status", example="sent")
438
+ internal_note: Optional[str] = Field(None, description="Updated note", example="Customer confirmed")
439
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-02T09:00:00Z")
440
+
441
+ class JobCreateRequest(BaseModel):
442
+ job_number: str = Field(..., description="Unique job number", example="J-2025-0332")
443
+ customer_id: int = Field(..., description="Customer ID", example=1)
444
+ quote_id: Optional[int] = Field(None, description="Linked quote ID", example=1)
445
+ custom_spec_id: Optional[int] = Field(None, description="Linked custom spec ID", example=1)
446
+ priority: str = Field(..., description="Job priority", example="high")
447
+ due_date: Optional[datetime] = Field(None, description="Job due date (YYYY-MM-DD)", example="2026-01-20T00:00:00")
448
+ status: str = Field(..., description="Job status", example="planned")
449
+
450
+ class JobResponse(BaseModel):
451
+ model_config = ConfigDict(from_attributes=True)
452
+ id: int = Field(..., description="Job ID", example=1)
453
+ job_number: str = Field(..., description="Job number", example="J-2025-0332")
454
+ customer_id: int = Field(..., description="Customer ID", example=1)
455
+ quote_id: Optional[int] = Field(None, description="Quote ID", example=1)
456
+ custom_spec_id: Optional[int] = Field(None, description="Custom spec ID", example=1)
457
+ priority: str = Field(..., description="Job priority", example="high")
458
+ due_date: Optional[datetime] = Field(None, description="Due date", example="2026-01-20T00:00:00")
459
+ status: str = Field(..., description="Job status", example="planned")
460
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T11:00:00Z")
461
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T11:00:00Z")
462
+
463
+ class JobsListItemResponse(BaseModel):
464
+ model_config = ConfigDict(from_attributes=True)
465
+ id: int = Field(..., description="Job ID", example=1)
466
+ job_number: str = Field(..., description="Job number", example="J-2025-0332")
467
+ customer_id: int = Field(..., description="Customer ID", example=1)
468
+ status: str = Field(..., description="Job status", example="planned")
469
+ priority: str = Field(..., description="Job priority", example="high")
470
+ due_date: Optional[datetime] = Field(None, description="Due date", example="2026-01-20T00:00:00")
471
+
472
+ class JobsListResponse(BaseModel):
473
+ items: List[JobsListItemResponse] = Field(..., description="Jobs", example=[])
474
+ total: int = Field(..., description="Total matching jobs", example=1)
475
+
476
+ class JobUpdateRequest(BaseModel):
477
+ status: Optional[str] = Field(None, description="New job status", example="shipped")
478
+ priority: Optional[str] = Field(None, description="New job priority", example="high")
479
+ due_date: Optional[datetime] = Field(None, description="Updated job due date", example="2026-01-22T00:00:00")
480
+
481
+ class JobUpdateResponse(BaseModel):
482
+ model_config = ConfigDict(from_attributes=True)
483
+ id: int = Field(..., description="Job ID", example=1)
484
+ job_number: str = Field(..., description="Job number", example="J-2025-0279")
485
+ status: str = Field(..., description="Updated status", example="shipped")
486
+ priority: str = Field(..., description="Updated priority", example="high")
487
+ due_date: Optional[datetime] = Field(None, description="Updated due date", example="2026-01-22T00:00:00")
488
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-02T10:00:00Z")
489
+
490
+ class WorkCenterCreateRequest(BaseModel):
491
+ name: str = Field(..., description="Unique work center name", example="Laser Cutter LC-01")
492
+ description: Optional[str] = Field(None, description="Description of the work center", example="High power laser cutting machine")
493
+
494
+ class WorkCenterResponse(BaseModel):
495
+ model_config = ConfigDict(from_attributes=True)
496
+ id: int = Field(..., description="Work center ID", example=1)
497
+ name: str = Field(..., description="Work center name", example="Laser Cutter LC-01")
498
+ description: Optional[str] = Field(None, description="Work center description", example="High power laser cutting machine")
499
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T11:10:00Z")
500
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T11:10:00Z")
501
+
502
+ class WorkCentersListResponse(BaseModel):
503
+ items: List[WorkCenterResponse] = Field(..., description="Work centers", example=[])
504
+
505
+ class JobTaskCreateRequest(BaseModel):
506
+ task_code: str = Field(..., description="Unique task code", example="JT-8793")
507
+ job_id: int = Field(..., description="Associated job ID", example=1)
508
+ sequence_order: int = Field(..., description="Order within the job sequence", example=1)
509
+ task_name: str = Field(..., description="Task operation name", example="cutting")
510
+ work_center_id: int = Field(..., description="Work center ID for this task", example=1)
511
+ requiring_skill_level: Optional[str] = Field(None, description="Required operator skill level", example="intermediate")
512
+ planned_start: Optional[datetime] = Field(None, description="Planned start datetime in ISO8601", example="2026-01-05T08:00:00")
513
+ planned_finish: Optional[datetime] = Field(None, description="Planned finish datetime in ISO8601", example="2026-01-05T10:00:00")
514
+ planned_duration_hours: Optional[float] = Field(None, description="Planned duration in hours", example=2.0)
515
+
516
+ class JobTaskResponse(BaseModel):
517
+ model_config = ConfigDict(from_attributes=True)
518
+ id: int = Field(..., description="Job task ID", example=1)
519
+ task_code: str = Field(..., description="Unique task code", example="JT-8793")
520
+ job_id: int = Field(..., description="Job ID", example=1)
521
+ sequence_order: int = Field(..., description="Sequence order", example=1)
522
+ task_name: str = Field(..., description="Task name", example="cutting")
523
+ work_center_id: int = Field(..., description="Work center ID", example=1)
524
+ requiring_skill_level: Optional[str] = Field(None, description="Required skill level", example="intermediate")
525
+ planned_start: Optional[datetime] = Field(None, description="Planned start datetime", example="2026-01-05T08:00:00")
526
+ planned_finish: Optional[datetime] = Field(None, description="Planned finish datetime", example="2026-01-05T10:00:00")
527
+ planned_duration_hours: Optional[float] = Field(None, description="Planned duration hours", example=2.0)
528
+ actual_start: Optional[datetime] = Field(None, description="Actual start datetime or null", example=None)
529
+ actual_finish: Optional[datetime] = Field(None, description="Actual finish datetime or null", example=None)
530
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T11:15:00Z")
531
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T11:15:00Z")
532
+
533
+ class JobTasksListItemResponse(BaseModel):
534
+ model_config = ConfigDict(from_attributes=True)
535
+ id: int = Field(..., description="Task ID", example=1)
536
+ task_code: str = Field(..., description="Task code", example="JT-8793")
537
+ job_id: int = Field(..., description="Job ID", example=1)
538
+ sequence_order: int = Field(..., description="Sequence order", example=1)
539
+ task_name: str = Field(..., description="Task name", example="cutting")
540
+ work_center_id: int = Field(..., description="Work center ID", example=1)
541
+ planned_start: Optional[datetime] = Field(None, description="Planned start", example="2026-01-05T08:00:00")
542
+ planned_finish: Optional[datetime] = Field(None, description="Planned finish", example="2026-01-05T10:00:00")
543
+ planned_duration_hours: Optional[float] = Field(None, description="Planned duration", example=2.0)
544
+
545
+ class JobTasksListResponse(BaseModel):
546
+ items: List[JobTasksListItemResponse] = Field(..., description="Job tasks", example=[])
547
+ total: int = Field(..., description="Total matching tasks", example=3)
548
+
549
+ class TimeLogCreateRequest(BaseModel):
550
+ job_task_id: int = Field(..., description="Job task ID being logged", example=1)
551
+ operator_username: str = Field(..., description="Username of the operator", example="op_jwilliams")
552
+ work_center_id: int = Field(..., description="Work center ID where work was performed", example=2)
553
+ log_start: Optional[datetime] = Field(None, description="Start datetime of the log; defaults to now", example="2026-01-05T11:05:00")
554
+ actual_duration_hours: float = Field(..., description="Actual duration in hours", example=2.4)
555
+ scrap_quantity: Optional[int] = Field(None, description="Quantity scrapped during this log", example=1)
556
+ note: Optional[str] = Field(None, description="Notes about the work performed", example="Rewelded one bracket")
557
+
558
+ class TimeLogResponse(BaseModel):
559
+ model_config = ConfigDict(from_attributes=True)
560
+ id: int = Field(..., description="Time log ID", example=1)
561
+ job_task_id: int = Field(..., description="Job task ID", example=1)
562
+ operator_username: str = Field(..., description="Operator username", example="op_jwilliams")
563
+ work_center_id: int = Field(..., description="Work center ID", example=2)
564
+ log_start: Optional[datetime] = Field(None, description="Log start datetime", example="2026-01-05T11:05:00")
565
+ actual_duration_hours: float = Field(..., description="Actual duration hours", example=2.4)
566
+ scrap_quantity: Optional[int] = Field(None, description="Scrap quantity", example=1)
567
+ note: Optional[str] = Field(None, description="Log note", example="Rewelded one bracket")
568
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2026-01-05T13:50:00Z")
569
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2026-01-05T13:50:00Z")
570
+
571
+ class TimeLogsListItemResponse(BaseModel):
572
+ model_config = ConfigDict(from_attributes=True)
573
+ id: int = Field(..., description="Time log ID", example=1)
574
+ job_task_id: int = Field(..., description="Job task ID", example=1)
575
+ operator_username: str = Field(..., description="Operator username", example="op_jwilliams")
576
+ work_center_id: int = Field(..., description="Work center ID", example=2)
577
+ log_start: Optional[datetime] = Field(None, description="Log start datetime", example="2026-01-05T11:05:00")
578
+ actual_duration_hours: float = Field(..., description="Duration hours", example=2.4)
579
+ scrap_quantity: Optional[int] = Field(None, description="Scrap quantity", example=1)
580
+
581
+ class TimeLogsListResponse(BaseModel):
582
+ items: List[TimeLogsListItemResponse] = Field(..., description="Time logs", example=[])
583
+ total: int = Field(..., description="Total matching time logs", example=5)
584
+
585
+ class MaterialCreateRequest(BaseModel):
586
+ name: str = Field(..., description="Unique material name", example="Cold Rolled Steel Sheet 2mm")
587
+ unit_of_measure: str = Field(..., description="Unit of measure", example="kg")
588
+
589
+ class MaterialResponse(BaseModel):
590
+ model_config = ConfigDict(from_attributes=True)
591
+ id: int = Field(..., description="Material ID", example=1)
592
+ name: str = Field(..., description="Material name", example="Cold Rolled Steel Sheet 2mm")
593
+ unit_of_measure: str = Field(..., description="Unit of measure", example="kg")
594
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T11:25:00Z")
595
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T11:25:00Z")
596
+
597
+ class MaterialsListResponse(BaseModel):
598
+ items: List[MaterialResponse] = Field(..., description="Materials", example=[])
599
+
600
+ class InventoryLotCreateRequest(BaseModel):
601
+ lot_number: str = Field(..., description="Unique lot identifier", example="LOT-CRS-2401")
602
+ material_id: int = Field(..., description="Associated material ID", example=1)
603
+ on_hand_quantity: float = Field(..., description="Initial on hand quantity", example=1000.0)
604
+ reserved_quantity: Optional[float] = Field(0.0, description="Initial reserved quantity", example=0.0)
605
+
606
+ class InventoryLotResponse(BaseModel):
607
+ model_config = ConfigDict(from_attributes=True)
608
+ id: int = Field(..., description="Inventory lot ID", example=1)
609
+ lot_number: str = Field(..., description="Lot number", example="LOT-CRS-2401")
610
+ material_id: int = Field(..., description="Material ID", example=1)
611
+ on_hand_quantity: float = Field(..., description="On hand quantity", example=1000.0)
612
+ reserved_quantity: float = Field(..., description="Reserved quantity", example=150.0)
613
+ created_at: Optional[datetime] = Field(None, description="Creation time", example="2025-01-01T11:30:00Z")
614
+ updated_at: Optional[datetime] = Field(None, description="Last update time", example="2025-01-01T11:30:00Z")
615
+
616
+ class InventoryLotsListItemResponse(BaseModel):
617
+ model_config = ConfigDict(from_attributes=True)
618
+ id: int = Field(..., description="Lot ID", example=1)
619
+ lot_number: str = Field(..., description="Lot number", example="LOT-CRS-2401")
620
+ material_id: int = Field(..., description="Material ID", example=1)
621
+ on_hand_quantity: float = Field(..., description="On hand quantity", example=850.0)
622
+ reserved_quantity: float = Field(..., description="Reserved quantity", example=150.0)
623
+
624
+ class InventoryLotsListResponse(BaseModel):
625
+ items: List[InventoryLotsListItemResponse] = Field(..., description="Inventory lots", example=[])
626
+
627
+ class InventoryLotAdjustRequest(BaseModel):
628
+ on_hand_delta: Optional[float] = Field(None, description="Delta to apply to on_hand_quantity", example=-150.0)
629
+ reserved_delta: Optional[float] = Field(None, description="Delta to apply to reserved_quantity", example=150.0)
630
+
631
+ class InventoryLotAdjustResponse(BaseModel):
632
+ model_config = ConfigDict(from_attributes=True)
633
+ id: int = Field(..., description="Inventory lot ID", example=1)
634
+ lot_number: str = Field(..., description="Lot number", example="LOT-CRS-2401")
635
+ on_hand_quantity: float = Field(..., description="Updated on hand quantity", example=850.0)
636
+ reserved_quantity: float = Field(..., description="Updated reserved quantity", example=150.0)
637
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-02T09:00:00Z")
638
+
639
+ class MaterialReservationCreateRequest(BaseModel):
640
+ job_id: int = Field(..., description="Job ID that is reserving material", example=1)
641
+ inventory_lot_id: int = Field(..., description="Inventory lot ID to reserve from", example=1)
642
+ quantity: float = Field(..., description="Quantity to reserve", example=150.0)
643
+
644
+ class MaterialReservationResponse(BaseModel):
645
+ model_config = ConfigDict(from_attributes=True)
646
+ id: int = Field(..., description="Material reservation ID", example=1)
647
+ job_id: int = Field(..., description="Job ID", example=1)
648
+ inventory_lot_id: int = Field(..., description="Inventory lot ID", example=1)
649
+ quantity: float = Field(..., description="Reserved quantity", example=150.0)
650
+ created_at: Optional[datetime] = Field(None, description="Creation timestamp", example="2025-01-01T11:35:00Z")
651
+ updated_at: Optional[datetime] = Field(None, description="Last update timestamp", example="2025-01-01T11:35:00Z")
652
+
653
+ class MaterialReservationsListItemResponse(BaseModel):
654
+ model_config = ConfigDict(from_attributes=True)
655
+ id: int = Field(..., description="Reservation ID", example=1)
656
+ job_id: int = Field(..., description="Job ID", example=1)
657
+ inventory_lot_id: int = Field(..., description="Inventory lot ID", example=1)
658
+ quantity: float = Field(..., description="Reserved quantity", example=150.0)
659
+
660
+ class MaterialReservationsListResponse(BaseModel):
661
+ items: List[MaterialReservationsListItemResponse] = Field(..., description="Material reservations", example=[])
662
+
663
+ class ShipmentCreateRequest(BaseModel):
664
+ shipment_number: str = Field(..., description="Unique shipment number", example="SHP-2025-0101")
665
+ job_id: int = Field(..., description="Job ID being shipped", example=1)
666
+ customer_id: int = Field(..., description="Customer receiving the shipment", example=1)
667
+ delivery_status: str = Field(..., description="Shipment status", example="in_transit")
668
+ shipped_at: Optional[datetime] = Field(None, description="Datetime when shipment left the facility", example="2026-01-10T15:00:00")
669
+ delivered_at: Optional[datetime] = Field(None, description="Datetime when shipment was delivered", example=None)
670
+
671
+ class ShipmentResponse(BaseModel):
672
+ model_config = ConfigDict(from_attributes=True)
673
+ id: int = Field(..., description="Shipment ID", example=1)
674
+ shipment_number: str = Field(..., description="Shipment number", example="SHP-2025-0101")
675
+ job_id: int = Field(..., description="Job ID", example=1)
676
+ customer_id: int = Field(..., description="Customer ID", example=1)
677
+ delivery_status: str = Field(..., description="Shipment status", example="in_transit")
678
+ shipped_at: Optional[datetime] = Field(None, description="Shipped datetime", example="2026-01-10T15:00:00")
679
+ delivered_at: Optional[datetime] = Field(None, description="Delivered datetime or null", example=None)
680
+ created_at: Optional[datetime] = Field(None, description="Creation time", example="2026-01-10T15:05:00Z")
681
+ updated_at: Optional[datetime] = Field(None, description="Last update time", example="2026-01-10T15:05:00Z")
682
+
683
+ class ShipmentsListItemResponse(BaseModel):
684
+ model_config = ConfigDict(from_attributes=True)
685
+ id: int = Field(..., description="Shipment ID", example=1)
686
+ shipment_number: str = Field(..., description="Shipment number", example="SHP-2025-0101")
687
+ job_id: int = Field(..., description="Job ID", example=1)
688
+ customer_id: int = Field(..., description="Customer ID", example=1)
689
+ delivery_status: str = Field(..., description="Shipment status", example="in_transit")
690
+
691
+ class ShipmentsListResponse(BaseModel):
692
+ items: List[ShipmentsListItemResponse] = Field(..., description="Shipments", example=[])
693
+
694
+ class ShipmentUpdateRequest(BaseModel):
695
+ delivery_status: Optional[str] = Field(None, description="New delivery status", example="delivered")
696
+ shipped_at: Optional[datetime] = Field(None, description="Updated shipped_at datetime", example="2026-01-10T15:00:00")
697
+ delivered_at: Optional[datetime] = Field(None, description="Updated delivered_at datetime", example="2026-01-15T11:30:00")
698
+
699
+ class ShipmentUpdateResponse(BaseModel):
700
+ model_config = ConfigDict(from_attributes=True)
701
+ id: int = Field(..., description="Shipment ID", example=1)
702
+ shipment_number: str = Field(..., description="Shipment number", example="SHP-2025-0101")
703
+ delivery_status: str = Field(..., description="Updated delivery status", example="delivered")
704
+ shipped_at: Optional[datetime] = Field(None, description="Shipped datetime", example="2026-01-10T15:00:00")
705
+ delivered_at: Optional[datetime] = Field(None, description="Delivered datetime", example="2026-01-15T11:30:00")
706
+ updated_at: Optional[datetime] = Field(None, description="Last update time", example="2026-01-15T11:35:00Z")
707
+
708
+ class ShipmentPackageCreateRequest(BaseModel):
709
+ shipment_id: int = Field(..., description="Shipment ID that this package belongs to", example=1)
710
+ package_number: int = Field(..., description="Sequential package number within the shipment", example=1)
711
+ weight_kg: float = Field(..., description="Weight of the package in kg", example=45.0)
712
+ tracking_number: str = Field(..., description="Unique tracking number", example="CBX123456US")
713
+
714
+ class ShipmentPackageResponse(BaseModel):
715
+ model_config = ConfigDict(from_attributes=True)
716
+ id: int = Field(..., description="Shipment package ID", example=1)
717
+ shipment_id: int = Field(..., description="Shipment ID", example=1)
718
+ package_number: int = Field(..., description="Package number within shipment", example=1)
719
+ weight_kg: float = Field(..., description="Package weight in kg", example=45.0)
720
+ tracking_number: str = Field(..., description="Tracking number", example="CBX123456US")
721
+ created_at: Optional[datetime] = Field(None, description="Creation time", example="2026-01-10T15:10:00Z")
722
+ updated_at: Optional[datetime] = Field(None, description="Last update time", example="2026-01-10T15:10:00Z")
723
+
724
+ class ShipmentPackagesListItemResponse(BaseModel):
725
+ model_config = ConfigDict(from_attributes=True)
726
+ id: int = Field(..., description="Package ID", example=1)
727
+ shipment_id: int = Field(..., description="Shipment ID", example=1)
728
+ package_number: int = Field(..., description="Package number", example=1)
729
+ weight_kg: float = Field(..., description="Weight in kg", example=38.5)
730
+ tracking_number: str = Field(..., description="Tracking number", example="CBX123457US")
731
+
732
+ class ShipmentPackagesListResponse(BaseModel):
733
+ items: List[ShipmentPackagesListItemResponse] = Field(..., description="Shipment packages", example=[])
734
+
735
+ class CapacityTaskItem(BaseModel):
736
+ job_task_id: int = Field(..., description="Job task ID", example=10)
737
+ task_code: str = Field(..., description="Task code", example="JT-8801")
738
+ job_id: int = Field(..., description="Job ID", example=5)
739
+ task_name: str = Field(..., description="Task name", example="cutting")
740
+ planned_start: Optional[datetime] = Field(None, description="Planned start datetime", example="2026-01-05T08:00:00")
741
+ planned_finish: Optional[datetime] = Field(None, description="Planned finish datetime", example="2026-01-05T10:00:00")
742
+ planned_duration_hours: Optional[float] = Field(None, description="Planned hours for this task", example=2.0)
743
+ actual_hours: float = Field(..., description="Sum of actual_duration_hours from time_logs", example=1.8)
744
+
745
+ class CapacityUtilizationResponse(BaseModel):
746
+ work_center_id: int = Field(..., description="Analyzed work center ID", example=1)
747
+ planned_from: datetime = Field(..., description="Start of analysis window", example="2026-01-01T00:00:00")
748
+ planned_to: datetime = Field(..., description="End of analysis window", example="2026-01-31T23:59:59")
749
+ total_planned_hours: float = Field(..., description="Sum of planned_duration_hours", example=120.0)
750
+ total_actual_hours: float = Field(..., description="Sum of actual_duration_hours", example=98.5)
751
+ job_tasks: List[CapacityTaskItem] = Field(..., description="Job tasks scheduled in the period", example=[])
752
+
753
+ @app.post("/api/customers", response_model=CustomerResponse, summary="Create a new customer", description="Add a new customer with billing and contact details", tags=["customers"], operation_id="create_customer")
754
+ async def create_customer(request: CustomerCreateRequest = Body(...)) -> CustomerResponse:
755
+ session = SessionLocal()
756
+ obj = Customer(
757
+ name=request.name,
758
+ billing_address=request.billing_address,
759
+ contact_person=request.contact_person,
760
+ email=request.email,
761
+ phone=request.phone,
762
+ created_at=datetime.utcnow(),
763
+ updated_at=datetime.utcnow(),
764
+ )
765
+ session.add(obj)
766
+ session.commit()
767
+ session.refresh(obj)
768
+ session.close()
769
+ return CustomerResponse.model_validate(obj)
770
+
771
+ @app.get("/api/customers", response_model=CustomersListResponse, summary="List customers with optional name filter", description="Retrieve customers, optionally filtering by exact or partial name", tags=["customers"], operation_id="list_customers")
772
+ async def list_customers(name: Optional[str] = Query(None, description="Filter by name containing this text", example="Acme"), limit: Optional[int] = Query(50, description="Maximum records to return", example=50), offset: Optional[int] = Query(0, description="Offset for pagination", example=0)) -> CustomersListResponse:
773
+ session = SessionLocal()
774
+ query = session.query(Customer)
775
+ if name is not None:
776
+ query = query.filter(Customer.name.contains(name))
777
+ total = query.count()
778
+ objs = query.offset(offset).limit(limit).all()
779
+ items = [CustomerResponse.model_validate(o) for o in objs]
780
+ session.close()
781
+ return CustomersListResponse(items=items, total=total)
782
+
783
+ @app.get("/api/customers/{customer_id}", response_model=CustomerResponse, summary="Get a customer by ID", description="Retrieve a single customer record by its numeric ID", tags=["customers"], operation_id="get_customer_by_id")
784
+ async def get_customer_by_id(customer_id: int = Path(..., description="Customer primary key ID", example=1)) -> CustomerResponse:
785
+ session = SessionLocal()
786
+ obj = session.query(Customer).filter(Customer.id == customer_id).first()
787
+ session.close()
788
+ if obj is None:
789
+ return CustomerResponse(id=0, name="", billing_address="", contact_person=None, email=None, phone=None, created_at=None, updated_at=None)
790
+ return CustomerResponse.model_validate(obj)
791
+
792
+ @app.get("/api/customers/by-name/{customer_name}", response_model=CustomerResponse, summary="Get a customer by exact name", description="Lookup a single customer using its unique name", tags=["customers"], operation_id="get_customer_by_name")
793
+ async def get_customer_by_name(customer_name: str = Path(..., description="Exact customer name to lookup", example="Acme Robotics LLC")) -> CustomerResponse:
794
+ session = SessionLocal()
795
+ obj = session.query(Customer).filter(Customer.name == customer_name).first()
796
+ session.close()
797
+ if obj is None:
798
+ return CustomerResponse(id=0, name="", billing_address="", contact_person=None, email=None, phone=None, created_at=None, updated_at=None)
799
+ return CustomerResponse.model_validate(obj)
800
+
801
+ @app.post("/api/product-templates", response_model=ProductTemplateResponse, summary="Create a new product template", description="Define a new product template record with optional description", tags=["product_templates"], operation_id="create_product_template")
802
+ async def create_product_template(request: ProductTemplateCreateRequest = Body(...)) -> ProductTemplateResponse:
803
+ session = SessionLocal()
804
+ obj = ProductTemplate(
805
+ name=request.name,
806
+ description=request.description,
807
+ created_at=datetime.utcnow(),
808
+ updated_at=datetime.utcnow(),
809
+ )
810
+ session.add(obj)
811
+ session.commit()
812
+ session.refresh(obj)
813
+ session.close()
814
+ return ProductTemplateResponse.model_validate(obj)
815
+
816
+ @app.get("/api/product-templates", response_model=ProductTemplatesListResponse, summary="List product templates", description="Retrieve product templates with optional name filter", tags=["product_templates"], operation_id="list_product_templates")
817
+ async def list_product_templates(name: Optional[str] = Query(None, description="Filter templates containing this name", example="Workbench"), limit: Optional[int] = Query(50, description="Max number of templates to return", example=50), offset: Optional[int] = Query(0, description="Offset for pagination", example=0)) -> ProductTemplatesListResponse:
818
+ session = SessionLocal()
819
+ query = session.query(ProductTemplate)
820
+ if name is not None:
821
+ query = query.filter(ProductTemplate.name.contains(name))
822
+ total = query.count()
823
+ objs = query.offset(offset).limit(limit).all()
824
+ items = [ProductTemplateResponse.model_validate(o) for o in objs]
825
+ session.close()
826
+ return ProductTemplatesListResponse(items=items, total=total)
827
+
828
+ @app.get("/api/product-templates/{product_template_id}", response_model=ProductTemplateResponse, summary="Get product template by ID", description="Retrieve a single product template using its ID", tags=["product_templates"], operation_id="get_product_template_by_id")
829
+ async def get_product_template_by_id(product_template_id: int = Path(..., description="Product template ID", example=1)) -> ProductTemplateResponse:
830
+ session = SessionLocal()
831
+ obj = session.query(ProductTemplate).filter(ProductTemplate.id == product_template_id).first()
832
+ session.close()
833
+ if obj is None:
834
+ return ProductTemplateResponse(id=0, name="", description=None, created_at=None, updated_at=None)
835
+ return ProductTemplateResponse.model_validate(obj)
836
+
837
+ @app.get("/api/product-templates/by-name/{template_name}", response_model=ProductTemplateResponse, summary="Get product template by exact name", description="Lookup a product template using its unique name", tags=["product_templates"], operation_id="get_product_template_by_name")
838
+ async def get_product_template_by_name(template_name: str = Path(..., description="Exact product template name", example="Steel Workbench Pro")) -> ProductTemplateResponse:
839
+ session = SessionLocal()
840
+ obj = session.query(ProductTemplate).filter(ProductTemplate.name == template_name).first()
841
+ session.close()
842
+ if obj is None:
843
+ return ProductTemplateResponse(id=0, name="", description=None, created_at=None, updated_at=None)
844
+ return ProductTemplateResponse.model_validate(obj)
845
+
846
+ @app.post("/api/product-templates/{product_template_id}/options", response_model=ProductTemplateOptionResponse, summary="Create an option for a product template", description="Add a single option value for a given product template", tags=["product_template_options"], operation_id="create_product_template_option")
847
+ async def create_product_template_option(product_template_id: int = Path(..., description="Parent product template ID", example=1), request: ProductTemplateOptionCreateRequest = Body(...)) -> ProductTemplateOptionResponse:
848
+ session = SessionLocal()
849
+ obj = ProductTemplateOption(
850
+ product_template_id=product_template_id,
851
+ option_name=request.option_name,
852
+ option_value=request.option_value,
853
+ created_at=datetime.utcnow(),
854
+ updated_at=datetime.utcnow(),
855
+ )
856
+ session.add(obj)
857
+ session.commit()
858
+ session.refresh(obj)
859
+ session.close()
860
+ return ProductTemplateOptionResponse.model_validate(obj)
861
+
862
+ @app.get("/api/product-templates/{product_template_id}/options", response_model=ProductTemplateOptionsListResponse, summary="List options for a product template", description="Retrieve all option values for a specific product template", tags=["product_template_options"], operation_id="list_product_template_options")
863
+ async def list_product_template_options(product_template_id: int = Path(..., description="Product template ID", example=1), option_name: Optional[str] = Query(None, description="Filter by option name", example="color")) -> ProductTemplateOptionsListResponse:
864
+ session = SessionLocal()
865
+ query = session.query(ProductTemplateOption).filter(ProductTemplateOption.product_template_id == product_template_id)
866
+ if option_name is not None:
867
+ query = query.filter(ProductTemplateOption.option_name == option_name)
868
+ objs = query.all()
869
+ items = [ProductTemplateOptionResponse.model_validate(o) for o in objs]
870
+ session.close()
871
+ return ProductTemplateOptionsListResponse(items=items)
872
+
873
+ @app.post("/api/product-templates/{product_template_id}/standard-tasks", response_model=StandardTaskSequenceResponse, summary="Create a standard task for a template", description="Add a single task step into a product template's standard sequence", tags=["standard_task_sequences"], operation_id="create_standard_task_sequence")
874
+ async def create_standard_task_sequence(product_template_id: int = Path(..., description="Product template ID", example=1), request: StandardTaskSequenceCreateRequest = Body(...)) -> StandardTaskSequenceResponse:
875
+ session = SessionLocal()
876
+ obj = StandardTaskSequence(
877
+ product_template_id=product_template_id,
878
+ sequence_order=request.sequence_order,
879
+ task_name=request.task_name,
880
+ default_planned_duration_hours=request.default_planned_duration_hours,
881
+ created_at=datetime.utcnow(),
882
+ updated_at=datetime.utcnow(),
883
+ )
884
+ session.add(obj)
885
+ session.commit()
886
+ session.refresh(obj)
887
+ session.close()
888
+ return StandardTaskSequenceResponse.model_validate(obj)
889
+
890
+ @app.get("/api/product-templates/{product_template_id}/standard-tasks", response_model=StandardTaskSequencesListResponse, summary="List standard tasks for a template", description="Retrieve all standard tasks for a product template ordered by sequence", tags=["standard_task_sequences"], operation_id="list_standard_task_sequences")
891
+ async def list_standard_task_sequences(product_template_id: int = Path(..., description="Product template ID", example=1)) -> StandardTaskSequencesListResponse:
892
+ session = SessionLocal()
893
+ objs = session.query(StandardTaskSequence).filter(StandardTaskSequence.product_template_id == product_template_id).order_by(StandardTaskSequence.sequence_order.asc()).all()
894
+ items = [StandardTaskSequenceResponse.model_validate(o) for o in objs]
895
+ session.close()
896
+ return StandardTaskSequencesListResponse(items=items)
897
+
898
+ @app.post("/api/custom-specs", response_model=CustomSpecResponse, summary="Create a custom specification", description="Create a custom specification linking a customer and product template", tags=["custom_specs"], operation_id="create_custom_spec")
899
+ async def create_custom_spec(request: CustomSpecCreateRequest = Body(...)) -> CustomSpecResponse:
900
+ session = SessionLocal()
901
+ obj = CustomSpec(
902
+ customer_id=request.customer_id,
903
+ product_template_id=request.product_template_id,
904
+ notes=request.notes,
905
+ created_at=datetime.utcnow(),
906
+ updated_at=datetime.utcnow(),
907
+ )
908
+ session.add(obj)
909
+ session.commit()
910
+ session.refresh(obj)
911
+ session.close()
912
+ return CustomSpecResponse.model_validate(obj)
913
+
914
+ @app.get("/api/custom-specs", response_model=CustomSpecsListResponse, summary="List custom specs", description="List custom specs with optional filters by customer or product template", tags=["custom_specs"], operation_id="list_custom_specs")
915
+ async def list_custom_specs(customer_id: Optional[int] = Query(None, description="Filter by customer ID", example=1), product_template_id: Optional[int] = Query(None, description="Filter by product template ID", example=1), limit: Optional[int] = Query(50, description="Max records to return", example=50), offset: Optional[int] = Query(0, description="Offset for pagination", example=0)) -> CustomSpecsListResponse:
916
+ session = SessionLocal()
917
+ query = session.query(CustomSpec)
918
+ if customer_id is not None:
919
+ query = query.filter(CustomSpec.customer_id == customer_id)
920
+ if product_template_id is not None:
921
+ query = query.filter(CustomSpec.product_template_id == product_template_id)
922
+ total = query.count()
923
+ objs = query.offset(offset).limit(limit).all()
924
+ items = [CustomSpecResponse.model_validate(o) for o in objs]
925
+ session.close()
926
+ return CustomSpecsListResponse(items=items, total=total)
927
+
928
+ @app.get("/api/custom-specs/{custom_spec_id}", response_model=CustomSpecResponse, summary="Get custom spec by ID", description="Retrieve a single custom spec by its ID", tags=["custom_specs"], operation_id="get_custom_spec_by_id")
929
+ async def get_custom_spec_by_id(custom_spec_id: int = Path(..., description="Custom spec ID", example=1)) -> CustomSpecResponse:
930
+ session = SessionLocal()
931
+ obj = session.query(CustomSpec).filter(CustomSpec.id == custom_spec_id).first()
932
+ session.close()
933
+ if obj is None:
934
+ return CustomSpecResponse(id=0, customer_id=0, product_template_id=0, notes=None, created_at=None, updated_at=None)
935
+ return CustomSpecResponse.model_validate(obj)
936
+
937
+ @app.post("/api/custom-specs/{custom_spec_id}/options", response_model=CustomSpecOptionResponse, summary="Create or update a custom spec option", description="Set a named option value for a custom spec, upserting by option name", tags=["custom_spec_options"], operation_id="upsert_custom_spec_option")
938
+ async def upsert_custom_spec_option(custom_spec_id: int = Path(..., description="Custom spec ID", example=1), request: CustomSpecOptionUpsertRequest = Body(...)) -> CustomSpecOptionResponse:
939
+ session = SessionLocal()
940
+ obj = session.query(CustomSpecOption).filter(CustomSpecOption.custom_spec_id == custom_spec_id, CustomSpecOption.option_name == request.option_name).first()
941
+ now = datetime.utcnow()
942
+ if obj is None:
943
+ obj = CustomSpecOption(
944
+ custom_spec_id=custom_spec_id,
945
+ option_name=request.option_name,
946
+ option_value=request.option_value,
947
+ created_at=now,
948
+ updated_at=now,
949
+ )
950
+ session.add(obj)
951
+ else:
952
+ obj.option_value = request.option_value
953
+ obj.updated_at = now
954
+ session.commit()
955
+ session.refresh(obj)
956
+ session.close()
957
+ return CustomSpecOptionResponse.model_validate(obj)
958
+
959
+ @app.get("/api/custom-specs/{custom_spec_id}/options", response_model=CustomSpecOptionsListResponse, summary="List options for a custom spec", description="Retrieve all option name/value pairs for a custom spec", tags=["custom_spec_options"], operation_id="list_custom_spec_options")
960
+ async def list_custom_spec_options(custom_spec_id: int = Path(..., description="Custom spec ID", example=1)) -> CustomSpecOptionsListResponse:
961
+ session = SessionLocal()
962
+ objs = session.query(CustomSpecOption).filter(CustomSpecOption.custom_spec_id == custom_spec_id).all()
963
+ items = [CustomSpecOptionResponse.model_validate(o) for o in objs]
964
+ session.close()
965
+ return CustomSpecOptionsListResponse(items=items)
966
+
967
+ @app.post("/api/custom-specs/{custom_spec_id}/numeric-params", response_model=CustomSpecNumericParamResponse, summary="Create or update a numeric param", description="Set a numeric parameter with unit for a custom spec, upserting by name", tags=["custom_spec_numeric_params"], operation_id="upsert_custom_spec_numeric_param")
968
+ async def upsert_custom_spec_numeric_param(custom_spec_id: int = Path(..., description="Custom spec ID", example=1), request: CustomSpecNumericParamUpsertRequest = Body(...)) -> CustomSpecNumericParamResponse:
969
+ session = SessionLocal()
970
+ obj = session.query(CustomSpecNumericParam).filter(CustomSpecNumericParam.custom_spec_id == custom_spec_id, CustomSpecNumericParam.param_name == request.param_name).first()
971
+ now = datetime.utcnow()
972
+ if obj is None:
973
+ obj = CustomSpecNumericParam(
974
+ custom_spec_id=custom_spec_id,
975
+ param_name=request.param_name,
976
+ param_value=request.param_value,
977
+ unit=request.unit,
978
+ created_at=now,
979
+ updated_at=now,
980
+ )
981
+ session.add(obj)
982
+ else:
983
+ obj.param_value = request.param_value
984
+ obj.unit = request.unit
985
+ obj.updated_at = now
986
+ session.commit()
987
+ session.refresh(obj)
988
+ session.close()
989
+ return CustomSpecNumericParamResponse.model_validate(obj)
990
+
991
+ @app.get("/api/custom-specs/{custom_spec_id}/numeric-params", response_model=CustomSpecNumericParamsListResponse, summary="List numeric params for a custom spec", description="Retrieve all numeric parameters and units for a custom spec", tags=["custom_spec_numeric_params"], operation_id="list_custom_spec_numeric_params")
992
+ async def list_custom_spec_numeric_params(custom_spec_id: int = Path(..., description="Custom spec ID", example=1)) -> CustomSpecNumericParamsListResponse:
993
+ session = SessionLocal()
994
+ objs = session.query(CustomSpecNumericParam).filter(CustomSpecNumericParam.custom_spec_id == custom_spec_id).all()
995
+ items = [CustomSpecNumericParamResponse.model_validate(o) for o in objs]
996
+ session.close()
997
+ return CustomSpecNumericParamsListResponse(items=items)
998
+
999
+ @app.post("/api/quotes", response_model=QuoteResponse, summary="Create a quote", description="Create a quote linked to a customer and optional custom spec", tags=["quotes"], operation_id="create_quote")
1000
+ async def create_quote(request: QuoteCreateRequest = Body(...)) -> QuoteResponse:
1001
+ session = SessionLocal()
1002
+ obj = Quote(
1003
+ quote_number=request.quote_number,
1004
+ customer_id=request.customer_id,
1005
+ custom_spec_id=request.custom_spec_id,
1006
+ estimated_hours=request.estimated_hours,
1007
+ material_cost=request.material_cost,
1008
+ labor_rate=request.labor_rate,
1009
+ status=request.status,
1010
+ internal_note=request.internal_note,
1011
+ created_at=datetime.utcnow(),
1012
+ updated_at=datetime.utcnow(),
1013
+ )
1014
+ session.add(obj)
1015
+ session.commit()
1016
+ session.refresh(obj)
1017
+ session.close()
1018
+ return QuoteResponse.model_validate(obj)
1019
+
1020
+ @app.get("/api/quotes", response_model=QuotesListResponse, summary="List quotes with filters", description="Retrieve quotes filtered by customer, status, or quote number", tags=["quotes"], operation_id="list_quotes")
1021
+ async def list_quotes(quote_number: Optional[str] = Query(None, description="Filter by exact quote number", example="Q-2025-0147"), customer_id: Optional[int] = Query(None, description="Filter by customer ID", example=1), status: Optional[str] = Query(None, description="Filter by quote status", example="accepted"), limit: Optional[int] = Query(50, description="Max records to return", example=50), offset: Optional[int] = Query(0, description="Offset for pagination", example=0)) -> QuotesListResponse:
1022
+ session = SessionLocal()
1023
+ query = session.query(Quote)
1024
+ if quote_number is not None:
1025
+ query = query.filter(Quote.quote_number == quote_number)
1026
+ if customer_id is not None:
1027
+ query = query.filter(Quote.customer_id == customer_id)
1028
+ if status is not None:
1029
+ query = query.filter(Quote.status == status)
1030
+ total = query.count()
1031
+ objs = query.offset(offset).limit(limit).all()
1032
+ items = [QuotesListItemResponse.model_validate(o) for o in objs]
1033
+ session.close()
1034
+ return QuotesListResponse(items=items, total=total)
1035
+
1036
+ @app.get("/api/quotes/by-number/{quote_number}", response_model=QuoteResponse, summary="Get quote by quote number", description="Retrieve a single quote by its unique quote_number", tags=["quotes"], operation_id="get_quote_by_number")
1037
+ async def get_quote_by_number(quote_number: str = Path(..., description="Exact quote number to lookup", example="Q-2025-0147")) -> QuoteResponse:
1038
+ session = SessionLocal()
1039
+ obj = session.query(Quote).filter(Quote.quote_number == quote_number).first()
1040
+ session.close()
1041
+ if obj is None:
1042
+ return QuoteResponse(id=0, quote_number="", customer_id=0, custom_spec_id=None, estimated_hours=0.0, material_cost=0.0, labor_rate=0.0, status="", internal_note=None, created_at=None, updated_at=None)
1043
+ return QuoteResponse.model_validate(obj)
1044
+
1045
+ @app.patch("/api/quotes/{quote_id}", response_model=QuoteUpdateResponse, summary="Update quote status or note", description="Update mutable fields such as status or internal_note for a quote", tags=["quotes"], operation_id="update_quote_partial")
1046
+ async def update_quote_partial(quote_id: int = Path(..., description="Quote ID to update", example=1), request: QuoteUpdateRequest = Body(...)) -> QuoteUpdateResponse:
1047
+ session = SessionLocal()
1048
+ obj = session.query(Quote).filter(Quote.id == quote_id).first()
1049
+ now = datetime.utcnow()
1050
+ if obj is not None:
1051
+ if request.status is not None:
1052
+ obj.status = request.status
1053
+ if request.internal_note is not None:
1054
+ obj.internal_note = request.internal_note
1055
+ obj.updated_at = now
1056
+ session.commit()
1057
+ session.refresh(obj)
1058
+ session.close()
1059
+ if obj is None:
1060
+ return QuoteUpdateResponse(id=0, quote_number="", status="", internal_note=None, updated_at=None)
1061
+ return QuoteUpdateResponse.model_validate(obj)
1062
+
1063
+ @app.post("/api/jobs", response_model=JobResponse, summary="Create a job", description="Create a manufacturing job linked to customer, quote, and custom spec", tags=["jobs"], operation_id="create_job")
1064
+ async def create_job(request: JobCreateRequest = Body(...)) -> JobResponse:
1065
+ session = SessionLocal()
1066
+ due = None
1067
+ if request.due_date is not None:
1068
+ if isinstance(request.due_date, datetime):
1069
+ due = request.due_date.date()
1070
+ obj = Job(
1071
+ job_number=request.job_number,
1072
+ customer_id=request.customer_id,
1073
+ quote_id=request.quote_id,
1074
+ custom_spec_id=request.custom_spec_id,
1075
+ priority=request.priority,
1076
+ due_date=due,
1077
+ status=request.status,
1078
+ created_at=datetime.utcnow(),
1079
+ updated_at=datetime.utcnow(),
1080
+ )
1081
+ session.add(obj)
1082
+ session.commit()
1083
+ session.refresh(obj)
1084
+ session.close()
1085
+ resp_due = None
1086
+ if obj.due_date is not None:
1087
+ resp_due = datetime.combine(obj.due_date, datetime.min.time())
1088
+ return JobResponse(
1089
+ id=obj.id,
1090
+ job_number=obj.job_number,
1091
+ customer_id=obj.customer_id,
1092
+ quote_id=obj.quote_id,
1093
+ custom_spec_id=obj.custom_spec_id,
1094
+ priority=obj.priority,
1095
+ due_date=resp_due,
1096
+ status=obj.status,
1097
+ created_at=obj.created_at,
1098
+ updated_at=obj.updated_at,
1099
+ )
1100
+
1101
+ @app.get("/api/jobs", response_model=JobsListResponse, summary="List jobs with filters", description="Retrieve jobs filtered by customer, status, or job_number", tags=["jobs"], operation_id="list_jobs")
1102
+ async def list_jobs(job_number: Optional[str] = Query(None, description="Filter by exact job number", example="J-2025-0332"), customer_id: Optional[int] = Query(None, description="Filter by customer ID", example=1), status: Optional[str] = Query(None, description="Filter by job status", example="planned"), due_date_from: Optional[datetime] = Query(None, description="Filter by due date on or after this date", example="2026-01-01T00:00:00"), due_date_to: Optional[datetime] = Query(None, description="Filter by due date on or before this date", example="2026-01-31T00:00:00"), limit: Optional[int] = Query(50, description="Max records to return", example=50), offset: Optional[int] = Query(0, description="Offset for pagination", example=0)) -> JobsListResponse:
1103
+ session = SessionLocal()
1104
+ query = session.query(Job)
1105
+ if job_number is not None:
1106
+ query = query.filter(Job.job_number == job_number)
1107
+ if customer_id is not None:
1108
+ query = query.filter(Job.customer_id == customer_id)
1109
+ if status is not None:
1110
+ query = query.filter(Job.status == status)
1111
+ if due_date_from is not None:
1112
+ query = query.filter(Job.due_date >= due_date_from.date())
1113
+ if due_date_to is not None:
1114
+ query = query.filter(Job.due_date <= due_date_to.date())
1115
+ total = query.count()
1116
+ objs = query.offset(offset).limit(limit).all()
1117
+ items: List[JobsListItemResponse] = []
1118
+ for o in objs:
1119
+ resp_due = None
1120
+ if o.due_date is not None:
1121
+ resp_due = datetime.combine(o.due_date, datetime.min.time())
1122
+ items.append(JobsListItemResponse(id=o.id, job_number=o.job_number, customer_id=o.customer_id, status=o.status, priority=o.priority, due_date=resp_due))
1123
+ session.close()
1124
+ return JobsListResponse(items=items, total=total)
1125
+
1126
+ @app.get("/api/jobs/by-number/{job_number}", response_model=JobResponse, summary="Get job by job number", description="Retrieve a single job by its unique job_number", tags=["jobs"], operation_id="get_job_by_number")
1127
+ async def get_job_by_number(job_number: str = Path(..., description="Exact job number to lookup", example="J-2025-0332")) -> JobResponse:
1128
+ session = SessionLocal()
1129
+ obj = session.query(Job).filter(Job.job_number == job_number).first()
1130
+ session.close()
1131
+ if obj is None:
1132
+ return JobResponse(id=0, job_number="", customer_id=0, quote_id=None, custom_spec_id=None, priority="", due_date=None, status="", created_at=None, updated_at=None)
1133
+ resp_due = None
1134
+ if obj.due_date is not None:
1135
+ resp_due = datetime.combine(obj.due_date, datetime.min.time())
1136
+ return JobResponse(id=obj.id, job_number=obj.job_number, customer_id=obj.customer_id, quote_id=obj.quote_id, custom_spec_id=obj.custom_spec_id, priority=obj.priority, due_date=resp_due, status=obj.status, created_at=obj.created_at, updated_at=obj.updated_at)
1137
+
1138
+ @app.patch("/api/jobs/{job_id}", response_model=JobUpdateResponse, summary="Update job status or priority", description="Update mutable job fields like status, priority, or due_date", tags=["jobs"], operation_id="update_job_partial")
1139
+ async def update_job_partial(job_id: int = Path(..., description="Job ID to update", example=1), request: JobUpdateRequest = Body(...)) -> JobUpdateResponse:
1140
+ session = SessionLocal()
1141
+ obj = session.query(Job).filter(Job.id == job_id).first()
1142
+ now = datetime.utcnow()
1143
+ if obj is not None:
1144
+ if request.status is not None:
1145
+ obj.status = request.status
1146
+ if request.priority is not None:
1147
+ obj.priority = request.priority
1148
+ if request.due_date is not None:
1149
+ if isinstance(request.due_date, datetime):
1150
+ obj.due_date = request.due_date.date()
1151
+ obj.updated_at = now
1152
+ session.commit()
1153
+ session.refresh(obj)
1154
+ session.close()
1155
+ if obj is None:
1156
+ return JobUpdateResponse(id=0, job_number="", status="", priority="", due_date=None, updated_at=None)
1157
+ resp_due = None
1158
+ if obj.due_date is not None:
1159
+ resp_due = datetime.combine(obj.due_date, datetime.min.time())
1160
+ return JobUpdateResponse(id=obj.id, job_number=obj.job_number, status=obj.status, priority=obj.priority, due_date=resp_due, updated_at=obj.updated_at)
1161
+
1162
+ @app.post("/api/work-centers", response_model=WorkCenterResponse, summary="Create a work center", description="Create a new work center such as a machine or cell", tags=["work_centers"], operation_id="create_work_center")
1163
+ async def create_work_center(request: WorkCenterCreateRequest = Body(...)) -> WorkCenterResponse:
1164
+ session = SessionLocal()
1165
+ obj = WorkCenter(
1166
+ name=request.name,
1167
+ description=request.description,
1168
+ created_at=datetime.utcnow(),
1169
+ updated_at=datetime.utcnow(),
1170
+ )
1171
+ session.add(obj)
1172
+ session.commit()
1173
+ session.refresh(obj)
1174
+ session.close()
1175
+ return WorkCenterResponse.model_validate(obj)
1176
+
1177
+ @app.get("/api/work-centers", response_model=WorkCentersListResponse, summary="List work centers", description="Retrieve work centers with optional name filter", tags=["work_centers"], operation_id="list_work_centers")
1178
+ async def list_work_centers(name: Optional[str] = Query(None, description="Filter by name containing this text", example="Laser Cutter")) -> WorkCentersListResponse:
1179
+ session = SessionLocal()
1180
+ query = session.query(WorkCenter)
1181
+ if name is not None:
1182
+ query = query.filter(WorkCenter.name.contains(name))
1183
+ objs = query.all()
1184
+ items = [WorkCenterResponse.model_validate(o) for o in objs]
1185
+ session.close()
1186
+ return WorkCentersListResponse(items=items)
1187
+
1188
+ @app.get("/api/work-centers/by-name/{work_center_name}", response_model=WorkCenterResponse, summary="Get work center by name", description="Lookup a work center by its unique name", tags=["work_centers"], operation_id="get_work_center_by_name")
1189
+ async def get_work_center_by_name(work_center_name: str = Path(..., description="Exact work center name", example="Laser Cutter LC-01")) -> WorkCenterResponse:
1190
+ session = SessionLocal()
1191
+ obj = session.query(WorkCenter).filter(WorkCenter.name == work_center_name).first()
1192
+ session.close()
1193
+ if obj is None:
1194
+ return WorkCenterResponse(id=0, name="", description=None, created_at=None, updated_at=None)
1195
+ return WorkCenterResponse.model_validate(obj)
1196
+
1197
+ @app.post("/api/job-tasks", response_model=JobTaskResponse, summary="Create a job task", description="Create a single job task step for a specific job and work center", tags=["job_tasks"], operation_id="create_job_task")
1198
+ async def create_job_task(request: JobTaskCreateRequest = Body(...)) -> JobTaskResponse:
1199
+ session = SessionLocal()
1200
+ obj = JobTask(
1201
+ task_code=request.task_code,
1202
+ job_id=request.job_id,
1203
+ sequence_order=request.sequence_order,
1204
+ task_name=request.task_name,
1205
+ work_center_id=request.work_center_id,
1206
+ requiring_skill_level=request.requiring_skill_level,
1207
+ planned_start=request.planned_start,
1208
+ planned_finish=request.planned_finish,
1209
+ planned_duration_hours=request.planned_duration_hours,
1210
+ actual_start=None,
1211
+ actual_finish=None,
1212
+ created_at=datetime.utcnow(),
1213
+ updated_at=datetime.utcnow(),
1214
+ )
1215
+ session.add(obj)
1216
+ session.commit()
1217
+ session.refresh(obj)
1218
+ session.close()
1219
+ return JobTaskResponse.model_validate(obj)
1220
+
1221
+ @app.get("/api/job-tasks", response_model=JobTasksListResponse, summary="List job tasks with filters", description="List job tasks filtered by job, work center, or date range", tags=["job_tasks"], operation_id="list_job_tasks")
1222
+ async def list_job_tasks(job_id: Optional[int] = Query(None, description="Filter by job ID", example=1), work_center_id: Optional[int] = Query(None, description="Filter by work center ID", example=1), planned_start_from: Optional[datetime] = Query(None, description="Filter tasks with planned_start on or after this datetime", example="2026-01-01T00:00:00"), planned_finish_to: Optional[datetime] = Query(None, description="Filter tasks with planned_finish on or before this datetime", example="2026-01-31T23:59:59"), limit: Optional[int] = Query(100, description="Max records to return", example=100), offset: Optional[int] = Query(0, description="Offset for pagination", example=0)) -> JobTasksListResponse:
1223
+ session = SessionLocal()
1224
+ query = session.query(JobTask)
1225
+ if job_id is not None:
1226
+ query = query.filter(JobTask.job_id == job_id)
1227
+ if work_center_id is not None:
1228
+ query = query.filter(JobTask.work_center_id == work_center_id)
1229
+ if planned_start_from is not None:
1230
+ query = query.filter(JobTask.planned_start >= planned_start_from)
1231
+ if planned_finish_to is not None:
1232
+ query = query.filter(JobTask.planned_finish <= planned_finish_to)
1233
+ total = query.count()
1234
+ objs = query.offset(offset).limit(limit).all()
1235
+ items = [JobTasksListItemResponse.model_validate(o) for o in objs]
1236
+ session.close()
1237
+ return JobTasksListResponse(items=items, total=total)
1238
+
1239
+ @app.get("/api/job-tasks/by-code/{task_code}", response_model=JobTaskResponse, summary="Get job task by task code", description="Retrieve a single job task by its unique task_code", tags=["job_tasks"], operation_id="get_job_task_by_code")
1240
+ async def get_job_task_by_code(task_code: str = Path(..., description="Task code to lookup", example="JT-8793")) -> JobTaskResponse:
1241
+ session = SessionLocal()
1242
+ obj = session.query(JobTask).filter(JobTask.task_code == task_code).first()
1243
+ session.close()
1244
+ if obj is None:
1245
+ return JobTaskResponse(id=0, task_code="", job_id=0, sequence_order=0, task_name="", work_center_id=0, requiring_skill_level=None, planned_start=None, planned_finish=None, planned_duration_hours=None, actual_start=None, actual_finish=None, created_at=None, updated_at=None)
1246
+ return JobTaskResponse.model_validate(obj)
1247
+
1248
+ @app.post("/api/time-logs", response_model=TimeLogResponse, summary="Create a time log for a job task", description="Record actual time, scrap, and notes for a job task at a work center", tags=["time_logs"], operation_id="create_time_log")
1249
+ async def create_time_log(request: TimeLogCreateRequest = Body(...)) -> TimeLogResponse:
1250
+ session = SessionLocal()
1251
+ log_start_value = request.log_start if request.log_start is not None else datetime.utcnow()
1252
+ scrap_quantity_value = request.scrap_quantity if request.scrap_quantity is not None else 0
1253
+ obj = TimeLog(
1254
+ job_task_id=request.job_task_id,
1255
+ operator_username=request.operator_username,
1256
+ work_center_id=request.work_center_id,
1257
+ log_start=log_start_value,
1258
+ actual_duration_hours=request.actual_duration_hours,
1259
+ scrap_quantity=scrap_quantity_value,
1260
+ note=request.note,
1261
+ created_at=datetime.utcnow(),
1262
+ updated_at=datetime.utcnow(),
1263
+ )
1264
+ session.add(obj)
1265
+ session.commit()
1266
+ session.refresh(obj)
1267
+ session.close()
1268
+ return TimeLogResponse.model_validate(obj)
1269
+
1270
+ @app.get("/api/time-logs", response_model=TimeLogsListResponse, summary="List time logs with filters", description="List time logs by job_task, work center, or date range", tags=["time_logs"], operation_id="list_time_logs")
1271
+ async def list_time_logs(job_task_id: Optional[int] = Query(None, description="Filter by job task ID", example=1), work_center_id: Optional[int] = Query(None, description="Filter by work center ID", example=2), log_start_from: Optional[datetime] = Query(None, description="Filter logs with log_start on or after this datetime", example="2026-01-01T00:00:00"), log_start_to: Optional[datetime] = Query(None, description="Filter logs with log_start on or before this datetime", example="2026-01-31T23:59:59"), limit: Optional[int] = Query(100, description="Max records to return", example=100), offset: Optional[int] = Query(0, description="Offset for pagination", example=0)) -> TimeLogsListResponse:
1272
+ session = SessionLocal()
1273
+ query = session.query(TimeLog)
1274
+ if job_task_id is not None:
1275
+ query = query.filter(TimeLog.job_task_id == job_task_id)
1276
+ if work_center_id is not None:
1277
+ query = query.filter(TimeLog.work_center_id == work_center_id)
1278
+ if log_start_from is not None:
1279
+ query = query.filter(TimeLog.log_start >= log_start_from)
1280
+ if log_start_to is not None:
1281
+ query = query.filter(TimeLog.log_start <= log_start_to)
1282
+ total = query.count()
1283
+ objs = query.offset(offset).limit(limit).all()
1284
+ items = [TimeLogsListItemResponse.model_validate(o) for o in objs]
1285
+ session.close()
1286
+ return TimeLogsListResponse(items=items, total=total)
1287
+
1288
+ @app.post("/api/materials", response_model=MaterialResponse, summary="Create a material", description="Create a new material definition with unit of measure", tags=["materials"], operation_id="create_material")
1289
+ async def create_material(request: MaterialCreateRequest = Body(...)) -> MaterialResponse:
1290
+ session = SessionLocal()
1291
+ obj = Material(
1292
+ name=request.name,
1293
+ unit_of_measure=request.unit_of_measure,
1294
+ created_at=datetime.utcnow(),
1295
+ updated_at=datetime.utcnow(),
1296
+ )
1297
+ session.add(obj)
1298
+ session.commit()
1299
+ session.refresh(obj)
1300
+ session.close()
1301
+ return MaterialResponse.model_validate(obj)
1302
+
1303
+ @app.get("/api/materials", response_model=MaterialsListResponse, summary="List materials", description="Retrieve materials with optional name filter", tags=["materials"], operation_id="list_materials")
1304
+ async def list_materials(name: Optional[str] = Query(None, description="Filter materials containing this name", example="Cold Rolled Steel")) -> MaterialsListResponse:
1305
+ session = SessionLocal()
1306
+ query = session.query(Material)
1307
+ if name is not None:
1308
+ query = query.filter(Material.name.contains(name))
1309
+ objs = query.all()
1310
+ items = [MaterialResponse.model_validate(o) for o in objs]
1311
+ session.close()
1312
+ return MaterialsListResponse(items=items)
1313
+
1314
+ @app.get("/api/materials/by-name/{material_name}", response_model=MaterialResponse, summary="Get material by name", description="Lookup a material by its unique name", tags=["materials"], operation_id="get_material_by_name")
1315
+ async def get_material_by_name(material_name: str = Path(..., description="Exact material name", example="Cold Rolled Steel Sheet 2mm")) -> MaterialResponse:
1316
+ session = SessionLocal()
1317
+ obj = session.query(Material).filter(Material.name == material_name).first()
1318
+ session.close()
1319
+ if obj is None:
1320
+ return MaterialResponse(id=0, name="", unit_of_measure="", created_at=None, updated_at=None)
1321
+ return MaterialResponse.model_validate(obj)
1322
+
1323
+ @app.post("/api/inventory-lots", response_model=InventoryLotResponse, summary="Create an inventory lot", description="Create a new inventory lot for a material with quantity balances", tags=["inventory_lots"], operation_id="create_inventory_lot")
1324
+ async def create_inventory_lot(request: InventoryLotCreateRequest = Body(...)) -> InventoryLotResponse:
1325
+ session = SessionLocal()
1326
+ reserved = request.reserved_quantity if request.reserved_quantity is not None else 0.0
1327
+ obj = InventoryLot(
1328
+ lot_number=request.lot_number,
1329
+ material_id=request.material_id,
1330
+ on_hand_quantity=request.on_hand_quantity,
1331
+ reserved_quantity=reserved,
1332
+ created_at=datetime.utcnow(),
1333
+ updated_at=datetime.utcnow(),
1334
+ )
1335
+ session.add(obj)
1336
+ session.commit()
1337
+ session.refresh(obj)
1338
+ session.close()
1339
+ return InventoryLotResponse.model_validate(obj)
1340
+
1341
+ @app.get("/api/inventory-lots", response_model=InventoryLotsListResponse, summary="List inventory lots", description="List inventory lots filtered by material or lot_number", tags=["inventory_lots"], operation_id="list_inventory_lots")
1342
+ async def list_inventory_lots(lot_number: Optional[str] = Query(None, description="Filter by exact lot number", example="LOT-CRS-2401"), material_id: Optional[int] = Query(None, description="Filter by material ID", example=1)) -> InventoryLotsListResponse:
1343
+ session = SessionLocal()
1344
+ query = session.query(InventoryLot)
1345
+ if lot_number is not None:
1346
+ query = query.filter(InventoryLot.lot_number == lot_number)
1347
+ if material_id is not None:
1348
+ query = query.filter(InventoryLot.material_id == material_id)
1349
+ objs = query.all()
1350
+ items = [InventoryLotsListItemResponse.model_validate(o) for o in objs]
1351
+ session.close()
1352
+ return InventoryLotsListResponse(items=items)
1353
+
1354
+ @app.get("/api/inventory-lots/by-number/{lot_number}", response_model=InventoryLotResponse, summary="Get inventory lot by lot number", description="Retrieve a single inventory lot by its unique lot_number", tags=["inventory_lots"], operation_id="get_inventory_lot_by_number")
1355
+ async def get_inventory_lot_by_number(lot_number: str = Path(..., description="Exact lot number", example="LOT-CRS-2401")) -> InventoryLotResponse:
1356
+ session = SessionLocal()
1357
+ obj = session.query(InventoryLot).filter(InventoryLot.lot_number == lot_number).first()
1358
+ session.close()
1359
+ if obj is None:
1360
+ return InventoryLotResponse(id=0, lot_number="", material_id=0, on_hand_quantity=0.0, reserved_quantity=0.0, created_at=None, updated_at=None)
1361
+ return InventoryLotResponse.model_validate(obj)
1362
+
1363
+ @app.post("/api/inventory-lots/{inventory_lot_id}/adjust", response_model=InventoryLotAdjustResponse, summary="Adjust inventory lot quantities", description="Atomically adjust on_hand_quantity and reserved_quantity for a lot", tags=["inventory_lots"], operation_id="adjust_inventory_lot")
1364
+ async def adjust_inventory_lot(inventory_lot_id: int = Path(..., description="Inventory lot ID", example=1), request: InventoryLotAdjustRequest = Body(...)) -> InventoryLotAdjustResponse:
1365
+ session = SessionLocal()
1366
+ obj = session.query(InventoryLot).filter(InventoryLot.id == inventory_lot_id).first()
1367
+ if obj is not None:
1368
+ if request.on_hand_delta is not None:
1369
+ obj.on_hand_quantity = obj.on_hand_quantity + request.on_hand_delta
1370
+ if request.reserved_delta is not None:
1371
+ obj.reserved_quantity = obj.reserved_quantity + request.reserved_delta
1372
+ obj.updated_at = datetime.utcnow()
1373
+ session.commit()
1374
+ session.refresh(obj)
1375
+ session.close()
1376
+ if obj is None:
1377
+ return InventoryLotAdjustResponse(id=0, lot_number="", on_hand_quantity=0.0, reserved_quantity=0.0, updated_at=None)
1378
+ return InventoryLotAdjustResponse.model_validate(obj)
1379
+
1380
+ @app.post("/api/material-reservations", response_model=MaterialReservationResponse, summary="Create a material reservation", description="Reserve a quantity from an inventory lot for a job", tags=["material_reservations"], operation_id="create_material_reservation")
1381
+ async def create_material_reservation(request: MaterialReservationCreateRequest = Body(...)) -> MaterialReservationResponse:
1382
+ session = SessionLocal()
1383
+ obj = MaterialReservation(
1384
+ job_id=request.job_id,
1385
+ inventory_lot_id=request.inventory_lot_id,
1386
+ quantity=request.quantity,
1387
+ created_at=datetime.utcnow(),
1388
+ updated_at=datetime.utcnow(),
1389
+ )
1390
+ session.add(obj)
1391
+ lot = session.query(InventoryLot).filter(InventoryLot.id == request.inventory_lot_id).first()
1392
+ if lot is not None:
1393
+ lot.reserved_quantity = lot.reserved_quantity + request.quantity
1394
+ lot.on_hand_quantity = lot.on_hand_quantity - request.quantity
1395
+ lot.updated_at = datetime.utcnow()
1396
+ session.commit()
1397
+ session.refresh(obj)
1398
+ session.close()
1399
+ return MaterialReservationResponse.model_validate(obj)
1400
+
1401
+ @app.get("/api/material-reservations", response_model=MaterialReservationsListResponse, summary="List material reservations", description="List material reservations filtered by job or inventory lot", tags=["material_reservations"], operation_id="list_material_reservations")
1402
+ async def list_material_reservations(job_id: Optional[int] = Query(None, description="Filter by job ID", example=1), inventory_lot_id: Optional[int] = Query(None, description="Filter by inventory lot ID", example=1)) -> MaterialReservationsListResponse:
1403
+ session = SessionLocal()
1404
+ query = session.query(MaterialReservation)
1405
+ if job_id is not None:
1406
+ query = query.filter(MaterialReservation.job_id == job_id)
1407
+ if inventory_lot_id is not None:
1408
+ query = query.filter(MaterialReservation.inventory_lot_id == inventory_lot_id)
1409
+ objs = query.all()
1410
+ items = [MaterialReservationsListItemResponse.model_validate(o) for o in objs]
1411
+ session.close()
1412
+ return MaterialReservationsListResponse(items=items)
1413
+
1414
+ @app.post("/api/shipments", response_model=ShipmentResponse, summary="Create a shipment", description="Create a shipment record for a job and customer with initial status", tags=["shipments"], operation_id="create_shipment")
1415
+ async def create_shipment(request: ShipmentCreateRequest = Body(...)) -> ShipmentResponse:
1416
+ session = SessionLocal()
1417
+ obj = Shipment(
1418
+ shipment_number=request.shipment_number,
1419
+ job_id=request.job_id,
1420
+ customer_id=request.customer_id,
1421
+ delivery_status=request.delivery_status,
1422
+ shipped_at=request.shipped_at,
1423
+ delivered_at=request.delivered_at,
1424
+ created_at=datetime.utcnow(),
1425
+ updated_at=datetime.utcnow(),
1426
+ )
1427
+ session.add(obj)
1428
+ session.commit()
1429
+ session.refresh(obj)
1430
+ session.close()
1431
+ return ShipmentResponse.model_validate(obj)
1432
+
1433
+ @app.get("/api/shipments", response_model=ShipmentsListResponse, summary="List shipments", description="List shipments filtered by job, customer, or status", tags=["shipments"], operation_id="list_shipments")
1434
+ async def list_shipments(shipment_number: Optional[str] = Query(None, description="Filter by shipment number", example="SHP-2025-0101"), job_id: Optional[int] = Query(None, description="Filter by job ID", example=1), customer_id: Optional[int] = Query(None, description="Filter by customer ID", example=1), delivery_status: Optional[str] = Query(None, description="Filter by delivery status", example="in_transit")) -> ShipmentsListResponse:
1435
+ session = SessionLocal()
1436
+ query = session.query(Shipment)
1437
+ if shipment_number is not None:
1438
+ query = query.filter(Shipment.shipment_number == shipment_number)
1439
+ if job_id is not None:
1440
+ query = query.filter(Shipment.job_id == job_id)
1441
+ if customer_id is not None:
1442
+ query = query.filter(Shipment.customer_id == customer_id)
1443
+ if delivery_status is not None:
1444
+ query = query.filter(Shipment.delivery_status == delivery_status)
1445
+ objs = query.all()
1446
+ items = [ShipmentsListItemResponse.model_validate(o) for o in objs]
1447
+ session.close()
1448
+ return ShipmentsListResponse(items=items)
1449
+
1450
+ @app.patch("/api/shipments/{shipment_id}", response_model=ShipmentUpdateResponse, summary="Update shipment status or dates", description="Update shipment delivery_status, shipped_at, or delivered_at", tags=["shipments"], operation_id="update_shipment_partial")
1451
+ async def update_shipment_partial(shipment_id: int = Path(..., description="Shipment ID", example=1), request: ShipmentUpdateRequest = Body(...)) -> ShipmentUpdateResponse:
1452
+ session = SessionLocal()
1453
+ obj = session.query(Shipment).filter(Shipment.id == shipment_id).first()
1454
+ now = datetime.utcnow()
1455
+ if obj is not None:
1456
+ if request.delivery_status is not None:
1457
+ obj.delivery_status = request.delivery_status
1458
+ if request.shipped_at is not None:
1459
+ obj.shipped_at = request.shipped_at
1460
+ if request.delivered_at is not None:
1461
+ obj.delivered_at = request.delivered_at
1462
+ obj.updated_at = now
1463
+ session.commit()
1464
+ session.refresh(obj)
1465
+ session.close()
1466
+ if obj is None:
1467
+ return ShipmentUpdateResponse(id=0, shipment_number="", delivery_status="", shipped_at=None, delivered_at=None, updated_at=None)
1468
+ return ShipmentUpdateResponse.model_validate(obj)
1469
+
1470
+ @app.post("/api/shipment-packages", response_model=ShipmentPackageResponse, summary="Create a shipment package", description="Create a single package entry for an existing shipment", tags=["shipment_packages"], operation_id="create_shipment_package")
1471
+ async def create_shipment_package(request: ShipmentPackageCreateRequest = Body(...)) -> ShipmentPackageResponse:
1472
+ session = SessionLocal()
1473
+ obj = ShipmentPackage(
1474
+ shipment_id=request.shipment_id,
1475
+ package_number=request.package_number,
1476
+ weight_kg=request.weight_kg,
1477
+ tracking_number=request.tracking_number,
1478
+ created_at=datetime.utcnow(),
1479
+ updated_at=datetime.utcnow(),
1480
+ )
1481
+ session.add(obj)
1482
+ session.commit()
1483
+ session.refresh(obj)
1484
+ session.close()
1485
+ return ShipmentPackageResponse.model_validate(obj)
1486
+
1487
+ @app.get("/api/shipment-packages", response_model=ShipmentPackagesListResponse, summary="List shipment packages", description="List packages filtered by shipment or tracking_number", tags=["shipment_packages"], operation_id="list_shipment_packages")
1488
+ async def list_shipment_packages(shipment_id: Optional[int] = Query(None, description="Filter by shipment ID", example=1), tracking_number: Optional[str] = Query(None, description="Filter by tracking number", example="CBX123456US")) -> ShipmentPackagesListResponse:
1489
+ session = SessionLocal()
1490
+ query = session.query(ShipmentPackage)
1491
+ if shipment_id is not None:
1492
+ query = query.filter(ShipmentPackage.shipment_id == shipment_id)
1493
+ if tracking_number is not None:
1494
+ query = query.filter(ShipmentPackage.tracking_number == tracking_number)
1495
+ objs = query.all()
1496
+ items = [ShipmentPackagesListItemResponse.model_validate(o) for o in objs]
1497
+ session.close()
1498
+ return ShipmentPackagesListResponse(items=items)
1499
+
1500
+ @app.get("/api/work-centers/{work_center_id}/capacity-utilization", response_model=CapacityUtilizationResponse, summary="Get work center capacity utilization", description="Aggregate planned vs actual hours for a work center over a date range", tags=["capacity", "work_centers", "job_tasks", "time_logs"], operation_id="get_work_center_capacity_utilization")
1501
+ async def get_work_center_capacity_utilization(work_center_id: int = Path(..., description="Work center ID to analyze", example=1), planned_from: datetime = Query(..., description="Start of planned window (inclusive, ISO8601 datetime)", example="2026-01-01T00:00:00"), planned_to: datetime = Query(..., description="End of planned window (inclusive, ISO8601 datetime)", example="2026-01-31T23:59:59")) -> CapacityUtilizationResponse:
1502
+ session = SessionLocal()
1503
+ tasks_query = session.query(JobTask).filter(JobTask.work_center_id == work_center_id, JobTask.planned_start != None, JobTask.planned_finish != None, JobTask.planned_start >= planned_from, JobTask.planned_finish <= planned_to)
1504
+ tasks = tasks_query.all()
1505
+ total_planned_hours = 0.0
1506
+ total_actual_hours = 0.0
1507
+ items: List[CapacityTaskItem] = []
1508
+ for t in tasks:
1509
+ planned = t.planned_duration_hours if t.planned_duration_hours is not None else 0.0
1510
+ total_planned_hours = total_planned_hours + planned
1511
+ logs = session.query(TimeLog).filter(TimeLog.job_task_id == t.id, TimeLog.work_center_id == work_center_id).all()
1512
+ actual_sum = 0.0
1513
+ for lg in logs:
1514
+ actual_sum = actual_sum + float(lg.actual_duration_hours)
1515
+ total_actual_hours = total_actual_hours + actual_sum
1516
+ items.append(CapacityTaskItem(job_task_id=t.id, task_code=t.task_code, job_id=t.job_id, task_name=t.task_name, planned_start=t.planned_start, planned_finish=t.planned_finish, planned_duration_hours=t.planned_duration_hours if t.planned_duration_hours is not None else 0.0, actual_hours=actual_sum))
1517
+ session.close()
1518
+ return CapacityUtilizationResponse(work_center_id=work_center_id, planned_from=planned_from, planned_to=planned_to, total_planned_hours=total_planned_hours, total_actual_hours=total_actual_hours, job_tasks=items)
1519
+
1520
+ if __name__ == "__main__":
1521
+ import uvicorn
1522
+ host = os.getenv("HOST", "127.0.0.1")
1523
+ port = int(os.getenv("PORT", "8000"))
1524
+ uvicorn.run(app, host=host, port=port)
components/awm/private/tasks/awm-manufacturing-1-schedule/original_verifier.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def verify_task_completion(initial_db_path: str, final_db_path: str, final_answer: str | None = None) -> dict:
2
+ import sqlite3
3
+ from datetime import datetime
4
+
5
+ def safe_query(db_path: str, query: str, params: tuple = ()) -> list:
6
+ try:
7
+ conn = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True)
8
+ cursor = conn.cursor()
9
+ cursor.execute(query, params)
10
+ results = cursor.fetchall()
11
+ conn.close()
12
+ return results
13
+ except Exception:
14
+ return []
15
+
16
+ # Get job_id for J-2025-0332
17
+ job_query = "SELECT id FROM jobs WHERE job_number = ?"
18
+ job_results = safe_query(final_db_path, job_query, ('J-2025-0332',))
19
+ if not job_results:
20
+ return {"result": "others"}
21
+ job_id = job_results[0][0]
22
+
23
+ # Get work center IDs
24
+ wc_query = "SELECT id, name FROM work_centers WHERE name IN (?, ?, ?)"
25
+ wc_results = safe_query(final_db_path, wc_query, ('Laser Cutter LC-01', 'Weld Cell WC-02', 'Paint Booth PB-01'))
26
+ if len(wc_results) != 3:
27
+ return {"result": "others"}
28
+
29
+ wc_map = {name: wc_id for wc_id, name in wc_results}
30
+ laser_cutter_id = wc_map.get('Laser Cutter LC-01')
31
+ weld_cell_id = wc_map.get('Weld Cell WC-02')
32
+ paint_booth_id = wc_map.get('Paint Booth PB-01')
33
+
34
+ if not all([laser_cutter_id, weld_cell_id, paint_booth_id]):
35
+ return {"result": "others"}
36
+
37
+ # Count initial job_tasks for this job
38
+ initial_tasks_query = "SELECT COUNT(*) FROM job_tasks WHERE job_id = ?"
39
+ initial_count_result = safe_query(initial_db_path, initial_tasks_query, (job_id,))
40
+ initial_count = initial_count_result[0][0] if initial_count_result else 0
41
+
42
+ # Count final job_tasks for this job
43
+ final_count_result = safe_query(final_db_path, initial_tasks_query, (job_id,))
44
+ final_count = final_count_result[0][0] if final_count_result else 0
45
+
46
+ # Should have exactly 3 more tasks
47
+ if final_count != initial_count + 3:
48
+ return {"result": "others"}
49
+
50
+ # Get all job_tasks for this job from final database
51
+ tasks_query = """SELECT task_name, work_center_id, requiring_skill_level,
52
+ planned_start, planned_finish
53
+ FROM job_tasks
54
+ WHERE job_id = ?
55
+ ORDER BY id"""
56
+ final_tasks = safe_query(final_db_path, tasks_query, (job_id,))
57
+
58
+ if len(final_tasks) < 3:
59
+ return {"result": "others"}
60
+
61
+ # Get the last 3 tasks (newly added)
62
+ new_tasks = final_tasks[-3:]
63
+
64
+ # Expected task definitions
65
+ expected_tasks = [
66
+ ('cutting', laser_cutter_id, 'intermediate', '2026-01-05 08:00:00', '2026-01-05 10:00:00'),
67
+ ('welding', weld_cell_id, 'advanced', '2026-01-05 11:00:00', '2026-01-05 14:00:00'),
68
+ ('painting', paint_booth_id, 'intermediate', '2026-01-06 09:00:00', '2026-01-06 11:00:00')
69
+ ]
70
+
71
+ # Verify each new task matches expected values
72
+ for i, (task_name, work_center_id, skill_level, planned_start, planned_finish) in enumerate(new_tasks):
73
+ expected = expected_tasks[i]
74
+
75
+ # Check task_name
76
+ if task_name != expected[0]:
77
+ return {"result": "others"}
78
+
79
+ # Check work_center_id
80
+ if work_center_id != expected[1]:
81
+ return {"result": "others"}
82
+
83
+ # Check requiring_skill_level
84
+ if skill_level != expected[2]:
85
+ return {"result": "others"}
86
+
87
+ # Check planned_start (normalize format)
88
+ if planned_start:
89
+ planned_start_normalized = planned_start.replace('T', ' ').replace('.000000', '')
90
+ if planned_start_normalized != expected[3]:
91
+ return {"result": "others"}
92
+ else:
93
+ return {"result": "others"}
94
+
95
+ # Check planned_finish (normalize format)
96
+ if planned_finish:
97
+ planned_finish_normalized = planned_finish.replace('T', ' ').replace('.000000', '')
98
+ if planned_finish_normalized != expected[4]:
99
+ return {"result": "others"}
100
+ else:
101
+ return {"result": "others"}
102
+
103
+ # All checks passed
104
+ return {"result": "complete"}
components/awm/requirements.lock ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Linux/amd64 CPython 3.12 wheel lock. Offline inputs: vendor/build-manifest.json.
2
+ # OpenEnv source commit: 86a180ede21e044f7929b9a7783ad83aa67d83a3.
3
+ aiofile==3.12.3 --hash=sha256:5c1bcc9e929c50834608e8cc1a4cc1d7503eb60c15a535b779fd39e2f372c017
4
+ annotated-doc==0.0.5 --hash=sha256:117bac03a25ede5df5440e855b32d556049ca169ead221505badf432fed4b101
5
+ annotated-types==0.8.0 --hash=sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0
6
+ anyio==4.15.1 --hash=sha256:6152fdbbf9a77fdec97731721bebf7c4c44f7c29b424b0065826173efc7ed101
7
+ attrs==26.1.0 --hash=sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309
8
+ Authlib==1.8.0 --hash=sha256:88aebbd9af6757e14e912d5dc007ae1dc1f3e27e3b2152ce7c552ee2c3b3c121
9
+ beartype==0.22.9 --hash=sha256:d16c9bbc61ea14637596c5f6fbff2ee99cbe3573e46a716401734ef50c3060c2
10
+ brotli==1.2.0 --hash=sha256:072e7624b1fc4d601036ab3f4f27942ef772887e876beff0301d261210bca97f
11
+ cachetools==7.2.1 --hash=sha256:63aa53dfe7473c10cccdd5a01dedf76ef2c4b73a58840d9396e7d0752cbdac3b
12
+ caio==0.12.9 --hash=sha256:bf12d4f014b2a33e642ed7905b5787656ede2fc24be21f7c086826ff0d32cec3
13
+ certifi==2026.7.22 --hash=sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775
14
+ cffi==2.1.1 --hash=sha256:c1453022f490d2459a11819d83ad1d586e9ff65a12ac3e705ffebd46d3685dcf
15
+ charset-normalizer==3.5.2 --hash=sha256:3d31298449090ab8d47b7b1b2a555ff73cac7ed438a08b7ac160980c7ebed649
16
+ click==8.5.0 --hash=sha256:255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360
17
+ cryptography==50.0.2 --hash=sha256:4061c0079120205fb760c58acab6443e217307dcf05e3702cf970e0689972856
18
+ cyclopts==5.2.0 --hash=sha256:5da2a5d65164e03008621fc4795946b88a722b881398b5dfa58afa6218342cff
19
+ dnspython==2.9.0 --hash=sha256:9a4aedb833c3c1b49214d04d44d3032ab7a9135f7c1d29a549b4ff78fd82fda9
20
+ docstring_parser==0.18.0 --hash=sha256:b3fcbed555c47d8479be0796ef7e19c2670d428d72e96da63f3a40122860374b
21
+ email-validator==2.3.0 --hash=sha256:80f13f623413e6b197ae73bb10bf4eb0908faf509ad8362c5edeb0be7fd450b4
22
+ exceptiongroup==1.3.1 --hash=sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598
23
+ fastapi==0.143.0 --hash=sha256:3e9395fd35276425b61b516a31fdd7c77fe2af83e41b4da22e30696fb1304c5d
24
+ fastmcp==3.4.8 --hash=sha256:ab4e8abe6c9d50b110f367e8c29f82b90c1478ac9180be61af10354f84f0ad8c
25
+ fastmcp-slim==3.4.8 --hash=sha256:e72c6b74e90c5dcdc8f58087fbdf213636d8b5d339384a498de1c5df6fc037a7
26
+ filelock==4.1.0 --hash=sha256:2ce9818e3e2d8f284c1a964414447ef148d42a5fd5e2a477a7118e574b293ec1
27
+ fsspec==2026.9.0 --hash=sha256:8dd6e646e99ea382bd85f97a45e6b526a442d79423a7dc673f1e2756d05fcb5f
28
+ gradio==6.30.0 --hash=sha256:aae3aa81ec9f44e55781b498ad2ba12b117aa512e8d2bb0ef3e52af7f2ee6305
29
+ gradio_client==2.7.2 --hash=sha256:12c9d2d940df28eb8dce58eef61f5e808265ad87bbbca53704d1330aa701e5e2
30
+ griffelib==2.3.2 --hash=sha256:8e710afededd5607f95bf3c8ccc175ee306e7084459faf27b9f9f44ef2a7a274
31
+ groovy==0.1.2 --hash=sha256:7f7975bab18c729a257a8b1ae9dcd70b7cafb1720481beae47719af57c35fa64
32
+ h11==0.16.0 --hash=sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86
33
+ hf-gradio==0.4.1 --hash=sha256:76b8cb8be6abe62d74c1ad2d35b42f0629db89aa9e1a8d033cecfe7c856eeab3
34
+ hf-xet==1.7.0 --hash=sha256:2814a6e999d13464c4d679b788cc5d784eb5a4edfc638a31f10e9a11ab531ef8
35
+ httpcore==1.0.9 --hash=sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55
36
+ httpcore2==2.13.1 --hash=sha256:e1e05d4f25f7d7d496bfb96748f6f4b67657b03da069b3a68c36069f3db73d0a
37
+ httpx==0.28.1 --hash=sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad
38
+ httpx-sse==0.4.3 --hash=sha256:0ac1c9fe3c0afad2e0ebb25a934a59f4c7823b60792691f779fad2c5568830fc
39
+ httpx2==2.13.1 --hash=sha256:6dff50fabc270ee5fd25d845d0b078ed20564579744d6d962850975996d2f9a4
40
+ huggingface_hub==2.2.0 --hash=sha256:1667f145dc56dc210d60966069397df9ecfca9607a5d43db88b308c89dae56b3
41
+ idna==3.20 --hash=sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c
42
+ iniconfig==2.3.1 --hash=sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7
43
+ jaraco.classes==3.4.0 --hash=sha256:f662826b6bed8cace05e7ff873ce0f9283b5c924470fe664fff1c2f00f581790
44
+ jaraco.context==6.1.2 --hash=sha256:bf8150b79a2d5d91ae48629d8b427a8f7ba0e1097dd6202a9059f29a36379535
45
+ jaraco.functools==4.6.0 --hash=sha256:99e3dc0060c5cbe8fcd1cdb36258e2a65ca40f1566b2033b12abb1bb44dd3c30
46
+ jeepney==0.9.0 --hash=sha256:97e5714520c16fc0a45695e5365a2e11b81ea79bba796e26f9f1d178cb182683
47
+ Jinja2==3.1.6 --hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
48
+ jiter==0.17.0 --hash=sha256:8c21265b251d99bbb40080d178a8953e35601d3a1564e05c4de4c0d2ca616797
49
+ joserfc==1.7.5 --hash=sha256:add2c2c84e8373b084d526a8b53daba5d7a513a118cd2dcd9fc9f979d0922159
50
+ jsonref==1.1.0 --hash=sha256:590dc7773df6c21cbf948b5dac07a72a251db28b0238ceecce0a2abfa8ec30a9
51
+ jsonschema==4.26.0 --hash=sha256:d489f15263b8d200f8387e64b4c3a75f06629559fb73deb8fdfb525f2dab50ce
52
+ jsonschema-path==0.5.0 --hash=sha256:2790a070bc7abb08ea3dbe4d340ece4efadf639223001f020c7503229ba068e2
53
+ jsonschema-specifications==2025.9.1 --hash=sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe
54
+ keyring==25.7.0 --hash=sha256:be4a0b195f149690c166e850609a477c532ddbfbaed96a404d4e43f8d5e2689f
55
+ markdown-it-py==4.2.0 --hash=sha256:9f7ebbcd14fe59494226453aed97c1070d83f8d24b6fc3a3bcf9a38092641c4a
56
+ MarkupSafe==3.0.4 --hash=sha256:8e124f974786f831d6043728e38296969d3579db8896fe004682f5758e613581
57
+ mcp==1.30.0 --hash=sha256:666edb5009503e1047c9d60346a756f94b261f05cc2625f23d41c728ffc484d0
58
+ mdurl==0.1.2 --hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8
59
+ more-itertools==11.1.0 --hash=sha256:4b65538ae22f6fed0ce4874efd317463a7489796a0939fa66824dd542125a192
60
+ numpy==2.5.3 --hash=sha256:b7e18c623bb5c95acb3b3328861272816ba199fb531921c5d6d0b675f1fde9e3
61
+ openai==3.28.0 --hash=sha256:1ea40a084ffe2f9f16fd3bea6e870f757853b536b18d8e737c518ef849a2920c
62
+ openapi-pydantic==0.6.0 --hash=sha256:8bd6d548a250da37db96f461bcd52b3468e8834ad7d6db14b00a6b2ebbd163a3
63
+ openenv==0.6.1.dev0 --hash=sha256:93a5781b64e2f174f17fff40a558d43745a7f4e48a8b247363da4f27906be53a
64
+ opentelemetry-api==1.45.1 --hash=sha256:b31553efa588ae44bc306f863c785c5333a9ecc091248c6ee68b4b6c87fdedfb
65
+ orjson==3.13.0 --hash=sha256:bceadfd314bd238f584fc229a4bbaf0e573597e7a026dec5429fbf29fd66c641
66
+ packaging==26.3 --hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c
67
+ pandas==3.0.6 --hash=sha256:0704044b676496b8350e023b09f174a26772456c974a2b11c36bebb558c9490d
68
+ pathable==0.6.0 --hash=sha256:82c4ca6c98c502ad12e0d4e9779b6210afee93c38990988c8c5d1b49bdcdf566
69
+ pillow==12.3.0 --hash=sha256:78cb2c6865a35ab8ff8b75fd122f6033b92a62c82801110e48ddd6c936a45d91
70
+ platformdirs==4.12.4 --hash=sha256:78bfb9db2a8471ed7eebe3c3c932da413911042994e699b384fbb4493fa872d7
71
+ pluggy==1.6.0 --hash=sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746
72
+ py-key-value-aio==0.4.6 --hash=sha256:820b30c7959fc738ea3d00160cdb10cd258f51e38737b2add530defeea1ded77
73
+ pycparser==3.11 --hash=sha256:51d5a8ba2be0bbe440b99d2112604c95bbbc3c2748a64260186c541e1729cd80
74
+ pydantic==2.14.0 --hash=sha256:15fab1bea6f1dc5003b54fc2ecab230c1fd1dbade2acd4addc52d81e32416d4b
75
+ pydantic-settings==2.15.0 --hash=sha256:0ba092c291c94baceb5eff768aa0d56400a457585bc0175925a5a5510303da42
76
+ pydantic_core==2.50.0 --hash=sha256:f187030fc3d62c668feb0f09e92852e0eb414d7fcefc4748f2e67d245aade37e
77
+ pydub==0.25.1 --hash=sha256:65617e33033874b59d87db603aa1ed450633288aefead953b30bded59cb599a6
78
+ Pygments==2.21.0 --hash=sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9
79
+ PyJWT==2.15.1 --hash=sha256:42d59d631f7768a1028a64c7ff581a9bf7519804daf91fc5b6c56e30eec5e193
80
+ pyperclip==1.11.0 --hash=sha256:299403e9ff44581cb9ba2ffeed69c7aa96a008622ad0c46cb575ca75b5b84273
81
+ pytest==9.1.1 --hash=sha256:37a86b45efb9a47a61a36449063e8e18d0cab3161329fc099eb21783169c4f0c
82
+ python-dateutil==2.9.0.post0 --hash=sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427
83
+ python-dotenv==1.2.4 --hash=sha256:42269a8a5b3fd54ffa6f3d84b18abed50064717576b4ecf03dc4a55d8aa04fdc
84
+ python-multipart==0.0.32 --hash=sha256:ff6d3f776f16878c894e52e107296ffc890e913c611b1a4ec6c44e2821fe2e23
85
+ pytz==2026.5 --hash=sha256:e658af3757f9e26a9d25dd2aff38335acd92bc9104f890a894b2c1ba28311b03
86
+ PyYAML==6.0.3 --hash=sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc
87
+ referencing==0.37.0 --hash=sha256:381329a9f99628c9069361716891d34ad94af76e461dcb0335825aecc7692231
88
+ requests==2.34.2 --hash=sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0
89
+ rich==15.0.0 --hash=sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb
90
+ rich-rst==2.2.0 --hash=sha256:1ea1c43813dc4a8d86475fce27ffb74e0ada3d4656c9f8130ba2a59868055fe9
91
+ rpds-py==2026.9.1 --hash=sha256:addeda51556dac7c1a2f14cda62db8b621cd12afba3091d03a96c72932387eab
92
+ safehttpx==0.1.7 --hash=sha256:c4f4a162db6993464d7ca3d7cc4af0ffc6515a606dfd220b9f82c6945d869cde
93
+ SecretStorage==3.5.0 --hash=sha256:0ce65888c0725fcb2c5bc0fdb8e5438eece02c523557ea40ce0703c266248137
94
+ semantic-version==2.10.0 --hash=sha256:de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177
95
+ shellingham==1.5.4 --hash=sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686
96
+ six==1.17.0 --hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274
97
+ sniffio==1.3.1 --hash=sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2
98
+ sse-starlette==3.5.0 --hash=sha256:3e6e1070df3f0f5d9cea81496de92dbb72f6721871d99748ece67441dd8b7997
99
+ starlette==1.7.0 --hash=sha256:67f8e99895493dd2911a03f11314af6ceebeae4e704bb9f43dfc6a9db151c93e
100
+ tomli==2.5.0 --hash=sha256:6cf74416bdc94ae458b14e37286c1073081850ac8459a00d0c5efef5d44294c6
101
+ tomli_w==1.2.0 --hash=sha256:188306098d013b691fcadc011abd66727d3c414c571bb01b1a174ba8c983cf90
102
+ tomlkit==0.14.0 --hash=sha256:592064ed85b40fa213469f81ac584f67a4f2992509a7c3ea2d632208623a3680
103
+ tqdm==4.70.1 --hash=sha256:c293e525e6fef9c20e8728fd4612df02a0aa31bb5fe91ecd93e123b1b7bffa73
104
+ truststore==0.10.4 --hash=sha256:adaeaecf1cbb5f4de3b1959b42d41f6fab57b2b1666adb59e89cb0b53361d981
105
+ typer==0.27.3 --hash=sha256:e50022f28b82a86313e54501317a1db64bf8f8d036ff8cfe5ca7e47675454aff
106
+ typing-inspection==0.4.4 --hash=sha256:65b8397ba37ccbce054456aaccddfc91e6e3083c92824df348d96ca832f3f147
107
+ typing_extensions==4.16.0 --hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8
108
+ uncalled-for==0.4.1 --hash=sha256:b611b38879d9fe5088297e7bb28f2ddd12d2d73dad933d93da107fb63eb4058e
109
+ urllib3==2.8.0 --hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3
110
+ uvicorn==0.54.0 --hash=sha256:505bdb0f318731d45f1f712071fc781a8981f6847a31c902c9f5e652d4f67faf
111
+ watchfiles==1.3.0 --hash=sha256:b5768b49e426fd5b550b012c866db347cdf15c398ef98dc557b6e6b72fa74cd1
112
+ websockets==17.2 --hash=sha256:6627b913b8586b1c06db9516b31dd0dfbc621de3bb9312616d92a7e44f268a5b
components/awm/runtime/awm/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+
components/awm/runtime/awm/adapter.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import base64
3
+ from functools import wraps
4
+ import hashlib
5
+ import json
6
+ import math
7
+ import os
8
+ from pathlib import Path
9
+ import subprocess
10
+ import tempfile
11
+ from threading import RLock
12
+ import time
13
+
14
+ import jsonschema
15
+ from common.contracts import ACTION_SCHEMA, observation_payload
16
+
17
+
18
+ def serialized(method):
19
+ @wraps(method)
20
+ def invoke(self,*args,**kwargs):
21
+ with self._lock:return method(self,*args,**kwargs)
22
+ return invoke
23
+
24
+
25
+ class AWMAdapter:
26
+ def __init__(self, task_entries, runtime_parent):
27
+ self._lock=RLock();self.registry=dict(task_entries);self.runtime_parent=Path(runtime_parent)
28
+ self.runtime_parent.mkdir(parents=True,exist_ok=True)
29
+ for name,entry in self.registry.items():
30
+ if entry['task_id']!=name or entry['split']!='train':raise ValueError('Invalid registry')
31
+ for relative,digest in entry['original_sha256'].items():
32
+ p=Path(entry['directory'])/relative
33
+ if p.is_symlink() or hashlib.sha256(p.read_bytes()).hexdigest()!=digest:raise ValueError('Original source integrity mismatch')
34
+ self.temporary=None;self.task_id=None;self.done=False;self.reward=None;self.tool_calls=0;self.started=None
35
+
36
+ def _worker(self, operation, payload=None):
37
+ if self.temporary is None:raise ValueError('reset is required')
38
+ request=base64.b64encode(json.dumps(payload or {},allow_nan=False).encode()).decode()
39
+ args=['/opt/awm-venv/bin/python','-I','-B','/opt/awm/runtime/awm/worker.py',str(self.registry[self.task_id]['directory']),str(Path(self.temporary.name)/'state'),operation,request]
40
+ env={'PATH':'/opt/awm-venv/bin:/usr/local/bin:/usr/bin:/bin','HOME':'/nonexistent','LANG':'C.UTF-8','LC_ALL':'C.UTF-8','PYTHONDONTWRITEBYTECODE':'1'}
41
+ try:r=subprocess.run(args,env=env,capture_output=True,text=True,timeout=60)
42
+ except (OSError,subprocess.TimeoutExpired) as exc:raise RuntimeError('Original AWM worker did not complete') from exc
43
+ if r.returncode:
44
+
45
+ (Path(self.temporary.name)/'worker-error.log').write_text(r.stderr[-24000:])
46
+ raise RuntimeError('Original AWM worker failed; inspect its private log')
47
+ if len(r.stdout)>4*1024*1024:raise RuntimeError('Original AWM worker response is too large')
48
+ return json.loads(r.stdout)
49
+
50
+ @serialized
51
+ def reset(self, task_id=None):
52
+ if task_id is None and len(self.registry)==1:task_id=next(iter(self.registry))
53
+ if task_id not in self.registry:raise ValueError('Unknown task id')
54
+ self.close();self.task_id=task_id;self.temporary=tempfile.TemporaryDirectory(prefix='awm-',dir=self.runtime_parent)
55
+ self.done=False;self.reward=None;self.tool_calls=0
56
+ value=self._worker('reset');self.started=time.monotonic()
57
+ return observation_payload(task_id,value['instructions'],{'available_ops':['call','finish'],'tools':value['tools'],'situation':value['situation'],'original_format':value['original_format'],'delivery':'Return one JSON action per step. Use the listed business tools through op=call; finish when the requested business state is complete.'},reward=0.0,done=False)
58
+
59
+ def _terminal(self):
60
+ if self.reward is None:
61
+ self._worker('finalize');value=self._worker('verify');reward=value['reward']
62
+ if type(reward) not in (int,float) or not math.isfinite(reward) or reward not in (0,1):raise RuntimeError('Invalid original AWM reward')
63
+ self.reward=float(reward)
64
+ self.done=True
65
+ return observation_payload(self.task_id,'The business workflow episode has ended.',{'tool_calls':self.tool_calls},reward=self.reward,done=True)
66
+
67
+ @serialized
68
+ def step(self, action):
69
+ if self.temporary is None:raise ValueError('reset is required')
70
+ if hasattr(action,'action_payload'):action=action.action_payload()
71
+ jsonschema.validate(action,ACTION_SCHEMA)
72
+ if self.done:return self._terminal()
73
+ if time.monotonic()-self.started>=self.registry[self.task_id]['timeout_seconds']:return self._terminal()
74
+ if action['op']=='finish':return self._terminal()
75
+ if action['op']=='exec':
76
+ return observation_payload(self.task_id,'Shell execution is unavailable. Use a listed business tool.',{'is_error':True,'tool_calls':self.tool_calls},reward=0.0,done=False)
77
+ value=self._worker('call',{'name':action['tool'],'arguments':action['arguments']});self.tool_calls=value['tool_calls']
78
+ if time.monotonic()-self.started>=self.registry[self.task_id]['timeout_seconds']:return self._terminal()
79
+ return observation_payload(self.task_id,value['content'],{'is_error':value['is_error'],'tool_calls':self.tool_calls},reward=0.0,done=False)
80
+
81
+ @property
82
+ @serialized
83
+ def state(self):
84
+ return {'task_id':self.task_id,'initialized':self.temporary is not None,'done':self.done,'tool_calls':self.tool_calls}
85
+
86
+ @serialized
87
+ def close(self):
88
+ if self.temporary is not None:self.temporary.cleanup()
89
+ self.temporary=None;self.task_id=None;self.done=False;self.reward=None;self.tool_calls=0;self.started=None
components/awm/runtime/awm/launch_service.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import argparse
3
+ import json
4
+ import os
5
+ from pathlib import Path
6
+ import subprocess
7
+ import time
8
+ import urllib.request
9
+
10
+
11
+ class RejectRedirects(urllib.request.HTTPRedirectHandler):
12
+ def redirect_request(self,*args,**kwargs):
13
+ raise RuntimeError('Redirects are forbidden for the local readiness probe')
14
+
15
+
16
+ def main():
17
+ parser=argparse.ArgumentParser()
18
+ parser.add_argument('--python',default='/usr/local/bin/python')
19
+ parser.add_argument('--config',default='/opt/awm/config.json')
20
+ args=parser.parse_args()
21
+ if os.geteuid()!=0:raise PermissionError('Only the trusted supervisor may launch this service')
22
+ if args.config!='/opt/awm/config.json':raise ValueError('This prototype uses its fixed image registry')
23
+ opener=urllib.request.build_opener(urllib.request.ProxyHandler({}),RejectRedirects())
24
+ url='http://127.0.0.1:8000/metadata'
25
+ def ready():
26
+ try:
27
+ with opener.open(url,timeout=2) as response:
28
+ return json.load(response).get('name')=='awm_original'
29
+ except Exception:return False
30
+ if ready():
31
+ print(json.dumps({'status':'already_running','base_url':'http://127.0.0.1:8000'}));return
32
+ private=Path('/opt/awm/private');private.mkdir(parents=True,exist_ok=True);private.chmod(0o700)
33
+ log=private/'service.log'
34
+ env={'PATH':'/usr/local/bin:/usr/bin:/bin','HOME':'/root','LANG':'C.UTF-8','LC_ALL':'C.UTF-8',
35
+ 'PYTHONPATH':'/opt/awm/runtime','PYTHONDONTWRITEBYTECODE':'1','PYTHONUNBUFFERED':'1',
36
+ 'ARENA_DEDICATED_CONTAINER':'1','ENABLE_WEB_INTERFACE':'false',
37
+ 'OPENENV_MODE':'simulation','GRADIO_ANALYTICS_ENABLED':'false','HF_HUB_OFFLINE':'1'}
38
+ with log.open('w') as stream:
39
+ process=subprocess.Popen([args.python,'-m','awm.server'],env=env,stdin=subprocess.DEVNULL,
40
+ stdout=stream,stderr=subprocess.STDOUT,start_new_session=True)
41
+ (private/'service.pid').write_text(str(process.pid)+'\n')
42
+ deadline=time.monotonic()+90
43
+ while time.monotonic()<deadline:
44
+ if process.poll() is not None:raise RuntimeError('OpenEnv service exited; inspect its private service.log')
45
+ if ready():
46
+ print(json.dumps({'status':'ready','pid':process.pid,'base_url':'http://127.0.0.1:8000'}));return
47
+ time.sleep(.1)
48
+ process.terminate()
49
+ raise RuntimeError('OpenEnv service did not become ready')
50
+
51
+
52
+ if __name__=='__main__':main()
components/awm/runtime/awm/openenv_app.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from pathlib import Path
3
+ from threading import RLock
4
+ from uuid import uuid4
5
+
6
+ from openenv.core.env_server.http_server import create_app
7
+ from openenv.core.env_server.interfaces import Environment
8
+ from openenv.core.env_server.types import EnvironmentMetadata, State
9
+ from common.models import ArenaAction, ArenaObservation
10
+ from common.http_routes import install_persistent_http_routes
11
+ from .adapter import AWMAdapter
12
+
13
+
14
+ def create_awm_app(task_entries, runtime_parent: Path, *, max_sessions=4):
15
+ task_entries = dict(task_entries)
16
+
17
+ class AWMEnvironment(Environment):
18
+ SUPPORTS_CONCURRENT_SESSIONS = True
19
+
20
+ def __init__(self):
21
+ super().__init__()
22
+ self.backend = AWMAdapter(task_entries, runtime_parent)
23
+ self.lock = RLock()
24
+ self.episode_id = None
25
+ self.step_count = 0
26
+
27
+ def reset(self, *, task_id=None, index=None, split='train', seed=None, episode_id=None, **kwargs):
28
+ with self.lock:
29
+ if kwargs:
30
+ raise ValueError('Unknown reset parameters: ' + ', '.join(sorted(kwargs)))
31
+ if split != 'train':
32
+ raise ValueError('Unknown split')
33
+ names = list(task_entries)
34
+ if index is not None:
35
+ if type(index) is not int or not 0 <= index < len(names):
36
+ raise ValueError('Invalid task index')
37
+ if task_id is not None and task_id != names[index]:
38
+ raise ValueError('task_id and index select different tasks')
39
+ task_id = names[index]
40
+ if task_id is None:
41
+ task_id = names[0]
42
+ value = self.backend.reset(task_id)
43
+ self.episode_id = episode_id or uuid4().hex
44
+ self.step_count = 0
45
+ return ArenaObservation.model_validate(value)
46
+
47
+ def step(self, action, timeout_s=None, **kwargs):
48
+ with self.lock:
49
+ if kwargs:
50
+ raise ValueError('Unknown step parameters')
51
+ validated = action if isinstance(action, ArenaAction) else ArenaAction.model_validate(action)
52
+ was_done = self.backend.state.get('done', False)
53
+ value = self.backend.step(validated)
54
+ if not was_done:
55
+ self.step_count += 1
56
+ return ArenaObservation.model_validate(value)
57
+
58
+ @property
59
+ def state(self):
60
+ with self.lock:
61
+ return State.model_validate({'episode_id': self.episode_id,
62
+ 'step_count': self.step_count, **self.backend.state})
63
+
64
+ def close(self):
65
+ with self.lock:
66
+ self.backend.close()
67
+ self.episode_id = None
68
+ self.step_count = 0
69
+
70
+ def get_metadata(self):
71
+ return EnvironmentMetadata(name='awm_original', version='0.1.0',
72
+ description='Original AWM business workflows with multi-step API tools, isolated state and unchanged state verifiers.')
73
+
74
+ def list_splits(self): return ['train']
75
+
76
+ def list_tasks(self, split):
77
+ if split != 'train':
78
+ raise ValueError('Unknown split')
79
+ return [{'id': name, 'index': index} for index, name in enumerate(task_entries)]
80
+
81
+ def num_tasks(self, split): return len(self.list_tasks(split))
82
+
83
+ def get_task(self, split, index):
84
+ values = self.list_tasks(split)
85
+ if type(index) is not int or not 0 <= index < len(values):
86
+ raise ValueError('Invalid task index')
87
+ return values[index]
88
+
89
+ def get_task_range(self, split, start=None, stop=None):
90
+ return self.list_tasks(split)[start:stop]
91
+
92
+ app = create_app(AWMEnvironment, ArenaAction, ArenaObservation,
93
+ env_name='awm_original', max_concurrent_envs=max_sessions)
94
+ install_persistent_http_routes(app, AWMEnvironment())
95
+ return app
components/awm/runtime/awm/server.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import json
3
+ import os
4
+ from pathlib import Path
5
+
6
+ from .openenv_app import create_awm_app
7
+
8
+
9
+ def load_registry(root):
10
+ root = Path(root).resolve()
11
+ config = json.loads((root / 'config.json').read_text())
12
+ entries = {}
13
+ for item in config['tasks']:
14
+ name = item['task_id']
15
+ directory = (root / 'private/tasks' / name).resolve()
16
+ if directory.parent != root / 'private/tasks' or name in entries:
17
+ raise ValueError('Invalid trusted task registry')
18
+ entries[name] = dict(item, directory=directory)
19
+ return entries
20
+
21
+
22
+ def main():
23
+ import uvicorn
24
+ os.umask(0o077)
25
+ root = Path('/opt/awm')
26
+ app = create_awm_app(load_registry(root), Path('/var/lib/awm'))
27
+ uvicorn.run(app, host='0.0.0.0', port=8000, log_level='warning')
28
+
29
+
30
+ if __name__ == '__main__':
31
+ main()
components/awm/runtime/awm/wire_client.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import argparse
3
+ import base64
4
+ import json
5
+ import math
6
+ import os
7
+ import sys
8
+ import urllib.error
9
+ import urllib.parse
10
+ import urllib.request
11
+
12
+
13
+ class WireProtocolError(RuntimeError):
14
+ pass
15
+
16
+
17
+ class RejectRedirects(urllib.request.HTTPRedirectHandler):
18
+ def redirect_request(self,request,fp,code,message,headers,new_url):
19
+ raise WireProtocolError('Redirects are forbidden for the local OpenEnv transport')
20
+
21
+
22
+ def _constant(value):
23
+ raise WireProtocolError('Non-finite JSON number: '+value)
24
+
25
+
26
+ def _unique(pairs):
27
+ result={}
28
+ for key,value in pairs:
29
+ if key in result:raise WireProtocolError('Duplicate JSON key')
30
+ result[key]=value
31
+ return result
32
+
33
+
34
+ def _finite(value):
35
+ if isinstance(value,float) and not math.isfinite(value):
36
+ raise WireProtocolError('Non-finite wire value')
37
+ if isinstance(value,dict):
38
+ for item in value.values():_finite(item)
39
+ elif isinstance(value,list):
40
+ for item in value:_finite(item)
41
+
42
+
43
+ def loads(raw):
44
+ value=json.loads(raw,parse_constant=_constant,object_pairs_hook=_unique)
45
+ _finite(value)
46
+ return value
47
+
48
+
49
+ def validate_envelope(value,*,require_done=False):
50
+ if not isinstance(value,dict) or not isinstance(value.get('observation'),dict):
51
+ raise WireProtocolError('Missing SDK observation object')
52
+ observation=value['observation']
53
+ if (set(observation)!={'task_id','message','data','metadata'} or
54
+ not isinstance(observation['task_id'],str) or not isinstance(observation['message'],str) or
55
+ not isinstance(observation['data'],dict) or not isinstance(observation['metadata'],dict)):
56
+ raise WireProtocolError('Observation does not match the common public contract')
57
+ if type(value.get('done')) is not bool:
58
+ raise WireProtocolError('SDK done must be a JSON boolean')
59
+ reward=value.get('reward')
60
+ if reward is not None and (type(reward) not in (int,float) or not math.isfinite(reward) or not 0<=reward<=1):
61
+ raise WireProtocolError('SDK reward is not a finite number in [0,1]')
62
+ if require_done and (not value['done'] or reward is None):
63
+ raise WireProtocolError('Finish did not return a terminal numeric score')
64
+ _finite(value)
65
+ return value
66
+
67
+
68
+ class WireClient:
69
+ def __init__(self,base_url='http://127.0.0.1:8000',timeout=330):
70
+ if os.geteuid()!=0:
71
+ raise PermissionError('Wire client is reserved for the trusted supervisor')
72
+ url=urllib.parse.urlsplit(base_url)
73
+ if url.scheme!='http' or url.hostname not in ('127.0.0.1','localhost','::1') or url.username or url.password or url.query or url.fragment or url.path not in ('','/'):
74
+ raise ValueError('Only an unauthenticated local HTTP server is allowed')
75
+ self.base_url=base_url.rstrip('/')
76
+ self.timeout=timeout
77
+ self.opener=urllib.request.build_opener(urllib.request.ProxyHandler({}),RejectRedirects())
78
+
79
+ def _post(self,path,payload):
80
+ body=json.dumps(payload,ensure_ascii=False,allow_nan=False,separators=(',',':')).encode()
81
+ request=urllib.request.Request(self.base_url+path,data=body,headers={'Content-Type':'application/json'})
82
+ try:
83
+ with self.opener.open(request,timeout=self.timeout) as response:
84
+ if response.status!=200:raise WireProtocolError('Unexpected HTTP status')
85
+ raw=response.read(2*1024*1024+1)
86
+ except urllib.error.HTTPError as exc:
87
+ raise WireProtocolError(f'OpenEnv HTTP {exc.code}: '+exc.read(2048).decode(errors='replace')) from exc
88
+ if len(raw)>2*1024*1024:raise WireProtocolError('SDK response exceeds the transport limit')
89
+ return validate_envelope(loads(raw))
90
+
91
+ def reset(self,**kwargs):
92
+ return self._post('/reset',kwargs)
93
+
94
+ def step(self,action):
95
+ return self._post('/step',{'action':action})
96
+
97
+ def finish(self):
98
+ return validate_envelope(self.step({'op':'finish'}),require_done=True)
99
+
100
+
101
+ def main():
102
+ parser=argparse.ArgumentParser()
103
+ parser.add_argument('operation',choices=['reset','step','finish'])
104
+ parser.add_argument('--payload-base64')
105
+ parser.add_argument('--url',default='http://127.0.0.1:8000')
106
+ parser.add_argument('--timeout',type=float,default=330)
107
+ args=parser.parse_args()
108
+ payload={} if args.payload_base64 is None else loads(base64.b64decode(args.payload_base64,validate=True))
109
+ if not isinstance(payload,dict):raise WireProtocolError('Payload must be a JSON object')
110
+ client=WireClient(args.url,args.timeout)
111
+ if args.operation=='reset':result=client.reset(**payload)
112
+ elif args.operation=='step':result=client.step(payload)
113
+ else:
114
+ if payload:raise WireProtocolError('Finish has no payload')
115
+ result=client.finish()
116
+ print(json.dumps(result,ensure_ascii=False,allow_nan=False,separators=(',',':')))
117
+
118
+
119
+ if __name__=='__main__':
120
+ try:main()
121
+ except Exception as exc:
122
+ print(type(exc).__name__+': '+str(exc),file=sys.stderr)
123
+ raise SystemExit(1)
components/awm/runtime/awm/worker.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import asyncio
3
+ import base64
4
+ import importlib.util
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+ import re
9
+ import shutil
10
+ import sqlite3
11
+ import sys
12
+ import traceback
13
+ import warnings
14
+
15
+ warnings.filterwarnings('ignore', category=DeprecationWarning)
16
+ ROOT=Path('/opt/awm')
17
+ PRIVATE=ROOT/'private'
18
+ STATE=Path('/var/lib/awm')
19
+
20
+
21
+ class AWMInfrastructureError(RuntimeError):
22
+
23
+ def __init__(self, kind):
24
+ self.kind=kind
25
+ super().__init__('AWM infrastructure failure: '+kind)
26
+
27
+
28
+ def load(name, path):
29
+ spec=importlib.util.spec_from_file_location(name,path)
30
+ module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module);return module
31
+
32
+
33
+ class Controller:
34
+ def __init__(self, private=PRIVATE, state=STATE):
35
+ self.private=Path(private);self.state=Path(state)
36
+ self.state.mkdir(parents=True,exist_ok=True)
37
+ self.initial=self.private/'initial.db';self.final=self.state/'final.db'
38
+ self.meta_path=self.state/'episode.json'
39
+ self.source=json.loads((self.private/'SOURCE.json').read_text())
40
+ self.api=None;self.mcp=None
41
+
42
+ def metadata(self):
43
+ return json.loads(self.meta_path.read_text())
44
+
45
+ def save(self, value):
46
+ tmp=self.meta_path.with_suffix('.tmp');tmp.write_text(json.dumps(value));tmp.replace(self.meta_path)
47
+
48
+ def runtime(self):
49
+ if self.api is None:
50
+ os.environ['DATABASE_PATH']='sqlite:///'+str(self.final)
51
+ self.api=load('original_business_api',self.private/'original_api.py')
52
+ from fastapi_mcp import FastApiMCP
53
+ self.mcp=FastApiMCP(self.api.app)
54
+ return self.api,self.mcp
55
+
56
+ async def close(self):
57
+ if self.mcp is not None:
58
+ await self.mcp._http_client.aclose()
59
+ if self.api is not None:
60
+ self.api.engine.dispose()
61
+
62
+ def reset(self):
63
+ shutil.copy2(self.initial,self.final)
64
+ self.save({'done':False,'tool_calls':0})
65
+ _,mcp=self.runtime()
66
+ tools=[{'name':t.name,'description':t.description or '',
67
+ 'inputSchema':t.inputSchema} for t in mcp.tools]
68
+ return {'instructions':self.source['task'],
69
+ 'situation':'You have already logged in, and your user id is 1 if required for the MCP tool.',
70
+ 'tools':tools,'task_id':self.source['task_id'],'source_split':'training release',
71
+ 'original_format':'FastAPI exposed through FastApiMCP 0.4.0',
72
+ 'done':False}
73
+
74
+ async def call(self, name, arguments):
75
+ meta=self.metadata()
76
+ if meta['done']:
77
+ return {'content':'Episode is finalized.','done':True,'is_error':True,
78
+ 'tool_calls':meta['tool_calls']}
79
+ api,mcp=self.runtime()
80
+ meta['tool_calls']+=1;self.save(meta)
81
+ schemas={t.name:t.inputSchema for t in mcp.tools}
82
+ if name not in schemas:
83
+ return {'content':f'Error: Unknown tool: {name}','done':False,'is_error':True,
84
+ 'tool_calls':meta['tool_calls']}
85
+
86
+ import httpx
87
+ import jsonschema
88
+ from sqlalchemy.exc import DataError, IntegrityError
89
+ try:
90
+ jsonschema.validate(arguments,schemas[name])
91
+ async with httpx.AsyncClient(transport=httpx.ASGITransport(app=api.app),
92
+ base_url='http://localhost',trust_env=False) as client:
93
+ contents=await mcp._execute_api_tool(client=client,tool_name=name,
94
+ arguments=arguments,operation_map=mcp.operation_map,http_request_info=None)
95
+ text='\n'.join(c.text for c in contents if hasattr(c,'text'))
96
+ return {'content':text,'done':False,'is_error':False,'tool_calls':meta['tool_calls']}
97
+ except (jsonschema.ValidationError, DataError, IntegrityError) as exc:
98
+
99
+
100
+ return {'content':'Error: '+str(exc),'done':False,'is_error':True,
101
+ 'error_kind':'business_argument_error','tool_calls':meta['tool_calls']}
102
+ except Exception as exc:
103
+ frames=traceback.extract_tb(exc.__traceback__)
104
+ invalid_date=isinstance(exc,ValueError) and any(
105
+ (frame.name=='_strptime' and frame.filename.endswith('/_strptime.py'))
106
+ or (frame.filename.endswith('/original_api.py')
107
+ and '.fromisoformat(' in (frame.line or ''))
108
+ for frame in frames)
109
+ if invalid_date:
110
+ return {'content':'Error: '+str(exc),'done':False,'is_error':True,
111
+ 'error_kind':'business_date_error','tool_calls':meta['tool_calls']}
112
+ match=re.match(r'^Error calling '+re.escape(name)+r'\. Status code: (\d{3})\. Response:',str(exc))
113
+ if match and 400<=int(match.group(1))<500:
114
+ return {'content':'Error: '+str(exc),'done':False,'is_error':True,
115
+ 'error_kind':'business_http_'+match.group(1),'tool_calls':meta['tool_calls']}
116
+ kind='api_http_'+match.group(1) if match else type(exc).__name__
117
+ raise AWMInfrastructureError(kind) from exc
118
+
119
+ def finalize(self):
120
+ meta=self.metadata();meta['done']=True;self.save(meta)
121
+ return {'content':'Episode finalized.','done':True,'tool_calls':meta['tool_calls']}
122
+
123
+ def verify(self):
124
+ original=load('original_task_verifier',self.private/'original_verifier.py')
125
+ result=original.verify_task_completion(str(self.initial),str(self.final),None)
126
+ return {'reward':float(result.get('result')=='complete'),'original_result':result,
127
+ 'task_id':self.source['task_id'],'tool_calls':self.metadata()['tool_calls']}
128
+
129
+
130
+
131
+ async def main():
132
+ controller=Controller(private=sys.argv[1],state=sys.argv[2]);operation=sys.argv[3]
133
+ request=json.loads(base64.b64decode(sys.argv[4])) if len(sys.argv)>4 else {}
134
+ if operation=='reset':result=controller.reset()
135
+ elif operation=='call':result=await controller.call(request['name'],request['arguments'])
136
+ elif operation=='finalize':result=controller.finalize()
137
+ elif operation=='verify':
138
+ result=controller.verify()
139
+ else:raise ValueError('Unknown trusted controller operation')
140
+ await controller.close()
141
+ print(json.dumps(result,ensure_ascii=False,allow_nan=False))
142
+
143
+
144
+ if __name__=='__main__':asyncio.run(main())
components/awm/runtime/common/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+
components/awm/runtime/common/contracts.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+
2
+ from copy import deepcopy
3
+
4
+ ACTION_SCHEMA = {'type': 'object', 'description': 'Return one action object per reply, then wait for its observation. To finish, send {"op":"finish"}. A command is a JSON string: encode newlines as \\n and internal double quotes as \\". Do not wrap the object in prose, Markdown, or <tool_call> tags.', 'examples': [{'op': 'finish'}], 'oneOf': [{'properties': {'op': {'const': 'exec'}, 'command': {'type': 'string'}}, 'required': ['op', 'command'], 'additionalProperties': False}, {'properties': {'op': {'const': 'call'}, 'tool': {'type': 'string'}, 'arguments': {'type': 'object'}}, 'required': ['op', 'tool', 'arguments'], 'additionalProperties': False}, {'properties': {'op': {'const': 'finish'}}, 'required': ['op'], 'additionalProperties': False}]}
5
+
6
+ def observation_payload(task_id, message, data=None, reward=0.0, done=False):
7
+ return {"task_id": str(task_id), "message": str(message), "data": {} if data is None else data, "reward": reward, "done": bool(done), "metadata": {}}
components/awm/runtime/common/http_routes.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from threading import RLock
3
+ from contextlib import asynccontextmanager
4
+ from copy import deepcopy
5
+ from fastapi import HTTPException
6
+ from pydantic import ValidationError
7
+ from starlette.concurrency import run_in_threadpool
8
+ from openenv.core.env_server.serialization import serialize_observation
9
+ from openenv.core.env_server.types import ResetRequest,ResetResponse,StepRequest,StepResponse
10
+ from .models import ArenaAction
11
+
12
+
13
+ def install_persistent_http_routes(app,env,conflict_error=None):
14
+ lock=RLock()
15
+ app.router.routes=[route for route in app.router.routes if getattr(route,'path',None) not in {'/reset','/step','/state'}]
16
+
17
+ def reset_sync(request):
18
+ with lock:
19
+ return ResetResponse(**serialize_observation(env.reset(**request.model_dump(exclude_unset=True))))
20
+
21
+ def step_sync(request):
22
+ with lock:
23
+ action=ArenaAction.model_validate(request.action)
24
+ return StepResponse(**serialize_observation(env.step(action,timeout_s=request.timeout_s)))
25
+
26
+ def state_sync():
27
+ with lock:
28
+ value=env.state
29
+ return value.model_copy(deep=True) if hasattr(value,'model_copy') else deepcopy(value)
30
+
31
+ @app.post('/reset',response_model=ResetResponse)
32
+ async def reset(request:ResetRequest):
33
+ try:return await run_in_threadpool(reset_sync,request)
34
+ except (ValueError,IndexError) as exc:raise HTTPException(status_code=400,detail=str(exc)) from exc
35
+ except Exception as exc:
36
+ if conflict_error is not None and isinstance(exc,conflict_error):
37
+ raise HTTPException(status_code=409,detail=str(exc)) from exc
38
+ raise
39
+
40
+ @app.post('/step',response_model=StepResponse)
41
+ async def step(request:StepRequest):
42
+ try:return await run_in_threadpool(step_sync,request)
43
+ except (ValueError,ValidationError) as exc:raise HTTPException(status_code=422,detail=str(exc)) from exc
44
+
45
+ @app.get('/state')
46
+ async def state():
47
+ return await run_in_threadpool(state_sync)
48
+
49
+ def shutdown():
50
+ with lock:env.close()
51
+
52
+
53
+
54
+
55
+ original_lifespan=app.router.lifespan_context
56
+
57
+ @asynccontextmanager
58
+ async def lifespan(application):
59
+ async with original_lifespan(application) as state:
60
+ try:yield state
61
+ finally:await run_in_threadpool(shutdown)
62
+
63
+ app.router.lifespan_context=lifespan
64
+ return lock
components/awm/runtime/common/models.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from copy import deepcopy
3
+ import math
4
+ from typing import Any, Literal
5
+ import jsonschema
6
+ from openenv.core.env_server.types import Action, Observation
7
+ from pydantic import ConfigDict, Field, model_serializer, model_validator
8
+ from .contracts import ACTION_SCHEMA
9
+
10
+
11
+ class ArenaAction(Action):
12
+ model_config=ConfigDict(extra='forbid',frozen=True,validate_assignment=False)
13
+ op: Literal['exec', 'call', 'finish']
14
+ command: str | None = None
15
+ tool: str | None = None
16
+ arguments: dict[str, Any] | None = None
17
+
18
+ @model_validator(mode='before')
19
+ @classmethod
20
+ def exact_contract(cls, value):
21
+ if isinstance(value, cls):
22
+ return value
23
+ def finite(item):
24
+ if isinstance(item,float) and not math.isfinite(item):
25
+ raise ValueError('Non-finite JSON number')
26
+ if isinstance(item,dict):
27
+ for part in item.values():finite(part)
28
+ elif isinstance(item,list):
29
+ for part in item:finite(part)
30
+ finite(value)
31
+ try:
32
+ jsonschema.Draft202012Validator(ACTION_SCHEMA).validate(value)
33
+ except jsonschema.ValidationError as exc:
34
+ raise ValueError(exc.message) from exc
35
+ return value
36
+
37
+ @classmethod
38
+ def __get_pydantic_json_schema__(cls, core_schema, handler):
39
+ return deepcopy(ACTION_SCHEMA)
40
+
41
+ def action_payload(self):
42
+ if self.op=='exec':return {'op':'exec','command':self.command}
43
+ if self.op=='call':return {'op':'call','tool':self.tool,'arguments':self.arguments}
44
+ return {'op':'finish'}
45
+
46
+ @model_serializer
47
+ def canonical_serialization(self):
48
+ return self.action_payload()
49
+
50
+
51
+ class ArenaObservation(Observation):
52
+ task_id: str = ''
53
+ message: str = ''
54
+ data: dict[str, Any] = Field(default_factory=dict)
components/awm/upstream/README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: "cc-by-4.0"
3
+ language:
4
+ - en
5
+ tags:
6
+ - agent
7
+ - tool-use
8
+ - reinforcement-learning
9
+ - mcp
10
+ - synthetic
11
+ pretty_name: "agent-world-model"
12
+ viewer: false
13
+ ---
14
+
15
+ <h1 align="center">AgentWorldModel-1K</h1>
16
+
17
+ <h3 align="center">Agent World Model: Infinity Synthetic Environments for Agentic Reinforcement Learning</h3>
18
+
19
+ <p align="center">
20
+ <a href="https://github.com/Raibows">Zhaoyang Wang<sup>1</sup></a>,
21
+ <a href="https://www.canwenxu.net/">Canwen Xu<sup>2</sup></a>,
22
+ <a href="https://www.snowflake.com/en/blog/authors/boyi-liu/">Boyi Liu<sup>2</sup></a>,
23
+ <a href="https://yitewang.github.io/">Yite Wang<sup>2</sup></a>,
24
+ <a href="https://lillianwei-h.github.io/">Siwei Han<sup>1</sup></a>,<br/>
25
+ <a href="https://yaozhewei.github.io/">Zhewei Yao<sup>2</sup></a>,
26
+ <a href="https://www.huaxiuyao.io/">Huaxiu Yao<sup>1</sup></a>,
27
+ <a href="https://www.snowflake.com/en/blog/authors/yuxiong-he/">Yuxiong He<sup>2</sup></a>
28
+ </p>
29
+ <p align="center">
30
+ <sup>1</sup>UNC-Chapel Hill &nbsp; <sup>2</sup>Snowflake AI Research &nbsp;
31
+ </p>
32
+
33
+
34
+
35
+ # Overview
36
+
37
+ **AgentWorldModel-1K** contains 1,000 fully synthetic, executable, SQL database-backed tool-use environments exposed via a unified MCP (Model Context Protocol) interface, designed for large-scale multi-turn agentic reinforcement learning.
38
+
39
+ Each environment is synthesized through the **Agent World Model (AWM)** pipeline:
40
+
41
+ 1. **Scenario** — A high-level description (e.g., "an online shopping platform")
42
+ 2. **Tasks** — 10 user tasks per scenario that serve as functional requirements
43
+ 3. **Database** — SQLite database schema and sample data as the state backend
44
+ 4. **Interface** — Python interface layer (FastAPI + MCP) as the action/observation space
45
+ 5. **Verification** — Verification code that inspects database state changes for reward signals
46
+
47
+ For the full synthesis pipeline, please visit [https://github.com/Snowflake-Labs/agent-world-model](https://github.com/Snowflake-Labs/agent-world-model).
48
+
49
+ # Resources
50
+ Related resources are also available, please check:
51
+
52
+ | Resource | Link |
53
+ |----------|------|
54
+ | 📄 Paper | [📄 arxiv.org/abs/2602.10090](https://arxiv.org/abs/2602.10090) |
55
+ | 💻 Code | [💻 Snowflake-Labs/agent-world-model](https://github.com/Snowflake-Labs/agent-world-model) |
56
+ | 📦 AgentWorldModel-1K | [🤗 Snowflake/AgentWorldModel-1K](https://huggingface.co/datasets/Snowflake/AgentWorldModel-1K) |
57
+ | 🤖 Arctic-AWM-4B | [🤗 Snowflake/Arctic-AWM-4B](https://huggingface.co/Snowflake/Arctic-AWM-4B) |
58
+ | 🤖 Arctic-AWM-8B | [🤗 Snowflake/Arctic-AWM-8B](https://huggingface.co/Snowflake/Arctic-AWM-8B) |
59
+ | 🤖 Arctic-AWM-14B | [🤗 Snowflake/Arctic-AWM-14B](https://huggingface.co/Snowflake/Arctic-AWM-14B) |
60
+
61
+
62
+ # Dataset Files
63
+
64
+ | File | #Entries | Description |
65
+ |------|----------|-------------|
66
+ | `gen_scenario.jsonl` | 1,000 | Synthesized scenario descriptions |
67
+ | `gen_tasks.jsonl` | 1,000 | 10 user tasks per scenario |
68
+ | `gen_db.jsonl` | 1,000 | Database schema definitions for each scenario |
69
+ | `gen_sample.jsonl` | 1,000 | Sample data to populate the initial database state |
70
+ | `gen_spec.jsonl` | 1,000 | API specifications for each scenario's interface |
71
+ | `gen_envs.jsonl` | 1,000 | MCP environment code (FastAPI + MCP server) |
72
+ | `gen_verifier.jsonl` | 10K | Verification code for code-augmented LLM-as-a-Judge |
73
+ | `gen_verifier.pure_code.jsonl` | 10K | Verification code for purely code-based Judge |
74
+
75
+ # Citation
76
+
77
+ If you find this resource useful, please kindly cite:
78
+
79
+ ```bibtex
80
+ @article{wang2026agentworldmodelinfinity,
81
+ title={Agent World Model: Infinity Synthetic Environments for Agentic Reinforcement Learning},
82
+ author={Zhaoyang Wang and Canwen Xu and Boyi Liu and Yite Wang and Siwei Han and Zhewei Yao and Huaxiu Yao and Yuxiong He},
83
+ year={2026},
84
+ eprint={2602.10090},
85
+ archivePrefix={arXiv},
86
+ primaryClass={cs.AI},
87
+ url={https://arxiv.org/abs/2602.10090},
88
+ }
89
+ ```
components/awm/upstream/accounting_1-gen_db.jsonl ADDED
@@ -0,0 +1 @@
 
 
1
+ {"scenario": "accounting_1", "db_schema": {"tables": [{"name": "users", "ddl": "CREATE TABLE users (\n id INTEGER PRIMARY KEY,\n username TEXT UNIQUE NOT NULL,\n email TEXT UNIQUE NOT NULL,\n full_name TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME\n);", "indexes": ["CREATE INDEX idx_users_email ON users(email);"]}, {"name": "departments", "ddl": "CREATE TABLE departments (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n description TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME\n);", "indexes": ["CREATE UNIQUE INDEX idx_departments_name ON departments(name);"]}, {"name": "tax_categories", "ddl": "CREATE TABLE tax_categories (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n description TEXT,\n rate REAL NOT NULL CHECK(rate >= 0),\n is_compound INTEGER NOT NULL DEFAULT 0 CHECK(is_compound IN (0,1)),\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME\n);", "indexes": ["CREATE UNIQUE INDEX idx_tax_categories_name ON tax_categories(name);"]}, {"name": "payment_terms", "ddl": "CREATE TABLE payment_terms (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n days INTEGER NOT NULL CHECK(days >= 0),\n description TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME\n);", "indexes": ["CREATE UNIQUE INDEX idx_payment_terms_name ON payment_terms(name);"]}, {"name": "customers", "ddl": "CREATE TABLE customers (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n billing_email TEXT,\n payment_terms_id INTEGER,\n default_tax_category_id INTEGER,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (payment_terms_id) REFERENCES payment_terms(id),\n FOREIGN KEY (default_tax_category_id) REFERENCES tax_categories(id)\n);", "indexes": ["CREATE UNIQUE INDEX idx_customers_name ON customers(name);", "CREATE INDEX idx_customers_payment_terms_id ON customers(payment_terms_id);", "CREATE INDEX idx_customers_tax_category_id ON customers(default_tax_category_id);"]}, {"name": "vendors", "ddl": "CREATE TABLE vendors (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n contact_email TEXT,\n payment_terms_id INTEGER,\n default_expense_category_id INTEGER,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (payment_terms_id) REFERENCES payment_terms(id),\n FOREIGN KEY (default_expense_category_id) REFERENCES accounts(id)\n);", "indexes": ["CREATE UNIQUE INDEX idx_vendors_name ON vendors(name);", "CREATE INDEX idx_vendors_payment_terms_id ON vendors(payment_terms_id);", "CREATE INDEX idx_vendors_expense_category_id ON vendors(default_expense_category_id);"]}, {"name": "accounts", "ddl": "CREATE TABLE accounts (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n code TEXT,\n type TEXT NOT NULL CHECK(type IN ('asset','liability','equity','income','expense','contra')), \n sub_type TEXT,\n is_active INTEGER NOT NULL DEFAULT 1 CHECK(is_active IN (0,1)),\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME\n);", "indexes": ["CREATE UNIQUE INDEX idx_accounts_name ON accounts(name);", "CREATE INDEX idx_accounts_type ON accounts(type);"]}, {"name": "bank_accounts", "ddl": "CREATE TABLE bank_accounts (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n institution_name TEXT,\n account_number_masked TEXT,\n account_id INTEGER NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (account_id) REFERENCES accounts(id)\n);", "indexes": ["CREATE UNIQUE INDEX idx_bank_accounts_name ON bank_accounts(name);", "CREATE INDEX idx_bank_accounts_account_id ON bank_accounts(account_id);"]}, {"name": "invoices", "ddl": "CREATE TABLE invoices (\n id INTEGER PRIMARY KEY,\n invoice_number TEXT NOT NULL UNIQUE,\n customer_id INTEGER NOT NULL,\n department_id INTEGER,\n tax_category_id INTEGER,\n invoice_date DATE NOT NULL,\n due_date DATE NOT NULL,\n currency TEXT NOT NULL DEFAULT 'USD',\n status TEXT NOT NULL CHECK(status IN ('draft','open','paid','void')), \n subtotal REAL NOT NULL DEFAULT 0 CHECK(subtotal >= 0),\n tax_amount REAL NOT NULL DEFAULT 0 CHECK(tax_amount >= 0),\n total REAL NOT NULL DEFAULT 0 CHECK(total >= 0),\n balance_due REAL NOT NULL DEFAULT 0,\n payment_terms_id INTEGER,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (customer_id) REFERENCES customers(id),\n FOREIGN KEY (department_id) REFERENCES departments(id),\n FOREIGN KEY (tax_category_id) REFERENCES tax_categories(id),\n FOREIGN KEY (payment_terms_id) REFERENCES payment_terms(id)\n);", "indexes": ["CREATE UNIQUE INDEX idx_invoices_invoice_number ON invoices(invoice_number);", "CREATE INDEX idx_invoices_customer_id ON invoices(customer_id);", "CREATE INDEX idx_invoices_department_id ON invoices(department_id);", "CREATE INDEX idx_invoices_tax_category_id ON invoices(tax_category_id);", "CREATE INDEX idx_invoices_invoice_date ON invoices(invoice_date);"]}, {"name": "invoice_line_items", "ddl": "CREATE TABLE invoice_line_items (\n id INTEGER PRIMARY KEY,\n invoice_id INTEGER NOT NULL,\n description TEXT NOT NULL,\n quantity REAL NOT NULL CHECK(quantity > 0),\n unit_price REAL NOT NULL CHECK(unit_price >= 0),\n discount_percent REAL NOT NULL DEFAULT 0 CHECK(discount_percent >= 0 AND discount_percent <= 100),\n line_subtotal REAL NOT NULL DEFAULT 0 CHECK(line_subtotal >= 0),\n tax_amount REAL NOT NULL DEFAULT 0 CHECK(tax_amount >= 0),\n total REAL NOT NULL DEFAULT 0 CHECK(total >= 0),\n revenue_account_id INTEGER,\n department_id INTEGER,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (invoice_id) REFERENCES invoices(id) ON DELETE CASCADE,\n FOREIGN KEY (revenue_account_id) REFERENCES accounts(id),\n FOREIGN KEY (department_id) REFERENCES departments(id)\n);", "indexes": ["CREATE INDEX idx_invoice_line_items_invoice_id ON invoice_line_items(invoice_id);", "CREATE INDEX idx_invoice_line_items_department_id ON invoice_line_items(department_id);"]}, {"name": "payments", "ddl": "CREATE TABLE payments (\n id INTEGER PRIMARY KEY,\n customer_id INTEGER NOT NULL,\n payment_date DATE NOT NULL,\n settlement_date DATE,\n amount REAL NOT NULL CHECK(amount > 0),\n currency TEXT NOT NULL DEFAULT 'USD',\n method TEXT NOT NULL,\n reference TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (customer_id) REFERENCES customers(id)\n);", "indexes": ["CREATE INDEX idx_payments_customer_id ON payments(customer_id);", "CREATE INDEX idx_payments_payment_date ON payments(payment_date);"]}, {"name": "payment_applications", "ddl": "CREATE TABLE payment_applications (\n id INTEGER PRIMARY KEY,\n payment_id INTEGER NOT NULL,\n invoice_id INTEGER NOT NULL,\n amount REAL NOT NULL CHECK(amount > 0),\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (payment_id) REFERENCES payments(id) ON DELETE CASCADE,\n FOREIGN KEY (invoice_id) REFERENCES invoices(id) ON DELETE CASCADE\n);", "indexes": ["CREATE INDEX idx_payment_applications_payment_id ON payment_applications(payment_id);", "CREATE INDEX idx_payment_applications_invoice_id ON payment_applications(invoice_id);"]}, {"name": "bills", "ddl": "CREATE TABLE bills (\n id INTEGER PRIMARY KEY,\n bill_number TEXT,\n vendor_id INTEGER NOT NULL,\n bill_date DATE NOT NULL,\n due_date DATE,\n currency TEXT NOT NULL DEFAULT 'USD',\n amount REAL NOT NULL CHECK(amount >= 0),\n description TEXT,\n department_id INTEGER,\n reimbursement_status TEXT NOT NULL CHECK(reimbursement_status IN ('Not Reimbursable','Reimbursable','Reimbursed')),\n payment_terms_id INTEGER,\n status TEXT NOT NULL DEFAULT 'open' CHECK(status IN ('open','paid','void')),\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (vendor_id) REFERENCES vendors(id),\n FOREIGN KEY (department_id) REFERENCES departments(id),\n FOREIGN KEY (payment_terms_id) REFERENCES payment_terms(id)\n);", "indexes": ["CREATE INDEX idx_bills_vendor_id ON bills(vendor_id);", "CREATE INDEX idx_bills_department_id ON bills(department_id);", "CREATE INDEX idx_bills_bill_date ON bills(bill_date);"]}, {"name": "recurring_expenses", "ddl": "CREATE TABLE recurring_expenses (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL,\n vendor_id INTEGER,\n amount REAL NOT NULL CHECK(amount >= 0),\n expense_account_id INTEGER NOT NULL,\n department_id INTEGER,\n frequency TEXT NOT NULL CHECK(frequency IN ('daily','weekly','monthly','quarterly','yearly')),\n next_run_date DATE NOT NULL,\n end_date DATE,\n is_active INTEGER NOT NULL DEFAULT 1 CHECK(is_active IN (0,1)),\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (vendor_id) REFERENCES vendors(id),\n FOREIGN KEY (expense_account_id) REFERENCES accounts(id),\n FOREIGN KEY (department_id) REFERENCES departments(id)\n);", "indexes": ["CREATE INDEX idx_recurring_expenses_vendor_id ON recurring_expenses(vendor_id);", "CREATE INDEX idx_recurring_expenses_next_run_date ON recurring_expenses(next_run_date);", "CREATE INDEX idx_recurring_expenses_department_id ON recurring_expenses(department_id);"]}, {"name": "bank_transactions", "ddl": "CREATE TABLE bank_transactions (\n id INTEGER PRIMARY KEY,\n bank_account_id INTEGER NOT NULL,\n transaction_date DATE NOT NULL,\n posted_date DATE,\n description TEXT NOT NULL,\n amount REAL NOT NULL,\n external_id TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (bank_account_id) REFERENCES bank_accounts(id)\n);", "indexes": ["CREATE INDEX idx_bank_transactions_account_id ON bank_transactions(bank_account_id);", "CREATE INDEX idx_bank_transactions_date ON bank_transactions(transaction_date);"]}, {"name": "journal_entries", "ddl": "CREATE TABLE journal_entries (\n id INTEGER PRIMARY KEY,\n entry_date DATE NOT NULL,\n description TEXT,\n department_id INTEGER,\n source TEXT,\n source_id INTEGER,\n created_by_user_id INTEGER,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (department_id) REFERENCES departments(id),\n FOREIGN KEY (created_by_user_id) REFERENCES users(id)\n);", "indexes": ["CREATE INDEX idx_journal_entries_entry_date ON journal_entries(entry_date);", "CREATE INDEX idx_journal_entries_department_id ON journal_entries(department_id);"]}, {"name": "journal_entry_lines", "ddl": "CREATE TABLE journal_entry_lines (\n id INTEGER PRIMARY KEY,\n journal_entry_id INTEGER NOT NULL,\n account_id INTEGER NOT NULL,\n department_id INTEGER,\n description TEXT,\n debit REAL NOT NULL DEFAULT 0 CHECK(debit >= 0),\n credit REAL NOT NULL DEFAULT 0 CHECK(credit >= 0),\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (journal_entry_id) REFERENCES journal_entries(id) ON DELETE CASCADE,\n FOREIGN KEY (account_id) REFERENCES accounts(id),\n FOREIGN KEY (department_id) REFERENCES departments(id)\n);", "indexes": ["CREATE INDEX idx_journal_entry_lines_entry_id ON journal_entry_lines(journal_entry_id);", "CREATE INDEX idx_journal_entry_lines_account_id ON journal_entry_lines(account_id);", "CREATE INDEX idx_journal_entry_lines_department_id ON journal_entry_lines(department_id);"]}, {"name": "bank_transaction_journal_links", "ddl": "CREATE TABLE bank_transaction_journal_links (\n id INTEGER PRIMARY KEY,\n bank_transaction_id INTEGER NOT NULL,\n journal_entry_id INTEGER NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (bank_transaction_id) REFERENCES bank_transactions(id) ON DELETE CASCADE,\n FOREIGN KEY (journal_entry_id) REFERENCES journal_entries(id) ON DELETE CASCADE\n);", "indexes": ["CREATE INDEX idx_bt_journal_links_bt_id ON bank_transaction_journal_links(bank_transaction_id);", "CREATE INDEX idx_bt_journal_links_je_id ON bank_transaction_journal_links(journal_entry_id);"]}, {"name": "recurring_invoices", "ddl": "CREATE TABLE recurring_invoices (\n id INTEGER PRIMARY KEY,\n customer_id INTEGER NOT NULL,\n name TEXT NOT NULL,\n description TEXT,\n quantity REAL NOT NULL CHECK(quantity > 0),\n unit_price REAL NOT NULL CHECK(unit_price >= 0),\n discount_percent REAL NOT NULL DEFAULT 0 CHECK(discount_percent >= 0 AND discount_percent <= 100),\n frequency TEXT NOT NULL CHECK(frequency IN ('daily','weekly','monthly','quarterly','yearly')),\n next_run_date DATE NOT NULL,\n end_date DATE,\n payment_terms_id INTEGER,\n tax_category_id INTEGER,\n department_id INTEGER,\n currency TEXT NOT NULL DEFAULT 'USD',\n is_active INTEGER NOT NULL DEFAULT 1 CHECK(is_active IN (0,1)),\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n FOREIGN KEY (customer_id) REFERENCES customers(id),\n FOREIGN KEY (payment_terms_id) REFERENCES payment_terms(id),\n FOREIGN KEY (tax_category_id) REFERENCES tax_categories(id),\n FOREIGN KEY (department_id) REFERENCES departments(id)\n);", "indexes": ["CREATE INDEX idx_recurring_invoices_customer_id ON recurring_invoices(customer_id);", "CREATE INDEX idx_recurring_invoices_next_run_date ON recurring_invoices(next_run_date);", "CREATE INDEX idx_recurring_invoices_department_id ON recurring_invoices(department_id);"]}, {"name": "accounting_periods", "ddl": "CREATE TABLE accounting_periods (\n id INTEGER PRIMARY KEY,\n start_date DATE NOT NULL,\n end_date DATE NOT NULL,\n close_date DATE,\n is_locked INTEGER NOT NULL DEFAULT 0 CHECK(is_locked IN (0,1)),\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME,\n CHECK (start_date <= end_date)\n);", "indexes": ["CREATE INDEX idx_accounting_periods_start_end ON accounting_periods(start_date, end_date);", "CREATE INDEX idx_accounting_periods_is_locked ON accounting_periods(is_locked);"]}]}, "db_path": "./outputs/databases/accounting_1.db"}
components/awm/upstream/accounting_1-gen_envs.jsonl ADDED
@@ -0,0 +1 @@
 
 
1
+ {"scenario": "accounting_1", "db_path": "./outputs/databases/accounting_1.db", "full_code": "from fastapi import FastAPI, Query, Path, Body\nfrom pydantic import BaseModel, Field, ConfigDict\nfrom typing import Optional, List, Dict\nfrom datetime import datetime, date\nimport os\nfrom sqlalchemy import (\n create_engine,\n Column,\n Integer,\n String,\n DateTime,\n Date,\n Float,\n Text,\n ForeignKey,\n CheckConstraint,\n Index,\n)\nfrom sqlalchemy.orm import declarative_base, relationship, sessionmaker\n\ndatabase_url = os.getenv(\"DATABASE_PATH\", \"sqlite:///outputs/databases/zenledger_small_business_accounting_suite.db\")\nengine = create_engine(database_url, future=True)\nSessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False, future=True)\nBase = declarative_base()\n\nclass User(Base):\n __tablename__ = \"users\"\n id = Column(Integer, primary_key=True)\n username = Column(Text, unique=True, nullable=False)\n email = Column(Text, unique=True, nullable=False)\n full_name = Column(Text)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass Department(Base):\n __tablename__ = \"departments\"\n id = Column(Integer, primary_key=True)\n name = Column(Text, unique=True, nullable=False)\n description = Column(Text)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass TaxCategory(Base):\n __tablename__ = \"tax_categories\"\n id = Column(Integer, primary_key=True)\n name = Column(Text, unique=True, nullable=False)\n description = Column(Text)\n rate = Column(Float, nullable=False)\n is_compound = Column(Integer, nullable=False, default=0)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass PaymentTerm(Base):\n __tablename__ = \"payment_terms\"\n id = Column(Integer, primary_key=True)\n name = Column(Text, unique=True, nullable=False)\n days = Column(Integer, nullable=False)\n description = Column(Text)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass Customer(Base):\n __tablename__ = \"customers\"\n id = Column(Integer, primary_key=True)\n name = Column(Text, unique=True, nullable=False)\n billing_email = Column(Text)\n payment_terms_id = Column(Integer, ForeignKey(\"payment_terms.id\"))\n default_tax_category_id = Column(Integer, ForeignKey(\"tax_categories.id\"))\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass Account(Base):\n __tablename__ = \"accounts\"\n id = Column(Integer, primary_key=True)\n name = Column(Text, unique=True, nullable=False)\n code = Column(Text)\n type = Column(Text, nullable=False)\n sub_type = Column(Text)\n is_active = Column(Integer, nullable=False, default=1)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass Vendor(Base):\n __tablename__ = \"vendors\"\n id = Column(Integer, primary_key=True)\n name = Column(Text, unique=True, nullable=False)\n contact_email = Column(Text)\n payment_terms_id = Column(Integer, ForeignKey(\"payment_terms.id\"))\n default_expense_category_id = Column(Integer, ForeignKey(\"accounts.id\"))\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass BankAccount(Base):\n __tablename__ = \"bank_accounts\"\n id = Column(Integer, primary_key=True)\n name = Column(Text, unique=True, nullable=False)\n institution_name = Column(Text)\n account_number_masked = Column(Text)\n account_id = Column(Integer, ForeignKey(\"accounts.id\"), nullable=False)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass Invoice(Base):\n __tablename__ = \"invoices\"\n id = Column(Integer, primary_key=True)\n invoice_number = Column(Text, unique=True, nullable=False)\n customer_id = Column(Integer, ForeignKey(\"customers.id\"), nullable=False)\n department_id = Column(Integer, ForeignKey(\"departments.id\"))\n tax_category_id = Column(Integer, ForeignKey(\"tax_categories.id\"))\n invoice_date = Column(Date, nullable=False)\n due_date = Column(Date, nullable=False)\n currency = Column(Text, nullable=False, default=\"USD\")\n status = Column(Text, nullable=False)\n subtotal = Column(Float, nullable=False, default=0.0)\n tax_amount = Column(Float, nullable=False, default=0.0)\n total = Column(Float, nullable=False, default=0.0)\n balance_due = Column(Float, nullable=False, default=0.0)\n payment_terms_id = Column(Integer, ForeignKey(\"payment_terms.id\"))\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass InvoiceLineItem(Base):\n __tablename__ = \"invoice_line_items\"\n id = Column(Integer, primary_key=True)\n invoice_id = Column(Integer, ForeignKey(\"invoices.id\", ondelete=\"CASCADE\"), nullable=False)\n description = Column(Text, nullable=False)\n quantity = Column(Float, nullable=False)\n unit_price = Column(Float, nullable=False)\n discount_percent = Column(Float, nullable=False, default=0.0)\n line_subtotal = Column(Float, nullable=False, default=0.0)\n tax_amount = Column(Float, nullable=False, default=0.0)\n total = Column(Float, nullable=False, default=0.0)\n revenue_account_id = Column(Integer, ForeignKey(\"accounts.id\"))\n department_id = Column(Integer, ForeignKey(\"departments.id\"))\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass Payment(Base):\n __tablename__ = \"payments\"\n id = Column(Integer, primary_key=True)\n customer_id = Column(Integer, ForeignKey(\"customers.id\"), nullable=False)\n payment_date = Column(Date, nullable=False)\n settlement_date = Column(Date)\n amount = Column(Float, nullable=False)\n currency = Column(Text, nullable=False, default=\"USD\")\n method = Column(Text, nullable=False)\n reference = Column(Text)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass PaymentApplication(Base):\n __tablename__ = \"payment_applications\"\n id = Column(Integer, primary_key=True)\n payment_id = Column(Integer, ForeignKey(\"payments.id\", ondelete=\"CASCADE\"), nullable=False)\n invoice_id = Column(Integer, ForeignKey(\"invoices.id\", ondelete=\"CASCADE\"), nullable=False)\n amount = Column(Float, nullable=False)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass Bill(Base):\n __tablename__ = \"bills\"\n id = Column(Integer, primary_key=True)\n bill_number = Column(Text)\n vendor_id = Column(Integer, ForeignKey(\"vendors.id\"), nullable=False)\n bill_date = Column(Date, nullable=False)\n due_date = Column(Date)\n currency = Column(Text, nullable=False, default=\"USD\")\n amount = Column(Float, nullable=False)\n description = Column(Text)\n department_id = Column(Integer, ForeignKey(\"departments.id\"))\n reimbursement_status = Column(Text, nullable=False)\n payment_terms_id = Column(Integer, ForeignKey(\"payment_terms.id\"))\n status = Column(Text, nullable=False, default=\"open\")\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass RecurringExpense(Base):\n __tablename__ = \"recurring_expenses\"\n id = Column(Integer, primary_key=True)\n name = Column(Text, nullable=False)\n vendor_id = Column(Integer, ForeignKey(\"vendors.id\"))\n amount = Column(Float, nullable=False)\n expense_account_id = Column(Integer, ForeignKey(\"accounts.id\"), nullable=False)\n department_id = Column(Integer, ForeignKey(\"departments.id\"))\n frequency = Column(Text, nullable=False)\n next_run_date = Column(Date, nullable=False)\n end_date = Column(Date)\n is_active = Column(Integer, nullable=False, default=1)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass BankTransaction(Base):\n __tablename__ = \"bank_transactions\"\n id = Column(Integer, primary_key=True)\n bank_account_id = Column(Integer, ForeignKey(\"bank_accounts.id\"), nullable=False)\n transaction_date = Column(Date, nullable=False)\n posted_date = Column(Date)\n description = Column(Text, nullable=False)\n amount = Column(Float, nullable=False)\n external_id = Column(Text)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass JournalEntry(Base):\n __tablename__ = \"journal_entries\"\n id = Column(Integer, primary_key=True)\n entry_date = Column(Date, nullable=False)\n description = Column(Text)\n department_id = Column(Integer, ForeignKey(\"departments.id\"))\n source = Column(Text)\n source_id = Column(Integer)\n created_by_user_id = Column(Integer, ForeignKey(\"users.id\"))\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass JournalEntryLine(Base):\n __tablename__ = \"journal_entry_lines\"\n id = Column(Integer, primary_key=True)\n journal_entry_id = Column(Integer, ForeignKey(\"journal_entries.id\", ondelete=\"CASCADE\"), nullable=False)\n account_id = Column(Integer, ForeignKey(\"accounts.id\"), nullable=False)\n department_id = Column(Integer, ForeignKey(\"departments.id\"))\n description = Column(Text)\n debit = Column(Float, nullable=False, default=0.0)\n credit = Column(Float, nullable=False, default=0.0)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass BankTransactionJournalLink(Base):\n __tablename__ = \"bank_transaction_journal_links\"\n id = Column(Integer, primary_key=True)\n bank_transaction_id = Column(Integer, ForeignKey(\"bank_transactions.id\", ondelete=\"CASCADE\"), nullable=False)\n journal_entry_id = Column(Integer, ForeignKey(\"journal_entries.id\", ondelete=\"CASCADE\"), nullable=False)\n created_at = Column(DateTime, default=datetime.utcnow)\n\nclass RecurringInvoice(Base):\n __tablename__ = \"recurring_invoices\"\n id = Column(Integer, primary_key=True)\n customer_id = Column(Integer, ForeignKey(\"customers.id\"), nullable=False)\n name = Column(Text, nullable=False)\n description = Column(Text)\n quantity = Column(Float, nullable=False)\n unit_price = Column(Float, nullable=False)\n discount_percent = Column(Float, nullable=False, default=0.0)\n frequency = Column(Text, nullable=False)\n next_run_date = Column(Date, nullable=False)\n end_date = Column(Date)\n payment_terms_id = Column(Integer, ForeignKey(\"payment_terms.id\"))\n tax_category_id = Column(Integer, ForeignKey(\"tax_categories.id\"))\n department_id = Column(Integer, ForeignKey(\"departments.id\"))\n currency = Column(Text, nullable=False, default=\"USD\")\n is_active = Column(Integer, nullable=False, default=1)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nclass AccountingPeriod(Base):\n __tablename__ = \"accounting_periods\"\n id = Column(Integer, primary_key=True)\n start_date = Column(Date, nullable=False)\n end_date = Column(Date, nullable=False)\n close_date = Column(Date)\n is_locked = Column(Integer, nullable=False, default=0)\n created_at = Column(DateTime, default=datetime.utcnow)\n updated_at = Column(DateTime)\n\nIndex(\"idx_users_email\", User.email)\nIndex(\"idx_departments_name\", Department.name, unique=True)\nIndex(\"idx_tax_categories_name\", TaxCategory.name, unique=True)\nIndex(\"idx_payment_terms_name\", PaymentTerm.name, unique=True)\nIndex(\"idx_customers_name\", Customer.name, unique=True)\nIndex(\"idx_customers_payment_terms_id\", Customer.payment_terms_id)\nIndex(\"idx_customers_tax_category_id\", Customer.default_tax_category_id)\nIndex(\"idx_vendors_name\", Vendor.name, unique=True)\nIndex(\"idx_vendors_payment_terms_id\", Vendor.payment_terms_id)\nIndex(\"idx_vendors_expense_category_id\", Vendor.default_expense_category_id)\nIndex(\"idx_accounts_name\", Account.name, unique=True)\nIndex(\"idx_accounts_type\", Account.type)\nIndex(\"idx_bank_accounts_name\", BankAccount.name, unique=True)\nIndex(\"idx_bank_accounts_account_id\", BankAccount.account_id)\nIndex(\"idx_invoices_invoice_number\", Invoice.invoice_number, unique=True)\nIndex(\"idx_invoices_customer_id\", Invoice.customer_id)\nIndex(\"idx_invoices_department_id\", Invoice.department_id)\nIndex(\"idx_invoices_tax_category_id\", Invoice.tax_category_id)\nIndex(\"idx_invoices_invoice_date\", Invoice.invoice_date)\nIndex(\"idx_invoice_line_items_invoice_id\", InvoiceLineItem.invoice_id)\nIndex(\"idx_invoice_line_items_department_id\", InvoiceLineItem.department_id)\nIndex(\"idx_payments_customer_id\", Payment.customer_id)\nIndex(\"idx_payments_payment_date\", Payment.payment_date)\nIndex(\"idx_payment_applications_payment_id\", PaymentApplication.payment_id)\nIndex(\"idx_payment_applications_invoice_id\", PaymentApplication.invoice_id)\nIndex(\"idx_bills_vendor_id\", Bill.vendor_id)\nIndex(\"idx_bills_department_id\", Bill.department_id)\nIndex(\"idx_bills_bill_date\", Bill.bill_date)\nIndex(\"idx_recurring_expenses_vendor_id\", RecurringExpense.vendor_id)\nIndex(\"idx_recurring_expenses_next_run_date\", RecurringExpense.next_run_date)\nIndex(\"idx_recurring_expenses_department_id\", RecurringExpense.department_id)\nIndex(\"idx_bank_transactions_account_id\", BankTransaction.bank_account_id)\nIndex(\"idx_bank_transactions_date\", BankTransaction.transaction_date)\nIndex(\"idx_journal_entries_entry_date\", JournalEntry.entry_date)\nIndex(\"idx_journal_entries_department_id\", JournalEntry.department_id)\nIndex(\"idx_journal_entry_lines_entry_id\", JournalEntryLine.journal_entry_id)\nIndex(\"idx_journal_entry_lines_account_id\", JournalEntryLine.account_id)\nIndex(\"idx_journal_entry_lines_department_id\", JournalEntryLine.department_id)\nIndex(\"idx_bt_journal_links_bt_id\", BankTransactionJournalLink.bank_transaction_id)\nIndex(\"idx_bt_journal_links_je_id\", BankTransactionJournalLink.journal_entry_id)\nIndex(\"idx_recurring_invoices_customer_id\", RecurringInvoice.customer_id)\nIndex(\"idx_recurring_invoices_next_run_date\", RecurringInvoice.next_run_date)\nIndex(\"idx_recurring_invoices_department_id\", RecurringInvoice.department_id)\nIndex(\"idx_accounting_periods_start_end\", AccountingPeriod.start_date, AccountingPeriod.end_date)\nIndex(\"idx_accounting_periods_is_locked\", AccountingPeriod.is_locked)\n\nBase.metadata.create_all(engine)\n\napp = FastAPI(title=\"ZenLedger Small Business Accounting Suite API\", version=\"1.0.0\")\n\nclass CustomerCreateRequest(BaseModel):\n name: str = Field(..., description=\"Customer legal or display name (must be unique)\", example=\"Acme Design Studio\")\n billing_email: Optional[str] = Field(None, description=\"Primary billing email address for invoices\", example=\"billing@acmedesign.com\")\n payment_terms_id: Optional[int] = Field(None, description=\"ID of payment_terms row to use as default terms\", example=2)\n default_tax_category_id: Optional[int] = Field(None, description=\"ID of tax_categories row used as default customer tax\", example=1)\n\nclass CustomerResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Unique customer identifier\", example=10)\n name: str = Field(..., description=\"Customer name\", example=\"Acme Design Studio\")\n billing_email: Optional[str] = Field(None, description=\"Customer billing email\", example=\"billing@acmedesign.com\")\n payment_terms_id: Optional[int] = Field(None, description=\"Linked payment_terms.id or null\", example=3)\n default_tax_category_id: Optional[int] = Field(None, description=\"Linked tax_categories.id or null\", example=1)\n created_at: Optional[datetime] = Field(None, description=\"Timestamp when customer was created (ISO 8601)\", example=\"2025-01-04T10:15:23Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Timestamp for last update or null\", example=None)\n\nclass CustomersListResponse(BaseModel):\n customers: List[CustomerResponse] = Field(..., description=\"List of customers\", example=[])\n\nclass PaymentTermResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Payment terms ID\", example=3)\n name: str = Field(..., description=\"Name of payment terms\", example=\"Net 30\")\n days: int = Field(..., description=\"Number of days from invoice date to due date\", example=30)\n description: Optional[str] = Field(None, description=\"Optional description\", example=\"Payment due 30 days from invoice date\")\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2024-01-01T00:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Last update timestamp\", example=None)\n\nclass PaymentTermsListResponse(BaseModel):\n payment_terms: List[PaymentTermResponse] = Field(..., description=\"List of payment terms\", example=[])\n\nclass TaxCategoryResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Tax category ID\", example=1)\n name: str = Field(..., description=\"Tax category name\", example=\"Standard Sales Tax 8.5%\")\n description: Optional[str] = Field(None, description=\"Optional description of when this tax applies\", example=\"Standard local sales tax\")\n rate: float = Field(..., description=\"Tax rate as decimal (e.g., 0.085 for 8.5%)\", example=0.085)\n is_compound: bool = Field(..., description=\"True if tax is compounded with other taxes\", example=False)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2024-01-01T00:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Last update timestamp\", example=None)\n\nclass TaxCategoriesListResponse(BaseModel):\n tax_categories: List[TaxCategoryResponse] = Field(..., description=\"List of tax categories\", example=[])\n\nclass DepartmentResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Department ID\", example=2)\n name: str = Field(..., description=\"Department name\", example=\"Design\")\n description: Optional[str] = Field(None, description=\"Optional department description\", example=\"Design and creative services\")\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2024-01-01T00:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Last update timestamp\", example=None)\n\nclass DepartmentsListResponse(BaseModel):\n departments: List[DepartmentResponse] = Field(..., description=\"List of departments\", example=[])\n\nclass AccountResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Account ID\", example=50)\n name: str = Field(..., description=\"Account name\", example=\"Software Subscriptions\")\n code: Optional[str] = Field(None, description=\"Optional account code\", example=\"6100\")\n type: str = Field(..., description=\"High-level account type\", example=\"expense\")\n sub_type: Optional[str] = Field(None, description=\"Optional subtype classification\", example=\"Operating Expense\")\n is_active: bool = Field(..., description=\"Whether account can be posted to\", example=True)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2024-01-01T00:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Last update timestamp\", example=None)\n\nclass AccountsListResponse(BaseModel):\n accounts: List[AccountResponse] = Field(..., description=\"List of accounts\", example=[])\n\nclass BankAccountResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Bank account ID\", example=1)\n name: str = Field(..., description=\"Display name for the bank account\", example=\"Chase Business Checking ****1023\")\n institution_name: Optional[str] = Field(None, description=\"Financial institution name\", example=\"Chase\")\n account_number_masked: Optional[str] = Field(None, description=\"Masked bank account number\", example=\"****1023\")\n account_id: int = Field(..., description=\"Linked GL account ID\", example=101)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2024-01-01T00:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Last update timestamp\", example=None)\n\nclass BankAccountsListResponse(BaseModel):\n bank_accounts: List[BankAccountResponse] = Field(..., description=\"List of bank accounts\", example=[])\n\nclass InvoiceCreateRequest(BaseModel):\n invoice_number: str = Field(..., description=\"Unique invoice number\", example=\"INV-2025-001\")\n customer_id: int = Field(..., description=\"Customer ID that this invoice belongs to\", example=10)\n invoice_date: str = Field(..., description=\"Invoice date in ISO format YYYY-MM-DD\", example=\"2025-01-05\")\n due_date: str = Field(..., description=\"Due date in ISO format YYYY-MM-DD\", example=\"2025-02-04\")\n department_id: Optional[int] = Field(None, description=\"Department responsible for this invoice\", example=2)\n tax_category_id: Optional[int] = Field(None, description=\"Tax category applied at invoice level\", example=1)\n payment_terms_id: Optional[int] = Field(None, description=\"Payment terms to apply; defaults to customer terms if omitted\", example=3)\n currency: Optional[str] = Field(\"USD\", description=\"Currency code, defaults to USD\", example=\"USD\")\n status: Optional[str] = Field(\"draft\", description=\"Initial status (draft or open)\", example=\"open\")\n\nclass InvoiceResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Invoice ID\", example=1001)\n invoice_number: str = Field(..., description=\"Unique invoice number\", example=\"INV-2025-001\")\n customer_id: int = Field(..., description=\"Linked customer ID\", example=10)\n department_id: Optional[int] = Field(None, description=\"Linked department ID\", example=2)\n tax_category_id: Optional[int] = Field(None, description=\"Linked tax category ID\", example=1)\n invoice_date: date = Field(..., description=\"Invoice date\", example=\"2025-01-05\")\n due_date: date = Field(..., description=\"Due date\", example=\"2025-02-04\")\n currency: str = Field(..., description=\"Currency code\", example=\"USD\")\n status: str = Field(..., description=\"Invoice status\", example=\"open\")\n subtotal: float = Field(..., description=\"Sum of line_subtotals before tax\", example=2000.0)\n tax_amount: float = Field(..., description=\"Total tax applied to invoice\", example=170.0)\n total: float = Field(..., description=\"Invoice total including tax\", example=2170.0)\n balance_due: float = Field(..., description=\"Remaining balance due on invoice\", example=2170.0)\n payment_terms_id: Optional[int] = Field(None, description=\"Linked payment_terms ID\", example=3)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-05T09:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass InvoiceLineItemCreateRequest(BaseModel):\n invoice_id: int = Field(..., description=\"ID of the invoice this line belongs to\", example=1001)\n description: str = Field(..., description=\"Description of the product or service\", example=\"Logo redesign\")\n quantity: float = Field(..., description=\"Quantity of units sold\", example=1.0)\n unit_price: float = Field(..., description=\"Price per unit\", example=1200.0)\n discount_percent: Optional[float] = Field(0.0, description=\"Discount percentage applied to this line\", example=10.0)\n revenue_account_id: Optional[int] = Field(None, description=\"Revenue account to credit for this line\", example=400)\n department_id: Optional[int] = Field(None, description=\"Department for this line; overrides invoice department\", example=2)\n\nclass InvoiceLineItemResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Invoice line item ID\", example=5001)\n invoice_id: int = Field(..., description=\"Parent invoice ID\", example=1001)\n description: str = Field(..., description=\"Line item description\", example=\"Logo redesign\")\n quantity: float = Field(..., description=\"Quantity\", example=1.0)\n unit_price: float = Field(..., description=\"Unit price\", example=1200.0)\n discount_percent: float = Field(..., description=\"Discount percent\", example=0.0)\n line_subtotal: float = Field(..., description=\"Subtotal before tax for this line\", example=1200.0)\n tax_amount: float = Field(..., description=\"Tax for this line\", example=102.0)\n total: float = Field(..., description=\"Total including tax for this line\", example=1302.0)\n revenue_account_id: Optional[int] = Field(None, description=\"Linked revenue account ID\", example=400)\n department_id: Optional[int] = Field(None, description=\"Linked department ID\", example=2)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-05T09:10:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass InvoiceRecalculateTotalsResponse(BaseModel):\n invoice_id: int = Field(..., description=\"Invoice ID\", example=1001)\n subtotal: float = Field(..., description=\"Updated subtotal\", example=2000.0)\n tax_amount: float = Field(..., description=\"Updated tax amount\", example=170.0)\n total: float = Field(..., description=\"Updated total\", example=2170.0)\n balance_due: float = Field(..., description=\"Updated balance due after payments\", example=1270.0)\n\nclass InvoicesListItemResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Invoice ID\", example=1001)\n invoice_number: str = Field(..., description=\"Invoice number\", example=\"INV-2025-001\")\n customer_id: int = Field(..., description=\"Customer ID\", example=10)\n invoice_date: date = Field(..., description=\"Invoice date\", example=\"2025-01-05\")\n due_date: date = Field(..., description=\"Due date\", example=\"2025-02-04\")\n status: str = Field(..., description=\"Invoice status\", example=\"open\")\n subtotal: float = Field(..., description=\"Subtotal amount\", example=2000.0)\n tax_amount: float = Field(..., description=\"Tax amount\", example=170.0)\n total: float = Field(..., description=\"Total invoice amount\", example=2170.0)\n balance_due: float = Field(..., description=\"Outstanding balance\", example=1270.0)\n department_id: Optional[int] = Field(None, description=\"Linked department ID\", example=2)\n tax_category_id: Optional[int] = Field(None, description=\"Linked tax category ID\", example=1)\n payment_terms_id: Optional[int] = Field(None, description=\"Linked payment terms ID\", example=3)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-05T09:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Last update timestamp\", example=\"2025-01-10T10:00:00Z\")\n\nclass InvoicesListResponse(BaseModel):\n invoices: List[InvoicesListItemResponse] = Field(..., description=\"List of invoices\", example=[])\n\nclass PaymentCreateRequest(BaseModel):\n customer_id: int = Field(..., description=\"Customer who made the payment\", example=10)\n payment_date: str = Field(..., description=\"Date payment was received (YYYY-MM-DD)\", example=\"2025-01-10\")\n settlement_date: Optional[str] = Field(None, description=\"Date payment settled in bank (YYYY-MM-DD)\", example=\"2025-01-10\")\n amount: float = Field(..., description=\"Gross payment amount\", example=900.0)\n currency: Optional[str] = Field(\"USD\", description=\"Currency code (defaults to USD)\", example=\"USD\")\n method: str = Field(..., description=\"Payment method description\", example=\"Credit Card\")\n reference: Optional[str] = Field(None, description=\"External reference or transaction ID\", example=\"STRIPE-12345\")\n\nclass PaymentResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Payment ID\", example=2001)\n customer_id: int = Field(..., description=\"Customer ID\", example=10)\n payment_date: date = Field(..., description=\"Payment date\", example=\"2025-01-10\")\n settlement_date: Optional[date] = Field(None, description=\"Settlement date\", example=\"2025-01-10\")\n amount: float = Field(..., description=\"Payment amount\", example=900.0)\n currency: str = Field(..., description=\"Payment currency\", example=\"USD\")\n method: str = Field(..., description=\"Payment method\", example=\"Credit Card\")\n reference: Optional[str] = Field(None, description=\"External reference ID\", example=\"STRIPE-12345\")\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-10T12:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass PaymentApplicationCreateRequest(BaseModel):\n payment_id: int = Field(..., description=\"Payment to allocate\", example=2001)\n invoice_id: int = Field(..., description=\"Invoice receiving this payment portion\", example=1001)\n amount: float = Field(..., description=\"Amount applied from payment to invoice\", example=900.0)\n\nclass PaymentApplicationResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Payment application ID\", example=3001)\n payment_id: int = Field(..., description=\"Linked payment ID\", example=2001)\n invoice_id: int = Field(..., description=\"Linked invoice ID\", example=1001)\n amount: float = Field(..., description=\"Amount applied\", example=900.0)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-10T12:05:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass VendorCreateRequest(BaseModel):\n name: str = Field(..., description=\"Vendor legal or display name\", example=\"PixelPrint Supplies\")\n contact_email: Optional[str] = Field(None, description=\"Vendor accounts payable contact email\", example=\"accounts@pixelprint.com\")\n payment_terms_id: Optional[int] = Field(None, description=\"Default payment terms for this vendor\", example=2)\n default_expense_category_id: Optional[int] = Field(None, description=\"Default expense account for purchases from this vendor\", example=60)\n\nclass VendorResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Vendor ID\", example=20)\n name: str = Field(..., description=\"Vendor name\", example=\"PixelPrint Supplies\")\n contact_email: Optional[str] = Field(None, description=\"Vendor email\", example=\"accounts@pixelprint.com\")\n payment_terms_id: Optional[int] = Field(None, description=\"Linked payment_terms ID\", example=2)\n default_expense_category_id: Optional[int] = Field(None, description=\"Linked default expense account ID\", example=60)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-03T08:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass VendorsListResponse(BaseModel):\n vendors: List[VendorResponse] = Field(..., description=\"List of vendors\", example=[])\n\nclass BillCreateRequest(BaseModel):\n bill_number: Optional[str] = Field(None, description=\"Vendor-provided bill or invoice number\", example=\"BILL-2025-001\")\n vendor_id: int = Field(..., description=\"Vendor this bill is from\", example=20)\n bill_date: str = Field(..., description=\"Date on the vendor bill (YYYY-MM-DD)\", example=\"2025-01-03\")\n due_date: Optional[str] = Field(None, description=\"Due date if known (YYYY-MM-DD)\", example=\"2025-01-18\")\n currency: Optional[str] = Field(\"USD\", description=\"Bill currency code\", example=\"USD\")\n amount: float = Field(..., description=\"Total bill amount\", example=325.5)\n description: Optional[str] = Field(None, description=\"Description of the bill or purpose\", example=\"Printer ink and paper\")\n department_id: Optional[int] = Field(None, description=\"Department to expense this bill to\", example=3)\n reimbursement_status: str = Field(..., description=\"Reimbursement status (Not Reimbursable, Reimbursable, Reimbursed)\", example=\"Not Reimbursable\")\n payment_terms_id: Optional[int] = Field(None, description=\"Payment terms used for due_date calculation\", example=1)\n status: Optional[str] = Field(\"open\", description=\"Bill status (open, paid, void)\", example=\"open\")\n\nclass BillResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Bill ID\", example=7001)\n bill_number: Optional[str] = Field(None, description=\"Vendor bill number\", example=\"BILL-2025-001\")\n vendor_id: int = Field(..., description=\"Vendor ID\", example=20)\n bill_date: date = Field(..., description=\"Bill date\", example=\"2025-01-03\")\n due_date: Optional[date] = Field(None, description=\"Due date\", example=\"2025-01-18\")\n currency: str = Field(..., description=\"Currency code\", example=\"USD\")\n amount: float = Field(..., description=\"Bill amount\", example=325.5)\n description: Optional[str] = Field(None, description=\"Bill description\", example=\"Printer ink and paper\")\n department_id: Optional[int] = Field(None, description=\"Department ID\", example=3)\n reimbursement_status: str = Field(..., description=\"Reimbursement status\", example=\"Not Reimbursable\")\n payment_terms_id: Optional[int] = Field(None, description=\"Payment terms ID\", example=1)\n status: str = Field(..., description=\"Bill status\", example=\"open\")\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-03T09:30:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass RecurringExpenseCreateRequest(BaseModel):\n name: str = Field(..., description=\"Name of the recurring expense\", example=\"Monthly Co-working Space Rent\")\n vendor_id: Optional[int] = Field(None, description=\"Vendor providing the recurring service\", example=30)\n amount: float = Field(..., description=\"Recurring amount for each run\", example=650.0)\n expense_account_id: int = Field(..., description=\"Expense account ID to debit\", example=80)\n department_id: Optional[int] = Field(None, description=\"Department that bears this recurring expense\", example=4)\n frequency: str = Field(..., description=\"Run frequency (daily, weekly, monthly, quarterly, yearly)\", example=\"monthly\")\n next_run_date: str = Field(..., description=\"Next date the template should generate an expense (YYYY-MM-DD)\", example=\"2025-02-01\")\n end_date: Optional[str] = Field(None, description=\"Date after which no more runs occur\", example=\"2025-12-01\")\n is_active: Optional[bool] = Field(True, description=\"Whether this template is active\", example=True)\n\nclass RecurringExpenseResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Recurring expense template ID\", example=9001)\n name: str = Field(..., description=\"Template name\", example=\"Monthly Co-working Space Rent\")\n vendor_id: Optional[int] = Field(None, description=\"Vendor ID\", example=30)\n amount: float = Field(..., description=\"Recurring amount\", example=650.0)\n expense_account_id: int = Field(..., description=\"Expense account ID\", example=80)\n department_id: Optional[int] = Field(None, description=\"Department ID\", example=4)\n frequency: str = Field(..., description=\"Frequency\", example=\"monthly\")\n next_run_date: date = Field(..., description=\"Next run date\", example=\"2025-02-01\")\n end_date: Optional[date] = Field(None, description=\"End date\", example=\"2025-12-01\")\n is_active: bool = Field(..., description=\"Whether template is active\", example=True)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-15T09:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass BankTransactionItemRequest(BaseModel):\n transaction_date: str = Field(..., description=\"Transaction date (YYYY-MM-DD)\", example=\"2025-01-01\")\n posted_date: Optional[str] = Field(None, description=\"Posted date (YYYY-MM-DD)\", example=\"2025-01-02\")\n description: str = Field(..., description=\"Bank description\", example=\"Client payment ACME\")\n amount: float = Field(..., description=\"Transaction amount (positive or negative)\", example=1500.0)\n external_id: Optional[str] = Field(None, description=\"External bank transaction identifier\", example=\"txn_001\")\n\nclass BankTransactionsBatchImportRequest(BaseModel):\n bank_account_id: int = Field(..., description=\"Bank account ID these transactions belong to\", example=1)\n transactions: List[BankTransactionItemRequest] = Field(..., description=\"Array of bank transactions to import\", example=[])\n\nclass BankTransactionResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Bank transaction ID\", example=6001)\n bank_account_id: int = Field(..., description=\"Bank account ID\", example=1)\n transaction_date: date = Field(..., description=\"Transaction date\", example=\"2025-01-01\")\n posted_date: Optional[date] = Field(None, description=\"Posted date\", example=\"2025-01-02\")\n description: str = Field(..., description=\"Transaction description\", example=\"Client payment ACME\")\n amount: float = Field(..., description=\"Transaction amount\", example=1500.0)\n external_id: Optional[str] = Field(None, description=\"External transaction ID\", example=\"txn_001\")\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-07T10:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass BankTransactionsBatchImportResponse(BaseModel):\n bank_transactions: List[BankTransactionResponse] = Field(..., description=\"Imported bank transactions\", example=[])\n\nclass BankTransactionsListResponse(BaseModel):\n bank_transactions: List[BankTransactionResponse] = Field(..., description=\"List of bank transactions\", example=[])\n\nclass JournalEntryCreateRequest(BaseModel):\n entry_date: str = Field(..., description=\"Date of the journal entry (YYYY-MM-DD)\", example=\"2024-12-31\")\n description: Optional[str] = Field(None, description=\"Narrative description of the entry\", example=\"Year-end accrual for expenses\")\n department_id: Optional[int] = Field(None, description=\"Department that this entry belongs to\", example=4)\n source: Optional[str] = Field(None, description=\"System source of this entry\", example=\"manual\")\n source_id: Optional[int] = Field(None, description=\"External source ID if applicable\", example=None)\n\nclass JournalEntryResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Journal entry ID\", example=8001)\n entry_date: date = Field(..., description=\"Entry date\", example=\"2024-12-31\")\n description: Optional[str] = Field(None, description=\"Entry description\", example=\"Year-end accrual for expenses\")\n department_id: Optional[int] = Field(None, description=\"Department ID\", example=4)\n source: Optional[str] = Field(None, description=\"Source system\", example=\"manual\")\n source_id: Optional[int] = Field(None, description=\"Source record ID\", example=None)\n created_by_user_id: Optional[int] = Field(None, description=\"User who created the entry (always 1)\", example=1)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2024-12-31T23:50:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass JournalEntryLineCreateRequest(BaseModel):\n journal_entry_id: int = Field(..., description=\"Parent journal entry ID\", example=8001)\n account_id: int = Field(..., description=\"Account to debit or credit\", example=50)\n department_id: Optional[int] = Field(None, description=\"Department for this line if different from header\", example=4)\n description: Optional[str] = Field(None, description=\"Line-specific description\", example=\"Accrual for December software expenses\")\n debit: Optional[float] = Field(0.0, description=\"Debit amount (0 if this is a credit line)\", example=300.0)\n credit: Optional[float] = Field(0.0, description=\"Credit amount (0 if this is a debit line)\", example=0.0)\n\nclass JournalEntryLineResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Journal entry line ID\", example=8101)\n journal_entry_id: int = Field(..., description=\"Parent journal entry ID\", example=8001)\n account_id: int = Field(..., description=\"Account ID\", example=50)\n department_id: Optional[int] = Field(None, description=\"Department ID\", example=4)\n description: Optional[str] = Field(None, description=\"Line description\", example=\"Accrual for December software expenses\")\n debit: float = Field(..., description=\"Debit amount\", example=300.0)\n credit: float = Field(..., description=\"Credit amount\", example=0.0)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2024-12-31T23:51:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass BankTransactionJournalLinkCreateRequest(BaseModel):\n bank_transaction_id: int = Field(..., description=\"Bank transaction ID being reconciled\", example=6001)\n journal_entry_id: int = Field(..., description=\"Journal entry ID representing the accounting for this transaction\", example=8005)\n\nclass BankTransactionJournalLinkResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Link ID\", example=90001)\n bank_transaction_id: int = Field(..., description=\"Bank transaction ID\", example=6001)\n journal_entry_id: int = Field(..., description=\"Journal entry ID\", example=8005)\n created_at: Optional[datetime] = Field(None, description=\"Link creation timestamp\", example=\"2025-01-07T11:00:00Z\")\n\nclass RecurringInvoiceCreateRequest(BaseModel):\n customer_id: int = Field(..., description=\"Customer who will receive recurring invoices\", example=15)\n name: str = Field(..., description=\"Name of the recurring invoice template\", example=\"Monthly SEO Retainer\")\n description: Optional[str] = Field(None, description=\"Description of the service or product\", example=\"Monthly SEO services retainer\")\n quantity: float = Field(..., description=\"Quantity per recurring invoice\", example=1.0)\n unit_price: float = Field(..., description=\"Unit price per run\", example=1500.0)\n discount_percent: Optional[float] = Field(0.0, description=\"Discount percent per run\", example=0.0)\n frequency: str = Field(..., description=\"Frequency (daily, weekly, monthly, quarterly, yearly)\", example=\"monthly\")\n next_run_date: str = Field(..., description=\"Date of next invoice generation (YYYY-MM-DD)\", example=\"2025-02-01\")\n end_date: Optional[str] = Field(None, description=\"Final date for invoice generation\", example=\"2025-07-01\")\n payment_terms_id: Optional[int] = Field(None, description=\"Payment terms applied to generated invoices\", example=4)\n tax_category_id: Optional[int] = Field(None, description=\"Tax category for generated invoices\", example=5)\n department_id: Optional[int] = Field(None, description=\"Department for generated invoices\", example=2)\n currency: Optional[str] = Field(\"USD\", description=\"Currency for generated invoices\", example=\"USD\")\n is_active: Optional[bool] = Field(True, description=\"Whether this recurring schedule is active\", example=True)\n\nclass RecurringInvoiceResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Recurring invoice template ID\", example=9501)\n customer_id: int = Field(..., description=\"Customer ID\", example=15)\n name: str = Field(..., description=\"Template name\", example=\"Monthly SEO Retainer\")\n description: Optional[str] = Field(None, description=\"Template description\", example=\"Monthly SEO services retainer\")\n quantity: float = Field(..., description=\"Quantity per invoice\", example=1.0)\n unit_price: float = Field(..., description=\"Unit price\", example=1500.0)\n discount_percent: float = Field(..., description=\"Discount percent\", example=0.0)\n frequency: str = Field(..., description=\"Frequency\", example=\"monthly\")\n next_run_date: date = Field(..., description=\"Next run date\", example=\"2025-02-01\")\n end_date: Optional[date] = Field(None, description=\"End date\", example=\"2025-07-01\")\n payment_terms_id: Optional[int] = Field(None, description=\"Payment terms ID\", example=4)\n tax_category_id: Optional[int] = Field(None, description=\"Tax category ID\", example=5)\n department_id: Optional[int] = Field(None, description=\"Department ID\", example=2)\n currency: str = Field(..., description=\"Currency\", example=\"USD\")\n is_active: bool = Field(..., description=\"Whether template is active\", example=True)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2025-01-20T09:00:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass AccountingPeriodCreateRequest(BaseModel):\n start_date: str = Field(..., description=\"Start date of the period (YYYY-MM-DD)\", example=\"2024-01-01\")\n end_date: str = Field(..., description=\"End date of the period (YYYY-MM-DD)\", example=\"2024-12-31\")\n close_date: Optional[str] = Field(None, description=\"Date when the period was closed\", example=\"2024-12-31\")\n is_locked: Optional[bool] = Field(False, description=\"Whether the period is locked against changes\", example=True)\n\nclass AccountingPeriodUpdateRequest(BaseModel):\n close_date: Optional[str] = Field(None, description=\"New close date or null to clear\", example=\"2024-12-31\")\n is_locked: Optional[bool] = Field(None, description=\"Set true to lock or false to unlock\", example=True)\n\nclass AccountingPeriodResponse(BaseModel):\n model_config = ConfigDict(from_attributes=True)\n id: int = Field(..., description=\"Accounting period ID\", example=10001)\n start_date: date = Field(..., description=\"Start date\", example=\"2024-01-01\")\n end_date: date = Field(..., description=\"End date\", example=\"2024-12-31\")\n close_date: Optional[date] = Field(None, description=\"Close date or null\", example=\"2024-12-31\")\n is_locked: bool = Field(..., description=\"Locked flag\", example=True)\n created_at: Optional[datetime] = Field(None, description=\"Creation timestamp\", example=\"2024-12-31T23:55:00Z\")\n updated_at: Optional[datetime] = Field(None, description=\"Update timestamp\", example=None)\n\nclass ProfitAndLossReportResponse(BaseModel):\n start_date: str = Field(..., description=\"Report start date\", example=\"2025-01-01\")\n end_date: str = Field(..., description=\"Report end date\", example=\"2025-01-31\")\n department_id: Optional[int] = Field(None, description=\"Department filter or null if not filtered\", example=2)\n total_revenue: float = Field(..., description=\"Sum of income account balances for the period\", example=5000.0)\n total_expenses: float = Field(..., description=\"Sum of expense account balances for the period\", example=3000.0)\n net_profit: float = Field(..., description=\"total_revenue - total_expenses\", example=2000.0)\n detail: Dict[str, List[Dict[str, Optional[float]]]] = Field(..., description=\"Optional breakdown of accounts\", example={\"income_accounts\": [], \"expense_accounts\": []})\n\n@app.post(\n \"/api/customers\",\n response_model=CustomerResponse,\n summary=\"Create a new customer\",\n description=\"Create a customer with optional payment terms and tax category.\",\n tags=[\"customers\"],\n operation_id=\"create_customer\",\n)\nasync def create_customer_endpoint(body: CustomerCreateRequest = Body(...)) -> CustomerResponse:\n session = SessionLocal()\n customer = Customer(\n name=body.name,\n billing_email=body.billing_email,\n payment_terms_id=body.payment_terms_id,\n default_tax_category_id=body.default_tax_category_id,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(customer)\n session.commit()\n session.refresh(customer)\n session.close()\n return CustomerResponse(\n id=customer.id,\n name=customer.name,\n billing_email=customer.billing_email,\n payment_terms_id=customer.payment_terms_id,\n default_tax_category_id=customer.default_tax_category_id,\n created_at=customer.created_at,\n updated_at=customer.updated_at,\n )\n\n@app.get(\n \"/api/customers\",\n response_model=CustomersListResponse,\n summary=\"List customers with optional filters\",\n description=\"Retrieve customers filtered by name or billing email.\",\n tags=[\"customers\"],\n operation_id=\"list_customers\",\n)\nasync def list_customers_endpoint(\n name: Optional[str] = Query(None, description=\"Filter by exact or partial customer name\", example=\"Acme\"),\n billing_email: Optional[str] = Query(None, description=\"Filter customers by billing_email exact match\", example=\"billing@acmedesign.com\"),\n limit: Optional[int] = Query(50, description=\"Maximum number of records to return\", example=50),\n offset: Optional[int] = Query(0, description=\"Number of records to skip for pagination\", example=0),\n) -> CustomersListResponse:\n session = SessionLocal()\n query = session.query(Customer)\n if name is not None:\n query = query.filter(Customer.name.contains(name))\n if billing_email is not None:\n query = query.filter(Customer.billing_email == billing_email)\n customers = query.offset(offset).limit(limit).all()\n session.close()\n return CustomersListResponse(customers=customers)\n\n@app.get(\n \"/api/customers/{customer_id}\",\n response_model=CustomerResponse,\n summary=\"Get a single customer by ID\",\n description=\"Fetch one customer by ID to inspect billing settings.\",\n tags=[\"customers\"],\n operation_id=\"get_customer\",\n)\nasync def get_customer_endpoint(\n customer_id: int = Path(..., description=\"Customer ID to retrieve\", example=10)\n) -> CustomerResponse:\n session = SessionLocal()\n customer = session.query(Customer).filter(Customer.id == customer_id).first()\n session.close()\n if customer is None:\n return CustomerResponse(\n id=0,\n name=\"\",\n billing_email=None,\n payment_terms_id=None,\n default_tax_category_id=None,\n created_at=None,\n updated_at=None,\n )\n return CustomerResponse(\n id=customer.id,\n name=customer.name,\n billing_email=customer.billing_email,\n payment_terms_id=customer.payment_terms_id,\n default_tax_category_id=customer.default_tax_category_id,\n created_at=customer.created_at,\n updated_at=customer.updated_at,\n )\n\n@app.get(\n \"/api/payment_terms\",\n response_model=PaymentTermsListResponse,\n summary=\"List payment terms\",\n description=\"Retrieve payment_terms records optionally filtered by name.\",\n tags=[\"payment_terms\"],\n operation_id=\"list_payment_terms\",\n)\nasync def list_payment_terms_endpoint(\n name: Optional[str] = Query(None, description=\"Filter terms by name\", example=\"Net 30\")\n) -> PaymentTermsListResponse:\n session = SessionLocal()\n query = session.query(PaymentTerm)\n if name is not None:\n query = query.filter(PaymentTerm.name.contains(name))\n payment_terms = query.all()\n session.close()\n return PaymentTermsListResponse(payment_terms=payment_terms)\n\n@app.get(\n \"/api/tax_categories\",\n response_model=TaxCategoriesListResponse,\n summary=\"List tax categories\",\n description=\"Retrieve available tax_categories optionally filtered by name.\",\n tags=[\"tax_categories\"],\n operation_id=\"list_tax_categories\",\n)\nasync def list_tax_categories_endpoint(\n name: Optional[str] = Query(None, description=\"Filter tax categories by exact or partial name\", example=\"Standard Sales Tax 8.5%\")\n) -> TaxCategoriesListResponse:\n session = SessionLocal()\n query = session.query(TaxCategory)\n if name is not None:\n query = query.filter(TaxCategory.name.contains(name))\n rows = query.all()\n tax_categories: List[TaxCategoryResponse] = []\n for r in rows:\n tax_categories.append(\n TaxCategoryResponse(\n id=r.id,\n name=r.name,\n description=r.description,\n rate=r.rate,\n is_compound=bool(r.is_compound),\n created_at=r.created_at,\n updated_at=r.updated_at,\n )\n )\n session.close()\n return TaxCategoriesListResponse(tax_categories=tax_categories)\n\n@app.get(\n \"/api/departments\",\n response_model=DepartmentsListResponse,\n summary=\"List departments\",\n description=\"Retrieve departments to map human-readable names to IDs.\",\n tags=[\"departments\"],\n operation_id=\"list_departments\",\n)\nasync def list_departments_endpoint(\n name: Optional[str] = Query(None, description=\"Filter departments by name\", example=\"Design\")\n) -> DepartmentsListResponse:\n session = SessionLocal()\n query = session.query(Department)\n if name is not None:\n query = query.filter(Department.name.contains(name))\n departments = query.all()\n session.close()\n return DepartmentsListResponse(departments=departments)\n\n@app.get(\n \"/api/accounts\",\n response_model=AccountsListResponse,\n summary=\"List chart of accounts\",\n description=\"Retrieve accounts filtered by type or name.\",\n tags=[\"accounts\"],\n operation_id=\"list_accounts\",\n)\nasync def list_accounts_endpoint(\n type: Optional[str] = Query(None, description=\"Filter accounts by type (asset, liability, equity, income, expense, contra)\", example=\"expense\"),\n name: Optional[str] = Query(None, description=\"Filter accounts by name\", example=\"Software Subscriptions\"),\n) -> AccountsListResponse:\n session = SessionLocal()\n query = session.query(Account)\n if type is not None:\n query = query.filter(Account.type == type)\n if name is not None:\n query = query.filter(Account.name.contains(name))\n rows = query.all()\n accounts_list: List[AccountResponse] = []\n for a in rows:\n accounts_list.append(\n AccountResponse(\n id=a.id,\n name=a.name,\n code=a.code,\n type=a.type,\n sub_type=a.sub_type,\n is_active=bool(a.is_active),\n created_at=a.created_at,\n updated_at=a.updated_at,\n )\n )\n session.close()\n return AccountsListResponse(accounts=accounts_list)\n\n@app.get(\n \"/api/bank_accounts\",\n response_model=BankAccountsListResponse,\n summary=\"List bank accounts\",\n description=\"Retrieve bank_accounts to find IDs for bank transactions.\",\n tags=[\"bank_accounts\"],\n operation_id=\"list_bank_accounts\",\n)\nasync def list_bank_accounts_endpoint(\n name: Optional[str] = Query(None, description=\"Filter bank accounts by name\", example=\"Chase Business Checking ****1023\")\n) -> BankAccountsListResponse:\n session = SessionLocal()\n query = session.query(BankAccount)\n if name is not None:\n query = query.filter(BankAccount.name.contains(name))\n bank_accounts = query.all()\n session.close()\n return BankAccountsListResponse(bank_accounts=bank_accounts)\n\n@app.post(\n \"/api/invoices\",\n response_model=InvoiceResponse,\n summary=\"Create a new invoice header\",\n description=\"Create an invoice record without line items.\",\n tags=[\"invoices\"],\n operation_id=\"create_invoice\",\n)\nasync def create_invoice_endpoint(body: InvoiceCreateRequest = Body(...)) -> InvoiceResponse:\n session = SessionLocal()\n invoice = Invoice(\n invoice_number=body.invoice_number,\n customer_id=body.customer_id,\n department_id=body.department_id,\n tax_category_id=body.tax_category_id,\n invoice_date=date.fromisoformat(body.invoice_date),\n due_date=date.fromisoformat(body.due_date),\n currency=body.currency if body.currency is not None else \"USD\",\n status=body.status if body.status is not None else \"draft\",\n subtotal=0.0,\n tax_amount=0.0,\n total=0.0,\n balance_due=0.0,\n payment_terms_id=body.payment_terms_id,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(invoice)\n session.commit()\n session.refresh(invoice)\n session.close()\n return InvoiceResponse(\n id=invoice.id,\n invoice_number=invoice.invoice_number,\n customer_id=invoice.customer_id,\n department_id=invoice.department_id,\n tax_category_id=invoice.tax_category_id,\n invoice_date=invoice.invoice_date,\n due_date=invoice.due_date,\n currency=invoice.currency,\n status=invoice.status,\n subtotal=invoice.subtotal,\n tax_amount=invoice.tax_amount,\n total=invoice.total,\n balance_due=invoice.balance_due,\n payment_terms_id=invoice.payment_terms_id,\n created_at=invoice.created_at,\n updated_at=invoice.updated_at,\n )\n\n@app.post(\n \"/api/invoice_line_items\",\n response_model=InvoiceLineItemResponse,\n summary=\"Add a line item to an invoice\",\n description=\"Create an invoice line and update invoice totals.\",\n tags=[\"invoices\", \"invoice_line_items\"],\n operation_id=\"create_invoice_line_item\",\n)\nasync def create_invoice_line_item_endpoint(\n body: InvoiceLineItemCreateRequest = Body(...)\n) -> InvoiceLineItemResponse:\n session = SessionLocal()\n invoice = session.query(Invoice).filter(Invoice.id == body.invoice_id).first()\n tax_rate = 0.0\n if invoice is not None and invoice.tax_category_id is not None:\n tax_cat = session.query(TaxCategory).filter(TaxCategory.id == invoice.tax_category_id).first()\n if tax_cat is not None:\n tax_rate = tax_cat.rate\n discount_percent = body.discount_percent if body.discount_percent is not None else 0.0\n gross = body.quantity * body.unit_price\n discount_amount = gross * (discount_percent / 100.0)\n line_subtotal = gross - discount_amount\n tax_amount = line_subtotal * tax_rate\n total = line_subtotal + tax_amount\n item = InvoiceLineItem(\n invoice_id=body.invoice_id,\n description=body.description,\n quantity=body.quantity,\n unit_price=body.unit_price,\n discount_percent=discount_percent,\n line_subtotal=line_subtotal,\n tax_amount=tax_amount,\n total=total,\n revenue_account_id=body.revenue_account_id,\n department_id=body.department_id if body.department_id is not None else (invoice.department_id if invoice is not None else None),\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(item)\n if invoice is not None:\n subtotal_sum = session.query(InvoiceLineItem).filter(InvoiceLineItem.invoice_id == invoice.id).all()\n subtotal_value = 0.0\n tax_value = 0.0\n total_value = 0.0\n for li in subtotal_sum:\n subtotal_value += li.line_subtotal\n tax_value += li.tax_amount\n total_value += li.total\n subtotal_value += line_subtotal\n tax_value += tax_amount\n total_value += total\n invoice.subtotal = subtotal_value\n invoice.tax_amount = tax_value\n invoice.total = total_value\n payments = session.query(PaymentApplication).filter(PaymentApplication.invoice_id == invoice.id).all()\n paid_amount = 0.0\n for p in payments:\n paid_amount += p.amount\n invoice.balance_due = invoice.total - paid_amount\n invoice.updated_at = datetime.utcnow()\n session.commit()\n session.refresh(item)\n session.close()\n return InvoiceLineItemResponse(\n id=item.id,\n invoice_id=item.invoice_id,\n description=item.description,\n quantity=item.quantity,\n unit_price=item.unit_price,\n discount_percent=item.discount_percent,\n line_subtotal=item.line_subtotal,\n tax_amount=item.tax_amount,\n total=item.total,\n revenue_account_id=item.revenue_account_id,\n department_id=item.department_id,\n created_at=item.created_at,\n updated_at=item.updated_at,\n )\n\n@app.post(\n \"/api/invoices/{invoice_id}/recalculate_totals\",\n response_model=InvoiceRecalculateTotalsResponse,\n summary=\"Recalculate invoice totals\",\n description=\"Recompute totals from line items and applied payments.\",\n tags=[\"invoices\"],\n operation_id=\"recalculate_invoice_totals\",\n)\nasync def recalculate_invoice_totals_endpoint(\n invoice_id: int = Path(..., description=\"Invoice ID whose totals should be recalculated\", example=1001)\n) -> InvoiceRecalculateTotalsResponse:\n session = SessionLocal()\n invoice = session.query(Invoice).filter(Invoice.id == invoice_id).first()\n if invoice is None:\n session.close()\n return InvoiceRecalculateTotalsResponse(invoice_id=0, subtotal=0.0, tax_amount=0.0, total=0.0, balance_due=0.0)\n lines = session.query(InvoiceLineItem).filter(InvoiceLineItem.invoice_id == invoice_id).all()\n subtotal = 0.0\n tax_amount = 0.0\n total = 0.0\n for li in lines:\n subtotal += li.line_subtotal\n tax_amount += li.tax_amount\n total += li.total\n payments = session.query(PaymentApplication).filter(PaymentApplication.invoice_id == invoice_id).all()\n paid_amount = 0.0\n for pa in payments:\n paid_amount += pa.amount\n invoice.subtotal = subtotal\n invoice.tax_amount = tax_amount\n invoice.total = total\n invoice.balance_due = total - paid_amount\n invoice.updated_at = datetime.utcnow()\n session.commit()\n session.close()\n return InvoiceRecalculateTotalsResponse(\n invoice_id=invoice_id,\n subtotal=subtotal,\n tax_amount=tax_amount,\n total=total,\n balance_due=invoice.balance_due,\n )\n\n@app.get(\n \"/api/invoices\",\n response_model=InvoicesListResponse,\n summary=\"List invoices with filters\",\n description=\"Retrieve invoices filtered by number, customer, status, or dates.\",\n tags=[\"invoices\"],\n operation_id=\"list_invoices\",\n)\nasync def list_invoices_endpoint(\n invoice_number: Optional[str] = Query(None, description=\"Filter by invoice_number\", example=\"INV-2025-001\"),\n customer_id: Optional[int] = Query(None, description=\"Filter invoices for a given customer ID\", example=10),\n status: Optional[str] = Query(None, description=\"Filter by invoice status (draft, open, paid, void)\", example=\"open\"),\n from_date: Optional[str] = Query(None, description=\"Filter by minimum invoice_date (YYYY-MM-DD)\", example=\"2025-01-01\"),\n to_date: Optional[str] = Query(None, description=\"Filter by maximum invoice_date (YYYY-MM-DD)\", example=\"2025-01-31\"),\n limit: Optional[int] = Query(50, description=\"Max number of invoices to return\", example=50),\n offset: Optional[int] = Query(0, description=\"Number of invoices to skip\", example=0),\n) -> InvoicesListResponse:\n session = SessionLocal()\n query = session.query(Invoice)\n if invoice_number is not None:\n query = query.filter(Invoice.invoice_number == invoice_number)\n if customer_id is not None:\n query = query.filter(Invoice.customer_id == customer_id)\n if status is not None:\n query = query.filter(Invoice.status == status)\n if from_date is not None:\n query = query.filter(Invoice.invoice_date >= date.fromisoformat(from_date))\n if to_date is not None:\n query = query.filter(Invoice.invoice_date <= date.fromisoformat(to_date))\n invoices = query.offset(offset).limit(limit).all()\n session.close()\n return InvoicesListResponse(invoices=invoices)\n\n@app.post(\n \"/api/payments\",\n response_model=PaymentResponse,\n summary=\"Record a customer payment\",\n description=\"Create a payment row for a customer without allocations.\",\n tags=[\"payments\"],\n operation_id=\"create_payment\",\n)\nasync def create_payment_endpoint(body: PaymentCreateRequest = Body(...)) -> PaymentResponse:\n session = SessionLocal()\n payment = Payment(\n customer_id=body.customer_id,\n payment_date=date.fromisoformat(body.payment_date),\n settlement_date=date.fromisoformat(body.settlement_date) if body.settlement_date is not None else None,\n amount=body.amount,\n currency=body.currency if body.currency is not None else \"USD\",\n method=body.method,\n reference=body.reference,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(payment)\n session.commit()\n session.refresh(payment)\n session.close()\n return PaymentResponse(\n id=payment.id,\n customer_id=payment.customer_id,\n payment_date=payment.payment_date,\n settlement_date=payment.settlement_date,\n amount=payment.amount,\n currency=payment.currency,\n method=payment.method,\n reference=payment.reference,\n created_at=payment.created_at,\n updated_at=payment.updated_at,\n )\n\n@app.post(\n \"/api/payment_applications\",\n response_model=PaymentApplicationResponse,\n summary=\"Apply a payment to an invoice\",\n description=\"Allocate part or all of a payment amount to a specific invoice.\",\n tags=[\"payments\", \"payment_applications\"],\n operation_id=\"create_payment_application\",\n)\nasync def create_payment_application_endpoint(\n body: PaymentApplicationCreateRequest = Body(...)\n) -> PaymentApplicationResponse:\n session = SessionLocal()\n payment_app = PaymentApplication(\n payment_id=body.payment_id,\n invoice_id=body.invoice_id,\n amount=body.amount,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(payment_app)\n invoice = session.query(Invoice).filter(Invoice.id == body.invoice_id).first()\n if invoice is not None:\n payments = session.query(PaymentApplication).filter(PaymentApplication.invoice_id == body.invoice_id).all()\n total_applied = 0.0\n for p in payments:\n total_applied += p.amount\n total_applied += body.amount\n invoice.balance_due = invoice.total - total_applied\n if invoice.balance_due <= 0:\n invoice.status = \"paid\"\n invoice.updated_at = datetime.utcnow()\n session.commit()\n session.refresh(payment_app)\n session.close()\n return PaymentApplicationResponse(\n id=payment_app.id,\n payment_id=payment_app.payment_id,\n invoice_id=payment_app.invoice_id,\n amount=payment_app.amount,\n created_at=payment_app.created_at,\n updated_at=payment_app.updated_at,\n )\n\n@app.post(\n \"/api/vendors\",\n response_model=VendorResponse,\n summary=\"Create a new vendor\",\n description=\"Create a vendor with default payment terms and expense category.\",\n tags=[\"vendors\"],\n operation_id=\"create_vendor\",\n)\nasync def create_vendor_endpoint(body: VendorCreateRequest = Body(...)) -> VendorResponse:\n session = SessionLocal()\n vendor = Vendor(\n name=body.name,\n contact_email=body.contact_email,\n payment_terms_id=body.payment_terms_id,\n default_expense_category_id=body.default_expense_category_id,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(vendor)\n session.commit()\n session.refresh(vendor)\n session.close()\n return VendorResponse(\n id=vendor.id,\n name=vendor.name,\n contact_email=vendor.contact_email,\n payment_terms_id=vendor.payment_terms_id,\n default_expense_category_id=vendor.default_expense_category_id,\n created_at=vendor.created_at,\n updated_at=vendor.updated_at,\n )\n\n@app.get(\n \"/api/vendors\",\n response_model=VendorsListResponse,\n summary=\"List vendors\",\n description=\"Retrieve vendors to find IDs when creating bills.\",\n tags=[\"vendors\"],\n operation_id=\"list_vendors\",\n)\nasync def list_vendors_endpoint(\n name: Optional[str] = Query(None, description=\"Filter vendors by name\", example=\"PixelPrint\")\n) -> VendorsListResponse:\n session = SessionLocal()\n query = session.query(Vendor)\n if name is not None:\n query = query.filter(Vendor.name.contains(name))\n vendors = query.all()\n session.close()\n return VendorsListResponse(vendors=vendors)\n\n@app.post(\n \"/api/bills\",\n response_model=BillResponse,\n summary=\"Create a bill\",\n description=\"Create a bills row for vendor expenses.\",\n tags=[\"bills\"],\n operation_id=\"create_bill\",\n)\nasync def create_bill_endpoint(body: BillCreateRequest = Body(...)) -> BillResponse:\n session = SessionLocal()\n bill = Bill(\n bill_number=body.bill_number,\n vendor_id=body.vendor_id,\n bill_date=date.fromisoformat(body.bill_date),\n due_date=date.fromisoformat(body.due_date) if body.due_date is not None else None,\n currency=body.currency if body.currency is not None else \"USD\",\n amount=body.amount,\n description=body.description,\n department_id=body.department_id,\n reimbursement_status=body.reimbursement_status,\n payment_terms_id=body.payment_terms_id,\n status=body.status if body.status is not None else \"open\",\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(bill)\n session.commit()\n session.refresh(bill)\n session.close()\n return BillResponse(\n id=bill.id,\n bill_number=bill.bill_number,\n vendor_id=bill.vendor_id,\n bill_date=bill.bill_date,\n due_date=bill.due_date,\n currency=bill.currency,\n amount=bill.amount,\n description=bill.description,\n department_id=bill.department_id,\n reimbursement_status=bill.reimbursement_status,\n payment_terms_id=bill.payment_terms_id,\n status=bill.status,\n created_at=bill.created_at,\n updated_at=bill.updated_at,\n )\n\n@app.post(\n \"/api/recurring_expenses\",\n response_model=RecurringExpenseResponse,\n summary=\"Create a recurring expense template\",\n description=\"Create recurring_expenses templates such as monthly rent.\",\n tags=[\"recurring_expenses\"],\n operation_id=\"create_recurring_expense\",\n)\nasync def create_recurring_expense_endpoint(\n body: RecurringExpenseCreateRequest = Body(...)\n) -> RecurringExpenseResponse:\n session = SessionLocal()\n recurring = RecurringExpense(\n name=body.name,\n vendor_id=body.vendor_id,\n amount=body.amount,\n expense_account_id=body.expense_account_id,\n department_id=body.department_id,\n frequency=body.frequency,\n next_run_date=date.fromisoformat(body.next_run_date),\n end_date=date.fromisoformat(body.end_date) if body.end_date is not None else None,\n is_active=1 if (body.is_active if body.is_active is not None else True) else 0,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(recurring)\n session.commit()\n session.refresh(recurring)\n session.close()\n return RecurringExpenseResponse(\n id=recurring.id,\n name=recurring.name,\n vendor_id=recurring.vendor_id,\n amount=recurring.amount,\n expense_account_id=recurring.expense_account_id,\n department_id=recurring.department_id,\n frequency=recurring.frequency,\n next_run_date=recurring.next_run_date,\n end_date=recurring.end_date,\n is_active=bool(recurring.is_active),\n created_at=recurring.created_at,\n updated_at=recurring.updated_at,\n )\n\n@app.post(\n \"/api/bank_transactions/batch_import\",\n response_model=BankTransactionsBatchImportResponse,\n summary=\"Import a batch of bank transactions\",\n description=\"Insert multiple bank_transactions for a bank account in one call.\",\n tags=[\"bank_transactions\"],\n operation_id=\"batch_import_bank_transactions\",\n)\nasync def batch_import_bank_transactions_endpoint(\n body: BankTransactionsBatchImportRequest = Body(...)\n) -> BankTransactionsBatchImportResponse:\n session = SessionLocal()\n created_items: List[BankTransactionResponse] = []\n for t in body.transactions:\n bt = BankTransaction(\n bank_account_id=body.bank_account_id,\n transaction_date=date.fromisoformat(t.transaction_date),\n posted_date=date.fromisoformat(t.posted_date) if t.posted_date is not None else None,\n description=t.description,\n amount=t.amount,\n external_id=t.external_id,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(bt)\n session.commit()\n session.refresh(bt)\n created_items.append(\n BankTransactionResponse(\n id=bt.id,\n bank_account_id=bt.bank_account_id,\n transaction_date=bt.transaction_date,\n posted_date=bt.posted_date,\n description=bt.description,\n amount=bt.amount,\n external_id=bt.external_id,\n created_at=bt.created_at,\n updated_at=bt.updated_at,\n )\n )\n session.close()\n return BankTransactionsBatchImportResponse(bank_transactions=created_items)\n\n@app.get(\n \"/api/bank_transactions\",\n response_model=BankTransactionsListResponse,\n summary=\"List bank transactions\",\n description=\"Retrieve bank_transactions for a bank account filtered by date.\",\n tags=[\"bank_transactions\"],\n operation_id=\"list_bank_transactions\",\n)\nasync def list_bank_transactions_endpoint(\n bank_account_id: int = Query(..., description=\"Bank account ID to filter transactions\", example=1),\n from_date: Optional[str] = Query(None, description=\"Minimum transaction_date (YYYY-MM-DD)\", example=\"2025-01-01\"),\n to_date: Optional[str] = Query(None, description=\"Maximum transaction_date (YYYY-MM-DD)\", example=\"2025-01-07\"),\n limit: Optional[int] = Query(100, description=\"Maximum number of records\", example=100),\n offset: Optional[int] = Query(0, description=\"Records to skip\", example=0),\n) -> BankTransactionsListResponse:\n session = SessionLocal()\n query = session.query(BankTransaction).filter(BankTransaction.bank_account_id == bank_account_id)\n if from_date is not None:\n query = query.filter(BankTransaction.transaction_date >= date.fromisoformat(from_date))\n if to_date is not None:\n query = query.filter(BankTransaction.transaction_date <= date.fromisoformat(to_date))\n transactions = query.offset(offset).limit(limit).all()\n session.close()\n return BankTransactionsListResponse(bank_transactions=transactions)\n\n@app.post(\n \"/api/journal_entries\",\n response_model=JournalEntryResponse,\n summary=\"Create a journal entry header\",\n description=\"Create a journal_entries header with entry_date and description.\",\n tags=[\"journal_entries\"],\n operation_id=\"create_journal_entry\",\n)\nasync def create_journal_entry_endpoint(\n body: JournalEntryCreateRequest = Body(...)\n) -> JournalEntryResponse:\n session = SessionLocal()\n entry = JournalEntry(\n entry_date=date.fromisoformat(body.entry_date),\n description=body.description,\n department_id=body.department_id,\n source=body.source,\n source_id=body.source_id,\n created_by_user_id=1,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(entry)\n session.commit()\n session.refresh(entry)\n session.close()\n return JournalEntryResponse(\n id=entry.id,\n entry_date=entry.entry_date,\n description=entry.description,\n department_id=entry.department_id,\n source=entry.source,\n source_id=entry.source_id,\n created_by_user_id=entry.created_by_user_id,\n created_at=entry.created_at,\n updated_at=entry.updated_at,\n )\n\n@app.post(\n \"/api/journal_entry_lines\",\n response_model=JournalEntryLineResponse,\n summary=\"Add a line to a journal entry\",\n description=\"Create a journal_entry_lines row for an account with debit or credit.\",\n tags=[\"journal_entries\", \"journal_entry_lines\"],\n operation_id=\"create_journal_entry_line\",\n)\nasync def create_journal_entry_line_endpoint(\n body: JournalEntryLineCreateRequest = Body(...)\n) -> JournalEntryLineResponse:\n session = SessionLocal()\n debit_value = body.debit if body.debit is not None else 0.0\n credit_value = body.credit if body.credit is not None else 0.0\n line = JournalEntryLine(\n journal_entry_id=body.journal_entry_id,\n account_id=body.account_id,\n department_id=body.department_id,\n description=body.description,\n debit=debit_value,\n credit=credit_value,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(line)\n session.commit()\n session.refresh(line)\n session.close()\n return JournalEntryLineResponse(\n id=line.id,\n journal_entry_id=line.journal_entry_id,\n account_id=line.account_id,\n department_id=line.department_id,\n description=line.description,\n debit=line.debit,\n credit=line.credit,\n created_at=line.created_at,\n updated_at=line.updated_at,\n )\n\n@app.post(\n \"/api/bank_transaction_journal_links\",\n response_model=BankTransactionJournalLinkResponse,\n summary=\"Link a bank transaction to a journal entry\",\n description=\"Create a bank_transaction_journal_links row to connect bank_transactions with journal_entries.\",\n tags=[\"bank_transactions\", \"journal_entries\"],\n operation_id=\"create_bank_transaction_journal_link\",\n)\nasync def create_bank_transaction_journal_link_endpoint(\n body: BankTransactionJournalLinkCreateRequest = Body(...)\n) -> BankTransactionJournalLinkResponse:\n session = SessionLocal()\n link = BankTransactionJournalLink(\n bank_transaction_id=body.bank_transaction_id,\n journal_entry_id=body.journal_entry_id,\n created_at=datetime.utcnow(),\n )\n session.add(link)\n session.commit()\n session.refresh(link)\n session.close()\n return BankTransactionJournalLinkResponse(\n id=link.id,\n bank_transaction_id=link.bank_transaction_id,\n journal_entry_id=link.journal_entry_id,\n created_at=link.created_at,\n )\n\n@app.post(\n \"/api/recurring_invoices\",\n response_model=RecurringInvoiceResponse,\n summary=\"Create a recurring invoice schedule\",\n description=\"Create a recurring_invoices template specifying settings.\",\n tags=[\"recurring_invoices\"],\n operation_id=\"create_recurring_invoice\",\n)\nasync def create_recurring_invoice_endpoint(\n body: RecurringInvoiceCreateRequest = Body(...)\n) -> RecurringInvoiceResponse:\n session = SessionLocal()\n recurring = RecurringInvoice(\n customer_id=body.customer_id,\n name=body.name,\n description=body.description,\n quantity=body.quantity,\n unit_price=body.unit_price,\n discount_percent=body.discount_percent if body.discount_percent is not None else 0.0,\n frequency=body.frequency,\n next_run_date=date.fromisoformat(body.next_run_date),\n end_date=date.fromisoformat(body.end_date) if body.end_date is not None else None,\n payment_terms_id=body.payment_terms_id,\n tax_category_id=body.tax_category_id,\n department_id=body.department_id,\n currency=body.currency if body.currency is not None else \"USD\",\n is_active=1 if (body.is_active if body.is_active is not None else True) else 0,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(recurring)\n session.commit()\n session.refresh(recurring)\n session.close()\n return RecurringInvoiceResponse(\n id=recurring.id,\n customer_id=recurring.customer_id,\n name=recurring.name,\n description=recurring.description,\n quantity=recurring.quantity,\n unit_price=recurring.unit_price,\n discount_percent=recurring.discount_percent,\n frequency=recurring.frequency,\n next_run_date=recurring.next_run_date,\n end_date=recurring.end_date,\n payment_terms_id=recurring.payment_terms_id,\n tax_category_id=recurring.tax_category_id,\n department_id=recurring.department_id,\n currency=recurring.currency,\n is_active=bool(recurring.is_active),\n created_at=recurring.created_at,\n updated_at=recurring.updated_at,\n )\n\n@app.post(\n \"/api/accounting_periods\",\n response_model=AccountingPeriodResponse,\n summary=\"Create an accounting period\",\n description=\"Create an accounting_periods row representing a fiscal period.\",\n tags=[\"accounting_periods\"],\n operation_id=\"create_accounting_period\",\n)\nasync def create_accounting_period_endpoint(\n body: AccountingPeriodCreateRequest = Body(...)\n) -> AccountingPeriodResponse:\n session = SessionLocal()\n period = AccountingPeriod(\n start_date=date.fromisoformat(body.start_date),\n end_date=date.fromisoformat(body.end_date),\n close_date=date.fromisoformat(body.close_date) if body.close_date is not None else None,\n is_locked=1 if (body.is_locked if body.is_locked is not None else False) else 0,\n created_at=datetime.utcnow(),\n updated_at=None,\n )\n session.add(period)\n session.commit()\n session.refresh(period)\n session.close()\n return AccountingPeriodResponse(\n id=period.id,\n start_date=period.start_date,\n end_date=period.end_date,\n close_date=period.close_date,\n is_locked=bool(period.is_locked),\n created_at=period.created_at,\n updated_at=period.updated_at,\n )\n\n@app.patch(\n \"/api/accounting_periods/{period_id}\",\n response_model=AccountingPeriodResponse,\n summary=\"Update an accounting period lock status\",\n description=\"Update close_date and is_locked for an accounting period.\",\n tags=[\"accounting_periods\"],\n operation_id=\"update_accounting_period_lock\",\n)\nasync def update_accounting_period_lock_endpoint(\n period_id: int = Path(..., description=\"Accounting period ID to update\", example=10001),\n body: AccountingPeriodUpdateRequest = Body(...),\n) -> AccountingPeriodResponse:\n session = SessionLocal()\n period = session.query(AccountingPeriod).filter(AccountingPeriod.id == period_id).first()\n if period is None:\n session.close()\n return AccountingPeriodResponse(\n id=0,\n start_date=date.fromisoformat(\"1970-01-01\"),\n end_date=date.fromisoformat(\"1970-01-01\"),\n close_date=None,\n is_locked=False,\n created_at=None,\n updated_at=None,\n )\n if body.close_date is not None:\n period.close_date = date.fromisoformat(body.close_date)\n if body.close_date is None and body.close_date is not ...:\n if body.close_date is None:\n period.close_date = None\n if body.is_locked is not None:\n period.is_locked = 1 if body.is_locked else 0\n period.updated_at = datetime.utcnow()\n session.commit()\n session.refresh(period)\n session.close()\n return AccountingPeriodResponse(\n id=period.id,\n start_date=period.start_date,\n end_date=period.end_date,\n close_date=period.close_date,\n is_locked=bool(period.is_locked),\n created_at=period.created_at,\n updated_at=period.updated_at,\n )\n\n@app.get(\n \"/api/reports/profit_and_loss\",\n response_model=ProfitAndLossReportResponse,\n summary=\"Generate a profit and loss report\",\n description=\"Compute revenue, expenses, and net profit for a date range.\",\n tags=[\"reports\"],\n operation_id=\"generate_profit_and_loss\",\n)\nasync def generate_profit_and_loss_endpoint(\n start_date: str = Query(..., description=\"Start date for the report (YYYY-MM-DD)\", example=\"2025-01-01\"),\n end_date: str = Query(..., description=\"End date for the report (YYYY-MM-DD)\", example=\"2025-01-31\"),\n department_id: Optional[int] = Query(None, description=\"Optional department filter to restrict results\", example=2),\n) -> ProfitAndLossReportResponse:\n session = SessionLocal()\n start = date.fromisoformat(start_date)\n end = date.fromisoformat(end_date)\n entries_query = session.query(JournalEntry).filter(\n JournalEntry.entry_date >= start, JournalEntry.entry_date <= end\n )\n if department_id is not None:\n entries_query = entries_query.filter(JournalEntry.department_id == department_id)\n entries = entries_query.all()\n entry_ids = [e.id for e in entries]\n lines_query = session.query(JournalEntryLine).filter(JournalEntryLine.journal_entry_id.in_(entry_ids)) if entry_ids else session.query(JournalEntryLine).filter(JournalEntryLine.id == -1)\n if department_id is not None:\n lines_query = lines_query.filter(\n (JournalEntryLine.department_id == department_id) | (JournalEntryLine.department_id.is_(None))\n )\n lines = lines_query.all()\n account_ids = list({l.account_id for l in lines})\n accounts = {}\n if account_ids:\n account_rows = session.query(Account).filter(Account.id.in_(account_ids)).all()\n for a in account_rows:\n accounts[a.id] = a\n total_revenue = 0.0\n total_expenses = 0.0\n income_details: List[Dict[str, Optional[float]]] = []\n expense_details: List[Dict[str, Optional[float]]] = []\n income_map: Dict[int, float] = {}\n expense_map: Dict[int, float] = {}\n for l in lines:\n a = accounts.get(l.account_id)\n if a is None:\n continue\n net_amount = l.debit - l.credit\n if a.type == \"income\":\n amount = -net_amount\n total_revenue += amount\n income_map[a.id] = income_map.get(a.id, 0.0) + amount\n if a.type == \"expense\":\n amount = net_amount\n total_expenses += amount\n expense_map[a.id] = expense_map.get(a.id, 0.0) + amount\n for aid, amt in income_map.items():\n a = accounts.get(aid)\n if a is not None:\n income_details.append({\"account_id\": float(a.id), \"account_name\": a.name, \"amount\": amt})\n for aid, amt in expense_map.items():\n a = accounts.get(aid)\n if a is not None:\n expense_details.append({\"account_id\": float(a.id), \"account_name\": a.name, \"amount\": amt})\n net_profit = total_revenue - total_expenses\n session.close()\n detail = {\n \"income_accounts\": income_details,\n \"expense_accounts\": expense_details,\n }\n return ProfitAndLossReportResponse(\n start_date=start_date,\n end_date=end_date,\n department_id=department_id,\n total_revenue=total_revenue,\n total_expenses=total_expenses,\n net_profit=net_profit,\n detail=detail,\n )\n\nif __name__ == \"__main__\":\n import uvicorn, os\n host = os.getenv(\"HOST\", \"127.0.0.1\")\n port = int(os.getenv(\"PORT\", \"8000\"))\n uvicorn.run(app, host=host, port=port)"}
components/awm/upstream/accounting_1-gen_sample.jsonl ADDED
@@ -0,0 +1 @@
 
 
1
+ {"scenario": "accounting_1", "tables_count": 20, "inserts_count": 121, "sample_data": {"tables": [{"table_name": "users", "reasoning": "Provides a current authenticated user (id=1) and additional users to associate with journal entries or other audit fields that reference created_by_user_id, enabling realistic multi-user scenarios.", "insert_statements": ["INSERT INTO users (id, username, email, full_name, created_at) VALUES (1, 'current_user', 'user@example.com', 'Current User', '2024-11-01 10:00:00');", "INSERT INTO users (id, username, email, full_name, created_at) VALUES (2, 'staff_anna', 'anna@example.com', 'Anna Staff', '2024-11-15 09:00:00');", "INSERT INTO users (id, username, email, full_name, created_at) VALUES (3, 'staff_bob', 'bob@example.com', 'Bob Staff', '2024-12-01 12:00:00');"]}, {"table_name": "departments", "reasoning": "Defines departments referenced across tasks: Design, Operations, General & Administrative. Also includes extra departments to support filtering, reporting, and edge cases where data belongs to other departments.", "insert_statements": ["INSERT INTO departments (id, name, description, created_at) VALUES (1, 'Design', 'Design and creative services', '2024-10-01 09:00:00');", "INSERT INTO departments (id, name, description, created_at) VALUES (2, 'Operations', 'Operations and logistics', '2024-10-01 09:05:00');", "INSERT INTO departments (id, name, description, created_at) VALUES (3, 'General & Administrative', 'G&A overhead costs', '2024-10-01 09:10:00');", "INSERT INTO departments (id, name, description, created_at) VALUES (4, 'Marketing', 'Marketing and advertising expenses', '2024-10-01 09:15:00');", "INSERT INTO departments (id, name, description, created_at) VALUES (5, 'Sales', 'Sales team activities', '2024-10-01 09:20:00');"]}, {"table_name": "tax_categories", "reasoning": "Provides tax options for invoices and recurring invoices. Includes the requested 'Standard Sales Tax 8.5%' and 'No Tax' plus additional categories for more realistic filtering and historical data.", "insert_statements": ["INSERT INTO tax_categories (id, name, description, rate, is_compound, created_at) VALUES (1, 'Standard Sales Tax 8.5%', 'Standard state and local sales tax at 8.5%', 0.085, 0, '2024-10-10 08:00:00');", "INSERT INTO tax_categories (id, name, description, rate, is_compound, created_at) VALUES (2, 'Reduced Sales Tax 5%', 'Reduced rate for certain services', 0.05, 0, '2024-10-10 08:05:00');", "INSERT INTO tax_categories (id, name, description, rate, is_compound, created_at) VALUES (3, 'No Tax', 'No sales tax applicable', 0.0, 0, '2024-10-10 08:10:00');", "INSERT INTO tax_categories (id, name, description, rate, is_compound, created_at) VALUES (4, 'Digital Services Tax 10%', 'Higher rate for digital-only services', 0.10, 0, '2024-10-10 08:15:00');", "INSERT INTO tax_categories (id, name, description, rate, is_compound, created_at) VALUES (5, 'VAT 20%', 'Value Added Tax at 20%', 0.20, 0, '2024-10-10 08:20:00');"]}, {"table_name": "payment_terms", "reasoning": "Defines available payment terms. Includes Net 30, Net 15, and others for invoices, bills, customers, vendors, and recurring invoices as required by the tasks.", "insert_statements": ["INSERT INTO payment_terms (id, name, days, description, created_at) VALUES (1, 'Due on Receipt', 0, 'Payment due immediately upon receipt', '2024-09-20 09:00:00');", "INSERT INTO payment_terms (id, name, days, description, created_at) VALUES (2, 'Net 15', 15, 'Payment due 15 days from invoice date', '2024-09-20 09:05:00');", "INSERT INTO payment_terms (id, name, days, description, created_at) VALUES (3, 'Net 30', 30, 'Payment due 30 days from invoice date', '2024-09-20 09:10:00');", "INSERT INTO payment_terms (id, name, days, description, created_at) VALUES (4, 'Net 45', 45, 'Payment due 45 days from invoice date', '2024-09-20 09:15:00');", "INSERT INTO payment_terms (id, name, days, description, created_at) VALUES (5, 'Net 60', 60, 'Payment due 60 days from invoice date', '2024-09-20 09:20:00');"]}, {"table_name": "accounts", "reasoning": "Provides chart of accounts to support revenue, expenses, assets, liabilities, and equity. Required for linking vendors\u2019 default_expense_category, recurring_expenses, journal entries, and bank-related postings.", "insert_statements": ["INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (1, 'Chase Business Checking', '1000', 'asset', 'bank', 1, '2024-09-01 08:00:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (2, 'Accounts Receivable', '1100', 'asset', 'receivable', 1, '2024-09-01 08:05:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (3, 'Prepaid Rent', '1200', 'asset', 'prepaid_expense', 1, '2024-09-01 08:10:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (4, 'Office Supplies', '5200', 'expense', 'office', 1, '2024-09-01 08:15:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (5, 'Software Subscriptions', '5300', 'expense', 'software', 1, '2024-09-01 08:20:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (6, 'Contractor Expenses', '5400', 'expense', 'contractor', 1, '2024-09-01 08:25:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (7, 'Rent Expense', '5500', 'expense', 'rent', 1, '2024-09-01 08:30:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (8, 'Accrued Expenses', '2100', 'liability', 'accrual', 1, '2024-09-01 08:35:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (9, 'Design Services Revenue', '4000', 'income', 'services', 1, '2024-09-01 08:40:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (10, 'Client Income - General', '4010', 'income', 'services', 1, '2024-09-01 08:45:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (11, 'Bank Service Charges', '6100', 'expense', 'bank_fees', 1, '2024-09-01 08:50:00');", "INSERT INTO accounts (id, name, code, type, sub_type, is_active, created_at) VALUES (12, 'Owner Equity', '3000', 'equity', 'owner_equity', 1, '2024-09-01 08:55:00');"]}, {"table_name": "bank_accounts", "reasoning": "Creates a bank account mapped to the cash account. Required for importing bank_transactions into 'Chase Business Checking ****1023' and linking them to journal entries.", "insert_statements": ["INSERT INTO bank_accounts (id, name, institution_name, account_number_masked, account_id, created_at) VALUES (1, 'Chase Business Checking ****1023', 'Chase Bank', '****1023', 1, '2024-09-05 09:00:00');", "INSERT INTO bank_accounts (id, name, institution_name, account_number_masked, account_id, created_at) VALUES (2, 'PayPal Business ****7788', 'PayPal', '****7788', 1, '2024-09-05 09:05:00');"]}, {"table_name": "customers", "reasoning": "Defines customers including Acme Design Studio and BrightFuture Marketing required by tasks. Other customers give realistic listing and filtering behavior for reports and invoice operations.", "insert_statements": ["INSERT INTO customers (id, name, billing_email, payment_terms_id, default_tax_category_id, created_at) VALUES (1, 'Acme Design Studio', 'billing@acmedesign.com', 3, 1, '2024-11-20 10:00:00');", "INSERT INTO customers (id, name, billing_email, payment_terms_id, default_tax_category_id, created_at) VALUES (2, 'BrightFuture Marketing', 'ap@brightfuture.com', 2, 3, '2024-11-21 11:00:00');", "INSERT INTO customers (id, name, billing_email, payment_terms_id, default_tax_category_id, created_at) VALUES (3, 'Northwind Traders', 'accounts@northwind.com', 3, 1, '2024-10-15 09:00:00');", "INSERT INTO customers (id, name, billing_email, payment_terms_id, default_tax_category_id, created_at) VALUES (4, 'Global Retail Co', 'billing@globalretail.co', 4, 1, '2024-10-20 09:30:00');", "INSERT INTO customers (id, name, billing_email, payment_terms_id, default_tax_category_id, created_at) VALUES (5, 'UrbanHub Cowork Member', 'member@urbanhub.com', 1, 3, '2024-11-01 08:45:00');"]}, {"table_name": "vendors", "reasoning": "Creates vendors including PixelPrint Supplies and UrbanHub Cowork for bills and recurring expenses, plus additional vendors to exercise listing, filtering, and reporting across multiple payees.", "insert_statements": ["INSERT INTO vendors (id, name, contact_email, payment_terms_id, default_expense_category_id, created_at) VALUES (1, 'PixelPrint Supplies', 'accounts@pixelprint.com', 2, 4, '2024-11-10 14:00:00');", "INSERT INTO vendors (id, name, contact_email, payment_terms_id, default_expense_category_id, created_at) VALUES (2, 'UrbanHub Cowork', 'billing@urbanhubcowork.com', 3, 7, '2024-11-11 10:00:00');", "INSERT INTO vendors (id, name, contact_email, payment_terms_id, default_expense_category_id, created_at) VALUES (3, 'SaaSify Cloud', 'billing@saasify.com', 1, 5, '2024-10-05 11:00:00');", "INSERT INTO vendors (id, name, contact_email, payment_terms_id, default_expense_category_id, created_at) VALUES (4, 'Creative Contractors LLC', 'ap@creativecontractors.com', 2, 6, '2024-10-06 11:15:00');", "INSERT INTO vendors (id, name, contact_email, payment_terms_id, default_expense_category_id, created_at) VALUES (5, 'City Storage Units', 'accounts@citystorage.com', 3, 7, '2024-10-07 11:30:00');"]}, {"table_name": "invoices", "reasoning": "Includes INV-2025-001 for Acme with proper department, tax_category, and amounts, plus other invoices spanning dates and departments to support reporting and payment application scenarios.", "insert_statements": ["INSERT INTO invoices (id, invoice_number, customer_id, department_id, tax_category_id, invoice_date, due_date, currency, status, subtotal, tax_amount, total, balance_due, payment_terms_id, created_at) VALUES (1, 'INV-2024-010', 3, 1, 1, '2024-12-15', '2025-01-14', 'USD', 'open', 2000.0, 170.0, 2170.0, 2170.0, 3, '2024-12-15 09:00:00');", "INSERT INTO invoices (id, invoice_number, customer_id, department_id, tax_category_id, invoice_date, due_date, currency, status, subtotal, tax_amount, total, balance_due, payment_terms_id, created_at) VALUES (2, 'INV-2024-011', 4, 2, 3, '2024-12-20', '2025-01-19', 'USD', 'draft', 1500.0, 0.0, 1500.0, 1500.0, 4, '2024-12-20 10:00:00');", "INSERT INTO invoices (id, invoice_number, customer_id, department_id, tax_category_id, invoice_date, due_date, currency, status, subtotal, tax_amount, total, balance_due, payment_terms_id, created_at) VALUES (3, 'INV-2025-001', 1, 1, 1, '2025-01-05', '2025-02-04', 'USD', 'open', 1920.0, 163.2, 2083.2, 1183.2, 3, '2025-01-05 09:30:00');", "INSERT INTO invoices (id, invoice_number, customer_id, department_id, tax_category_id, invoice_date, due_date, currency, status, subtotal, tax_amount, total, balance_due, payment_terms_id, created_at) VALUES (4, 'INV-2025-002', 2, 4, 3, '2025-01-10', '2025-01-25', 'USD', 'open', 1500.0, 0.0, 1500.0, 1500.0, 2, '2025-01-10 11:00:00');", "INSERT INTO invoices (id, invoice_number, customer_id, department_id, tax_category_id, invoice_date, due_date, currency, status, subtotal, tax_amount, total, balance_due, payment_terms_id, created_at) VALUES (5, 'INV-2025-003', 1, 1, 1, '2025-01-20', '2025-02-19', 'USD', 'draft', 800.0, 68.0, 868.0, 868.0, 3, '2025-01-20 14:00:00');", "INSERT INTO invoices (id, invoice_number, customer_id, department_id, tax_category_id, invoice_date, due_date, currency, status, subtotal, tax_amount, total, balance_due, payment_terms_id, created_at) VALUES (6, 'INV-2025-004', 3, 5, 1, '2025-01-15', '2025-02-14', 'USD', 'paid', 5000.0, 425.0, 5425.0, 0.0, 3, '2025-01-15 10:30:00');"]}, {"table_name": "invoice_line_items", "reasoning": "Populates invoice lines including Acme\u2019s logo redesign and brand guideline items with correct discounts and department. Extra lines across invoices and departments support revenue reporting by department.", "insert_statements": ["INSERT INTO invoice_line_items (id, invoice_id, description, quantity, unit_price, discount_percent, line_subtotal, tax_amount, total, revenue_account_id, department_id, created_at) VALUES (1, 1, 'Website redesign project', 1.0, 2000.0, 0.0, 2000.0, 170.0, 2170.0, 9, 1, '2024-12-15 09:05:00');", "INSERT INTO invoice_line_items (id, invoice_id, description, quantity, unit_price, discount_percent, line_subtotal, tax_amount, total, revenue_account_id, department_id, created_at) VALUES (2, 2, 'Operations consulting retainer', 1.0, 1500.0, 0.0, 1500.0, 0.0, 1500.0, 10, 2, '2024-12-20 10:05:00');", "INSERT INTO invoice_line_items (id, invoice_id, description, quantity, unit_price, discount_percent, line_subtotal, tax_amount, total, revenue_account_id, department_id, created_at) VALUES (3, 3, 'Logo redesign', 1.0, 1200.0, 0.0, 1200.0, 102.0, 1302.0, 9, 1, '2025-01-05 09:35:00');", "INSERT INTO invoice_line_items (id, invoice_id, description, quantity, unit_price, discount_percent, line_subtotal, tax_amount, total, revenue_account_id, department_id, created_at) VALUES (4, 3, 'Brand guideline document', 1.0, 800.0, 10.0, 720.0, 61.2, 781.2, 9, 1, '2025-01-05 09:36:00');", "INSERT INTO invoice_line_items (id, invoice_id, description, quantity, unit_price, discount_percent, line_subtotal, tax_amount, total, revenue_account_id, department_id, created_at) VALUES (5, 4, 'Monthly SEO Retainer', 1.0, 1500.0, 0.0, 1500.0, 0.0, 1500.0, 10, 4, '2025-01-10 11:05:00');", "INSERT INTO invoice_line_items (id, invoice_id, description, quantity, unit_price, discount_percent, line_subtotal, tax_amount, total, revenue_account_id, department_id, created_at) VALUES (6, 5, 'Social media asset pack', 1.0, 800.0, 0.0, 800.0, 68.0, 868.0, 9, 1, '2025-01-20 14:05:00');", "INSERT INTO invoice_line_items (id, invoice_id, description, quantity, unit_price, discount_percent, line_subtotal, tax_amount, total, revenue_account_id, department_id, created_at) VALUES (7, 6, 'Enterprise UX audit', 1.0, 5000.0, 0.0, 5000.0, 425.0, 5425.0, 9, 5, '2025-01-15 10:35:00');"]}, {"table_name": "payments", "reasoning": "Records customer payments including the partial credit card payment for Acme against INV-2025-001, plus other payments to support open, paid, and partially paid invoice scenarios.", "insert_statements": ["INSERT INTO payments (id, customer_id, payment_date, settlement_date, amount, currency, method, reference, created_at) VALUES (1, 1, '2025-01-10', '2025-01-10', 900.0, 'USD', 'Credit Card', 'STRIPE-12345', '2025-01-10 12:00:00');", "INSERT INTO payments (id, customer_id, payment_date, settlement_date, amount, currency, method, reference, created_at) VALUES (2, 3, '2025-01-16', '2025-01-16', 5425.0, 'USD', 'Bank Transfer', 'ACH-778899', '2025-01-16 10:00:00');", "INSERT INTO payments (id, customer_id, payment_date, settlement_date, amount, currency, method, reference, created_at) VALUES (3, 3, '2025-01-05', '2025-01-06', 1000.0, 'USD', 'Check', 'CHK-1001', '2025-01-05 15:00:00');", "INSERT INTO payments (id, customer_id, payment_date, settlement_date, amount, currency, method, reference, created_at) VALUES (4, 4, '2025-01-21', '2025-01-21', 1500.0, 'USD', 'Credit Card', 'STRIPE-67890', '2025-01-21 11:30:00');", "INSERT INTO payments (id, customer_id, payment_date, settlement_date, amount, currency, method, reference, created_at) VALUES (5, 1, '2025-02-10', '2025-02-10', 1183.2, 'USD', 'Credit Card', 'STRIPE-ACME-FINAL', '2025-02-10 09:00:00');"]}, {"table_name": "payment_applications", "reasoning": "Applies payments to specific invoices, particularly linking the 900 USD payment to INV-2025-001. Additional applications demonstrate full and partial settlements for reporting and balance calculations.", "insert_statements": ["INSERT INTO payment_applications (id, payment_id, invoice_id, amount, created_at) VALUES (1, 1, 3, 900.0, '2025-01-10 12:05:00');", "INSERT INTO payment_applications (id, payment_id, invoice_id, amount, created_at) VALUES (2, 2, 6, 5425.0, '2025-01-16 10:05:00');", "INSERT INTO payment_applications (id, payment_id, invoice_id, amount, created_at) VALUES (3, 3, 1, 1000.0, '2025-01-05 15:05:00');", "INSERT INTO payment_applications (id, payment_id, invoice_id, amount, created_at) VALUES (4, 4, 2, 1500.0, '2025-01-21 11:35:00');", "INSERT INTO payment_applications (id, payment_id, invoice_id, amount, created_at) VALUES (5, 5, 3, 1183.2, '2025-02-10 09:05:00');"]}, {"table_name": "bills", "reasoning": "Creates bills including the PixelPrint Supplies bill for printer ink and paper, and extra bills across vendors and departments to test payables workflows and reimbursement_status filters.", "insert_statements": ["INSERT INTO bills (id, bill_number, vendor_id, bill_date, due_date, currency, amount, description, department_id, reimbursement_status, payment_terms_id, status, created_at) VALUES (1, 'BILL-2025-001', 1, '2025-01-03', '2025-01-18', 'USD', 325.50, 'Printer ink and paper', 2, 'Not Reimbursable', 2, 'open', '2025-01-03 10:00:00');", "INSERT INTO bills (id, bill_number, vendor_id, bill_date, due_date, currency, amount, description, department_id, reimbursement_status, payment_terms_id, status, created_at) VALUES (2, 'BILL-2024-015', 2, '2024-12-01', '2024-12-31', 'USD', 650.0, 'December co-working rent', 3, 'Not Reimbursable', 3, 'paid', '2024-12-01 09:00:00');", "INSERT INTO bills (id, bill_number, vendor_id, bill_date, due_date, currency, amount, description, department_id, reimbursement_status, payment_terms_id, status, created_at) VALUES (3, 'BILL-2025-002', 2, '2025-01-01', '2025-01-31', 'USD', 650.0, 'January co-working rent', 3, 'Not Reimbursable', 3, 'open', '2025-01-01 09:00:00');", "INSERT INTO bills (id, bill_number, vendor_id, bill_date, due_date, currency, amount, description, department_id, reimbursement_status, payment_terms_id, status, created_at) VALUES (4, 'BILL-2025-003', 3, '2025-01-05', '2025-02-04', 'USD', 300.0, 'SaaS subscription January', 3, 'Not Reimbursable', 1, 'open', '2025-01-05 11:00:00');", "INSERT INTO bills (id, bill_number, vendor_id, bill_date, due_date, currency, amount, description, department_id, reimbursement_status, payment_terms_id, status, created_at) VALUES (5, 'BILL-2025-004', 4, '2025-01-07', '2025-01-22', 'USD', 1200.0, 'Contract design support', 1, 'Not Reimbursable', 2, 'open', '2025-01-07 13:00:00');"]}, {"table_name": "recurring_expenses", "reasoning": "Defines a recurring expense template for Monthly Co-working Space Rent tied to UrbanHub Cowork and department G&A, plus other recurring templates to test scheduling and frequency behavior.", "insert_statements": ["INSERT INTO recurring_expenses (id, name, vendor_id, amount, expense_account_id, department_id, frequency, next_run_date, end_date, is_active, created_at) VALUES (1, 'Monthly Co-working Space Rent', 2, 650.0, 7, 3, 'monthly', '2025-02-01', '2025-12-01', 1, '2025-01-01 08:00:00');", "INSERT INTO recurring_expenses (id, name, vendor_id, amount, expense_account_id, department_id, frequency, next_run_date, end_date, is_active, created_at) VALUES (2, 'SaaS Project Management Tool', 3, 150.0, 5, 3, 'monthly', '2025-02-01', NULL, 1, '2025-01-01 08:05:00');", "INSERT INTO recurring_expenses (id, name, vendor_id, amount, expense_account_id, department_id, frequency, next_run_date, end_date, is_active, created_at) VALUES (3, 'Cloud Hosting', 3, 200.0, 5, 2, 'monthly', '2025-02-05', NULL, 1, '2025-01-05 09:00:00');", "INSERT INTO recurring_expenses (id, name, vendor_id, amount, expense_account_id, department_id, frequency, next_run_date, end_date, is_active, created_at) VALUES (4, 'Office Snacks', 1, 75.0, 4, 2, 'weekly', '2025-01-10', NULL, 1, '2025-01-03 10:30:00');", "INSERT INTO recurring_expenses (id, name, vendor_id, amount, expense_account_id, department_id, frequency, next_run_date, end_date, is_active, created_at) VALUES (5, 'Annual Domain Renewals', 3, 120.0, 5, 3, 'yearly', '2025-12-15', '2027-12-15', 1, '2024-12-15 08:00:00');"]}, {"table_name": "bank_transactions", "reasoning": "Imports 5 transactions into the Chase account between 2025-01-01 and 2025-01-07 with varied descriptions and amounts, used to categorize into income or expenses and link to journal entries.", "insert_statements": ["INSERT INTO bank_transactions (id, bank_account_id, transaction_date, posted_date, description, amount, external_id, created_at) VALUES (1, 1, '2025-01-01', '2025-01-02', 'Client deposit - Northwind', 2500.0, 'BTX-1001', '2025-01-02 09:00:00');", "INSERT INTO bank_transactions (id, bank_account_id, transaction_date, posted_date, description, amount, external_id, created_at) VALUES (2, 1, '2025-01-02', '2025-01-03', 'Software subscription - SaaSify', -150.0, 'BTX-1002', '2025-01-03 09:05:00');", "INSERT INTO bank_transactions (id, bank_account_id, transaction_date, posted_date, description, amount, external_id, created_at) VALUES (3, 1, '2025-01-03', '2025-01-04', 'Office supplies - PixelPrint', -85.75, 'BTX-1003', '2025-01-04 09:10:00');", "INSERT INTO bank_transactions (id, bank_account_id, transaction_date, posted_date, description, amount, external_id, created_at) VALUES (4, 1, '2025-01-05', '2025-01-06', 'Client payment - BrightFuture', 1500.0, 'BTX-1004', '2025-01-06 09:15:00');", "INSERT INTO bank_transactions (id, bank_account_id, transaction_date, posted_date, description, amount, external_id, created_at) VALUES (5, 1, '2025-01-07', '2025-01-08', 'Software subscription - AnalyticsPro', -99.0, 'BTX-1005', '2025-01-08 09:20:00');", "INSERT INTO bank_transactions (id, bank_account_id, transaction_date, posted_date, description, amount, external_id, created_at) VALUES (6, 2, '2025-01-04', '2025-01-05', 'Misc PayPal income', 300.0, 'PP-2001', '2025-01-05 10:00:00');"]}, {"table_name": "journal_entries", "reasoning": "Creates year-end accrual entries on 2024-12-31 and entries generated from bank transaction categorizations, all tied to departments and sources where relevant, enabling reporting and period-lock testing.", "insert_statements": ["INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (1, '2024-12-31', 'Accrue December software subscriptions', 3, 'year_end_accrual', 1, 1, '2024-12-31 16:00:00');", "INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (2, '2024-12-31', 'Accrue December contractor expenses', 3, 'year_end_accrual', 2, 1, '2024-12-31 16:05:00');", "INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (3, '2024-12-31', 'Adjust prepaid rent', 3, 'year_end_accrual', 3, 1, '2024-12-31 16:10:00');", "INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (4, '2025-01-01', 'Bank tx BTX-1001 - Client income', 3, 'bank_transaction', 1, 1, '2025-01-02 09:30:00');", "INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (5, '2025-01-02', 'Bank tx BTX-1002 - Software subscription', 3, 'bank_transaction', 2, 1, '2025-01-03 09:30:00');", "INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (6, '2025-01-03', 'Bank tx BTX-1003 - Office supplies', 2, 'bank_transaction', 3, 1, '2025-01-04 09:30:00');", "INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (7, '2025-01-05', 'Bank tx BTX-1004 - Client income', 4, 'bank_transaction', 4, 1, '2025-01-06 09:30:00');", "INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (8, '2025-01-07', 'Bank tx BTX-1005 - Software subscription', 3, 'bank_transaction', 5, 1, '2025-01-08 09:30:00');", "INSERT INTO journal_entries (id, entry_date, description, department_id, source, source_id, created_by_user_id, created_at) VALUES (9, '2024-12-15', 'Manual adjustment prior to period close', 3, 'manual', 1, 2, '2024-12-15 10:00:00');"]}, {"table_name": "journal_entry_lines", "reasoning": "Adds debits and credits for year-end accruals and bank-transaction-based entries, ensuring balanced postings and proper account usage for income and expense categorization tests.", "insert_statements": ["INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (1, 1, 5, 3, 'Accrue December SaaS', 300.0, 0.0, '2024-12-31 16:01:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (2, 1, 8, 3, 'Accrued expenses', 0.0, 300.0, '2024-12-31 16:01:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (3, 2, 6, 3, 'Accrue contractor fees', 1200.0, 0.0, '2024-12-31 16:06:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (4, 2, 8, 3, 'Accrued expenses', 0.0, 1200.0, '2024-12-31 16:06:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (5, 3, 7, 3, 'Recognize rent expense', 650.0, 0.0, '2024-12-31 16:11:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (6, 3, 3, 3, 'Reduce prepaid rent', 0.0, 650.0, '2024-12-31 16:11:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (7, 4, 1, 3, 'Client deposit Northwind', 2500.0, 0.0, '2025-01-02 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (8, 4, 10, 3, 'Client income from deposit', 0.0, 2500.0, '2025-01-02 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (9, 5, 5, 3, 'SaaSify subscription', 150.0, 0.0, '2025-01-03 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (10, 5, 1, 3, 'Bank payment for SaaSify', 0.0, 150.0, '2025-01-03 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (11, 6, 4, 2, 'PixelPrint office supplies', 85.75, 0.0, '2025-01-04 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (12, 6, 1, 2, 'Bank payment for supplies', 0.0, 85.75, '2025-01-04 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (13, 7, 1, 4, 'BrightFuture client receipt', 1500.0, 0.0, '2025-01-06 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (14, 7, 10, 4, 'Client income BrightFuture', 0.0, 1500.0, '2025-01-06 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (15, 8, 5, 3, 'AnalyticsPro subscription', 99.0, 0.0, '2025-01-08 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (16, 8, 1, 3, 'Bank payment for AnalyticsPro', 0.0, 99.0, '2025-01-08 09:31:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (17, 9, 11, 3, 'Bank fees adjustment', 50.0, 0.0, '2024-12-15 10:01:00');", "INSERT INTO journal_entry_lines (id, journal_entry_id, account_id, department_id, description, debit, credit, created_at) VALUES (18, 9, 1, 3, 'Bank account adjustment', 0.0, 50.0, '2024-12-15 10:01:00');"]}, {"table_name": "bank_transaction_journal_links", "reasoning": "Links each imported bank_transaction to its corresponding journal_entry, allowing traceability between bank feeds and general ledger for reconciliation and categorization validation.", "insert_statements": ["INSERT INTO bank_transaction_journal_links (id, bank_transaction_id, journal_entry_id, created_at) VALUES (1, 1, 4, '2025-01-02 09:35:00');", "INSERT INTO bank_transaction_journal_links (id, bank_transaction_id, journal_entry_id, created_at) VALUES (2, 2, 5, '2025-01-03 09:35:00');", "INSERT INTO bank_transaction_journal_links (id, bank_transaction_id, journal_entry_id, created_at) VALUES (3, 3, 6, '2025-01-04 09:35:00');", "INSERT INTO bank_transaction_journal_links (id, bank_transaction_id, journal_entry_id, created_at) VALUES (4, 4, 7, '2025-01-06 09:35:00');", "INSERT INTO bank_transaction_journal_links (id, bank_transaction_id, journal_entry_id, created_at) VALUES (5, 5, 8, '2025-01-08 09:35:00');"]}, {"table_name": "recurring_invoices", "reasoning": "Creates a recurring invoice schedule for BrightFuture Marketing\u2019s Monthly SEO Retainer with Net 15 terms and No Tax, plus other templates to test frequencies, departments, and active flags.", "insert_statements": ["INSERT INTO recurring_invoices (id, customer_id, name, description, quantity, unit_price, discount_percent, frequency, next_run_date, end_date, payment_terms_id, tax_category_id, department_id, currency, is_active, created_at) VALUES (1, 2, 'Monthly SEO Retainer', 'Ongoing SEO strategy and reporting', 1.0, 1500.0, 0.0, 'monthly', '2025-02-01', '2025-07-01', 2, 3, 4, 'USD', 1, '2025-01-10 12:00:00');", "INSERT INTO recurring_invoices (id, customer_id, name, description, quantity, unit_price, discount_percent, frequency, next_run_date, end_date, payment_terms_id, tax_category_id, department_id, currency, is_active, created_at) VALUES (2, 1, 'Monthly Design Support', 'Block of 10 design hours', 10.0, 120.0, 0.0, 'monthly', '2025-02-05', NULL, 3, 1, 1, 'USD', 1, '2025-01-15 10:00:00');", "INSERT INTO recurring_invoices (id, customer_id, name, description, quantity, unit_price, discount_percent, frequency, next_run_date, end_date, payment_terms_id, tax_category_id, department_id, currency, is_active, created_at) VALUES (3, 3, 'Quarterly UX Audit', 'Comprehensive UX review', 1.0, 4000.0, 5.0, 'quarterly', '2025-04-01', '2026-04-01', 3, 1, 5, 'USD', 1, '2025-01-05 09:00:00');", "INSERT INTO recurring_invoices (id, customer_id, name, description, quantity, unit_price, discount_percent, frequency, next_run_date, end_date, payment_terms_id, tax_category_id, department_id, currency, is_active, created_at) VALUES (4, 4, 'Annual Brand Review', 'Yearly brand health check', 1.0, 2500.0, 0.0, 'yearly', '2025-12-31', '2027-12-31', 4, 1, 1, 'USD', 1, '2024-12-31 13:00:00');", "INSERT INTO recurring_invoices (id, customer_id, name, description, quantity, unit_price, discount_percent, frequency, next_run_date, end_date, payment_terms_id, tax_category_id, department_id, currency, is_active, created_at) VALUES (5, 5, 'Weekly Social Media Pack', 'Design of weekly post templates', 4.0, 200.0, 10.0, 'weekly', '2025-01-12', '2025-06-30', 1, 1, 1, 'USD', 1, '2025-01-01 12:00:00');"]}, {"table_name": "accounting_periods", "reasoning": "Defines accounting periods and locks all transactions on or before 2024-12-31 by setting close_date and is_locked, supporting period-close logic and preventing subsequent edits via the API.", "insert_statements": ["INSERT INTO accounting_periods (id, start_date, end_date, close_date, is_locked, created_at) VALUES (1, '2024-01-01', '2024-12-31', '2024-12-31', 1, '2025-01-01 09:00:00');", "INSERT INTO accounting_periods (id, start_date, end_date, close_date, is_locked, created_at) VALUES (2, '2025-01-01', '2025-12-31', NULL, 0, '2025-01-01 09:05:00');", "INSERT INTO accounting_periods (id, start_date, end_date, close_date, is_locked, created_at) VALUES (3, '2023-01-01', '2023-12-31', '2024-01-31', 1, '2024-02-01 10:00:00');"]}]}}
components/awm/upstream/manufacturing_execution_system_1-gen_db.jsonl ADDED
@@ -0,0 +1 @@
 
 
1
+ {"scenario": "manufacturing_execution_system_1", "db_schema": {"tables": [{"name": "users", "ddl": "CREATE TABLE users (\n id INTEGER PRIMARY KEY,\n username TEXT UNIQUE NOT NULL,\n email TEXT UNIQUE NOT NULL,\n full_name TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);", "indexes": ["CREATE INDEX idx_users_username ON users(username);", "CREATE INDEX idx_users_email ON users(email);"]}, {"name": "customers", "ddl": "CREATE TABLE customers (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n billing_address TEXT NOT NULL,\n contact_person TEXT,\n email TEXT,\n phone TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);", "indexes": ["CREATE INDEX idx_customers_name ON customers(name);"]}, {"name": "product_templates", "ddl": "CREATE TABLE product_templates (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n description TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);", "indexes": ["CREATE INDEX idx_product_templates_name ON product_templates(name);"]}, {"name": "product_template_options", "ddl": "CREATE TABLE product_template_options (\n id INTEGER PRIMARY KEY,\n product_template_id INTEGER NOT NULL,\n option_name TEXT NOT NULL,\n option_value TEXT NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (product_template_id) REFERENCES product_templates(id) ON DELETE CASCADE,\n UNIQUE (product_template_id, option_name, option_value)\n);", "indexes": ["CREATE INDEX idx_pto_template ON product_template_options(product_template_id);", "CREATE INDEX idx_pto_name_value ON product_template_options(option_name, option_value);"]}, {"name": "standard_task_sequences", "ddl": "CREATE TABLE standard_task_sequences (\n id INTEGER PRIMARY KEY,\n product_template_id INTEGER NOT NULL,\n sequence_order INTEGER NOT NULL,\n task_name TEXT NOT NULL,\n default_planned_duration_hours REAL NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (product_template_id) REFERENCES product_templates(id) ON DELETE CASCADE,\n UNIQUE (product_template_id, sequence_order)\n);", "indexes": ["CREATE INDEX idx_sts_template ON standard_task_sequences(product_template_id);"]}, {"name": "custom_specs", "ddl": "CREATE TABLE custom_specs (\n id INTEGER PRIMARY KEY,\n customer_id INTEGER NOT NULL,\n product_template_id INTEGER NOT NULL,\n notes TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE RESTRICT,\n FOREIGN KEY (product_template_id) REFERENCES product_templates(id) ON DELETE RESTRICT\n);", "indexes": ["CREATE INDEX idx_custom_specs_customer ON custom_specs(customer_id);", "CREATE INDEX idx_custom_specs_template ON custom_specs(product_template_id);"]}, {"name": "custom_spec_options", "ddl": "CREATE TABLE custom_spec_options (\n id INTEGER PRIMARY KEY,\n custom_spec_id INTEGER NOT NULL,\n option_name TEXT NOT NULL,\n option_value TEXT NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (custom_spec_id) REFERENCES custom_specs(id) ON DELETE CASCADE,\n UNIQUE (custom_spec_id, option_name)\n);", "indexes": ["CREATE INDEX idx_cso_custom_spec ON custom_spec_options(custom_spec_id);"]}, {"name": "custom_spec_numeric_params", "ddl": "CREATE TABLE custom_spec_numeric_params (\n id INTEGER PRIMARY KEY,\n custom_spec_id INTEGER NOT NULL,\n param_name TEXT NOT NULL,\n param_value REAL NOT NULL,\n unit TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (custom_spec_id) REFERENCES custom_specs(id) ON DELETE CASCADE,\n UNIQUE (custom_spec_id, param_name)\n);", "indexes": ["CREATE INDEX idx_csnp_custom_spec ON custom_spec_numeric_params(custom_spec_id);"]}, {"name": "quotes", "ddl": "CREATE TABLE quotes (\n id INTEGER PRIMARY KEY,\n quote_number TEXT NOT NULL UNIQUE,\n customer_id INTEGER NOT NULL,\n custom_spec_id INTEGER,\n estimated_hours REAL NOT NULL,\n material_cost REAL NOT NULL,\n labor_rate REAL NOT NULL,\n status TEXT NOT NULL,\n internal_note TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE RESTRICT,\n FOREIGN KEY (custom_spec_id) REFERENCES custom_specs(id) ON DELETE SET NULL\n);", "indexes": ["CREATE INDEX idx_quotes_customer ON quotes(customer_id);", "CREATE INDEX idx_quotes_status ON quotes(status);"]}, {"name": "jobs", "ddl": "CREATE TABLE jobs (\n id INTEGER PRIMARY KEY,\n job_number TEXT NOT NULL UNIQUE,\n customer_id INTEGER NOT NULL,\n quote_id INTEGER,\n custom_spec_id INTEGER,\n priority TEXT NOT NULL,\n due_date DATE,\n status TEXT NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE RESTRICT,\n FOREIGN KEY (quote_id) REFERENCES quotes(id) ON DELETE SET NULL,\n FOREIGN KEY (custom_spec_id) REFERENCES custom_specs(id) ON DELETE SET NULL\n);", "indexes": ["CREATE INDEX idx_jobs_job_number ON jobs(job_number);", "CREATE INDEX idx_jobs_customer ON jobs(customer_id);", "CREATE INDEX idx_jobs_status ON jobs(status);", "CREATE INDEX idx_jobs_due_date ON jobs(due_date);"]}, {"name": "work_centers", "ddl": "CREATE TABLE work_centers (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n description TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);", "indexes": ["CREATE INDEX idx_work_centers_name ON work_centers(name);"]}, {"name": "job_tasks", "ddl": "CREATE TABLE job_tasks (\n id INTEGER PRIMARY KEY,\n task_code TEXT NOT NULL UNIQUE,\n job_id INTEGER NOT NULL,\n sequence_order INTEGER NOT NULL,\n task_name TEXT NOT NULL,\n work_center_id INTEGER NOT NULL,\n requiring_skill_level TEXT,\n planned_start DATETIME,\n planned_finish DATETIME,\n planned_duration_hours REAL,\n actual_start DATETIME,\n actual_finish DATETIME,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE,\n FOREIGN KEY (work_center_id) REFERENCES work_centers(id) ON DELETE RESTRICT,\n UNIQUE (job_id, sequence_order)\n);", "indexes": ["CREATE INDEX idx_job_tasks_job ON job_tasks(job_id);", "CREATE INDEX idx_job_tasks_work_center ON job_tasks(work_center_id);", "CREATE INDEX idx_job_tasks_planned_range ON job_tasks(planned_start, planned_finish);"]}, {"name": "time_logs", "ddl": "CREATE TABLE time_logs (\n id INTEGER PRIMARY KEY,\n job_task_id INTEGER NOT NULL,\n operator_username TEXT NOT NULL,\n work_center_id INTEGER NOT NULL,\n log_start DATETIME DEFAULT CURRENT_TIMESTAMP,\n actual_duration_hours REAL NOT NULL,\n scrap_quantity INTEGER DEFAULT 0,\n note TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (job_task_id) REFERENCES job_tasks(id) ON DELETE CASCADE,\n FOREIGN KEY (work_center_id) REFERENCES work_centers(id) ON DELETE RESTRICT\n);", "indexes": ["CREATE INDEX idx_time_logs_job_task ON time_logs(job_task_id);", "CREATE INDEX idx_time_logs_work_center ON time_logs(work_center_id);", "CREATE INDEX idx_time_logs_log_start ON time_logs(log_start);"]}, {"name": "materials", "ddl": "CREATE TABLE materials (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL UNIQUE,\n unit_of_measure TEXT NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);", "indexes": ["CREATE INDEX idx_materials_name ON materials(name);"]}, {"name": "inventory_lots", "ddl": "CREATE TABLE inventory_lots (\n id INTEGER PRIMARY KEY,\n lot_number TEXT NOT NULL UNIQUE,\n material_id INTEGER NOT NULL,\n on_hand_quantity REAL NOT NULL,\n reserved_quantity REAL NOT NULL DEFAULT 0,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (material_id) REFERENCES materials(id) ON DELETE RESTRICT\n);", "indexes": ["CREATE INDEX idx_inventory_lots_material ON inventory_lots(material_id);", "CREATE INDEX idx_inventory_lots_lot_number ON inventory_lots(lot_number);"]}, {"name": "material_reservations", "ddl": "CREATE TABLE material_reservations (\n id INTEGER PRIMARY KEY,\n job_id INTEGER NOT NULL,\n inventory_lot_id INTEGER NOT NULL,\n quantity REAL NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE,\n FOREIGN KEY (inventory_lot_id) REFERENCES inventory_lots(id) ON DELETE RESTRICT\n);", "indexes": ["CREATE INDEX idx_material_reservations_job ON material_reservations(job_id);", "CREATE INDEX idx_material_reservations_lot ON material_reservations(inventory_lot_id);"]}, {"name": "shipments", "ddl": "CREATE TABLE shipments (\n id INTEGER PRIMARY KEY,\n shipment_number TEXT NOT NULL UNIQUE,\n job_id INTEGER NOT NULL,\n customer_id INTEGER NOT NULL,\n delivery_status TEXT NOT NULL,\n shipped_at DATETIME,\n delivered_at DATETIME,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE RESTRICT,\n FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE RESTRICT\n);", "indexes": ["CREATE INDEX idx_shipments_job ON shipments(job_id);", "CREATE INDEX idx_shipments_customer ON shipments(customer_id);", "CREATE INDEX idx_shipments_status ON shipments(delivery_status);"]}, {"name": "shipment_packages", "ddl": "CREATE TABLE shipment_packages (\n id INTEGER PRIMARY KEY,\n shipment_id INTEGER NOT NULL,\n package_number INTEGER NOT NULL,\n weight_kg REAL NOT NULL,\n tracking_number TEXT NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (shipment_id) REFERENCES shipments(id) ON DELETE CASCADE,\n UNIQUE (shipment_id, package_number),\n UNIQUE (tracking_number)\n);", "indexes": ["CREATE INDEX idx_shipment_packages_shipment ON shipment_packages(shipment_id);", "CREATE INDEX idx_shipment_packages_tracking ON shipment_packages(tracking_number);"]}]}, "db_path": "./outputs/databases/manufacturing_execution_system_1.db"}
components/awm/upstream/manufacturing_execution_system_1-gen_envs.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
components/awm/upstream/manufacturing_execution_system_1-gen_sample.jsonl ADDED
@@ -0,0 +1 @@
 
 
1
+ {"scenario": "manufacturing_execution_system_1", "tables_count": 18, "inserts_count": 114, "sample_data": {"tables": [{"table_name": "users", "reasoning": "Users represent system operators or authenticated agents. Creating a primary user with id=1 and additional users allows time_logs and ownership associations for realistic operations. Although user_id is not referenced directly in other tables, having multiple realistic users supports broader testing and aligns with the requirement that user id=1 exists as the main actor.", "insert_statements": ["INSERT INTO users (id, username, email, full_name, created_at, updated_at) VALUES (1, 'planner_anna', 'anna.planner@example.com', 'Anna Planner', '2025-10-01 09:00:00', '2025-12-01 10:00:00');", "INSERT INTO users (id, username, email, full_name, created_at, updated_at) VALUES (2, 'op_jwilliams', 'jwilliams@example.com', 'James Williams', '2025-10-05 08:30:00', '2025-12-15 14:20:00');", "INSERT INTO users (id, username, email, full_name, created_at, updated_at) VALUES (3, 'op_mgarcia', 'mgarcia@example.com', 'Maria Garcia', '2025-11-01 07:45:00', '2025-12-20 16:10:00');", "INSERT INTO users (id, username, email, full_name, created_at, updated_at) VALUES (4, 'scheduler_bot', 'scheduler.bot@example.com', 'Scheduler Bot', '2025-12-01 12:00:00', '2025-12-25 12:00:00');"]}, {"table_name": "customers", "reasoning": "Customers are required for creating quotes, jobs, custom specs, and shipments. We create Acme Robotics LLC for the tasks plus additional customers to support searching, listing, and shipping variations. Data adheres to schema constraints including unique names and non-null billing_address.", "insert_statements": ["INSERT INTO customers (id, name, billing_address, contact_person, email, phone, created_at, updated_at) VALUES (1, 'Acme Robotics LLC', '1200 Industrial Way, Dayton, OH 45402', 'Maria Santos', 'm.santos@acmerobotics.com', '+1-937-555-0142', '2025-12-20 10:00:00', '2025-12-20 10:00:00');", "INSERT INTO customers (id, name, billing_address, contact_person, email, phone, created_at, updated_at) VALUES (2, 'Precision Automation Inc', '4550 Tech Park Dr, Columbus, OH 43215', 'Liam Chen', 'liam.chen@precisionauto.com', '+1-614-555-0101', '2025-11-15 09:30:00', '2025-12-10 11:45:00');", "INSERT INTO customers (id, name, billing_address, contact_person, email, phone, created_at, updated_at) VALUES (3, 'Greenfield Fabrication Co', '890 Foundry Rd, Cincinnati, OH 45202', 'Emily Davis', 'edavis@greenfieldfab.com', '+1-513-555-0199', '2025-10-05 14:15:00', '2025-12-05 16:00:00');", "INSERT INTO customers (id, name, billing_address, contact_person, email, phone, created_at, updated_at) VALUES (4, 'Summit Industrial Solutions', '2300 Summit Blvd, Akron, OH 44308', 'Robert King', 'rking@summitindustrial.com', '+1-330-555-0222', '2025-09-01 11:20:00', '2025-11-01 12:00:00');", "INSERT INTO customers (id, name, billing_address, contact_person, email, phone, created_at, updated_at) VALUES (5, 'Metro Machine Works', '101 Machine Way, Toledo, OH 43604', 'Olivia Perez', 'operez@metromachineworks.com', '+1-419-555-0333', '2025-07-18 13:40:00', '2025-12-01 09:05:00');"]}, {"table_name": "product_templates", "reasoning": "Product templates define configurable products used by custom_specs and standard_task_sequences. We add Steel Workbench Pro per the task and other templates for diversity. Names are unique as required, enabling agents to select templates and derive default task sequences.", "insert_statements": ["INSERT INTO product_templates (id, name, description, created_at, updated_at) VALUES (1, 'Steel Workbench Pro', 'Heavy-duty steel workbench with configurable size, color, and finish.', '2025-12-21 09:00:00', '2025-12-21 09:00:00');", "INSERT INTO product_templates (id, name, description, created_at, updated_at) VALUES (2, 'Aluminum Equipment Rack', 'Modular aluminum equipment rack for industrial control systems.', '2025-10-10 10:00:00', '2025-12-01 10:00:00');", "INSERT INTO product_templates (id, name, description, created_at, updated_at) VALUES (3, 'Stainless Storage Cabinet', 'Corrosion-resistant storage cabinet with adjustable shelves.', '2025-09-15 11:30:00', '2025-11-01 08:20:00');", "INSERT INTO product_templates (id, name, description, created_at, updated_at) VALUES (4, 'Robot Safety Guard Rail', 'Guard rail system for robotic work cells.', '2025-08-05 13:10:00', '2025-10-01 09:45:00');", "INSERT INTO product_templates (id, name, description, created_at, updated_at) VALUES (5, 'Custom Machine Base', 'Fabricated steel base for automated machinery.', '2025-07-22 15:00:00', '2025-09-20 15:30:00');"]}, {"table_name": "product_template_options", "reasoning": "Template options define available discrete configuration choices for each product template, like color or size. We create full option sets for Steel Workbench Pro and varied options for other templates. Unique constraints per template and option_name/option_value are respected.", "insert_statements": ["INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (1, 1, 'color', 'gray', '2025-12-21 09:05:00', '2025-12-21 09:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (2, 1, 'color', 'blue', '2025-12-21 09:05:00', '2025-12-21 09:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (3, 1, 'size', '4ft', '2025-12-21 09:05:00', '2025-12-21 09:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (4, 1, 'size', '6ft', '2025-12-21 09:05:00', '2025-12-21 09:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (5, 1, 'finish_type', 'powder_coat', '2025-12-21 09:05:00', '2025-12-21 09:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (6, 1, 'finish_type', 'galvanized', '2025-12-21 09:05:00', '2025-12-21 09:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (7, 2, 'height', '42U', '2025-10-10 10:05:00', '2025-10-10 10:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (8, 2, 'height', '24U', '2025-10-10 10:05:00', '2025-10-10 10:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (9, 2, 'finish', 'anodized', '2025-10-10 10:05:00', '2025-10-10 10:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (10, 3, 'door_type', 'swing', '2025-09-15 11:35:00', '2025-09-15 11:35:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (11, 3, 'door_type', 'sliding', '2025-09-15 11:35:00', '2025-09-15 11:35:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (12, 4, 'coating', 'safety_yellow', '2025-08-05 13:15:00', '2025-08-05 13:15:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (13, 4, 'coating', 'galvanized', '2025-08-05 13:15:00', '2025-08-05 13:15:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (14, 5, 'mounting_style', 'floor', '2025-07-22 15:05:00', '2025-07-22 15:05:00');", "INSERT INTO product_template_options (id, product_template_id, option_name, option_value, created_at, updated_at) VALUES (15, 5, 'mounting_style', 'frame', '2025-07-22 15:05:00', '2025-07-22 15:05:00');"]}, {"table_name": "standard_task_sequences", "reasoning": "Standard task sequences provide default operations and durations for each product template. We define the requested cutting\u2192welding\u2192grinding\u2192painting sequence for Steel Workbench Pro and additional sequences for other templates. This supports auto-creation of job_tasks from templates.", "insert_statements": ["INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (1, 1, 1, 'cutting', 1.5, '2025-12-21 09:10:00', '2025-12-21 09:10:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (2, 1, 2, 'welding', 2.0, '2025-12-21 09:10:00', '2025-12-21 09:10:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (3, 1, 3, 'grinding', 0.75, '2025-12-21 09:10:00', '2025-12-21 09:10:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (4, 1, 4, 'painting', 1.0, '2025-12-21 09:10:00', '2025-12-21 09:10:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (5, 2, 1, 'cutting', 1.0, '2025-10-10 10:10:00', '2025-10-10 10:10:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (6, 2, 2, 'drilling', 1.2, '2025-10-10 10:10:00', '2025-10-10 10:10:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (7, 2, 3, 'assembly', 1.5, '2025-10-10 10:10:00', '2025-10-10 10:10:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (8, 3, 1, 'cutting', 0.8, '2025-09-15 11:40:00', '2025-09-15 11:40:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (9, 3, 2, 'forming', 1.3, '2025-09-15 11:40:00', '2025-09-15 11:40:00');", "INSERT INTO standard_task_sequences (id, product_template_id, sequence_order, task_name, default_planned_duration_hours, created_at, updated_at) VALUES (10, 3, 3, 'welding', 1.7, '2025-09-15 11:40:00', '2025-09-15 11:40:00');"]}, {"table_name": "custom_specs", "reasoning": "Custom specs bind a customer to a product template with specific configuration. We create the requested spec for Acme Robotics LLC and others for variety. Foreign keys to customers and product_templates ensure integrity, enabling quoting and job creation based on these specs.", "insert_statements": ["INSERT INTO custom_specs (id, customer_id, product_template_id, notes, created_at, updated_at) VALUES (1, 1, 1, 'Blue 6ft workbench with powder coat finish for robotics cell.', '2025-12-22 08:00:00', '2025-12-22 08:00:00');", "INSERT INTO custom_specs (id, customer_id, product_template_id, notes, created_at, updated_at) VALUES (2, 2, 2, '42U anodized rack with reinforced base.', '2025-11-20 09:15:00', '2025-11-20 09:15:00');", "INSERT INTO custom_specs (id, customer_id, product_template_id, notes, created_at, updated_at) VALUES (3, 3, 3, 'Stainless cabinet for chemical storage, sliding doors.', '2025-10-10 10:20:00', '2025-10-10 10:20:00');", "INSERT INTO custom_specs (id, customer_id, product_template_id, notes, created_at, updated_at) VALUES (4, 1, 4, 'Guard rail around dual-robot cell.', '2025-11-05 13:00:00', '2025-11-05 13:00:00');", "INSERT INTO custom_specs (id, customer_id, product_template_id, notes, created_at, updated_at) VALUES (5, 4, 5, 'Machine base with integrated leveling feet.', '2025-09-25 14:30:00', '2025-09-25 14:30:00');"]}, {"table_name": "custom_spec_options", "reasoning": "Custom spec options store chosen values for configurable attributes per custom spec. We add explicit color, size, and finish_type for Acme\u2019s Steel Workbench Pro and other specs. Unique constraints per custom_spec_id and option_name are respected to avoid duplicates.", "insert_statements": ["INSERT INTO custom_spec_options (id, custom_spec_id, option_name, option_value, created_at, updated_at) VALUES (1, 1, 'color', 'blue', '2025-12-22 08:05:00', '2025-12-22 08:05:00');", "INSERT INTO custom_spec_options (id, custom_spec_id, option_name, option_value, created_at, updated_at) VALUES (2, 1, 'size', '6ft', '2025-12-22 08:05:00', '2025-12-22 08:05:00');", "INSERT INTO custom_spec_options (id, custom_spec_id, option_name, option_value, created_at, updated_at) VALUES (3, 1, 'finish_type', 'powder_coat', '2025-12-22 08:05:00', '2025-12-22 08:05:00');", "INSERT INTO custom_spec_options (id, custom_spec_id, option_name, option_value, created_at, updated_at) VALUES (4, 2, 'height', '42U', '2025-11-20 09:20:00', '2025-11-20 09:20:00');", "INSERT INTO custom_spec_options (id, custom_spec_id, option_name, option_value, created_at, updated_at) VALUES (5, 2, 'finish', 'anodized', '2025-11-20 09:20:00', '2025-11-20 09:20:00');", "INSERT INTO custom_spec_options (id, custom_spec_id, option_name, option_value, created_at, updated_at) VALUES (6, 3, 'door_type', 'sliding', '2025-10-10 10:25:00', '2025-10-10 10:25:00');", "INSERT INTO custom_spec_options (id, custom_spec_id, option_name, option_value, created_at, updated_at) VALUES (7, 4, 'coating', 'safety_yellow', '2025-11-05 13:05:00', '2025-11-05 13:05:00');", "INSERT INTO custom_spec_options (id, custom_spec_id, option_name, option_value, created_at, updated_at) VALUES (8, 5, 'mounting_style', 'floor', '2025-09-25 14:35:00', '2025-09-25 14:35:00');"]}, {"table_name": "custom_spec_numeric_params", "reasoning": "Numeric parameters store dimensional and tolerance data for each spec. We define length, width, height, and flatness_tolerance for Acme\u2019s workbench and additional metrics for other specs. Units are provided where appropriate, supporting engineering calculations and quoting.", "insert_statements": ["INSERT INTO custom_spec_numeric_params (id, custom_spec_id, param_name, param_value, unit, created_at, updated_at) VALUES (1, 1, 'length', 1830.0, 'mm', '2025-12-22 08:10:00', '2025-12-22 08:10:00');", "INSERT INTO custom_spec_numeric_params (id, custom_spec_id, param_name, param_value, unit, created_at, updated_at) VALUES (2, 1, 'width', 760.0, 'mm', '2025-12-22 08:10:00', '2025-12-22 08:10:00');", "INSERT INTO custom_spec_numeric_params (id, custom_spec_id, param_name, param_value, unit, created_at, updated_at) VALUES (3, 1, 'height', 900.0, 'mm', '2025-12-22 08:10:00', '2025-12-22 08:10:00');", "INSERT INTO custom_spec_numeric_params (id, custom_spec_id, param_name, param_value, unit, created_at, updated_at) VALUES (4, 1, 'flatness_tolerance', 0.5, 'mm', '2025-12-22 08:10:00', '2025-12-22 08:10:00');", "INSERT INTO custom_spec_numeric_params (id, custom_spec_id, param_name, param_value, unit, created_at, updated_at) VALUES (5, 2, 'depth', 800.0, 'mm', '2025-11-20 09:25:00', '2025-11-20 09:25:00');", "INSERT INTO custom_spec_numeric_params (id, custom_spec_id, param_name, param_value, unit, created_at, updated_at) VALUES (6, 3, 'height', 2000.0, 'mm', '2025-10-10 10:30:00', '2025-10-10 10:30:00');", "INSERT INTO custom_spec_numeric_params (id, custom_spec_id, param_name, param_value, unit, created_at, updated_at) VALUES (7, 4, 'rail_length', 6000.0, 'mm', '2025-11-05 13:10:00', '2025-11-05 13:10:00');", "INSERT INTO custom_spec_numeric_params (id, custom_spec_id, param_name, param_value, unit, created_at, updated_at) VALUES (8, 5, 'base_length', 2500.0, 'mm', '2025-09-25 14:40:00', '2025-09-25 14:40:00');"]}, {"table_name": "quotes", "reasoning": "Quotes link customers to estimated cost and time for custom specs, feeding job creation. We include the requested new quote for Acme\u2019s workbench, plus quote Q-2025-0147 in accepted status and several others with varied statuses, supporting conversion and listing workflows.", "insert_statements": ["INSERT INTO quotes (id, quote_number, customer_id, custom_spec_id, estimated_hours, material_cost, labor_rate, status, internal_note, created_at, updated_at) VALUES (1, 'Q-2025-0100', 2, 2, 18.0, 650.00, 70.00, 'draft', 'Initial rack concept.', '2025-11-21 10:00:00', '2025-11-22 11:00:00');", "INSERT INTO quotes (id, quote_number, customer_id, custom_spec_id, estimated_hours, material_cost, labor_rate, status, internal_note, created_at, updated_at) VALUES (2, 'Q-2025-0125', 3, 3, 22.5, 980.00, 62.00, 'sent', 'Stainless cabinet for chemical storage.', '2025-10-12 09:30:00', '2025-10-13 09:30:00');", "INSERT INTO quotes (id, quote_number, customer_id, custom_spec_id, estimated_hours, material_cost, labor_rate, status, internal_note, created_at, updated_at) VALUES (3, 'Q-2025-0140', 1, 4, 30.0, 1500.00, 65.00, 'rejected', 'Guard rail around dual-robot cell, price too high per customer.', '2025-11-06 10:15:00', '2025-11-20 10:15:00');", "INSERT INTO quotes (id, quote_number, customer_id, custom_spec_id, estimated_hours, material_cost, labor_rate, status, internal_note, created_at, updated_at) VALUES (4, 'Q-2025-0147', 1, 1, 16.0, 520.00, 65.00, 'accepted', 'Steel Workbench Pro for robotics line.', '2025-12-10 08:45:00', '2025-12-18 09:00:00');", "INSERT INTO quotes (id, quote_number, customer_id, custom_spec_id, estimated_hours, material_cost, labor_rate, status, internal_note, created_at, updated_at) VALUES (5, 'Q-2025-0155', 4, 5, 40.0, 2100.00, 68.00, 'accepted', 'Custom machine base with vibration damping.', '2025-09-27 13:00:00', '2025-10-02 13:00:00');", "INSERT INTO quotes (id, quote_number, customer_id, custom_spec_id, estimated_hours, material_cost, labor_rate, status, internal_note, created_at, updated_at) VALUES (6, 'Q-2025-0160', 1, 1, 12.0, 420.00, 65.00, 'sent', 'Rush order requested, target ship in 10 business days.', '2025-12-22 09:00:00', '2025-12-22 09:00:00');"]}, {"table_name": "jobs", "reasoning": "Jobs represent approved work tied to customers, quotes, and specs. We add job from accepted quote Q-2025-0147 with high priority and planned status, plus jobs J-2025-0332 and J-2025-0279 for tasks, inventory, and shipment operations, and additional jobs for capacity analysis.", "insert_statements": ["INSERT INTO jobs (id, job_number, customer_id, quote_id, custom_spec_id, priority, due_date, status, created_at, updated_at) VALUES (1, 'J-2025-0279', 1, 3, 4, 'medium', '2025-12-15', 'completed', '2025-11-25 08:00:00', '2025-12-16 17:00:00');", "INSERT INTO jobs (id, job_number, customer_id, quote_id, custom_spec_id, priority, due_date, status, created_at, updated_at) VALUES (2, 'J-2025-0332', 2, 1, 2, 'high', '2026-01-22', 'in_progress', '2025-12-28 09:00:00', '2025-12-30 10:00:00');", "INSERT INTO jobs (id, job_number, customer_id, quote_id, custom_spec_id, priority, due_date, status, created_at, updated_at) VALUES (3, 'J-2025-0340', 3, 2, 3, 'low', '2026-01-10', 'planned', '2025-12-20 10:30:00', '2025-12-20 10:30:00');", "INSERT INTO jobs (id, job_number, customer_id, quote_id, custom_spec_id, priority, due_date, status, created_at, updated_at) VALUES (4, 'J-2025-0350', 4, 5, 5, 'high', '2026-01-18', 'planned', '2025-12-21 11:00:00', '2025-12-21 11:00:00');", "INSERT INTO jobs (id, job_number, customer_id, quote_id, custom_spec_id, priority, due_date, status, created_at, updated_at) VALUES (5, 'J-2026-0005', 1, 4, 1, 'high', '2026-01-20', 'planned', '2025-12-22 10:00:00', '2025-12-22 10:00:00');", "INSERT INTO jobs (id, job_number, customer_id, quote_id, custom_spec_id, priority, due_date, status, created_at, updated_at) VALUES (6, 'J-2026-0006', 1, 6, 1, 'high', '2026-01-25', 'planned', '2025-12-23 09:15:00', '2025-12-23 09:15:00');"]}, {"table_name": "work_centers", "reasoning": "Work centers identify physical or logical production resources used in job_tasks and time_logs. We add Laser Cutter LC-01, Weld Cell WC-02, Paint Booth PB-01, and other centers for diverse scheduling and capacity utilization analysis, conforming to unique name constraint.", "insert_statements": ["INSERT INTO work_centers (id, name, description, created_at, updated_at) VALUES (1, 'Laser Cutter LC-01', 'Trumpf fiber laser cutting cell.', '2025-07-01 08:00:00', '2025-12-01 08:00:00');", "INSERT INTO work_centers (id, name, description, created_at, updated_at) VALUES (2, 'Weld Cell WC-02', 'Robotic MIG welding cell.', '2025-07-01 08:05:00', '2025-12-01 08:05:00');", "INSERT INTO work_centers (id, name, description, created_at, updated_at) VALUES (3, 'Paint Booth PB-01', 'Powder coating booth.', '2025-07-01 08:10:00', '2025-12-01 08:10:00');", "INSERT INTO work_centers (id, name, description, created_at, updated_at) VALUES (4, 'Grinding Station GS-01', 'Manual grinding station.', '2025-07-01 08:15:00', '2025-12-01 08:15:00');", "INSERT INTO work_centers (id, name, description, created_at, updated_at) VALUES (5, 'Assembly Cell AC-01', 'Bench assembly area.', '2025-07-01 08:20:00', '2025-12-01 08:20:00');"]}, {"table_name": "job_tasks", "reasoning": "Job tasks break jobs into sequenced operations at specific work centers, required for planning, execution, and time logging. We define tasks for job J-2025-0332 per instructions, create task JT-8793 for welding, and add multiple LC-01 tasks in January 2026 for utilization queries.", "insert_statements": ["INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (1, 'JT-8001', 2, 1, 'cutting', 1, 'intermediate', '2026-01-05 08:00:00', '2026-01-05 10:00:00', 2.0, NULL, NULL, '2025-12-28 09:10:00', '2025-12-28 09:10:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (2, 'JT-8002', 2, 2, 'welding', 2, 'advanced', '2026-01-05 11:00:00', '2026-01-05 14:00:00', 3.0, NULL, NULL, '2025-12-28 09:10:00', '2025-12-28 09:10:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (3, 'JT-8003', 2, 3, 'painting', 3, 'intermediate', '2026-01-06 09:00:00', '2026-01-06 11:00:00', 2.0, NULL, NULL, '2025-12-28 09:10:00', '2025-12-28 09:10:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (4, 'JT-8793', 2, 4, 'welding rework', 2, 'advanced', '2026-01-07 08:00:00', '2026-01-07 10:30:00', 2.5, NULL, NULL, '2025-12-29 08:00:00', '2025-12-29 08:00:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (5, 'JT-8100', 1, 1, 'cutting', 1, 'intermediate', '2025-12-05 08:00:00', '2025-12-05 10:00:00', 2.0, '2025-12-05 08:05:00', '2025-12-05 09:50:00', '2025-11-25 08:10:00', '2025-12-05 10:00:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (6, 'JT-8101', 1, 2, 'welding', 2, 'advanced', '2025-12-06 08:00:00', '2025-12-06 11:00:00', 3.0, '2025-12-06 08:10:00', '2025-12-06 11:05:00', '2025-11-25 08:10:00', '2025-12-06 11:10:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (7, 'JT-8200', 3, 1, 'cutting', 1, 'intermediate', '2026-01-03 07:00:00', '2026-01-03 09:00:00', 2.0, NULL, NULL, '2025-12-20 10:40:00', '2025-12-20 10:40:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (8, 'JT-8201', 4, 1, 'cutting', 1, 'intermediate', '2026-01-15 08:00:00', '2026-01-15 12:00:00', 4.0, NULL, NULL, '2025-12-21 11:10:00', '2025-12-21 11:10:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (9, 'JT-8202', 5, 1, 'cutting', 1, 'intermediate', '2026-01-20 13:00:00', '2026-01-20 16:00:00', 3.0, NULL, NULL, '2025-12-22 10:10:00', '2025-12-22 10:10:00');", "INSERT INTO job_tasks (id, task_code, job_id, sequence_order, task_name, work_center_id, requiring_skill_level, planned_start, planned_finish, planned_duration_hours, actual_start, actual_finish, created_at, updated_at) VALUES (10, 'JT-8203', 6, 1, 'cutting', 1, 'intermediate', '2026-02-01 09:00:00', '2026-02-01 11:00:00', 2.0, NULL, NULL, '2025-12-23 09:20:00', '2025-12-23 09:20:00');"]}, {"table_name": "time_logs", "reasoning": "Time logs capture actual work done on job_tasks at specific work centers, with operators, durations, and scrap. We add the requested log for operator op_jwilliams on JT-8793 and additional logs for various LC-01 tasks to enable capacity utilization and performance analysis.", "insert_statements": ["INSERT INTO time_logs (id, job_task_id, operator_username, work_center_id, log_start, actual_duration_hours, scrap_quantity, note, created_at, updated_at) VALUES (1, 4, 'op_jwilliams', 2, '2026-01-07 08:05:00', 2.4, 1, 'Rewelded one bracket due to misalignment found during in-process check', '2026-01-07 10:45:00', '2026-01-07 10:45:00');", "INSERT INTO time_logs (id, job_task_id, operator_username, work_center_id, log_start, actual_duration_hours, scrap_quantity, note, created_at, updated_at) VALUES (2, 1, 'op_mgarcia', 1, '2026-01-05 08:00:00', 1.8, 0, 'Cut parts per program WB-332.', '2026-01-05 10:00:00', '2026-01-05 10:00:00');", "INSERT INTO time_logs (id, job_task_id, operator_username, work_center_id, log_start, actual_duration_hours, scrap_quantity, note, created_at, updated_at) VALUES (3, 7, 'op_mgarcia', 1, '2026-01-03 07:05:00', 2.1, 0, 'Cut cabinet panels.', '2026-01-03 09:15:00', '2026-01-03 09:15:00');", "INSERT INTO time_logs (id, job_task_id, operator_username, work_center_id, log_start, actual_duration_hours, scrap_quantity, note, created_at, updated_at) VALUES (4, 8, 'op_jwilliams', 1, '2026-01-15 08:10:00', 3.9, 2, 'Extra skeleton parts cut due to nesting error.', '2026-01-15 12:10:00', '2026-01-15 12:10:00');", "INSERT INTO time_logs (id, job_task_id, operator_username, work_center_id, log_start, actual_duration_hours, scrap_quantity, note, created_at, updated_at) VALUES (5, 9, 'op_mgarcia', 1, '2026-01-20 13:05:00', 2.7, 0, 'Rush laser job for Acme workbench.', '2026-01-20 16:00:00', '2026-01-20 16:00:00');", "INSERT INTO time_logs (id, job_task_id, operator_username, work_center_id, log_start, actual_duration_hours, scrap_quantity, note, created_at, updated_at) VALUES (6, 5, 'op_mgarcia', 1, '2025-12-05 08:05:00', 1.6, 0, 'Cut parts for completed job.', '2025-12-05 09:55:00', '2025-12-05 09:55:00');"]}, {"table_name": "materials", "reasoning": "Materials represent inventory items that can be reserved for jobs. We create Cold Rolled Steel Sheet 2mm for the reservation task and several other materials to simulate a realistic inventory environment with different units of measure.", "insert_statements": ["INSERT INTO materials (id, name, unit_of_measure, created_at, updated_at) VALUES (1, 'Cold Rolled Steel Sheet 2mm', 'sheet', '2025-06-01 08:00:00', '2025-12-01 08:00:00');", "INSERT INTO materials (id, name, unit_of_measure, created_at, updated_at) VALUES (2, 'Hot Rolled Steel Plate 10mm', 'kg', '2025-06-01 08:05:00', '2025-12-01 08:05:00');", "INSERT INTO materials (id, name, unit_of_measure, created_at, updated_at) VALUES (3, 'Stainless Steel Sheet 1.5mm', 'sheet', '2025-06-01 08:10:00', '2025-12-01 08:10:00');", "INSERT INTO materials (id, name, unit_of_measure, created_at, updated_at) VALUES (4, 'Powder Coat Paint Blue', 'kg', '2025-06-01 08:15:00', '2025-12-01 08:15:00');", "INSERT INTO materials (id, name, unit_of_measure, created_at, updated_at) VALUES (5, 'Shielding Gas Mix 92/8', 'cylinder', '2025-06-01 08:20:00', '2025-12-01 08:20:00');"]}, {"table_name": "inventory_lots", "reasoning": "Inventory lots track on-hand and reserved quantities per material. We define LOT-CRS-2401 with sufficient quantity for the 150-unit reservation and multiple other lots to test different reservation and availability scenarios. Quantities comply with non-null constraints.", "insert_statements": ["INSERT INTO inventory_lots (id, lot_number, material_id, on_hand_quantity, reserved_quantity, created_at, updated_at) VALUES (1, 'LOT-CRS-2401', 1, 500.0, 0.0, '2025-12-15 09:00:00', '2025-12-15 09:00:00');", "INSERT INTO inventory_lots (id, lot_number, material_id, on_hand_quantity, reserved_quantity, created_at, updated_at) VALUES (2, 'LOT-CRS-2399', 1, 120.0, 20.0, '2025-11-10 09:00:00', '2025-12-10 09:00:00');", "INSERT INTO inventory_lots (id, lot_number, material_id, on_hand_quantity, reserved_quantity, created_at, updated_at) VALUES (3, 'LOT-HRS-2310', 2, 2000.0, 300.0, '2025-10-01 08:00:00', '2025-12-01 08:00:00');", "INSERT INTO inventory_lots (id, lot_number, material_id, on_hand_quantity, reserved_quantity, created_at, updated_at) VALUES (4, 'LOT-SSS-2402', 3, 150.0, 0.0, '2025-12-18 10:00:00', '2025-12-18 10:00:00');", "INSERT INTO inventory_lots (id, lot_number, material_id, on_hand_quantity, reserved_quantity, created_at, updated_at) VALUES (5, 'LOT-PCB-2401', 4, 80.0, 10.0, '2025-12-01 11:00:00', '2025-12-10 11:00:00');"]}, {"table_name": "material_reservations", "reasoning": "Material reservations link jobs to specific inventory lots and quantities. We reserve 150 units from LOT-CRS-2401 for job J-2025-0332 as requested, and create additional reservations to test reporting and constraints. Values observe foreign keys to jobs and inventory_lots.", "insert_statements": ["INSERT INTO material_reservations (id, job_id, inventory_lot_id, quantity, created_at, updated_at) VALUES (1, 2, 1, 150.0, '2025-12-29 09:30:00', '2025-12-29 09:30:00');", "INSERT INTO material_reservations (id, job_id, inventory_lot_id, quantity, created_at, updated_at) VALUES (2, 1, 2, 50.0, '2025-11-26 08:30:00', '2025-11-26 08:30:00');", "INSERT INTO material_reservations (id, job_id, inventory_lot_id, quantity, created_at, updated_at) VALUES (3, 3, 4, 40.0, '2025-12-21 09:00:00', '2025-12-21 09:00:00');", "INSERT INTO material_reservations (id, job_id, inventory_lot_id, quantity, created_at, updated_at) VALUES (4, 5, 1, 80.0, '2025-12-23 10:30:00', '2025-12-23 10:30:00');"]}, {"table_name": "shipments", "reasoning": "Shipments capture outbound deliveries of completed jobs to customers. We create a shipment for completed job J-2025-0279 to Acme Robotics LLC with status in_transit so job_status can be updated to shipped by the agent, plus extra shipments to support listing and filtering.", "insert_statements": ["INSERT INTO shipments (id, shipment_number, job_id, customer_id, delivery_status, shipped_at, delivered_at, created_at, updated_at) VALUES (1, 'SHP-2025-0200', 1, 1, 'in_transit', '2025-12-17 09:00:00', NULL, '2025-12-17 09:00:00', '2025-12-17 09:00:00');", "INSERT INTO shipments (id, shipment_number, job_id, customer_id, delivery_status, shipped_at, delivered_at, created_at, updated_at) VALUES (2, 'SHP-2025-0180', 3, 3, 'delivered', '2025-12-10 14:00:00', '2025-12-12 10:00:00', '2025-12-10 14:00:00', '2025-12-12 10:00:00');", "INSERT INTO shipments (id, shipment_number, job_id, customer_id, delivery_status, shipped_at, delivered_at, created_at, updated_at) VALUES (3, 'SHP-2025-0185', 4, 4, 'ready_to_ship', NULL, NULL, '2025-12-15 15:00:00', '2025-12-15 15:00:00');"]}, {"table_name": "shipment_packages", "reasoning": "Shipment packages store per-package weights and tracking numbers. For the Acme job shipment, we create two packages with specified weights and tracking numbers. Additional packages for other shipments provide variety. Unique constraints on tracking_number and (shipment_id, package_number) are maintained.", "insert_statements": ["INSERT INTO shipment_packages (id, shipment_id, package_number, weight_kg, tracking_number, created_at, updated_at) VALUES (1, 1, 1, 45.0, 'CBX123456US', '2025-12-17 09:05:00', '2025-12-17 09:05:00');", "INSERT INTO shipment_packages (id, shipment_id, package_number, weight_kg, tracking_number, created_at, updated_at) VALUES (2, 1, 2, 38.5, 'CBX123457US', '2025-12-17 09:05:00', '2025-12-17 09:05:00');", "INSERT INTO shipment_packages (id, shipment_id, package_number, weight_kg, tracking_number, created_at, updated_at) VALUES (3, 2, 1, 55.0, 'CBX123458US', '2025-12-10 14:05:00', '2025-12-10 14:05:00');", "INSERT INTO shipment_packages (id, shipment_id, package_number, weight_kg, tracking_number, created_at, updated_at) VALUES (4, 3, 1, 30.0, 'CBX123459US', '2025-12-15 15:05:00', '2025-12-15 15:05:00');"]}]}}
components/math/ADAPTATIONS.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Interface: exec and finish. Working directory: /workdir. Input: instance.json. Output: answer.json.
2
+ Reset restores the original task input; finish invokes the original checker. Registered tasks and alternatives are listed in the root REGISTRATION.json.
components/math/FILE_ALLOWLIST.json ADDED
@@ -0,0 +1,596 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "component": "math",
3
+ "files": [
4
+ {
5
+ "path": "ADAPTATIONS.txt",
6
+ "sha256": "15c3c4f106c052941f16970b3981ae9c9a7bbe4c913430bcac10edbc14e73151",
7
+ "bytes": 253,
8
+ "role": "adapter_documentation",
9
+ "parent_sha256": "f737285b66a06c5927f29c4abc1a88eb0e3e105013d655ef4ea142b2c185e981"
10
+ },
11
+ {
12
+ "path": "NOTICE.txt",
13
+ "sha256": "73b544ecebc5d10e34e72f187bfdccf8ad66c9df4c37b03eeca7323a12401248",
14
+ "bytes": 703,
15
+ "role": "license_and_attribution"
16
+ },
17
+ {
18
+ "path": "SDK_DEPENDENCIES.json",
19
+ "sha256": "a037cf3ce617aa3e0216bf5e0677d229679bfffdd30dba9057b58bb413c39732",
20
+ "bytes": 25904,
21
+ "role": "dependency_manifest"
22
+ },
23
+ {
24
+ "path": "SOURCE.json",
25
+ "sha256": "a91ceb6c6b39e532fbef753034f1979d2364672d9bb6a45395c946dd8208befd",
26
+ "bytes": 1081,
27
+ "role": "metadata"
28
+ },
29
+ {
30
+ "path": "TASKS.json",
31
+ "sha256": "fe67677e50ff773b044feb9122e26a4dbb1dc647a5c88ba9db0adf952167104a",
32
+ "bytes": 3905,
33
+ "role": "metadata",
34
+ "parent_sha256": "55358840bcbda8eb1efed14464392594a96390c781ff914756eea0acfbe36137"
35
+ },
36
+ {
37
+ "path": "config.json",
38
+ "sha256": "190f2c6c257c0cbc4cb6bfa2efe8e5fdca221b1c18b39aa70331781f2be79afa",
39
+ "bytes": 5968,
40
+ "role": "runtime_registry"
41
+ },
42
+ {
43
+ "path": "licenses/MathConstraint-LICENSE",
44
+ "sha256": "9e5f1b3c610b9c2da5c313bf81d577a7d1acec686bdb0384edefa6df0f90cd94",
45
+ "bytes": 18656,
46
+ "role": "license_and_attribution",
47
+ "source": {
48
+ "repo": "vireshpati/Math-Constraint",
49
+ "source_url": "https://github.com/vireshpati/Math-Constraint/blob/main/LICENSE",
50
+ "git_blob_sha": "4ea99c213c5c0c005ae4e80df8e52169d06896ec",
51
+ "license": {
52
+ "key": "cc-by-4.0",
53
+ "name": "Creative Commons Attribution 4.0 International",
54
+ "spdx_id": "CC-BY-4.0",
55
+ "url": "https://api.github.com/licenses/cc-by-4.0",
56
+ "node_id": "MDc6TGljZW5zZTI1"
57
+ },
58
+ "sha256": "9e5f1b3c610b9c2da5c313bf81d577a7d1acec686bdb0384edefa6df0f90cd94",
59
+ "retrieval_scope": "license text only; not a claim about the original generator revision"
60
+ }
61
+ },
62
+ {
63
+ "path": "licenses/RLVE-LICENSE",
64
+ "sha256": "10afac3400d1abccc7ec2322e07563a3e495c13ac39d3865564aa2e2423b398e",
65
+ "bytes": 1069,
66
+ "role": "license_and_attribution",
67
+ "source": {
68
+ "repo": "Zhiyuan-Zeng/RLVE",
69
+ "source_url": "https://github.com/Zhiyuan-Zeng/RLVE/blob/main/LICENSE",
70
+ "git_blob_sha": "5677eb6d02ee26cd27b6dce1cbfaa9676b1a2382",
71
+ "license": {
72
+ "key": "mit",
73
+ "name": "MIT License",
74
+ "spdx_id": "MIT",
75
+ "url": "https://api.github.com/licenses/mit",
76
+ "node_id": "MDc6TGljZW5zZTEz"
77
+ },
78
+ "sha256": "10afac3400d1abccc7ec2322e07563a3e495c13ac39d3865564aa2e2423b398e",
79
+ "retrieval_scope": "license text only; not a claim about the original generator revision"
80
+ }
81
+ },
82
+ {
83
+ "path": "licenses/UPSTREAM_COLLECTION_LICENSES.md",
84
+ "sha256": "200b2ce93f2a5b9671165f9aea3cc4d89db995352c1e1e3db6d418262b058516",
85
+ "bytes": 462,
86
+ "role": "license_and_attribution"
87
+ },
88
+ {
89
+ "path": "runtime/common/__init__.py",
90
+ "sha256": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
91
+ "bytes": 1,
92
+ "role": "execution_adapter",
93
+ "parent_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
94
+ },
95
+ {
96
+ "path": "runtime/common/contracts.py",
97
+ "sha256": "b1e1429208e84aefc2422ee1d2400ad793c43cd5c0e8db213a3b669fe0947ce1",
98
+ "bytes": 1015,
99
+ "role": "execution_adapter",
100
+ "parent_sha256": "2df4ab6636056806069216ee52576ac979255cb895b49b0c72c3686f3d9c5ae2"
101
+ },
102
+ {
103
+ "path": "runtime/common/http_routes.py",
104
+ "sha256": "7263c04e9175faf66501ed9b2ac2f9a637557a8b1966d839fb9944eb01abac0e",
105
+ "bytes": 2380,
106
+ "role": "execution_adapter",
107
+ "parent_sha256": "2876ad9a5d35eeb0e1ebb40346e5d230d8326ac8280ec260459798cf7a4eee18"
108
+ },
109
+ {
110
+ "path": "runtime/common/models.py",
111
+ "sha256": "26e7a67537ce7ae34909b724243c37242b9c8055cbfe0c717179dac74347786a",
112
+ "bytes": 1815,
113
+ "role": "execution_adapter",
114
+ "parent_sha256": "9fa259555127367477c21ca27f0ee6ac4a49e5f5744ecd91bf23a3ea1d0ab07d"
115
+ },
116
+ {
117
+ "path": "runtime/native_shell/__init__.py",
118
+ "sha256": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
119
+ "bytes": 1,
120
+ "role": "execution_adapter",
121
+ "parent_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
122
+ },
123
+ {
124
+ "path": "runtime/native_shell/actor_launcher.py",
125
+ "sha256": "80eb3b90287840668e72040dc55ba115bfc3f4251a25cb2b94af0ed3759dd6b3",
126
+ "bytes": 5012,
127
+ "role": "execution_adapter",
128
+ "parent_sha256": "254abfeedc1d69cf228f923b5b43452d820c8ba5889fd8595e322e19efc7a896"
129
+ },
130
+ {
131
+ "path": "runtime/native_shell/backend.py",
132
+ "sha256": "6cc693d7a384d6d76b8c99bfb6af2e5188c03aac81671cfec3414733fb98089a",
133
+ "bytes": 13484,
134
+ "role": "execution_adapter",
135
+ "parent_sha256": "2fb83a818f65fadd7562bdd14b92254b41d740f4d212f4dd8aba58c23c48db52"
136
+ },
137
+ {
138
+ "path": "runtime/native_shell/environment.py",
139
+ "sha256": "cfe9ed6c11b9da324f5e752ffbf1d8ca5c074120f6067dd01d99590e568adf53",
140
+ "bytes": 1616,
141
+ "role": "execution_adapter",
142
+ "parent_sha256": "1c1ded0928c4757a87696f818cf9004a29e55f992495ffa0aacde9112dad7fea"
143
+ },
144
+ {
145
+ "path": "runtime/native_shell/guard.py",
146
+ "sha256": "4217040e7b055f57c6faef5aaa2a481757eda9856afb5a8816098b65fe788ef1",
147
+ "bytes": 13254,
148
+ "role": "execution_adapter",
149
+ "parent_sha256": "8b24c249acc86d5d4fad2b495072c7927b353471b18bd4fd881ae7deef206d02"
150
+ },
151
+ {
152
+ "path": "runtime/native_shell/launch_service.py",
153
+ "sha256": "db4dc3e27abe2dc45cc29b534882975aa9ea8e5b8ebedb67c943fad83810805b",
154
+ "bytes": 2383,
155
+ "role": "execution_adapter",
156
+ "parent_sha256": "c698c3b27e551f9986bf9e5aac9d337bf2e662058f5ba05d0882aaf2008ff98a"
157
+ },
158
+ {
159
+ "path": "runtime/native_shell/server.py",
160
+ "sha256": "3a0de8fbd07613f323cbd1e42e4345f0268f7a21bc4326622c8e22f4d318f30e",
161
+ "bytes": 640,
162
+ "role": "execution_adapter",
163
+ "parent_sha256": "e993b18fd0e871ee97700a725d2d57722428209c34e6caf0fd86479ca6b7a374"
164
+ },
165
+ {
166
+ "path": "runtime/native_shell/verifier_launcher.py",
167
+ "sha256": "6934b8fa5117549cb5ba30a1e6ebbd00df2bf4191ba10765473d05a3fd346465",
168
+ "bytes": 962,
169
+ "role": "execution_adapter",
170
+ "parent_sha256": "aa03260a2bcc91c9e23fd32dda0d75d1979ee7f4f64e87ea635f6bcd6048b075"
171
+ },
172
+ {
173
+ "path": "runtime/native_shell/wire_client.py",
174
+ "sha256": "b5267c0f1cc015a68154affade8d89f6b6a01e9e4cc47a2dbdb74020e108ab5f",
175
+ "bytes": 4987,
176
+ "role": "execution_adapter",
177
+ "parent_sha256": "8b05bffad6831c34e38e26926aa121845dc7e4150a6620ef1df690191a84e0d1"
178
+ },
179
+ {
180
+ "path": "upstream/construct-mc-costas-array-l3-s0/environment/Dockerfile",
181
+ "sha256": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
182
+ "bytes": 389,
183
+ "role": "original_task_source",
184
+ "source": {
185
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
186
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
187
+ "path": "tasks/construct-mc-costas-array-l3-s0/environment/Dockerfile",
188
+ "sha256": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
189
+ "byte_identical": true
190
+ }
191
+ },
192
+ {
193
+ "path": "upstream/construct-mc-costas-array-l3-s0/environment/instance.json",
194
+ "sha256": "15a02495c009c52f7cbc0f2c1daa95e0a4d0981026e123b83aaa892565fd68b5",
195
+ "bytes": 98,
196
+ "role": "original_task_source",
197
+ "source": {
198
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
199
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
200
+ "path": "tasks/construct-mc-costas-array-l3-s0/environment/instance.json",
201
+ "sha256": "15a02495c009c52f7cbc0f2c1daa95e0a4d0981026e123b83aaa892565fd68b5",
202
+ "byte_identical": true
203
+ }
204
+ },
205
+ {
206
+ "path": "upstream/construct-mc-costas-array-l3-s0/instruction.md",
207
+ "sha256": "88e4a26e71d8483fbc89627210e4ed07f6dfef0fb16ce3e6d31e84a04bd050f9",
208
+ "bytes": 723,
209
+ "role": "original_task_source",
210
+ "source": {
211
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
212
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
213
+ "path": "tasks/construct-mc-costas-array-l3-s0/instruction.md",
214
+ "sha256": "88e4a26e71d8483fbc89627210e4ed07f6dfef0fb16ce3e6d31e84a04bd050f9",
215
+ "byte_identical": true
216
+ }
217
+ },
218
+ {
219
+ "path": "upstream/construct-mc-costas-array-l3-s0/task.toml",
220
+ "sha256": "b62ba527da418f1b84d165707ea56ea805953289b0993cc3176e988ef59c3d32",
221
+ "bytes": 694,
222
+ "role": "original_task_source",
223
+ "source": {
224
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
225
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
226
+ "path": "tasks/construct-mc-costas-array-l3-s0/task.toml",
227
+ "sha256": "b62ba527da418f1b84d165707ea56ea805953289b0993cc3176e988ef59c3d32",
228
+ "byte_identical": true
229
+ }
230
+ },
231
+ {
232
+ "path": "upstream/construct-mc-costas-array-l3-s0/tests/check.py",
233
+ "sha256": "3c0290e35201f077926099989cd0e82c10bf091cb33c572cacc02bca075debdb",
234
+ "bytes": 809,
235
+ "role": "original_task_source",
236
+ "source": {
237
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
238
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
239
+ "path": "tasks/construct-mc-costas-array-l3-s0/tests/check.py",
240
+ "sha256": "3c0290e35201f077926099989cd0e82c10bf091cb33c572cacc02bca075debdb",
241
+ "byte_identical": true
242
+ }
243
+ },
244
+ {
245
+ "path": "upstream/construct-mc-costas-array-l3-s0/tests/instance.json",
246
+ "sha256": "15a02495c009c52f7cbc0f2c1daa95e0a4d0981026e123b83aaa892565fd68b5",
247
+ "bytes": 98,
248
+ "role": "original_task_source",
249
+ "source": {
250
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
251
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
252
+ "path": "tasks/construct-mc-costas-array-l3-s0/tests/instance.json",
253
+ "sha256": "15a02495c009c52f7cbc0f2c1daa95e0a4d0981026e123b83aaa892565fd68b5",
254
+ "byte_identical": true
255
+ }
256
+ },
257
+ {
258
+ "path": "upstream/construct-mc-costas-array-l3-s0/tests/run.py",
259
+ "sha256": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
260
+ "bytes": 4652,
261
+ "role": "original_task_source",
262
+ "source": {
263
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
264
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
265
+ "path": "tasks/construct-mc-costas-array-l3-s0/tests/run.py",
266
+ "sha256": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
267
+ "byte_identical": true
268
+ }
269
+ },
270
+ {
271
+ "path": "upstream/construct-mc-costas-array-l3-s0/tests/test.sh",
272
+ "sha256": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
273
+ "bytes": 391,
274
+ "role": "original_task_source",
275
+ "source": {
276
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
277
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
278
+ "path": "tasks/construct-mc-costas-array-l3-s0/tests/test.sh",
279
+ "sha256": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
280
+ "byte_identical": true
281
+ }
282
+ },
283
+ {
284
+ "path": "upstream/construct-mc-ramsey-l4-s0/environment/Dockerfile",
285
+ "sha256": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
286
+ "bytes": 389,
287
+ "role": "original_task_source",
288
+ "source": {
289
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
290
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
291
+ "path": "tasks/construct-mc-ramsey-l4-s0/environment/Dockerfile",
292
+ "sha256": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
293
+ "byte_identical": true
294
+ }
295
+ },
296
+ {
297
+ "path": "upstream/construct-mc-ramsey-l4-s0/environment/instance.json",
298
+ "sha256": "9c2fb12f3e08390c54d4ec516860f404fee82ff0c9d1fdc952364965b6307b92",
299
+ "bytes": 84,
300
+ "role": "original_task_source",
301
+ "source": {
302
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
303
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
304
+ "path": "tasks/construct-mc-ramsey-l4-s0/environment/instance.json",
305
+ "sha256": "9c2fb12f3e08390c54d4ec516860f404fee82ff0c9d1fdc952364965b6307b92",
306
+ "byte_identical": true
307
+ }
308
+ },
309
+ {
310
+ "path": "upstream/construct-mc-ramsey-l4-s0/instruction.md",
311
+ "sha256": "dacf1d28faa912ac766cb9a8859b9a2d08940d2c52a9f8460c85ce0595a16c81",
312
+ "bytes": 599,
313
+ "role": "original_task_source",
314
+ "source": {
315
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
316
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
317
+ "path": "tasks/construct-mc-ramsey-l4-s0/instruction.md",
318
+ "sha256": "dacf1d28faa912ac766cb9a8859b9a2d08940d2c52a9f8460c85ce0595a16c81",
319
+ "byte_identical": true
320
+ }
321
+ },
322
+ {
323
+ "path": "upstream/construct-mc-ramsey-l4-s0/task.toml",
324
+ "sha256": "d2ea623dfdf1ab4864399d4231f17b7c6800cc73e1ad9d1c583816d149dca377",
325
+ "bytes": 672,
326
+ "role": "original_task_source",
327
+ "source": {
328
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
329
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
330
+ "path": "tasks/construct-mc-ramsey-l4-s0/task.toml",
331
+ "sha256": "d2ea623dfdf1ab4864399d4231f17b7c6800cc73e1ad9d1c583816d149dca377",
332
+ "byte_identical": true
333
+ }
334
+ },
335
+ {
336
+ "path": "upstream/construct-mc-ramsey-l4-s0/tests/check.py",
337
+ "sha256": "923f9e1258610a3cc3d5c2984b1855ed7341af13bc7592ff42aed0e0f91fc74d",
338
+ "bytes": 1220,
339
+ "role": "original_task_source",
340
+ "source": {
341
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
342
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
343
+ "path": "tasks/construct-mc-ramsey-l4-s0/tests/check.py",
344
+ "sha256": "923f9e1258610a3cc3d5c2984b1855ed7341af13bc7592ff42aed0e0f91fc74d",
345
+ "byte_identical": true
346
+ }
347
+ },
348
+ {
349
+ "path": "upstream/construct-mc-ramsey-l4-s0/tests/instance.json",
350
+ "sha256": "9c2fb12f3e08390c54d4ec516860f404fee82ff0c9d1fdc952364965b6307b92",
351
+ "bytes": 84,
352
+ "role": "original_task_source",
353
+ "source": {
354
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
355
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
356
+ "path": "tasks/construct-mc-ramsey-l4-s0/tests/instance.json",
357
+ "sha256": "9c2fb12f3e08390c54d4ec516860f404fee82ff0c9d1fdc952364965b6307b92",
358
+ "byte_identical": true
359
+ }
360
+ },
361
+ {
362
+ "path": "upstream/construct-mc-ramsey-l4-s0/tests/run.py",
363
+ "sha256": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
364
+ "bytes": 4652,
365
+ "role": "original_task_source",
366
+ "source": {
367
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
368
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
369
+ "path": "tasks/construct-mc-ramsey-l4-s0/tests/run.py",
370
+ "sha256": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
371
+ "byte_identical": true
372
+ }
373
+ },
374
+ {
375
+ "path": "upstream/construct-mc-ramsey-l4-s0/tests/test.sh",
376
+ "sha256": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
377
+ "bytes": 391,
378
+ "role": "original_task_source",
379
+ "source": {
380
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
381
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
382
+ "path": "tasks/construct-mc-ramsey-l4-s0/tests/test.sh",
383
+ "sha256": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
384
+ "byte_identical": true
385
+ }
386
+ },
387
+ {
388
+ "path": "upstream/construct-mc-social-golfers-l4-s0/environment/Dockerfile",
389
+ "sha256": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
390
+ "bytes": 389,
391
+ "role": "original_task_source",
392
+ "source": {
393
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
394
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
395
+ "path": "tasks/construct-mc-social-golfers-l4-s0/environment/Dockerfile",
396
+ "sha256": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
397
+ "byte_identical": true
398
+ }
399
+ },
400
+ {
401
+ "path": "upstream/construct-mc-social-golfers-l4-s0/environment/instance.json",
402
+ "sha256": "cb27969d6fe8e38fac137b603f5e86da8b5f66023bc8288c6476e1b8881bfe73",
403
+ "bytes": 100,
404
+ "role": "original_task_source",
405
+ "source": {
406
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
407
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
408
+ "path": "tasks/construct-mc-social-golfers-l4-s0/environment/instance.json",
409
+ "sha256": "cb27969d6fe8e38fac137b603f5e86da8b5f66023bc8288c6476e1b8881bfe73",
410
+ "byte_identical": true
411
+ }
412
+ },
413
+ {
414
+ "path": "upstream/construct-mc-social-golfers-l4-s0/instruction.md",
415
+ "sha256": "a638ef887b79167571086549b8d9438447d07b800772aac868b3e9a2e6899cd2",
416
+ "bytes": 560,
417
+ "role": "original_task_source",
418
+ "source": {
419
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
420
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
421
+ "path": "tasks/construct-mc-social-golfers-l4-s0/instruction.md",
422
+ "sha256": "a638ef887b79167571086549b8d9438447d07b800772aac868b3e9a2e6899cd2",
423
+ "byte_identical": true
424
+ }
425
+ },
426
+ {
427
+ "path": "upstream/construct-mc-social-golfers-l4-s0/task.toml",
428
+ "sha256": "fb08db6bba18360321c1ac959d0af5f655435579d5cb88864d924897254c7546",
429
+ "bytes": 705,
430
+ "role": "original_task_source",
431
+ "source": {
432
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
433
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
434
+ "path": "tasks/construct-mc-social-golfers-l4-s0/task.toml",
435
+ "sha256": "fb08db6bba18360321c1ac959d0af5f655435579d5cb88864d924897254c7546",
436
+ "byte_identical": true
437
+ }
438
+ },
439
+ {
440
+ "path": "upstream/construct-mc-social-golfers-l4-s0/tests/check.py",
441
+ "sha256": "9514518058e308fc2ae0ec0b8ce8a50993d5dfa09708ac9c3609e1edbbae126a",
442
+ "bytes": 1132,
443
+ "role": "original_task_source",
444
+ "source": {
445
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
446
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
447
+ "path": "tasks/construct-mc-social-golfers-l4-s0/tests/check.py",
448
+ "sha256": "9514518058e308fc2ae0ec0b8ce8a50993d5dfa09708ac9c3609e1edbbae126a",
449
+ "byte_identical": true
450
+ }
451
+ },
452
+ {
453
+ "path": "upstream/construct-mc-social-golfers-l4-s0/tests/instance.json",
454
+ "sha256": "cb27969d6fe8e38fac137b603f5e86da8b5f66023bc8288c6476e1b8881bfe73",
455
+ "bytes": 100,
456
+ "role": "original_task_source",
457
+ "source": {
458
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
459
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
460
+ "path": "tasks/construct-mc-social-golfers-l4-s0/tests/instance.json",
461
+ "sha256": "cb27969d6fe8e38fac137b603f5e86da8b5f66023bc8288c6476e1b8881bfe73",
462
+ "byte_identical": true
463
+ }
464
+ },
465
+ {
466
+ "path": "upstream/construct-mc-social-golfers-l4-s0/tests/run.py",
467
+ "sha256": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
468
+ "bytes": 4652,
469
+ "role": "original_task_source",
470
+ "source": {
471
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
472
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
473
+ "path": "tasks/construct-mc-social-golfers-l4-s0/tests/run.py",
474
+ "sha256": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
475
+ "byte_identical": true
476
+ }
477
+ },
478
+ {
479
+ "path": "upstream/construct-mc-social-golfers-l4-s0/tests/test.sh",
480
+ "sha256": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
481
+ "bytes": 391,
482
+ "role": "original_task_source",
483
+ "source": {
484
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
485
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
486
+ "path": "tasks/construct-mc-social-golfers-l4-s0/tests/test.sh",
487
+ "sha256": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
488
+ "byte_identical": true
489
+ }
490
+ },
491
+ {
492
+ "path": "upstream/construct-rlve-round-robin-scores-l3-s0/environment/Dockerfile",
493
+ "sha256": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
494
+ "bytes": 389,
495
+ "role": "original_task_source",
496
+ "source": {
497
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
498
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
499
+ "path": "tasks/construct-rlve-round-robin-scores-l3-s0/environment/Dockerfile",
500
+ "sha256": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
501
+ "byte_identical": true
502
+ }
503
+ },
504
+ {
505
+ "path": "upstream/construct-rlve-round-robin-scores-l3-s0/environment/instance.json",
506
+ "sha256": "b8c26f77936e8e23c97ff9488800c364a5c1b8663a93d508500dcde958a4721a",
507
+ "bytes": 99,
508
+ "role": "original_task_source",
509
+ "source": {
510
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
511
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
512
+ "path": "tasks/construct-rlve-round-robin-scores-l3-s0/environment/instance.json",
513
+ "sha256": "b8c26f77936e8e23c97ff9488800c364a5c1b8663a93d508500dcde958a4721a",
514
+ "byte_identical": true
515
+ }
516
+ },
517
+ {
518
+ "path": "upstream/construct-rlve-round-robin-scores-l3-s0/instruction.md",
519
+ "sha256": "db8d002ee820a699d6b7b819cb88ed583990529649255af446c22c98889ad370",
520
+ "bytes": 579,
521
+ "role": "original_task_source",
522
+ "source": {
523
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
524
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
525
+ "path": "tasks/construct-rlve-round-robin-scores-l3-s0/instruction.md",
526
+ "sha256": "db8d002ee820a699d6b7b819cb88ed583990529649255af446c22c98889ad370",
527
+ "byte_identical": true
528
+ }
529
+ },
530
+ {
531
+ "path": "upstream/construct-rlve-round-robin-scores-l3-s0/task.toml",
532
+ "sha256": "d42f4225ae8850e6abe3e1b612b0da6f2e896322a3e9e00e6addb988a8f8332a",
533
+ "bytes": 741,
534
+ "role": "original_task_source",
535
+ "source": {
536
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
537
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
538
+ "path": "tasks/construct-rlve-round-robin-scores-l3-s0/task.toml",
539
+ "sha256": "d42f4225ae8850e6abe3e1b612b0da6f2e896322a3e9e00e6addb988a8f8332a",
540
+ "byte_identical": true
541
+ }
542
+ },
543
+ {
544
+ "path": "upstream/construct-rlve-round-robin-scores-l3-s0/tests/check.py",
545
+ "sha256": "930cd10836482427303a497cfa896934ccdc24116879eaa4c5d32a572d01353c",
546
+ "bytes": 820,
547
+ "role": "original_task_source",
548
+ "source": {
549
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
550
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
551
+ "path": "tasks/construct-rlve-round-robin-scores-l3-s0/tests/check.py",
552
+ "sha256": "930cd10836482427303a497cfa896934ccdc24116879eaa4c5d32a572d01353c",
553
+ "byte_identical": true
554
+ }
555
+ },
556
+ {
557
+ "path": "upstream/construct-rlve-round-robin-scores-l3-s0/tests/instance.json",
558
+ "sha256": "b8c26f77936e8e23c97ff9488800c364a5c1b8663a93d508500dcde958a4721a",
559
+ "bytes": 99,
560
+ "role": "original_task_source",
561
+ "source": {
562
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
563
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
564
+ "path": "tasks/construct-rlve-round-robin-scores-l3-s0/tests/instance.json",
565
+ "sha256": "b8c26f77936e8e23c97ff9488800c364a5c1b8663a93d508500dcde958a4721a",
566
+ "byte_identical": true
567
+ }
568
+ },
569
+ {
570
+ "path": "upstream/construct-rlve-round-robin-scores-l3-s0/tests/run.py",
571
+ "sha256": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
572
+ "bytes": 4652,
573
+ "role": "original_task_source",
574
+ "source": {
575
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
576
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
577
+ "path": "tasks/construct-rlve-round-robin-scores-l3-s0/tests/run.py",
578
+ "sha256": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
579
+ "byte_identical": true
580
+ }
581
+ },
582
+ {
583
+ "path": "upstream/construct-rlve-round-robin-scores-l3-s0/tests/test.sh",
584
+ "sha256": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
585
+ "bytes": 391,
586
+ "role": "original_task_source",
587
+ "source": {
588
+ "repo": "amphora/MathConstructOptimize-Envs-harbor",
589
+ "revision": "66cd5c87d51113c76faaef1b05397f1a6282a0f7",
590
+ "path": "tasks/construct-rlve-round-robin-scores-l3-s0/tests/test.sh",
591
+ "sha256": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
592
+ "byte_identical": true
593
+ }
594
+ }
595
+ ]
596
+ }
components/math/MANIFEST.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "SOURCE.json": "a91ceb6c6b39e532fbef753034f1979d2364672d9bb6a45395c946dd8208befd",
3
+ "config.json": "190f2c6c257c0cbc4cb6bfa2efe8e5fdca221b1c18b39aa70331781f2be79afa",
4
+ "NOTICE.txt": "73b544ecebc5d10e34e72f187bfdccf8ad66c9df4c37b03eeca7323a12401248",
5
+ "SDK_DEPENDENCIES.json": "a037cf3ce617aa3e0216bf5e0677d229679bfffdd30dba9057b58bb413c39732",
6
+ "TASKS.json": "fe67677e50ff773b044feb9122e26a4dbb1dc647a5c88ba9db0adf952167104a",
7
+ "ADAPTATIONS.txt": "15c3c4f106c052941f16970b3981ae9c9a7bbe4c913430bcac10edbc14e73151",
8
+ "FILE_ALLOWLIST.json": "3391c140ba8b7dd1378d16065c7488379b3114ce3f6009461bf31c416138e2f5",
9
+ "licenses/RLVE-LICENSE": "10afac3400d1abccc7ec2322e07563a3e495c13ac39d3865564aa2e2423b398e",
10
+ "licenses/MathConstraint-LICENSE": "9e5f1b3c610b9c2da5c313bf81d577a7d1acec686bdb0384edefa6df0f90cd94",
11
+ "licenses/UPSTREAM_COLLECTION_LICENSES.md": "200b2ce93f2a5b9671165f9aea3cc4d89db995352c1e1e3db6d418262b058516",
12
+ "upstream/construct-rlve-round-robin-scores-l3-s0/instruction.md": "db8d002ee820a699d6b7b819cb88ed583990529649255af446c22c98889ad370",
13
+ "upstream/construct-rlve-round-robin-scores-l3-s0/task.toml": "d42f4225ae8850e6abe3e1b612b0da6f2e896322a3e9e00e6addb988a8f8332a",
14
+ "upstream/construct-mc-costas-array-l3-s0/instruction.md": "88e4a26e71d8483fbc89627210e4ed07f6dfef0fb16ce3e6d31e84a04bd050f9",
15
+ "upstream/construct-mc-costas-array-l3-s0/task.toml": "b62ba527da418f1b84d165707ea56ea805953289b0993cc3176e988ef59c3d32",
16
+ "upstream/construct-mc-social-golfers-l4-s0/instruction.md": "a638ef887b79167571086549b8d9438447d07b800772aac868b3e9a2e6899cd2",
17
+ "upstream/construct-mc-social-golfers-l4-s0/task.toml": "fb08db6bba18360321c1ac959d0af5f655435579d5cb88864d924897254c7546",
18
+ "upstream/construct-mc-ramsey-l4-s0/instruction.md": "dacf1d28faa912ac766cb9a8859b9a2d08940d2c52a9f8460c85ce0595a16c81",
19
+ "upstream/construct-mc-ramsey-l4-s0/task.toml": "d2ea623dfdf1ab4864399d4231f17b7c6800cc73e1ad9d1c583816d149dca377",
20
+ "upstream/construct-mc-ramsey-l4-s0/tests/run.py": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
21
+ "upstream/construct-mc-ramsey-l4-s0/tests/check.py": "923f9e1258610a3cc3d5c2984b1855ed7341af13bc7592ff42aed0e0f91fc74d",
22
+ "upstream/construct-mc-ramsey-l4-s0/tests/instance.json": "9c2fb12f3e08390c54d4ec516860f404fee82ff0c9d1fdc952364965b6307b92",
23
+ "upstream/construct-mc-ramsey-l4-s0/tests/test.sh": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
24
+ "upstream/construct-mc-ramsey-l4-s0/environment/Dockerfile": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
25
+ "upstream/construct-mc-ramsey-l4-s0/environment/instance.json": "9c2fb12f3e08390c54d4ec516860f404fee82ff0c9d1fdc952364965b6307b92",
26
+ "upstream/construct-mc-social-golfers-l4-s0/tests/run.py": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
27
+ "upstream/construct-mc-social-golfers-l4-s0/tests/check.py": "9514518058e308fc2ae0ec0b8ce8a50993d5dfa09708ac9c3609e1edbbae126a",
28
+ "upstream/construct-mc-social-golfers-l4-s0/tests/instance.json": "cb27969d6fe8e38fac137b603f5e86da8b5f66023bc8288c6476e1b8881bfe73",
29
+ "upstream/construct-mc-social-golfers-l4-s0/tests/test.sh": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
30
+ "upstream/construct-mc-social-golfers-l4-s0/environment/Dockerfile": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
31
+ "upstream/construct-mc-social-golfers-l4-s0/environment/instance.json": "cb27969d6fe8e38fac137b603f5e86da8b5f66023bc8288c6476e1b8881bfe73",
32
+ "upstream/construct-mc-costas-array-l3-s0/tests/run.py": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
33
+ "upstream/construct-mc-costas-array-l3-s0/tests/check.py": "3c0290e35201f077926099989cd0e82c10bf091cb33c572cacc02bca075debdb",
34
+ "upstream/construct-mc-costas-array-l3-s0/tests/instance.json": "15a02495c009c52f7cbc0f2c1daa95e0a4d0981026e123b83aaa892565fd68b5",
35
+ "upstream/construct-mc-costas-array-l3-s0/tests/test.sh": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
36
+ "upstream/construct-mc-costas-array-l3-s0/environment/Dockerfile": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
37
+ "upstream/construct-mc-costas-array-l3-s0/environment/instance.json": "15a02495c009c52f7cbc0f2c1daa95e0a4d0981026e123b83aaa892565fd68b5",
38
+ "upstream/construct-rlve-round-robin-scores-l3-s0/tests/run.py": "d364958443f46cf3ebb71808afc270e23203f62550246eb5008a847a8701bd73",
39
+ "upstream/construct-rlve-round-robin-scores-l3-s0/tests/check.py": "930cd10836482427303a497cfa896934ccdc24116879eaa4c5d32a572d01353c",
40
+ "upstream/construct-rlve-round-robin-scores-l3-s0/tests/instance.json": "b8c26f77936e8e23c97ff9488800c364a5c1b8663a93d508500dcde958a4721a",
41
+ "upstream/construct-rlve-round-robin-scores-l3-s0/tests/test.sh": "a35b815edf35d07fee8b5b341be2af0539010888f73ce39a0c15f025367eae3e",
42
+ "upstream/construct-rlve-round-robin-scores-l3-s0/environment/Dockerfile": "56b0b880643a6915bad1e66b9d127578e69853f00a5e198ddfdf3d72a490fa1c",
43
+ "upstream/construct-rlve-round-robin-scores-l3-s0/environment/instance.json": "b8c26f77936e8e23c97ff9488800c364a5c1b8663a93d508500dcde958a4721a",
44
+ "runtime/native_shell/server.py": "3a0de8fbd07613f323cbd1e42e4345f0268f7a21bc4326622c8e22f4d318f30e",
45
+ "runtime/native_shell/backend.py": "6cc693d7a384d6d76b8c99bfb6af2e5188c03aac81671cfec3414733fb98089a",
46
+ "runtime/native_shell/launch_service.py": "db4dc3e27abe2dc45cc29b534882975aa9ea8e5b8ebedb67c943fad83810805b",
47
+ "runtime/native_shell/wire_client.py": "b5267c0f1cc015a68154affade8d89f6b6a01e9e4cc47a2dbdb74020e108ab5f",
48
+ "runtime/native_shell/__init__.py": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
49
+ "runtime/native_shell/verifier_launcher.py": "6934b8fa5117549cb5ba30a1e6ebbd00df2bf4191ba10765473d05a3fd346465",
50
+ "runtime/native_shell/environment.py": "cfe9ed6c11b9da324f5e752ffbf1d8ca5c074120f6067dd01d99590e568adf53",
51
+ "runtime/native_shell/guard.py": "4217040e7b055f57c6faef5aaa2a481757eda9856afb5a8816098b65fe788ef1",
52
+ "runtime/native_shell/actor_launcher.py": "80eb3b90287840668e72040dc55ba115bfc3f4251a25cb2b94af0ed3759dd6b3",
53
+ "runtime/common/models.py": "26e7a67537ce7ae34909b724243c37242b9c8055cbfe0c717179dac74347786a",
54
+ "runtime/common/__init__.py": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
55
+ "runtime/common/http_routes.py": "7263c04e9175faf66501ed9b2ac2f9a637557a8b1966d839fb9944eb01abac0e",
56
+ "runtime/common/contracts.py": "b1e1429208e84aefc2422ee1d2400ad793c43cd5c0e8db213a3b669fe0947ce1"
57
+ }