Skip to content

✨ 2.0#770

Open
johangirod wants to merge 85 commits intomasterfrom
2.0
Open

✨ 2.0#770
johangirod wants to merge 85 commits intomasterfrom
2.0

Conversation

@johangirod
Copy link
Copy Markdown
Member

@johangirod johangirod commented Sep 22, 2025

Soon...

👉 Voir l'avancement : Publicodes 2

EmileRolley and others added 30 commits September 19, 2025 15:07
feat: add position to yaml scalar
* Output logs without interupting compilation

* Add warning for orphan rules
* feat: prepare adding type info to eval ast

* feat: add type_database

* feat: first version of type inference

* wip

* feat: type check return error with position
* feat: add cycle check

* wipp

* Add parameter computation
Refactors the evaluation system by replacing direct `evaluate` function
with a properly typed Engine class that supports context parameters.
Renames `evaluate` to `evaluateNode` and updates all relevant tests
and interfaces.
Convert compilation pipeline to produce TypeScript output, restructuring
the evaluation tree and type checking system for better modularity.
Changed position handling to use named parameters for clarity.
* Add support for sum mechanism in Publicodes compiler

Refactor parsing components to better handle expressions and add sum
support:
- Rename expressions directory to expr
- Extract mechanism parsing logic into separate file
- Extend AST to support Sum nodes
- Improve error handling in lexer and parser
- Fix pass numbering in main compiler flow

* Add product and logical operations to compiler

Implement new mechanisms:
- produit
- toutes ces conditions
- une de ces conditions

Update parser, resolver, type checker and code generator to handle
these new operations.

* Enforce single mechanism at the same indentation level in parser

* Add duplicate YAML key detection and handling
Add support for mechanisms in Publicodes compiler

---

Refactor parsing components to better handle expressions and add sum
support:
- Rename expressions directory to expr
- Extract mechanism parsing logic into separate file
- Extend AST to support Sum nodes
- Improve error handling in lexer and parser
- Fix pass numbering in main compiler flow

* Add product and logical operations to compiler

Implement new mechanisms:
- produit
- toutes ces conditions
- une de ces conditions

Update parser, resolver, type checker and code generator to handle
these new operations.

* Enforce single mechanism at the same indentation level in parser

* Add duplicate YAML key detection and handling

* Refactor AST to support more mechanisms

Rename constructors for consistency (BinaryOp→Binary_op, AnyOf→One_of)
Add new value types: Applicable_if, Not_applicable_if, Ceiling, Floor
Replace parse_mechanism with parse_value for better structure
Improve position handling in AST with naked_value type
Rename from_list to all_keep_logs for clarity

* Refactor AST to separate value and chainable mechanisms

Add a new structure where values have a list of chainable mechanisms
that are applied in order, rather than having them nested. This makes
the AST more consistent and the code more maintainable.

* Uncomment parser code and add chainable mechanisms tests

Update test assertions to work with new value structure containing
chainable mechanisms. Change p function to require length parameter.

* Remove parser utility functions

* Fix type checking for conditional expressions

Ensure condition is Bool type and result type matches branch type.
Make pattern matching more explicit for Undefined and Null cases.
@johangirod johangirod force-pushed the 2.0 branch 2 times, most recently from 31aef23 to d6e12cb Compare October 3, 2025 13:33
johangirod and others added 15 commits October 3, 2025 19:15
* feat(compiler): naive compilation to javascript

* feat(compiler): iterate on js compilation

* feat(compiler): generate .d.ts files

* feat(compiler): start to implement a runtime + add cache layer to the js engine

* feat(compiler): benchmark with first minimal runtime

* fix(compiler): correctly manage contexte and constants

* feat(compiler): allows to compile to js or json

+ start to debug the JS backend

* feat(runtime): allow to run tests with compiled to js code

* refactor(runtime): use public getters on outputs data

* fix(compiler): use the neq runtime and start to fix the ternary conditionnal

* fix(compiler): fix the js runtime semantic + add dune rule to embed js file in ocaml module

* fix(compiler): use default output file according the output type extension

