Hey all, want to make sure I'm not missing anything obvious before I submit a PR, but is @since
actually just missing implementation here:
Is this just not finished yet? It should actually be checking the since
and feature
members of Stability::Stable
but I think this isn't implemented yet (and needs to be)
Are you thinking that the packages version would be checked against @since
and the item would be omitted if the package's version was too small?
Otherwise though it's intentional that currenly the version number on @since
is ignored there, but I may be missing a use case
Yup that's exactly what I was thinking! Given a file like this:
package test:feature-gates@0.2.1;
interface foo {
a: func();
@since(version = 0.2.1)
b: func();
@since(version = 0.2.2)
c: func();
@unstable(feature = fancier-foo)
d: func();
}
I was thinking that both c
and d
should be missing.
Ah the full context might be more useful -- I'm working on adding feature gate support to jco
and this is exactly my test case.
@unstable
works great, but what I was finding was that c
still shows up (when I'd expect it not to). Though I do think that the case is a bit contrived -- normally the user would get an entirely new WIT (with c
included, where as in the past it wasn't present)...
I could personally go either way on this. On one hand it seems fine to add. On the other hand I'm doubtful this will show up in practice. Using @since
with a future version number seems akin to retroactively modifying a release which generally isn't great practice.
Yeah I could definitely see/understand that. Then the ideal use case is generally:
0.2.1
)0.2.0
to 0.2.1
somehow0.2.1
contains @since(0.2.1)
annotations and @since(0.2.0)
annotationsI think what makes me think this usecase is intended is when reading the WIT design:
Thus, when building a component targeting, e.g.,
0.2.1
,b
can be used, butc
cannot. An important expectation set by the@since
gate is that, once applied to an item, the item is not modified incompatibly going forward (according to general semantic versioning rules).
How would anyone targeting 0.2.1
ever even see c
(in that example), unless it was added to the WIT for 0.2.1
itself? Is there a targeting mechanism I'm missing?
I think this is something that I didn't fully understand when reading over the original PR for this. To me targetting an older version is done by checking out the WIT files as they were during that release. That's different than taking the latest WIT files and setting a version of "ignore everything above this version".
To me it's much more robust and reliable to use the older WIT files rather than always using the newest WIT files in a situation like this.
This is probably something I should have raised on the original PR though
To me it's much more robust and reliable to use the older WIT files rather than always using the newest WIT files in a situation like this.
Yeah so that definitely makes sense to me -- I think that's the sort of... PL/toolchain default -- you can't use the new features by virtue of them not being present. I think this is a more natural flow.
That's different than taking the latest WIT files and setting a version of "ignore everything above this version".
Do we think there could be a different way in the future to do this targeting? For example if the host knows of 0.2.2
, and the component only knows of 0.2.1
, is this a way (unfortunately somewhat dependent on people using @since
quite religiously and correctly) for the same WIT file to support both interfaces for "free"?
Yes that sort of support is already implemented in Wasmtime and planned for other runtimes
It's not fully documented in the component-model itself but with this section the idea is that if two version numbers canonicalize to the same string then that's what the runtime will support
so 0.2.1 and 0.2.2 both canonicalize to "0.2" so the runtime would support both
Ah yes -- I do remember seeing that in a PR (relatively recently?) IIRC!
Here's another possibility -- Does it seem reasonable to make this a bug?
i.e. error if a version number that is higher than the current package is used?
I think that might be reasonable yeah
help catch mistakes and/or raise more awareness of this issue on issue trackers
Thinking that maybe @Yoshua Wuyts and @Guy Bedford might want to weigh in on this as well. Seems like we could really go any one of the following ways:
@since
on a future versionYep, I'm also fine with making it a bug -- I can't imagine a use case yet where a package at x
would include code that targeted x + 1
... Feels like in that case people should just be using x + 1
, as we've discussed...
The only thing that sort of occurs to me is monkey/hot patching, but seems like a shaky rationale (given that if you can change the existing WIT file, then you can probably upgrade it).
yeah I think it's best to start more conservatively with a strict error here and it can always be relaxed in the future if necessary
OK I've got a first cut at the PR here:
https://github.com/bytecodealliance/wasm-tools/pull/1689
Last updated: Dec 23 2024 at 12:05 UTC