Skip to content

✨ 2.0#770

Open
johangirod wants to merge 130 commits into
masterfrom
2.0
Open

✨ 2.0#770
johangirod wants to merge 130 commits into
masterfrom
2.0

Conversation

@johangirod

@johangirod johangirod commented Sep 22, 2025

Copy link
Copy Markdown
Member

Soon...

👉 Voir l'avancement : Publicodes 2

@changeset-bot

changeset-bot Bot commented Sep 22, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad085aa

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify

netlify Bot commented Sep 22, 2025

Copy link
Copy Markdown

Deploy Preview for publicodes-website ready!

Name Link
🔨 Latest commit ad085aa
🔍 Latest deploy log https://app.netlify.com/projects/publicodes-website/deploys/6a310afde4efa20008ed639e
😎 Deploy Preview https://deploy-preview-770--publicodes-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 22, 2025

Copy link
Copy Markdown

Open in StackBlitz

@publicodes/cli

npm i https://pkg.pr.new/publicodes/publicodes/@publicodes/cli@770

@publicodes/codemod

npm i https://pkg.pr.new/publicodes/publicodes/@publicodes/codemod@770

publicodes

npm i https://pkg.pr.new/publicodes/publicodes@770

@publicodes/forms

npm i https://pkg.pr.new/publicodes/publicodes/@publicodes/forms@770

@publicodes/react-ui

npm i https://pkg.pr.new/publicodes/publicodes/@publicodes/react-ui@770

@publicodes/rest-api

npm i https://pkg.pr.new/publicodes/publicodes/@publicodes/rest-api@770

@publicodes/tools

npm i https://pkg.pr.new/publicodes/publicodes/@publicodes/tools@770

commit: ad085aa

In this situation, some internal would lack a type, and it is okay and
expected. Let's not warn in this situation.

Change-Id: Ic42acf10799d7e725d8a54873461f1926a6a6964
Change-Id: Ie69aacb3396fbb9aee77d84f1a6df6a96a6a6964
We plan to build a debug interface. Now that the evaluation frontends
are separated from the Publicodes models, we have to find a way to
reconciliate evaluated values and resolved rule trees.

To achieve that we now build a hashmap of the evaluated values while
returning them. The keys will reflect the target nodes from the resolved
Publicode models.

The keys are digest hashes of the positions in the model files. We
build them with the Jingoo models. We will also build them while
constructing the resolved Publicode models trees later.

The new option value "trace" can enable the trace building.

We thought about refactoring the $ret function call in the runtimes
themselves, but as we still have to return the main rule value from
the main methods, I think it is legitimate to keep all of them here.
Also this would not really simplify the code, because the most intrusive
part, the ids, remains in the main method. I think we could keep $ret
and runtime function separated for now.

Change-Id: Ib6f560088259f3d6b145ddcb7dea693b6a6a6964
Change-Id: Id3368cda3a15a40bc7054578e1af86e56a6a6964
Change-Id: Ieb8d62248b412c8de0730effe4a198a06a6a6964
"rule" is used too much here. "node" make more sense as it is a tree.
"rule" is kept for the output rules.

Change-Id: I63db77f295b798521c5c5688b43a8cf56a6a6964
Change-Id: Ie57eea8c55ff434860d14183ea711a506a6a6964
Stdin inputs can be openned again to display contextual hints. Let's
consider them as empty_files to display <No source available>.

Change-Id: If743739ce55d0589411a1cf0c3aa50e56a6a6964
For this to works we sometime have to re-order some module opennings, to
make sure Base.Option and Base.Result are openned later than Utils.

Change-Id: I66bc8f3c76ff3f1e483b61e31d9c79046a6a6964
Using ppx_deriving.enum, we can drop this manual function. This simplify
adding error codes, and conflicts on commit re-ordering.

Change-Id: I5dc1515de210e42bf22eefee8600889d6a6a6964
This implement an import feature, with a new mecanism "importer". The
expanded rules are namespaced similarly to "avec". The imported rules
are never re-exported, and the public is then used to allow cross-module
references.

This can take multiple forms:

	# to import a module
	importer: foo

	# a more verbose form
	importer:
	  module: foo

	# to import a module from a different package
	importer:
	  module: foo
	  package: bar

The "bar" package is determined using the environment variable
PUBLICODESPATH, splitted on ":". Each part is a directory root to find
the matching package. Not specifying a package means the module is
looked for in the current package.

All path arguments are validated, and the format is restricted to avoid
leaving the expected directory. This also gives better hints when an
invalid path is given.

Importing modules starting with "./" will cause a relative import. The
dot part is expanded with the current module path, meaning the imported
module will be looked for relatively to the current module directory
path.

Similarly to the "./" module path prefix, we also support a "./" prefix
for PUBLICODESPATH parts. When this prefix is present, we will be
looking for the vendor package from the package directory, instead of
pwd. This allow us to support the nested node_modules strategy. Contrary
to hoisted or shallow strategies, nested is structured this way:

	node_modules/
	  package a/
	    node_modules/
	      package b/

To cover all use cases, we can use "./node_modules:node_modules" as
PUBLICODESPATH.

We now track crawled module ids to detect circular imports, and
cross-module reference. This refactorize a bit how we pass
current_rule_name, to limit the number of argument we have to pass
arround.

The node id are now generated using also the rule name to avoid clash
on successive imports of the same modules. Because the id does not come
exclusively from the position anymore, we move it to the Shared module.

The "config" and "init" compile sub-commands has been dropped, because
now the config file feels obsolete, as this simplify the compiler
API to a single folder, as a module unit.

The "module" and "package" value validation has beed dependency
inverted, so that the gathering function only checks that arguments are
 valid Fpaths. This allow the compiler to gather files from non-valid
values, as relative paths as "./foo", or absolute paths as /foo.

Change-Id: I478bbc567c4137878e3eb8adeba758a66a6a6964
This became necessary now that we have imports.

Change-Id: I6fc694a91cecf87f3928127aa99be6976a6a6964
Change-Id: I6ef07e3280881b1e8ab0d59d0c78584c6a6a6964
A rule overrode with a "context" key should not appear in the rule
argument list.

Change-Id: I982c3eac5243fbcc4690cf6ffcedb5416a6a6964
Checks that shallowed rules with "context" are actually used.

Change-Id: If71431d52fc682fccde692a75b5bcd6c6a6a6964
Currently it fails with:
mot clé inattendu : Stream_end (attendu : the beginning of file)

Change-Id: Id09d3123906b7c8404477744c6b70cbb6a6a6964
Currently we export the whole ruleset as the default export. We keep
this merged ruleset, but we also export outputs and parameters
separately.

Change-Id: Ic162d3fc64b618d54b251eca0557ff736a6a6964
Benchmarks tests are broken since some patch, the evaluation trace, and
the import feature.

Change-Id: Ic1b944fdefc917737076e48e3320db306a6a6964
Currently when encountering a dependency cycle, we continue and write
the output logs in stderr as warning, but we still compile as expected.

This kind of logs should break the chain, and return early.

I'm surprised we don't have any return like code yet. Or maybe I'm this
wrong?

Change-Id: Ib605935e5437afc07fb74ea7f6e40b616a6a6964
Currently this None case seems to not be used by any test we have. I
suspect it is wrong, and should match the parent rule instead.

This change the error we get in an existing test, but we also add the
test reported here: #835

Change-Id: If34a0873cefd82ae9b2dde47561f21086a6a6964
The change related to the finite recursive algorithm broke this.

Change-Id: Ica8b390f3c48ebf056909af2ffc787226a6a6964
This refactorize a bit, and improve how we report import cycling errors:

E027 cycle d'import détecté [syntax error]
     ╒══  subjects/cycle/main.publicodes:2:13 ══
   1 │ cycle a:
   2 │   importer: cycle a
     │             ˘˘˘˘˘˘˘ module 'cycle a' importé ici
     ╒══  cycle a/rules.publicodes:2:13 ══
   1 │ cycle b:
   2 │   importer: cycle b
     │             ˘˘˘˘˘˘˘ module 'cycle b' importé ici, début du cycle
     ╒══  cycle b/rules.publicodes:2:13 ══
   1 │ cycle c:
   2 │   importer: cycle c
     │             ˘˘˘˘˘˘˘ module 'cycle c' importé ici
     ╒══  cycle c/rules.publicodes:2:13 ══
   1 │ cycle a:
   2 │   importer: cycle a
     │             ˘˘˘˘˘˘˘ module 'cycle a' importé à nouveau ici


Change-Id: Ifd4304314c73cdf631074ca5e717dac76a6a6964
Change-Id: Ib93ccb660a3997ee88fe45fc4f52db5f6a6a6964
This commit avoid conflicts between two ongoing works that both
depends on this.

Change-Id: I14e6ea73adee2772bfbf280f8f8584ab6a6a6964
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