* fix(compiler): fix the JS runtime round() function to have the correct precision

* fix(runtime): refactor tests

* fix(runtime): add the bun in dev deps

* fix(runtime): update auto-entrepreneur benchmark

- Everything is recompiled before running benchmark.
- Add support to the JS compiled engine.
- Check return values with assert in the benchmark to track regression
(note: the legacy engine doesn't return the same results as the new
ones, is it wanted?)

* refactor(runtime): remove unused benchmark file

* fix(compiler): start to fix parameters problem in JS compilation

And add dedicated test in the runtime specs to track regressions

* fix(compiler): remove artefacts

* feat(compiler): correctly handle needed/missing parameters with context in the JS compilation

* fix(compiler): correctly escape " from constant

* fix(compiler): correctly manage floor and ceiling tranformation

* fix(compiler): correctly manage lazy operators on null values

* feat(runtime): add more test for paramters

* feat(compiler): try a compilation to pure JS functions

* feat(runtime): improve the parameters handling -> better perfs

* fix(compiler): correctly manage ref in the JSON output

* fix(compiler): correctly parse emtpy string + add test for `par défaut` mechanism

* fix(compiler): correctly handle 'toutes ces conditions' with only one arguement

* fix(compiler): prefixes with $ runtime function to avoid name collision

* feat(compiler): expriment with js optim

* feat(compiler): export JS rules in a dedicated object

* feat(compiler): add cache for refs in the JS runtime

* feat(compiler): add missing JSDoc types in the javascript runtime

* refactor(compiler): add comment to the optim module

* feat(compiler): generates JSDoc types

* refactor(compiler): remove the JSON output as we only compile to JS now

* refactor(compiler): move To_hash as Tree.Hash + add some .mli files

* Add test and improve generated JS (#782)

* test: add test for context mechanism

* test: repare test for arrondi

* test: arrondi et applicable si

* test: applicable si / non applicable si / plafond / plancher

* test: par défaut

* test: add date

* feat: improve generated JS

1. Change rule signature to an object containing « evaluate » function
	This allows to add other meta (title, type, unit, description, etc) at the same place of the rule, and simplifies the API.
2. Improve generated JSDoc
	Use proper typing for param object
3. Add / update test
	Add some test, and update the previous ones

* fix: date equality comparison

* feat: fix js output

* fix: equality implementation

* test: add test for equality

* feat: add global cache and cleaning

* fix(compiler): avoid conflits with javascript identifiers

* refactor(compiler): use Pp instead of sprintf for the to_js module

* remove @publicodes/runtime package

- Move test and benchmark to compiler
- Create separate JS private package for each of theù

* fix JSDoc generation

* fix tests

---------

Co-authored-by: Emile Rolley <[email protected]>
direnv is good and safe enough to use
The model has been renamed to missing_terme.publicodes, breaking this
test.
This one was just needing a promote?
Now I think the trailing "-" is the error. The stdout ends with
a stdin error, and the CI fails harder. Remove this.
stacyharper and others added 8 commits March 12, 2026 16:22
Currently the tests are not re-run on binary change.

This dependency on the built binary was only used for this directory.
Using :whole_subtree make it recursive.
Odoc only build documentation for public libraries. We have to specify
public_name for odoc to consider them.
This add a -c command argument to pass a config file path. This allow
the user to specify multiple compilation targets. A default value
"publicodes.yaml" is used when absent. If both inputs files, and
config file are given by the user, the config file is ignored.

Currently the watch mode is not supported when building multiple
targets. An error message is displayed to the user for now.

The yaml format is simple, and specify the build targets:

	targets:
	  - output: test.js.local
	    inputs:
	      - test.publicodes.local
	    type: js
	    default_to_public: false

All fields are checked, and a corresponding error message is build to
the notice the user on invalid format. Ex:

Error: Parsing config: "targets" field error: "inputs" field error: Expected a string value

Co-authored-by: Emile Rolley <[email protected]>
The init subcommand generate and write a default configuration file.

Co-authored-by: Emile Rolley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants